function CheckAdvanceSearch(f)
{
	if(f.searchtext.value == "")
	{
		alert("Search Text is Mandatory.");
		do_blink(f.searchtext);
		return(false);
	}
	f.submit();
}
function validateCard(f)
{
	if(f.ccfname.value == "")
	{
		alert("Name on card is Mandatory.");
		do_blink(f.ccfname);
		return(false);
	}
	
	if(f.ACCT.value == "")
	{
		alert("Card Number is Mandatory.");
		do_blink(f.ACCT);
		return(false);
	}
	else
	{
		
		
		if(!checkCreditCard(f.ACCT.value,f.cardtype.value))
		{
			alert("Invalid card number.");
			return(false);
		}
	}
	if(f.ccv.value == "")
	{
		alert("Security Code is Mandatory.");
		do_blink(f.ccv);
		return(false);
	}
	var currdate = new Date();
	var indate = new Date(f.year.value,f.month.value);
	
	if(f.month.value == "")
	{
		alert("Expire month is Mandatory.");
		//do_blink(f.month);
		return(false);
	}
	if(f.year.value == "")
	{
		alert("Expire year is Mandatory.");
		//do_blink(f.year);
		return(false);
	}
	else
	{
		if (indate < currdate)
		{
			alert("Invalid expire date.");
			return(false);
			
		}	
	}

	f.submit();
}

function CheckShipBill(f)
{
	
	if(f.bname.value == '')
	{
		alert("Name is Mandatory.");
		do_blink(f.bname);
		return false;
	}
	
	if(f.bstreetadd1.value == '')
	{
		alert("Address is Mandatory.");
		do_blink(f.bstreetadd1);
		return false;
	}


	
	if(f.bcity.value == '')
	{
		alert("City is Mandatory.");
		do_blink(f.bcity);
		return false;
	}
		if(f.bstate.value == '')
	{
		alert("State is Mandatory.");
		do_blink(f.bstate);
		return false;
	}
		
	if(f.bzip.value == ""){
		alert("Zip is Mandatory.");
		do_blink(f.bzip);
		return(false);
	}
	if(f.bemail.value == "")
	{
		alert("Email is Mandatory.");
		do_blink(f.bemail);
		return false;
	}
	else
	{
		var f1=f.bemail.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.bemail);
			return false;
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 	alert("Email address contains illegal characters.");
				do_blink(f.bemail);
				return false;
		 }
	}
	if(f.sname.value == '')
	{
		alert("Name is Mandatory.");
		do_blink(f.sname);
		return false;
	}
	if(f.sstreetadd1.value == '')
	{
		alert("Street Address is Mandatory.");
		do_blink(f.sstreetadd1);
		return false;
	}
	
	if(f.scity.value == '')
	{
		alert("City is Mandatory.");
		do_blink(f.scity);
		return false;
	}
	if(f.sstate.value == '')
	{
		alert("State is Mandatory.");
		do_blink(f.sstate);
		return false;
	}
	
	if(f.szip.value == '')
	{
		alert("Zip is Mandatory.");
		do_blink(f.szip);
		return false;
	}
	/*if(f.deliverydate.value == '')
	{
		alert("Delivery Date is Mandatory.");
		do_blink(f.deliverydate);
		return false;
	}*/
	
		
	
	
	
	f.submit();
}
// convert shipping to billing
function copyshipbill(form)
{
	index_sep=11;
	if(form.shipbill.checked)
	{
		
		for(counter=0;counter<7;counter++)
		{
			
			//alert(form[counter].value);
			index_sep++;
			form[index_sep].value=form[counter].value;
			
		}
		
	}
	else
	{
		index_sep=11;
		for(counter=0;counter<7;counter++)
		{
			index_sep++;
			form[index_sep].value="";
		}	
	}
}
// convert shipping to billing
function copyshtobilling(form)
{
	index_sep=12;
	if(form.shsamebilling.checked)
	{
		
		for(counter=0;counter<12;counter++)
		{
			
			//alert(form[counter].value);
			index_sep++;
			form[index_sep].value=form[counter].value;
			
		}
		
	}
	else
	{
		index_sep=12;
		for(counter=0;counter<12;counter++)
		{
			index_sep++;
			form[index_sep].value="";
		}	
	}
}
// update qty
function CheckQty(f)
{
	var qty = document.getElementsByName('qty[]');

	var alertMsg = "";
	for(i=0;i<qty.length;i++)
	{
		if(qty[i].value == 0)
		{
			alertMsg = "Quantity Should not be Zero or Null.\n";
		}
		bool=qty[i].value.match("^[0-9]{1,2}$");
		if(isNaN(qty[i].value)||(qty[i].value.indexOf(".")!=-1))
		{
			alertMsg = "Quantity must be number.\n";
		}
		else if((!bool))
		{
			alertMsg += "Quantity must be 0-99.\n";	
		}
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		f.submit();
		return true;
	}

}

