//-----------valodation for Category starts----------------------//


function categorycheck(f)
{
		var alertMsg = "";
	if(f.cname.value == ""){
		alertMsg += "Category Name is Mandatory.\n";
		f.cname.focus();
	}
	if(f.sortby.value == ""){
		alertMsg += "Sortby is Mandatory.\n";
		f.sortby.focus();
	}
	if(f.sortby.value == 0){
		alertMsg += "Sortby is not zero.\n";
		f.sortby.focus();
	}
	bool=f.sortby.value.match("^[0-9]{1,4}$");
	if((!bool)||isNaN(f.sortby.value)||(f.sortby.value.indexOf(".")!=-1)){
		alertMsg += "Sortby must be number.\n";
		f.sortby.focus();
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
function categorycheckedit(f)
{
		var alertMsg = "";
	if(f.edit_name.value == ""){
		alertMsg += "Category Name is Mandatory.\n";
		f.edit_name.focus();
	}
	if(f.edit_sortby.value == ""){
		alertMsg += "Sortby is Mandatory.\n";
		f.edit_sortby.focus();
	}
	if(f.edit_sortby.value == 0){
		alertMsg += "Sortby is not zero.\n";
		f.edit_sortby.focus();
	}
	pattern="[0-9]{1,4}$";
	if( !f.edit_sortby.value.match(pattern) ){
		alertMsg += "Sortby must be number.\n";
		f.edit_sortby.focus();
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
//-----------valodation for category ends----------------------//


//-----------valodation for Change password start----------------------//

function checkpass(f)
{
		var alertMsg = "";
	if(f.old.value == ""){
		alertMsg += "Old Password is Mandatory.\n";
	}
	if(f.newp.value == ""){
		alertMsg += "New Password is Mandatory.\n";
	}
	if(f.conf_pass.value == ""){
		alertMsg += "Confirm Password is Mandatory.\n";
	}
	else
	{
		if(f.conf_pass.value != f.newp.value){
		alertMsg += "Password & Confirm Password didnot matched.\n";
		}	
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		//f.submit();
		return true;
	}

}

//-----------valodation for Change password ends----------------------//

//-----------valodation for Change password for client start----------------------//

function checkpassc(f)
{
		var alertMsg = "";
	if(f.old_pass.value == ""){
		alertMsg += "Old Password is Mandatory.\n";
	}
	if(f.new_pass.value == ""){
		alertMsg += "New Password is Mandatory.\n";
	}
	if(f.conf_pass.value == ""){
		alertMsg += "Confirm Password is Mandatory.\n";
	}
	else
	{
		if(f.conf_pass.value != f.new_pass.value){
		alertMsg += "Password & Confirm Password didnot matched.\n";
		}	
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		//f.submit();
		return true;
	}

}

//-----------valodation for Change password for client ends----------------------//


//-----------valodation for product starts----------------------//

function productcheck(f)
{
		var alertMsg = "";
	if(f.proname.value == ""){
		alertMsg += "Product Name is Mandatory.\n";
		f.proname.focus();
	}
	if(f.procode.value == ""){
		alertMsg += "Product Code is Mandatory.\n";
		f.procode.focus();
	}
	if(f.manufacture.value == 0){
		alertMsg += "Manufacture is Mandatory.\n";
		f.manufacture.focus();
	}
	if(f.proprice.value == ""){
		alertMsg += "Product Price is Mandatory.\n";
		f.proprice.focus();
	}
	else
	{
			pattern="[0-9]$";
			if( !f.proprice.value.match(pattern) ){
				alertMsg += "Price must be number.\n";
				f.proprice.focus();
			}
	}
	if(f.sortby.value == ""){
		alertMsg += "Sortby is Mandatory.\n";
		f.sortby.focus();
	}
	else
	{
			
			if(f.sortby.value == 0)
			{
				alertMsg += "Sortby is not null.\n";
				f.sortby.focus();
			}
			
			bool=f.sortby.value.match("^[0-9]{1,4}$");
			if((!bool)||isNaN(f.sortby.value)||(f.sortby.value.indexOf(".")!=-1)){
				alertMsg += "Sortby must be number.\n";
				f.sortby.focus();
			}
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
function productcheckedit(f)
{
		var alertMsg = "";
	if(f.eproname.value == ""){
		alertMsg += "Product Name is Mandatory.\n";
		f.eproname.focus();
	}
	if(f.eprocode.value == ""){
		alertMsg += "Product Code is Mandatory.\n";
		f.eprocode.focus();
	}
	if(f.emanufacture.value == 0){
		alertMsg += "Manufacture is Mandatory.\n";
		f.emanufacture.focus();
	}
	if(f.eprorate.value == ""){
		alertMsg += "Product Price is Mandatory.\n";
		f.eprorate.focus();
	}
	else
	{
			pattern="[0-9]$";
			if( !f.eprorate.value.match(pattern) ){
				alertMsg += "Price must be number.\n";
				f.eprorate.focus();
			}
	}
	if(f.eprosortby.value == ""){
		alertMsg += "Sortby is Mandatory.\n";
		f.eprosortby.focus();
	}
	else
	{
			if(f.eprosortby.value == 0)
			{
				alertMsg += "Sortby is not null.\n";
				f.eprosortby.focus();
			}
			
			bool=f.eprosortby.value.match("^[0-9]{1,4}$");
			if((!bool)||isNaN(f.eprosortby.value)||(f.eprosortby.value.indexOf(".")!=-1)){
				alertMsg += "Sortby must be number.\n";
				f.eprosortby.focus();
			}
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
//-----------valodation for product ends----------------------//

//-----------valodation for login starts----------------------//

function login(f)
{
	if( isloginname(f) && isloginpass(f) )
	{
		f.submit();
	}	
	else
	{
		return(false);
	}
}

function isloginname(f)
{
	if(f.username.value == "")
	{
		alert("Login Name is mandatory");
		f.username.focus();
		return(false);
	}
	else
	{
		return(true);
	}
}

function isloginpass(f)
{
	if(f.password.value=="")
	{
		alert("Password is mandatory");
		f.password.focus();
		return(false);
	}
return(true);
}
//-----------valodation for login ends----------------------//

//-----------valodation for admin email start----------------------//

function checkemail(f)
{
		var alertMsg = "";
	
	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(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		//f.submit();
		return true;
	}

}

//-----------valodation for admin email ends----------------------//

//-----------valodation for new registration starts----------------------//

function regcheck(f)
{
		var alertMsg = "";
	if(f.f_sh_name.value == ""){
		alertMsg += "Shipping Address First Name is Mandatory.\n";
	}
	if(f.sh_address.value == ""){
		alertMsg += "Shipping Address is Mandatory.\n";
	}
	if(f.sh_country.value == ""){
		alertMsg += "Shipping Address Country is Mandatory.\n";
	}
	if(f.sh_state.value == ""){
		alertMsg += "Shipping Address State is Mandatory.\n";
	}
	if(f.sh_city.value == ""){
		alertMsg += "Shipping Address City is Mandatory.\n";
	}
	if(f.sh_postalcode.value == ""){
		alertMsg += "Shipping Address Postal Code is Mandatory.\n";
	}
	if(f.f_b_name.value == ""){
		alertMsg += "Billing Address First Name is Mandatory.\n";
	}
	if(f.b_address.value == ""){
		alertMsg += "Billing Address is Mandatory.\n";
	}
	if(f.b_country.value == ""){
		alertMsg += "Billing Address Country is Mandatory.\n";
	}
	if(f.b_state.value == ""){
		alertMsg += "Billing Address state is Mandatory.\n";
	}
	if(f.b_city.value == ""){
		alertMsg += "Billing Address City is Mandatory.\n";
	}
	if(f.b_postalcode.value == ""){
		alertMsg += "Billing Address Postal Code is Mandatory.\n";
	}
	if(f.email.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	if(f.cemail.value == ""){
		alertMsg += "Confirm Email is Mandatory.\n";
	}
	if(f.cemail.value != f.email.value){
		alertMsg += "Email and Confirm Email did not matched.\n";
	}
	if(f.password.value == ""){
		alertMsg += "Password is Mandatory.\n";
	}
	if(f.cpassword.value == ""){
		alertMsg += "Confirm Password is Mandatory.\n";
	}
	if(f.password.value != f.cpassword.value){
		alertMsg += "Password and Confirm Password did not matched.\n";
	}
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

//-----------valodation for  new registration ends----------------------//
//-----------valodation for new registration starts----------------------//

function regshipbillcheck(f)
{
		var alertMsg = "";
	if(f.f_sh_name.value == ""){
		alertMsg += "Shipping Address First Name is Mandatory.\n";
	}
	if(f.sh_address.value == ""){
		alertMsg += "Shipping Address is Mandatory.\n";
	}
	if(f.sh_country.value == ""){
		alertMsg += "Shipping Address Country is Mandatory.\n";
	}
	if(f.sh_state.value == ""){
		alertMsg += "Shipping Address State is Mandatory.\n";
	}
	if(f.sh_city.value == ""){
		alertMsg += "Shipping Address City is Mandatory.\n";
	}
	if(f.sh_postalcode.value == ""){
		alertMsg += "Shipping Address Postal Code is Mandatory.\n";
	}
	if(f.f_b_name.value == ""){
		alertMsg += "Billing Address First Name is Mandatory.\n";
	}
	if(f.b_address.value == ""){
		alertMsg += "Billing Address is Mandatory.\n";
	}
	if(f.b_country.value == ""){
		alertMsg += "Billing Address Country is Mandatory.\n";
	}
	if(f.b_state.value == ""){
		alertMsg += "Billing Address state is Mandatory.\n";
	}
	if(f.b_city.value == ""){
		alertMsg += "Billing Address City is Mandatory.\n";
	}
	if(f.b_postalcode.value == ""){
		alertMsg += "Billing Address Postal Code is Mandatory.\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(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

//-----------valodation for  new registration ends----------------------//

//-----------valodation for coping sh to billing  starts----------------------//

function copyshtobilling(form)
{
	index_sep=8;
	if(form.shsamebilling.checked)
	{
		
		for(counter=0;counter<8;counter++)
		{
			
			//alert(form[counter].value);
			index_sep++;
			form[index_sep].value=form[counter].value;
			
		}
		
	}
	else
	{
		index_sep=8;
		for(counter=0;counter<8;counter++)
		{
			index_sep++;
			form[index_sep].value="";
		}	
	}
}
//-----------valodation for coping sh to billing  ends----------------------//
//-----------valodation for  credit card starts----------------------//

function cardcheck(f)
{
		var alertMsg = "";
	
	if(f.holder_name.value == ""){
		alertMsg += "Holder Name is Mandatory.\n";
	}
	if(f.credit_no.value == ""){
		
		alertMsg += "Cerdit Card Number is Mandatory.\n";
	}
	if(f.credit_no.value.length > 16){
		
		alertMsg += "Cerdit Card Number  must be less than sixteen.\n";
	}
	
	if(f.security_code.value == ""){
		alertMsg += "Security Code is Mandatory.\n";
	}
	if(f.security_code.value.length > 4){
		alertMsg += "Security Code must be less than four.\n";
	}
	if(f.exp_date.value == ""){
		alertMsg += "Expire Date is Mandatory.\n";
	}
	
	
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}


//-----------valodation for  credit card  ends----------------------//

//-----------valodation for update cart  satrts----------------------//


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((!bool)||isNaN(qty[i].value)||(qty[i].value.indexOf(".")!=-1))
		{
		alertMsg = "Quantity must be number.\n";
		
		}
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

//-----------valodation for update cart  ends----------------------//
//-----------valodation for forget password  start----------------------//

function checkforgetpass(f)
{
		
		var alertMsg = "";
	
	if(f.emailadd.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	else
	{
		var f1=f.emailadd.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;
	}

}

//-----------valodation for forget password ends----------------------//

//-----------valodation forlogin client starts----------------------//

function loginclientcheck(f)
{
		var alertMsg = "";
	if(f.email.value == ""){
		alertMsg += "Login Name is Mandatory.\n";
	}
	if(f.pass.value == ""){
		alertMsg += "Password is Mandatory.\n";
	}
	
	
	
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
//-----------valodation forlogin client ends----------------------//

//-----------valodation for sub Category starts----------------------//


function subcategorycheck(f)
{
		
		var alertMsg = "";
	if(f.subname.value == ""){
		alertMsg += "SubCategory Name is Mandatory.\n";
		f.subname.focus();
	}
	if(f.sortby.value == ""){
		alertMsg += "Sortby is Mandatory.\n";
		f.sortby.focus();
	}
	if(f.sortby.value == 0){
		alertMsg += "Sortby is not zero.\n";
		f.sortby.focus();
	}
		bool=f.sortby.value.match("^[0-9]{1,4}$");
	if((!bool)||isNaN(f.sortby.value)||(f.sortby.value.indexOf(".")!=-1)){
		alertMsg += "Sortby must be number.\n";
		f.sortby.focus();
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
//-----------valodation for sub Category ends----------------------//

//-----------valodation for edit sub Category starts----------------------//


function editsubcategorycheck(f)
{
		
		var alertMsg = "";
	if(f.ename.value == ""){
		alertMsg += "SubCategory Name is Mandatory.\n";
		f.ename.focus();
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
//-----------valodation for edit sub Category ends----------------------//
//-----------valodation for add to cart  satrts----------------------//


function checkaddtocart(f)
{
	
	var alertMsg = "";

	if(f.qty.value == ""){
		alertMsg += "Quantity is Mandatory.\n";
		f.qty.focus();
	}
	if(f.qty.value == 0){
		alertMsg += "Quantity is not zero.\n";
		f.qty.focus();
	}
		bool=f.qty.value.match("^[0-9]{1,2}$");

	if((!bool) || isNaN(f.qty.value)|| (f.qty.value.indexOf(".")!=-1)){
		alertMsg += "Quantity must be number.\n";
		f.qty.focus();
	}
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

//-----------valodation for add to cart  ends----------------------//

