//login.php
function login(f)
{
	
		var alertMsg = "";
	if(f.email.value == ""){
		alertMsg += "Username is Mandatory.\n";
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alertMsg += "Email address is incorrect.\n";
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alertMsg += "Email address contains illegal characters.\n";
		 }
	}
	if(f.pass.value == ""){
		alertMsg += "Password is Mandatory.\n";
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}
}

//forgetpass.php
function checkforgetpass(f)
{
		
		var alertMsg = "";
	
	if(f.emailreq.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	else
	{
		var f1=f.emailreq.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alertMsg += "Email address is incorrect.\n";
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alertMsg += "Email address contains illegal characters.\n";
		 }
		
		
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}

}

// our_menu.php
function checkmenuitem(f)
{
	var qty = document.getElementsByName('item[]');

	var alertMsg = "";
	for(i=0;i<qty.length;i++)
	{
		//alert(qty[i].checked);
		if(qty[i].checked == true)
		{
			f.submit();
			return true;
		}
		else
		{
			alertMsg = "Please Select Menu.\n";
		}
		
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}

}
//signup.php
function checksignup(f)
{
	var alertMsg = "";
	if(f.fname.value == ""){
		alertMsg += "First Name is Mandatory.\n";
	}
	if(f.mname.value == ""){
		alertMsg += "Middle Name is Mandatory.\n";
	}
	if(f.lname.value == ""){
		alertMsg += "Last Name is Mandatory.\n";
	}
	if(f.add1.value == ""){
		alertMsg += "Address1 is Mandatory.\n";
	}
	if(f.add2.value == ""){
		alertMsg += "Address2 is Mandatory.\n";
	}
	if(f.country.value == ""){
		alertMsg += "Country is Mandatory.\n";
	}
	if(f.state.value == ""){
		alertMsg += "State is Mandatory.\n";
	}
	if(f.city.value == ""){
		alertMsg += "City is Mandatory.\n";
	}
	if(f.zip.value == ""){
		alertMsg += "Zip Code is Mandatory.\n";
	}
	else
	{
			if(isNaN(f.zip.value))
			{
			alertMsg += "Zip Code should be number.\n";
			}
	}
	if(f.phone.value == ""){
		alertMsg += "Phone is Mandatory.\n";
	}
	else
	{
			if(isNaN(f.phone.value))
			{
			alertMsg += "Phone should be number.\n";
			}
	}
	if(f.email.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alertMsg += "Email address is incorrect.\n";
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alertMsg += "Email address contains illegal characters.\n";
		 }
	}
	if(f.pass.value == ""){
		alertMsg += "Password is Mandatory.\n";
	}
	if(f.cpass.value == ""){
		alertMsg += "Confirm Password is Mandatory.\n";
	}
	else
	{
		if(f.cpass.value != f.pass.value)
		{
			alertMsg += "Password and Confirm Password don't matched.\n";
		}
	}
	
	
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}	
}
//payment.php
function checkbillinguser(f)
{
	var qty = document.getElementsByName('qty[]');

	var alertMsg = "";
	for(i=0;i<qty.length;i++)
	{
		if(qty[i].value == "")
		{
			alertMsg = "Quantity is Mandatory.\n";
		}
		else
		{
			if(isNaN(qty[i].value))
			{
			alertMsg += "Quantity should be number.\n";
			}
		}
	
		
	}
	if(f.fname.value == ""){
		alertMsg += "First Name is Mandatory.\n";
	}
	if(f.mname.value == ""){
		alertMsg += "Middle Name is Mandatory.\n";
	}
	if(f.lname.value == ""){
		alertMsg += "Last Name is Mandatory.\n";
	}
	if(f.add1.value == ""){
		alertMsg += "Address1 is Mandatory.\n";
	}
	if(f.add2.value == ""){
		alertMsg += "Address2 is Mandatory.\n";
	}
	if(f.country.value == ""){
		alertMsg += "Country is Mandatory.\n";
	}
	if(f.state.value == ""){
		alertMsg += "State is Mandatory.\n";
	}
	if(f.city.value == ""){
		alertMsg += "City is Mandatory.\n";
	}
	if(f.zip.value == ""){
		alertMsg += "Zip Code is Mandatory.\n";
	}
	else
	{
			if(isNaN(f.zip.value))
			{
			alertMsg += "Zip Code should be number.\n";
			}
	}
	if(f.phone.value == ""){
		alertMsg += "Phone is Mandatory.\n";
	}
	else
	{
			if(isNaN(f.phone.value))
			{
			alertMsg += "Phone should be number.\n";
			}
	}
	if(f.holdername.value == ""){
		alertMsg += "Holder Name is Mandatory.\n";
	}
	if(f.dbno.value == ""){
		
		alertMsg += "Cerdit Card Number is Mandatory.\n";
	}
	else
	{
			if(isNaN(f.dbno.value))
			{
			alertMsg += "Cerdit Card Number should be number.\n";
			}
	}
	if(f.dbno.value.length > 16){
		
		alertMsg += "Cerdit Card Number  must be less than sixteen.\n";
	}
	
	if(f.code.value == ""){
		alertMsg += "Security Code is Mandatory.\n";
	}
	if(f.code.value.length > 4){
		alertMsg += "Security Code must be less than four.\n";
	}
	if(f.expdate.value == ""){
		alertMsg += "Expire Date is Mandatory.\n";
	}
	
	
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}	
}