function CheckContactUs(f)
{
	if(f.name.value == ""){
		alert("Name is Mandatory.");
		do_blink(f.name);
		return(false);
	}
		
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			alert("Email address contains illegal characters.");
			do_blink(f.email);
			return(false);
		 }
	}
	
	if(f.comments.value == ""){
		alert("Comments is Mandatory.");
		do_blink(f.comments);
		return(false);
	}
	
	if(f.txtCaptcha.value == ""){
		alert("Security code is Mandatory.");
		do_blink(f.txtCaptcha);
		return(false);
	}
	f.submit();
}
// check signup
function CheckSignup(f)
{
	
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	if(f.lname.value == ""){
		alert("Last Name is Mandatory.");
		do_blink(f.lname);
		return(false);
	}
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			alert("Email address contains illegal characters.");
			do_blink(f.email);
			return(false);
		 }
		
		
	}
	if(f.address1.value == ""){
		alert("Address1 is Mandatory.");
		do_blink(f.address1);
		return(false);
	}
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	if(f.postcode.value == ""){
		alert("Postcode is Mandatory.");
		do_blink(f.postcode);
		return(false);
	}
	/*else
	{
		if(!checkPostCode(f.postcode.value)) 
		{
			alert("Postcode is incorrect.");
			do_blink(f.postcode);
			return(false);
		}	
	}*/
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	if(f.county.value == ""){
		alert("County is Mandatory.");
		do_blink(f.county);
		return(false);
	}
	if(f.telephone.value == ""){
		alert("Telephone is Mandatory.");
		do_blink(f.telephone);
		return(false);
	}
	/*else
	{
		if (!checkUKTelephone(f.telephone.value)) 
		{
			alert("Telephone is incorrect.");
			do_blink(f.telephone);
			return(false);
		}	
	}*/
	if(f.password.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.password);
		return(false);
	}
	else
	{
		if(f.password.value.length < 6)
		{
			alert("Password must be atleast six character.");
			do_blink(f.password);
			return(false);
		}
	}
	if(f.cpassword.value == ""){
		alert("Confirm password is Mandatory.");
		do_blink(f.cpassword);
		return(false);
	}
	else
	{
		if(f.cpassword.value.length < 6)
		{
			alert("Confirm password must be atleast six character.");
			do_blink(f.cpassword);
			return(false);
		}
		else
		{
			if(f.password.value != f.cpassword.value)
			{
				alert("Password and Confirm password didn't match.");
				do_blink(f.password);
				do_blink(f.cpassword);
				return(false);	
			}
		}
	}
	
	f.submit();
	return true;
}
// check login
function CheckLogin(f)
{
	
	
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			alert("Email address contains illegal characters.");
			do_blink(f.email);
			return(false);
		 }
		
		
	}
	if(f.pass.value == ""){
		alert("Password is Mandatory.");
		do_blink(f.pass);
		return(false);
	}
	else
	{
		if(f.pass.value.length < 6)
		{
			alert("Invalid password length.Must be atleast six character.");
			do_blink(f.pass);
			return(false);	
		}
	}
	
	f.submit();
	return true;
}
// check forget pass
function CheckForgetPass(f)
{
	if(f.email.value == ""){
		alert("Email is Mandatory.");
		do_blink(f.email);
		return(false);
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  	alert("Email address is incorrect.");
			do_blink(f.email);
			return(false);
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			alert("Email address contains illegal characters.");
			do_blink(f.email);
			return(false);
		 }
	}
	f.submit();
	return true;
}
// check change pass
function CheckChangePass(f)
{
	if(f.oldpass.value == ""){
		alert("Old Password is Mandatory.");
		do_blink(f.oldpass);
		return(false);
	}
	else
	{
		if(f.oldpass.value.length < 6)
		{
			alert("Invalid password length.Must be atleast six character.");
			do_blink(f.oldpass);
			return(false);	
		}
	}
	
	if(f.newpass.value == ""){
		alert("New Password is Mandatory.");
		do_blink(f.newpass);
		return(false);
	}
	else
	{
		if(f.newpass.value.length < 6)
		{
			alert("Invalid password length.Must be atleast six character.");
			do_blink(f.newpass);
			return(false);	
		}
	}
	
	if(f.cnewpass.value == ""){
		alert("Confirm new password is Mandatory.");
		do_blink(f.cnewpass);
		return(false);
	}
	else
	{
		if(f.cnewpass.value.length < 6)
		{
			alert("Invalid password length.Must be atleast six character.");
			do_blink(f.cnewpass);
			return(false);	
		}
		else
		{
			if(f.cnewpass.value != f.newpass.value)
			{
				alert("New password and Confirm password didn't match.");
				do_blink(f.cnewpass);
				return(false);
			}	
		}
	}
	
	f.submit();
	return true;
}
// check account info
function CheckAccount(f)
{
	
	if(f.fname.value == ""){
		alert("First Name is Mandatory.");
		do_blink(f.fname);
		return(false);
	}
	if(f.lname.value == ""){
		alert("Last Name is Mandatory.");
		do_blink(f.lname);
		return(false);
	}
	
	
	if(f.address1.value == ""){
		alert("Address1 is Mandatory.");
		do_blink(f.address1);
		return(false);
	}
	if(f.city.value == ""){
		alert("City is Mandatory.");
		do_blink(f.city);
		return(false);
	}
	if(f.postcode.value == ""){
		alert("Postcode is Mandatory.");
		do_blink(f.postcode);
		return(false);
	}
	
	if(f.country.value == ""){
		alert("Country is Mandatory.");
		do_blink(f.country);
		return(false);
	}
	if(f.county.value == ""){
		alert("County is Mandatory.");
		do_blink(f.county);
		return(false);
	}
	if(f.telephone.value == ""){
		alert("Telephone is Mandatory.");
		do_blink(f.telephone);
		return(false);
	}
	
	
	
	f.submit();
	return true;
}


