function chkloginform()
{
	var msg = "";
	if (document.loginform.username.value == "" || document.loginform.username.value == "Enter your email") { msg = msg + "Username\n";}
	if (document.loginform.password.value == "") { msg = msg + "Password\n";}
	if (msg != "") 
	{
		alert("Please fill in following fields\n\n" + msg );
		return false;
	}

}

function chkchaccform()
{
	var msg = "";
	if (document.chaccform.first_name.value.length == "0") { msg = msg + "First Name\n";}
	if (document.chaccform.last_name.value.length == "0") { msg = msg + "Last Name\n";}
	if (document.chaccform.fr_month.value == "" || document.chaccform.fr_year.value == "" || document.chaccform.fr_day.value == "")	
	{ msg = msg + "DOB\n"	;}
	if (document.chaccform.address.value.length == "0") { msg = msg + "Address\n";}
	if (document.chaccform.city.value.length == "0") { msg = msg + "City\n";}
	if (document.chaccform.state.value.length == "0") { msg = msg + "State\n";}
	if (document.chaccform.country.value.length == "0") { msg = msg + "Country\n";}
	if (document.chaccform.pincode.value.length == "0") { msg = msg + "Pincode\n";}
	else if (!isNumeric(document.chaccform.pincode.value)) { msg = msg + "Invalid Pincode\n";}
	if (document.chaccform.stdcode.value.length == "0" || document.chaccform.phone.value.length == "0") { msg = msg + "Telephone\n";}
	if (document.chaccform.mobile.value.length == "0") { msg = msg + "Mobile\n";}
	if (document.chaccform.schools.value.length == "0") { msg = msg + "Schools\n";}
	if (document.chaccform.program.selectedIndex == "0" && (document.chaccform.other_prog.value.length == "0" || document.chaccform.other_prog.value == "If Other Specify"))
	{ msg = msg + "Type of Program\n";}
	else if (document.chaccform.program.value == "Other")
	{
		if (document.chaccform.other_prog.value.length == "0" || document.chaccform.other_prog.value == "If Other Specify")
		{ msg = msg + "Type of Program\n";}
	}

	
	
	if (msg != "") 
	{
		alert("Please fill in following fields\n\n" + msg );
		return false;
	}

}

function chkenqform()
{
	var msg = "";
	if (document.enqform.yourname.value.length == "0") { msg = msg + "Your Name\n";}
	if (document.enqform.email.value == "") { msg = msg + "Email\n";}
	else if (!isEmail(document.enqform.email.value)) { msg = msg + "Email\n";}

	if(document.getElementById("interest").selectedIndex == "-1" || document.getElementById("interest").selectedIndex == "0") { msg = msg + "Interested in\n";}
	if (document.enqform.mobile.value == "") { msg = msg + "Mobile\n";}
	if (document.enqform.phone.value == "" || document.enqform.std.value == "") { msg = msg + "Landline\n";}
	if (document.enqform.city.value == "") { msg = msg + "City\n";}
	if (document.enqform.pincode.value == "") { msg = msg + "Pincode\n";}
	else if (!isNumeric(document.enqform.pincode.value)) { msg = msg + "Invalid Pincode\n";}
	if (document.enqform.comment.value.length == "0") { msg = msg + "Comment\n";}

	if (msg != "") 
	{
		alert("Please fill in following fields\n\n" + msg );
		return false;
	}

 
	
}


function chkfreesignupform()
{
	var msg = "";
	if (document.freesignupform.yourname.value.length == "0") { msg = msg + "Your Name\n";}
	if (document.freesignupform.email.value == "") { msg = msg + "Email\n";}
	else if (!isEmail(document.freesignupform.email.value)) { msg = msg + "Email\n";}
	if (document.freesignupform.mobile.value == "") { msg = msg + "Mobile\n";}
	if (document.freesignupform.phone.value == "" || document.freesignupform.std.value == "") { msg = msg + "Landline\n";}
	if (document.freesignupform.city.value == "") { msg = msg + "City\n";}
	if (document.freesignupform.pincode.value == "") { msg = msg + "Pincode\n";}
	else if (!isNumeric(document.freesignupform.pincode.value)) { msg = msg + "Invalid Pincode\n";}

	if (msg != "") 
	{
		alert("Please fill in following fields\n\n" + msg );
		return false;
	}
}

function isNumeric(sText)
{
	var ValidChars = '0123456789.';
	var IsNumber=true;
	var Char;       
	if(sText=='') IsNumber = false;       
	for (i = 0; i < sText.length && IsNumber == true; i++)
	{           
		Char = sText.charAt(i);           
		if (ValidChars.indexOf(Char) == -1) IsNumber = false;       
	}       
	return IsNumber;    
}

function isEmail(sText)
{

	var  emailReegxp= /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;
	var IsEmail=true;

	if (!emailReegxp.test(sText))
	{
		IsEmail=false;
	}
	return IsEmail;
}







