

/*This style sheet id only for users.In which we define following function..*/
/*
1. function validate_cartpfrdfrm();  --for product_view.php

2. function validate_loginfrm();  --for login.php

*/





//Check add_product.php form

function validate_cartpfrdfrm()
             {
     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
/*For size Validation*/
	if(document.addtocartfrm.size.value==0)
				 {
                   document.getElementById('size_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Sorry ! Size is missing</b>";
				   if(focus_field=='') focus_field = 'size';
			       count_bug+=1;
				 }


	/* For color Name Validation*/

	if(document.addtocartfrm.color.value==0)
				 {
                   document.getElementById('color_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Sorry ! Color is missing</b>";
				   if(focus_field=='') focus_field = 'color';
			       count_bug+=1;
				 }

/* For quantity  Validation*/

	if(document.addtocartfrm.quantity.value==0)
				 {
                   document.getElementById('qty_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Sorry ! minimum quantity can't be 0.</b>";
				   if(focus_field=='') focus_field = 'quantity';
			       count_bug+=1;
				 }


	if(count_bug >0)
		return false;
	else
		return true;

}


function isNumberKey(evt,enabledot)
{
	if(!enabledot) enabledot=0;
 var charCode = (evt.which) ? evt.which : event.keyCode
	 //alert(charCode)
 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=46 && enabledot==1)
	return false;
 else if (charCode > 31 && (charCode < 48 || charCode > 57) && enabledot==0)
	return false;

 return true;
}

//////////////////////Checkform for addproduct Ends herer////////////////


/////////////////////////Check Bloks for Login ID///////////////////////
function showpass(){
//document.getElementById('pass').style.display=visible;
document.getElementById('pass').style.visibility = "visible";
}

function blockpass(){
//document.getElementById("pass").style.display=="hidden";
document.all.pass.style.visibility = "hidden";
}

function chekbug(){
if(count_bug >0){
		return false;
}else{
		return true;
}
}
///////////////////////////////////////////////////////////////////////










///////////////////////////////Login Frm Check//////////////////////////
//Check add_product.php form

function validate_loginfrm()
             {
     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
/*For email Validation*/
	if(document.loginfrm.email.value=='')
				 {
                   document.getElementById('email_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter email address</b>";
				   if(focus_field=='') focus_field = 'email';
			       count_bug+=1;
				 }


apos=document.loginfrm.email.value.indexOf("@");
dotpos=document.loginfrm.email.value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
				 {
                   document.getElementById('email_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Not a valid e-mail address!</b>";
				   if(focus_field=='') focus_field = 'email';
			       count_bug+=1;
				 }else{
                 document.getElementById('email_msg').innerHTML="";
				 count_bug=0;
				 }


	if(count_bug >0)
		return false;
	else
		return true;

}



/////////////////////////////////////////////////////////Ends//////////////////////////////////////////////////////////////////

///////////////////////////////Login Frm Check//////////////////////////
//Check add_product.php form

function validate_passwordfrm()
             {
     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}

	if(document.passwordfrm.userid.value=='')
				 {
                   document.getElementById('msg_userid').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your UserId</b>";
				   if(focus_field=='') focus_field = 'userid';
			       count_bug+=1;
				 }

/*For email Validation*/
	if(document.passwordfrm.email.value=='')
				 {
                   document.getElementById('msg_email').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter email address</b>";
				   if(focus_field=='') focus_field = 'email';
			       count_bug+=1;
				 }

else
				 {
apos=document.passwordfrm.email.value.indexOf("@");
dotpos=document.passwordfrm.email.value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
				 {
                   document.getElementById('msg_email').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Not a valid e-mail address!</b>";
				   if(focus_field=='') focus_field = 'email';
			       count_bug+=1;
				 }
				 }

	if(count_bug >0)
		return false;
	else
		return true;

}





//////////////////////////////////////////////////shopping cart form validations.///////////////////////////////////////////////////


function checkShoppingCartForm(frm){

 var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
//////////////////////////////////sender validation///////////////////////////////////////////////////////////////////////////////


/*For sender name Validation*/
	if(document.shipfrm.txiSenderName.value=='')
				 {
                   document.getElementById('send_name').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Name is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderName';
			       count_bug+=1;
				 }

/*For sender Desgination Validation*/
	/*if(document.shipfrm.txiSenderDesignation.value=='')
				 {
                   document.getElementById('send_desg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Designation is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderDesignation';
			       count_bug+=1;
				 }*/

//For sender Address Validation
	if(document.shipfrm.txaSenderAddress.value=='')
				 {
                   document.getElementById('send_address').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Address is missing</b>";
				   if(focus_field=='') focus_field = 'txaSenderAddress';
			       count_bug+=1;
				 }
//For sender City Validation
	if(document.shipfrm.txiSenderCity.value=='')
				 {
                   document.getElementById('send_city').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>City is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderCity';
			       count_bug+=1;
				 }
//For sender state Validation
	if(document.shipfrm.txiSenderState.value=='')
				 {
                   document.getElementById('send_state').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>State is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderState';
			       count_bug+=1;
				 }
//For sender zip Validation
	if(document.shipfrm.txiSenderZipcode.value=='')
				 {
                   document.getElementById('send_zip').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Zipcode is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderZipcode';
			       count_bug+=1;
				 }

//For sender phone Validation
	if(document.shipfrm.txiSenderPhone.value=='')
				 {
                   document.getElementById('send_phone').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Phone is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderPhone';
			       count_bug+=1;
				 }


//For sender email Validation
	if(document.shipfrm.txiSenderEmail.value=='')
				 {
                   document.getElementById('send_email').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Email is missing</b>";
				   if(focus_field=='') focus_field = 'txiSenderEmail';
			       count_bug+=1;
				 }

/////////////////////////////////////////////////////////end///////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////Reciepient Validations//////////////////////////////////////////////////////////////////

//For sender name Validation
	if(document.shipfrm.txiName.value=='')
				 {
                   document.getElementById('recip_name').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Name is missing</b>";
				   if(focus_field=='') focus_field = 'txiName';
			       count_bug+=1;
				 }

//For sender Desgination Validation
	/*if(document.shipfrm.txiDesignation.value=='')
				 {
                   document.getElementById('recip_desg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Designation is missing</b>";
				   if(focus_field=='') focus_field = 'txiDesignation';
			       count_bug+=1;
				 }*/

//For sender Address Validation
	if(document.shipfrm.txaAddress.value=='')
				 {
                   document.getElementById('recip_address').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Address is missing</b>";
				   if(focus_field=='') focus_field = 'txaAddress';
			       count_bug+=1;
				 }
//For sender City Validation
	if(document.shipfrm.txiCity.value=='')
				 {
                   document.getElementById('recip_city').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>City is missing</b>";
				   if(focus_field=='') focus_field = 'txiCity';
			       count_bug+=1;
				 }
//For sender state Validation
	if(document.shipfrm.txiState.value=='')
				 {
                   document.getElementById('recip_state').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>State is missing</b>";
				   if(focus_field=='') focus_field = 'txiState';
			       count_bug+=1;
				 }
//For sender zip Validation
	if(document.shipfrm.txiZipcode.value=='')
				 {
                   document.getElementById('recip_zip').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Zipcode is missing</b>";
				   if(focus_field=='') focus_field = 'txiZipcode';
			       count_bug+=1;
				 }

//For sender phone Validation
	if(document.shipfrm.txiPhone.value=='')
				 {
                   document.getElementById('recip_phone').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Phone is missing</b>";
				   if(focus_field=='') focus_field = 'txiPhone';
			       count_bug+=1;
				 }


//For sender email Validation
	if(document.shipfrm.txiEmail.value=='')
				 {
                   document.getElementById('recip_email').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Email is missing</b>";
				   if(focus_field=='') focus_field = 'txiEmail';
			       count_bug+=1;
				 }
/////////////////////////////////////////////////////end//////////////////////////////////////////////////////////////////////////////


if(count_bug >0)
		return false;
	else
		return true;

}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function doSameAs(frm){





	//if(document.frm.selSenderCountry.value=="United States"){


	if (window.document.shipfrm.sameAs.checked){


		window.document.shipfrm.selTitle.value	=			window.document.shipfrm.selSenderTitle.value;


		window.document.shipfrm.txiName.value	=			window.document.shipfrm.txiSenderName.value;


		window.document.shipfrm.txiDesignation.value	=		window.document.shipfrm.txiSenderDesignation.value;


		window.document.shipfrm.txiCompany.value	=		window.document.shipfrm.txiSenderCompany.value;


		


		window.document.shipfrm.txaAddress.value	=		window.document.shipfrm.txaSenderAddress.value;


		window.document.shipfrm.txiCity.value	=		window.document.shipfrm.txiSenderCity.value;


		window.document.shipfrm.txiState.value	=		window.document.shipfrm.txiSenderState.value;


		window.document.shipfrm.txiZipcode.value	=		window.document.shipfrm.txiSenderZipcode.value;


		window.document.shipfrm.selCountry.value	=		window.document.shipfrm.selSenderCountry.value;


		window.document.shipfrm.txiPhone.value	=		window.document.shipfrm.txiSenderPhone.value;


		window.document.shipfrm.txiEmail.value	=		window.document.shipfrm.txiSenderEmail.value;


		window.document.shipfrm.txaRemarks.value	=		window.document.shipfrm.txaSenderRemarks.value;


	}else{


		window.document.shipfrm.selTitle.value	= "";


		window.document.shipfrm.txiName.value	= "";


		window.document.shipfrm.txiDesignation.value	= "";


		window.document.shipfrm.txiCompany.value	= "";


		window.document.shipfrm.txaAddress.value	= "";


		window.document.shipfrm.txiCity.value	= "";


		window.document.shipfrm.txiState.value	= "";


		window.document.shipfrm.txiZipcode.value	= "";


		window.document.shipfrm.selCountry.value	= "";


		window.document.shipfrm.txiPhone.value	= "";


		window.document.shipfrm.txiEmail.value	= "";


		window.document.shipfrm.txaRemarks.value	= "";


	}


return true;//}


/*else{


	alert("To dispatch outside India, Please choose another Currency  ");


	return false;


}*/


}





//////////////////////////////////////////////////shopping cart form validations.///////////////////////////////////////////////////


///////////////////////////////Login Frm Check//////////////////////////
//Check add_product.php form

function validate_registration_form()
             {
     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
/*For email Validation*/
	if(document.registration_form.password.value=='')
				 {
                   document.getElementById('pass_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter Password</b>";
				   if(focus_field=='') focus_field = 'password';
			       count_bug+=1;
				 }else{
                 var passlen=document.registration_form.password.value;
				 var len=passlen.length;
                  if(len<=4){
                 document.getElementById('pass_msg').innerHTML ="&nbsp;<b>Strength is weak</b>";
				  }
				  else if((len<=6)&&(len>4)){
                document.getElementById('pass_msg').innerHTML ="&nbsp;<b>Strength is medium</b>";
				  }
				  else if(((len<=8)&&(len>6))||(len>8)){
                document.getElementById('pass_msg').innerHTML ="&nbsp;<b>Strength is high(<i>Secure</i>)</b>";
				  }
				 }



if(document.registration_form.txiName.value=='')
				 {
                   document.getElementById('name_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your name</b>";
				   if(focus_field=='') focus_field = 'txiName';
			       count_bug+=1;
				 }
if(document.registration_form.txiAddress.value=='')
				 {
                   document.getElementById('adds_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your Address</b>";
				   if(focus_field=='') focus_field = 'txiAddress';
			       count_bug+=1;
				 }

if(document.registration_form.txiCity.value=='')
				 {
                   document.getElementById('city_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your City</b>";
				   if(focus_field=='') focus_field = 'txiCity';
			       count_bug+=1;
				 }
if(document.registration_form.txiState.value=='')
				 {
                   document.getElementById('state_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your State</b>";
				   if(focus_field=='') focus_field = 'txiState';
			       count_bug+=1;
				 }
if(document.registration_form.txiPostCode.value=='')
				 {
                   document.getElementById('pin_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your Pincode</b>";
				   if(focus_field=='') focus_field = 'txiPostCode';
			       count_bug+=1;
				 }
if(document.registration_form.txiPhone.value=='')
				 {
                   document.getElementById('phone_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your Pincode</b>";
				   if(focus_field=='') focus_field = 'txiPhone';
			       count_bug+=1;
				 }
if(document.registration_form.txiEmailAddress.value=='')
				 {
                   document.getElementById('email_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Enter your email</b>";
				   if(focus_field=='') focus_field = 'txiEmailAddress';
			       count_bug+=1;
				 }

apos=document.registration_form.txiEmailAddress.value.indexOf("@");
dotpos=document.registration_form.txiEmailAddress.value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
				 {
                   document.getElementById('email_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Not a valid e-mail address!</b>";
				   if(focus_field=='') focus_field = 'txiEmailAddress';
			       count_bug+=1;
				 }




	if(count_bug >0)
		return false;
	else
		return true;

}



/////////////////////////////////////////////////////////Ends//////////////////////////////////////////////////////////////////


///////////////////////////////Change Passowrd Form Check//////////////////////////


function validate_changepass_form()
             {
     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
/*For email Validation*/
	
if(document.changepass_form.txiUserId.value!=document.changepass_form.uid.value)
				 {
                   document.getElementById('userid_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Sorry Wrong User Id</b>";
				   if(focus_field=='') focus_field = 'txiUserId';
			       count_bug+=1;
				 }
if(document.changepass_form.txiPassword.value!=document.changepass_form.oldpass.value)
				 {
                   document.getElementById('pass_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Sorry Wrong Password</b>";
				   if(focus_field=='') focus_field = 'txiPassword';
			       count_bug+=1;
				 }



	if(count_bug >0)
		return false;
	else
		return true;

}



/////////////////////////////////////////////////////////Ends//////////////////////////////////////////////////////////////////

///////////////////////////////Login Frm Check//////////////////////////
//Check add_product.php form

function validate_paymentfrm(thisform)
             {
				
myOption = -1;
for (i=thisform.pay.length-1; i > -1; i--) {
if (thisform.pay[i].checked) {
myOption = i; i = -1;
}
}


     var count_bug=0;
	var focus_field = '';	
	var tmp_arr = document.getElementsByTagName("div");
	for(var i = 0; i < tmp_arr.length; i++)
	{
		if(tmp_arr[i].className == "texterror")
		{
			 tmp_arr[i].innerHTML = "&nbsp;";
		}
	}
/*For Payment Options Validation*/
	if(myOption == -1)
				 {
                   document.getElementById('payment_msg').innerHTML ="<img src='images/error_icon.gif'>&nbsp;<b>Please Chose atlest One Payment Options</b>";
				   if(focus_field=='') focus_field = 'pay';
			       count_bug+=1;
				 }




	if(count_bug >0)
		return false;
	else
		return true;

}



/////////////////////////////////////////////////////////Ends//////////////////////////////////////////////////////////////////



///////////////////////////////Add to cart Check//////////////////////////

function check_quantity(qty)
{

if(qty==0){
alert("Sorry On selecting this quantity minimum quantity will be added");
}
}

///////////////////////////////////////Ends///////////////////////////////