// JavaScript Document

function validateLogin()
{
	if(document.loginForm.uname.value=="")
	{
	alert("please enter your username");
//	uname.selected=true;
	return false;
	}
	
		if(document.loginForm.pword.value=="")
	{
	alert("please enter your password");
//	pword.selected=true;
	return false;
	}
}


function msgnotBlank()
{
if(document.msgForm.messageTextArea.value=="")
{
	alert("The message cannot be blank, please enter your message");
	document.msgForm.messageTextArea.focus();
	return false;
}
return true;
}


function notBlank()
{
if(document.msgForm.messageTextArea.value=="")
{
	alert("The message cannot be blank, please enter your message");
	document.msgForm.messageTextArea.focus();
	return false;
}

if(document.msgForm.uname.value=="")
{
	alert("Please enter your name");
	document.msgForm.uname.focus();
	return false;
}

if(document.msgForm.email.value=="")
{
	alert("Please enter your email");
	document.msgForm.email.focus();
	return false;
}

email = document.msgForm.email.value;

if(email.indexOf("@")==-1 || email.indexOf(".")==-1)
{
alert("Invalid email ID");
document.msgForm.email.select();
return false;
}

return true;
}






function checkPasswords()
{
	pword1 = document.registrationForm.pword.value;
	pword2 = document.registrationForm.pwordReEnter.value;
	
	if(pword1!=pword2)
	{
		alert("The re-entered password does not match the original password");
		document.registrationForm.pwordReEnter.select();
		return false;
	}
}

function checkForm()
{

var checkFlag="t";

if(document.registrationForm.uname.value=="")
{
alert("Please enter your username");
document.registrationForm.uname.focus();
return false;
}

if(document.registrationForm.pword.value=="")
{
alert("Please enter your password");
document.registrationForm.pword.focus();
return false;
}

if(document.registrationForm.pwordReEnter.value=="")
{
alert("Please re-enter your password");
document.registrationForm.pwordReEnter.focus();
return false;
}

if(document.registrationForm.pname.value=="")
{
alert("Please enter your name");
document.registrationForm.pname.focus();
return false;
}

if(document.registrationForm.eMail.value=="")
{
alert("Please enter your email ID");
document.registrationForm.eMail.focus();
return false;
}

var validString = "abcdefghijklmnopqrstuvwxyz0123456789_";
var uname = (document.registrationForm.uname.value).toLowerCase();
//alert(uname.charAt(0));

var i;
var invalidChar;

for(i=0;i<uname.length;i++)
{
var stringLiteral = uname.charAt(i);
if(validString.indexOf(stringLiteral)==-1)
{
invalidChar=true;
break;
}

}


var pword = (document.registrationForm.pword.value).toLowerCase();
//alert(uname.charAt(0));

for(i=0;i<pword.length;i++)
{
var stringLiteral = pword.charAt(i);
if(validString.indexOf(stringLiteral)==-1)
{
invalidChar=true;
break;
}

}


var pname = (document.registrationForm.pname.value).toLowerCase();
//alert(uname.charAt(0));

for(i=0;i<pname.length;i++)
{
var stringLiteral = pname.charAt(i);
if(validString.indexOf(stringLiteral)==-1)
{
invalidChar=true;
break;
}

}

var validString2 = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
var email = (document.registrationForm.eMail.value).toLowerCase();
//alert(uname.charAt(0));

for(i=0;i<email.length;i++)
{
var stringLiteral = email.charAt(i);
if(validString2.indexOf(stringLiteral)==-1)
{
invalidChar=true;
break;
}

}


var designation = (document.registrationForm.designation.value).toLowerCase();
//alert(uname.charAt(0));

for(i=0;i<designation.length;i++)
{
var stringLiteral = designation.charAt(i);
if(validString2.indexOf(stringLiteral)==-1)
{
invalidChar=true;
break;
}

}


if(invalidChar==true)
{
alert("Invalid character in username, password, email, designation or your name. In case you think you are receiving this message in error, please use the feedback form to mail to us the username, password, your name, email and designation you are trying to fill in.");
return false;
}



if(email.indexOf("@")==-1 || email.indexOf(".")==-1)
{
alert("Invalid email ID");
document.registrationForm.eMail.select();
return false;
}

if(checkFlag=="t")
{
return true;
}
}