function chkmyform()
{
	var msg = "";
	var invalid = " "; // Invalid character is a space
	var minLength = 6; // Minimum length

	if (document.myform.email)
	{
		if (document.myform.email.value.length == "0") { msg = msg + "Email\n";}
		else if (!isEmail(document.myform.email.value)) { msg = msg + "Invalid Email Id\n";}
	}	

	if (document.myform.password)
	{
		var pw1 = document.myform.password.value;
		var pw2 = document.myform.cpassword.value;
	
	// check for a value in both fields.
		if (pw1 == '' || pw2 == '')
		{
			msg = msg + "Please enter your password twice\n";
		}
	
		// check for minimum length
		else if (pw1.length < minLength)
		{

			msg = msg + "Your password must be at least " + minLength + " characters long\n";
		}
	
		// check for spaces
		else if (pw1.indexOf(invalid) > -1)
		{
			msg = msg + "Spaces are not allowed in password\n";
		}
		else
		{
			if (pw1 != pw2) 
			{
				msg = msg + "You did not enter the same new password twice. Please re-enter your password\n";
			}
		}
	}
	if (document.myform.first_name)
	{	
		if (document.myform.first_name.value.length == "0") { msg = msg + "First Name\n";}
	}
	if (document.myform.last_name)
	{
		if (document.myform.last_name.value.length == "0") { msg = msg + "Last Name\n";}
	}
	if (document.myform.fr_month && document.myform.fr_day && document.myform.fr_year)
	{	
		if (document.myform.fr_month.value == "" || document.myform.fr_day.value == "" || document.myform.fr_year.value == "") { msg = msg + "DOB\n";}
	}
	if (document.myform.address)
	{
		if (document.myform.address.value.length == "0") { msg = msg + "Address\n";}
	}
	if(document.myform.city)
	{
		if (document.myform.city.value.length == "0") { msg = msg + "City\n";}
	}
	if(document.myform.state)
	{
		if (document.myform.state.value.length == "0") { msg = msg + "State\n";}
	}
	if (document.myform.country)
	{
		if (document.myform.country.value.length == "0") { msg = msg + "Country\n";}
	}
	if (document.myform.pincode)
	{
		if (document.myform.pincode.value == "") { msg = msg + "Pincode\n";}
		else if (!isNumeric(document.myform.pincode.value)) { msg = msg + "Invalid Pincode\n";}
	}
	if(document.myform.stdcode && document.myform.phone)
	{
		if (document.myform.stdcode.value == "" || document.myform.phone.value == "" ) { msg = msg + "Telephone\n";}
	}
	if (document.myform.mobile)
	{
		if (document.myform.mobile.value == "") { msg = msg + "Mobile\n";}
	}
	if (document.myform.schools)
	{
		if (document.myform.schools.value.length == "0") { msg = msg + "Schools\n";}
	}
	if (document.myform.program)
	{
		if (document.myform.program.value == "")
		{
			if(document.myform.other_prog.value == "" || document.myform.other_prog.value == "If Other Specify")
			{
				msg = msg + "Program\n";
			}
		}
		else if(document.myform.program.value == "Other")
		{
			if(document.myform.other_prog.value == "" || document.myform.other_prog.value == "If Other Specify")
			{
				msg = msg + "Program\n";
			}
		}
	}
	if(document.myform.mode.value == "")
	{
		msg = msg + "Payment Option";
	}
	



	
	
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+msg);
	}
	else
	{
		document.myform.submit();
	}
}

function chkchpwdform()
{
	var msg = "";
	if (document.chpwdform.currpwd.value.length == "") { msg = msg + "Current Password\n";}


	var invalid = " "; // Invalid character is a space
	var minLength = 6; // Minimum length

	var pw1 = document.chpwdform.newpwd.value;
	var pw2 = document.chpwdform.confnewpwd.value;

	// check for a value in both fields.
	if (pw1 == '' || pw2 == '')
	{
		msg = msg + "Please enter your password twice\n";
	}

	// check for minimum length
	else if (pw1.length < minLength)
	{
		msg = msg + "Your password must be at least " + minLength + " characters long\n";
	}

	// check for spaces
	else if (pw1.indexOf(invalid) > -1)
	{
		msg = msg + "Spaces are not allowed in password\n";
	}
	else
	{
		if (pw1 != pw2) 
		{
			msg = msg + "You did not enter the same new password twice. Please re-enter new password\n";
		}
	}

	if (msg != "") 
	{
		alert("Please fill in following fields\n\n"+msg);
		return false;
	}
}

function chkuploadform()
{
	var msg = "";

	if (document.uploadform.title.value.length == "0") { msg = msg + "File Title\n";}
	if (document.uploadform.service.value == "") { msg = msg + "Select Service\n";}
	if (document.uploadform.uploadedfile.value == "") { msg = msg + "File to be uploaded\n";}
	if (document.uploadform.comment.value.length == "0") { msg = msg + "Comment\n";}
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+msg);
		return false;
	}
}

function chkreuploadform()
{
	var msg = "";

	if (document.reuploadform.title.value.length == "0") { msg = msg + "File Title\n";}
	if (document.reuploadform.service.value == "") { msg = msg + "Select Service\n";}
	if (document.reuploadform.uploadedfile.value == "") { msg = msg + "File to be uploaded\n";}
	if (document.reuploadform.comment.value.length == "0") { msg = msg + "Comment\n";}
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+msg);
		return false;
	}
}

function chkadminreuploadform()
{
	var msg = "";

	if (document.reuploadform.filetitle.value.length == "0") { msg = msg + "File Title\n";}
	if (document.reuploadform.prodid.value == "") { msg = msg + "Select Service\n";}
	if (document.reuploadform.uploadedfile.value == "") { msg = msg + "File to be uploaded\n";}
	if (document.reuploadform.comment.value.length == "0") { msg = msg + "Comment\n";}
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+msg);
		return false;
	}
}


function validategetpwdform()
{
	var msg = "";
	if (document.getpwdform.email.value == "") { msg = msg + "Email Address\n";}
	if (document.getpwdform.security_code.value == "") { msg = msg + "Type Security code\n";}
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+ msg);
		return false;
	}
	else if (msg == "")
	{
		var houseReegxp = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;

		if (!houseReegxp.test(document.getpwdform.email.value))
		{
			alert("Invalid Email Address");
			return false;
		}
		
	}
}
