function addVal(fldName, flag) {
	var box = eval('document.frmCart.' + fldName); 
	if (flag=="1") {
		box.value=Math.floor(box.value)+1;
	}
 	else if (box.value>1) {
 		box.value=Math.floor(box.value)-1;
	}
}
function checkFrmInquiry() {
	var rForm=document.frmSendMail;
	var len=rForm.elements.length;  
	var isSelect=2;
	for(i=0; i<len; i++) {
        if (rForm.elements[i].type == "checkbox" && rForm.elements[i].checked==true) {
	        isSelect=1;
	        break;
		}
	}
	if(isSelect==2) {
		alert("Please select atleast one item, before submit this form !!");
		return false;
	}
}
//==login form validation
function chklogin(file) {
	var frm2=document.login;
	if(!checkEmail(frm2.email_address.value)) {
		alert("Please enter valid email address...");
		frm2.email_address.focus();
		return false;
	}
	if(frm2.email_address.value.indexOf('@') != frm2.email_address.value.lastIndexOf('@')) {
		  alert("Please enter One E-mail address only");
		  frm2.email_address.focus();
		  return false;
	}
	if(file=='mem_register') {
	if(chktrim(frm2.password.value).length <=0) {
		alert("Please enter your password.");
		frm2.password.focus();
        return false;
     }
   }
}
//===========================================//
//==This function is modified by Anajli as per required form field==//
function chkFrmProfile(file) {
	
	var frm2=document.registration;
	if(chktrim(frm2.vFName1.value).length <=0) {
		alert("Please enter your first name.");
		frm2.vFName1.focus();
        return false;
	}
	if(chktrim(frm2.vLName1.value).length <=0) {
		alert("Please enter your last name.");
		frm2.vLName1.focus();
        return false;
	}
	
	if(chktrim(frm2.vCode1.value).length <=0) {
		alert("Please enter your country code.");
		frm2.vCode1.focus();
        return false;
	}
	if(chktrim(frm2.vArea1.value).length <=0) {
		alert("Please enter your area code.");
		frm2.vArea1.focus();
        return false;
	}
	if(chktrim(frm2.vPhone1.value).length <=0) {
		alert("Please enter your phone number.");
		frm2.vPhone1.focus();
        return false;
	}
	if(chktrim(frm2.vAddress1.value).length <=0) {
		alert("Please enter your address details.");
		frm2.vAddress1.focus();
        return false;
	}
	if(chktrim(frm2.vCity1.value).length <=0) {
		alert("Please enter your city.");
		frm2.vCity1.focus();
        return false;
	}
	if(chktrim(frm2.vState1.value).length <=0) {
		alert("Please enter your state.");
		frm2.vState1.focus();
        return false;
	}
	if(chktrim(frm2.vZip1.value).length <=0) {
		alert("Please enter your pincode.");
		frm2.vZip1.focus();
        return false;
	}
	if(frm2.vContID1.value==0) {
		alert("Please select your country from the list.");
		frm2.vContID1.focus();
        return false;
	}
	if(chktrim(frm2.vFName2.value).length <=0) {
		alert("Please enter your first name.");
		frm2.vFName2.focus();
        return false;
	}
	if(chktrim(frm2.vLName2.value).length <=0) {
		alert("Please enter your last name.");
		frm2.vLName2.focus();
        return false;
	}
	
	if(chktrim(frm2.vCode2.value).length <=0) {
		alert("Please enter your country code.");
		frm2.vCode2.focus();
        return false;
	}
	if(chktrim(frm2.vArea2.value).length <=0) {
		alert("Please enter your area code.");
		frm2.vArea2.focus();
        return false;
	}
	if(chktrim(frm2.vPhone2.value).length <=0) {
		alert("Please enter your phone number.");
		frm2.vPhone2.focus();
        return false;
	}
	if(chktrim(frm2.vAddress3.value).length <=0) {
		alert("Please enter your address details.");
		frm2.vAddress3.focus();
        return false;
	}
	if(chktrim(frm2.vCity2.value).length <=0) {
		alert("Please enter your city.");
		frm2.vCity2.focus();
        return false;
	}
	if(chktrim(frm2.vState2.value).length <=0) {
		alert("Please enter your state.");
		frm2.vState2.focus();
        return false;
	}
	if(chktrim(frm2.vZip2.value).length <=0) {
		alert("Please enter your pincode.");
		frm2.vZip2.focus();
        return false;
	}
	if(frm2.vContID2.value==0) {
		alert("Please select your country from the list.");
		frm2.vContID2.focus();
        return false;
	}
	if(file=='new') {
		if(!checkEmail(frm2.vEmail.value)) {
			alert("Please enter valid email address...");
			frm2.vEmail.focus();
			return false;
		}
		if(frm2.vEmail.value.indexOf('@') != frm2.vEmail.value.lastIndexOf('@')) {
			  alert("Please enter One E-mail address only");
			  frm2.vEmail.focus();
			  return false;
		}
		if(frm2.vPassWord.value==0) {
		alert("Please enter your password.");
		frm2.vPassWord.focus();
        return false;
	}
  }
 else if(file=='edit')
  {
		 if(frm2.old_password.value=="")
	    {
		   alert("Please enter the old password...");  
	       frm2.old_password.focus();    
	       return false; 
		}
	    if(frm2.new_password.value=="")
	    {
		     alert(" Please enter the newpassword.");
	       	 frm2.new_password.focus();
	         return false;
		}
	    if(frm2.new_password_confirm.value=="")
	    {
	         alert(" Please confirm the new password.");
			 frm2.new_password_confirm.focus();
		     return false;
		}
		//check that newpassword and confirm password values are same or not
		if(frm2.new_password_confirm.value!="" && frm2.new_password_confirm.value!=frm2.new_password.value)
		 {
			 alert("Confirm password does not match with new password.");
			 frm2.new_password_confirm.focus();
			 return false;
		 }
		 
  }
}
//=========Address book form======//
function disable_shippingfield()
{
	
	if(document.registration.sendadd.checked==true)
	{
		/* document.registration.vGender2.disabled=false;
	    document.registration.vFName2.disabled=false;
        document.registration.vLName2.disabled=false;
        document.registration.vCode2.disabled=false;
        document.registration.vArea2.disabled=false;
        document.registration.vPhone2.disabled=false;
        document.registration.vAddress3.disabled=false;
        document.registration.vAddress4.disabled=false;
        document.registration.vCity2.disabled=false;
        document.registration.vState2.disabled=false;	     
        document.registration.vZip2.disabled=false;	     
        document.registration.vContID2.disabled=false; */    
      	document.registration.vGender2.value=document.registration.vGender1.value; 
	   	document.registration.vFName2.value=document.registration.vFName1.value;
	   	document.registration.vLName2.value=document.registration.vLName1.value;
	   	document.registration.vCode2.value=document.registration.vCode1.value;
	  	document.registration.vArea2.value=document.registration.vArea1.value;
	    document.registration.vPhone2.value=document.registration.vPhone1.value;
	    document.registration.vAddress3.value=document.registration.vAddress1.value;
	    document.registration.vAddress4.value=document.registration.vAddress2.value;
        document.registration.vCity2.value= document.registration.vCity1.value;
	    document.registration.vState2.value= document.registration.vState1.value;
	    document.registration.vZip2.value= document.registration.vZip1.value;
	    document.registration.vContID2.value= document.registration.vContID1.value;
    }
}
//=========Edit Address book================//
function edit_address()
{
	var frm2=document.address;	
   if(chktrim(frm2.vFName2.value)=='') {
		alert("Please enter your first name.");
		frm2.vFName2.focus();
        return false;
	}
	if(chktrim(frm2.vLName2.value)==''){
		alert("Please enter your last name.");
		frm2.vLName2.focus();
        return false;
	}
	
	if(chktrim(frm2.vCode2.value)==0) {
		alert("Please enter your country code.");
		frm2.vCode2.focus();
        return false;
	}
	if(chktrim(frm2.vArea2.value)==0) {
		alert("Please enter your area code.");
		frm2.vArea2.focus();
        return false;
	}
	if(chktrim(frm2.vPhone2.value)==0) {
		alert("Please enter your phone number.");
		frm2.vPhone2.focus();
        return false;
	}
	if(chktrim(frm2.vAddress3.value)==0) {
		alert("Please enter your address details.");
		frm2.vAddress3.focus();
        return false;
	}
	if(chktrim(frm2.vCity2.value)==0) {
		alert("Please enter your city.");
		frm2.vCity2.focus();
        return false;
	}
	if(chktrim(frm2.vState2.value)==0) {
		alert("Please enter your state.");
		frm2.vState2.focus();
        return false;
	}
	if(chktrim(frm2.vZip2.value)==0) {
		alert("Please enter your pincode.");
		frm2.vZip2.focus();
        return false;
	}
	if(frm2.vContID2.value==0) {
		alert("Please select your country from the list.");
		frm2.vContID2.focus();
        return false;
	}	
	return true;
}

function chkFrmRegLog() {
	var frm1=document.frmRegisterLogin;
	if(chktrim(frm1.vLoginID.value).length <=0) {
		alert("Please enter Login ID.");
		frm1.vLoginID.focus();
        return false;
	}
	if(chktrim(frm1.vLoginID.value).length > 20) {
    	alert("Login ID cann't exceed 20 characters");
        frm1.vLoginID.focus();
        return false;
	}
	if(chktrim(frm1.vPassWord.value).length <=0) {
		alert("Please enter Password.");
		frm1.vPassWord.focus();
        return false;
	}
	if(chktrim(frm1.vPassWord.value).length > 20) {
    	alert("Password cann't exceed 20 characters");
        frm1.vPassWord.focus();
        return false;
	}
}
/*--------------------------*/
function chkFrmMemberInfo() {
	var frm2=document.frmMemberInfo;
	
	if(chktrim(frm2.vSalutation.value).length <=0) {
		alert("Please select name salutation.");
		frm2.vSalutation.focus();
        return false;
	}
	if(chktrim(frm2.vFName.value).length <=0) {
		alert("Please enter your first name.");
		frm2.vFName.focus();
        return false;
	}
	if(chktrim(frm2.vDOBM.value).length <=0) {
		alert("Please select your birth date [Month]...");
		frm2.vDOBM.focus();
        return false;
	}
	if(chktrim(frm2.vDOBD.value).length <=0) {
		alert("Please select your birth date [Day]...");
		frm2.vDOBD.focus();
        return false;
	}
	if(chktrim(frm2.vDOBY.value).length <=0) {
		alert("Please select your birth date [Year]...");
		frm2.vDOBY.focus();
        return false;
	}
	
	if(chktrim(frm2.vAddress1.value).length <=0) {
		alert("Please enter your address details.");
		frm2.vAddress1.focus();
        return false;
	}
	if(chktrim(frm2.vCity.value).length <=0) {
		alert("Please enter your city.");
		frm2.vCity.focus();
        return false;
	}
	if(chktrim(frm2.vState.value).length <=0) {
		alert("Please enter your state.");
		frm2.vState.focus();
        return false;
	}
	if(chktrim(frm2.vZip.value).length <=0) {
		alert("Please enter your pincode.");
		frm2.vZip.focus();
        return false;
	}
	if(frm2.vContID.value==0) {
		alert("Please select your country from the list.");
		frm2.vContID.focus();
        return false;
	}
	if(chktrim(frm2.vPhNum.value).length <=0) {
		alert("Please enter your phone number.");
		frm2.vPhNum.focus();
        return false;
	}
	
	if(!checkEmail(frm2.vEmail.value)) {
		alert("Please enter valid email address...");
		frm2.vEmail.focus();
		return false;
	}
	if(frm2.vEmail.value.indexOf('@') != frm2.vEmail.value.lastIndexOf('@')) {
		  alert("Please enter One E-mail address only");
		  frm2.vEmail.focus();
		  return false;
	}
	if(frm2.isPass.checked==true) {
		if(chktrim(frm2.vPassWord.value).length <= 0) {
	    	alert("Enter Password...");
	        frm2.vPassWord.focus();
	        return false;
		}
		if(chktrim(frm2.vPassWord.value).length < 6) {
	    	alert("Password must contain atleast 6 characters");
	        frm2.vPassWord.focus();
	        return false;
		}
		if(chktrim(frm2.vPassWord.value).length > 10) {
	    	alert("Password must contain max. 10 characters");
	        frm2.vPassWord.focus();
	        return false;
		}
		if(frm2.vPassWord.value != frm2.vPassConfirm.value) {
			alert("Confirm password is not valid...");
	        frm2.vPassWord.focus();
	        return false;
		}
		if(chktrim(frm2.vSecQues.value).length <= 0) {
	    	alert("Select Security Question...");
	        frm2.vSecQues.focus();
	        return false;
		}
		if(chktrim(frm2.vSecAns.value).length <= 0) {
	    	alert("Please enter your answer...");
	        frm2.vSecAns.focus();
	        return false;
		}
	}
}
function chkFrmJoin() {
	var frm1=document.frmJoin;
	
	if(chktrim(frm1.vSalutation.value).length <=0) {
		alert("Please select name salutation.");
		frm1.vSalutation.focus();
        return false;
	}
	if(chktrim(frm1.vFName.value).length <=0) {
		alert("Please enter your first name.");
		frm1.vFName.focus();
        return false;
	}
	if(chktrim(frm1.vDOBM.value).length <=0) {
		alert("Please select your birth date [Month]...");
		frm1.vDOBM.focus();
        return false;
	}
	if(chktrim(frm1.vDOBD.value).length <=0) {
		alert("Please select your birth date [Day]...");
		frm1.vDOBD.focus();
        return false;
	}
	if(chktrim(frm1.vDOBY.value).length <=0) {
		alert("Please select your birth date [Year]...");
		frm1.vDOBY.focus();
        return false;
	}
	
	if(chktrim(frm1.vAddress1.value).length <=0) {
		alert("Please enter your address details.");
		frm1.vAddress1.focus();
        return false;
	}
	if(chktrim(frm1.vCity.value).length <=0) {
		alert("Please enter your city.");
		frm1.vCity.focus();
        return false;
	}
	if(chktrim(frm1.vState.value).length <=0) {
		alert("Please enter your state.");
		frm1.vState.focus();
        return false;
	}
	if(chktrim(frm1.vZip.value).length <=0) {
		alert("Please enter your pincode.");
		frm1.vZip.focus();
        return false;
	}
	if(frm1.vContID.value==0) {
		alert("Please select your country from the list.");
		frm1.vContID.focus();
        return false;
	}
	if(chktrim(frm1.vPhNum.value).length <=0) {
		alert("Please enter your phone number.");
		frm1.vPhNum.focus();
        return false;
	}
	
	if(!checkEmail(frm1.vEmail.value)) {
		alert("Please enter valid email address...");
		frm1.vEmail.focus();
		return false;
	}
	if(frm1.vEmail.value.indexOf('@') != frm1.vEmail.value.lastIndexOf('@')) {
		  alert("Please enter One E-mail address only");
		  frm1.vEmail.focus();
		  return false;
	}
	if(chktrim(frm1.vPassWord.value).length <= 0) {
    	alert("Enter Password...");
        frm1.vPassWord.focus();
        return false;
	}
	if(chktrim(frm1.vPassWord.value).length < 6) {
    	alert("Password must contain atleast 6 characters");
        frm1.vPassWord.focus();
        return false;
	}
	if(chktrim(frm1.vPassWord.value).length > 10) {
    	alert("Password must contain max. 10 characters");
        frm1.vPassWord.focus();
        return false;
	}
	if(frm1.vPassWord.value != frm1.vPassConfirm.value) {
		alert("Confirm password is not valid...");
        frm1.vPassWord.focus();
        return false;
	}
	if(chktrim(frm1.vSecQues.value).length <= 0) {
    	alert("Select Security Question...");
        frm1.vSecQues.focus();
        return false;
	}
	if(chktrim(frm1.vSecAns.value).length <= 0) {
    	alert("Please enter your answer...");
        frm1.vSecAns.focus();
        return false;
	}
	if(frm1.isAgree.checked==false) {
		alert("Sorry, you have not accepted our Agreement !!");
		frm1.isAgree.focus();
		return false;
	}
}
function checkAll(val, frmName) {
   dml=frmName;
   len=dml.elements.length;
   var i=0;
   for (i=0; i<len; i++) {
     if (dml.elements[i].type == "checkbox") {
        if (val == 1) { 
           dml.elements[i].checked=true;
        } 
		else {
           dml.elements[i].checked=false;
        }
     }   
   }
   return false;
}

function translator(pattern) {
	
	var open_in_same_window = 1;
	var my_location = unescape(document.location.toString());
	var new_location ='';
	var new_pattern = '';
	if (my_location.indexOf('translate_c?') != -1) {
		/// From google...
		var indexof_u = my_location.indexOf('u=');
		if (indexof_u == -1) {
			new_location = document.location;
		}
		else {
			var subs = my_location.substring(indexof_u, my_location.length);
			var ss = subs.split('&');
			new_location = ss[0].substring(2, ss[0].length);
		}
	}
	else {
		new_location = document.location;
	}

	indexof_p = pattern.indexOf('|');

	var isen = '';
	if (indexof_p == -1) {
		indexof_p1 = pattern.indexOf('><');
		if (indexof_p1 == -1) {
			new_pattern = pattern;
			if (pattern == 'en') {
				isen = 1;
			}
		}
		else {
			var psplit =pattern.split('><');
			new_pattern = psplit[0]+'|'+psplit[1];
			if (psplit[1] == 'en') {
				isen = 1;
			}
		}
	}
	else {
		var psplit = pattern.split('|');
		new_pattern = psplit[0]+'|'+psplit[1];
		if (psplit[1] == 'en') {
			isen = 1;
		}
	}

	var thisurl = '';
	if (isen == 1) {
		thisurl = new_location;
	}
	else {
		thisurl = 'http://translate.google.com/translate_c?langpair=' + new_pattern + "&u=" + new_location;
	}

	if (open_in_same_window == 1) {
		window.location.href = thisurl;
	}
	else {
		if (CanAnimate ){
			msgWindow=window.open('' ,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
			msgWindow.focus();
			msgWindow.location.href = thisurl;
		}
		else {
			msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');
		}
	}
}

function openwin1(file,Iwidth,Iheight) {
   var nw1=window.open(file,'nWin2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
function openBrWinHide(file,Iwidth,Iheight, winID) {
      var nw2=window.open(file, winID, 'x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
      return false;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
  return false;
}
function chktrim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   } 
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { 
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; 
}
function checkEmail(value) {
	valids = '@.'
	temp = 0;
	for(var i = 0; i < value.length; i++) {
		if (valids.indexOf(value.substr(i,1)) != -1) {
			temp++;
		}
	}
	if(temp >= 2)
		return true
	else
		return false;
}
//::::::::: End of Durgesh Suman JS Coding ::::::::

//THIS IS CheckAll() FUNCTION TO MARK ALL CHECK BOXES AS CHECKED---USED IN FORM 
//*******************written by anjali garg**********************//
function CheckAll(val,frm)
{
   var i;
	if(val == 1)
	{ 
		frm.checked = true;
	}
	else
	{
		for (i=0; i < val; i++) 
		{  
			
			frm[i].checked = true;
		}
	}
}
//THIS IS UnCheckAll() FUNCTION TO MARK ALL CHECK BOXES AS  UNCHECKED--USED IN FORM 
//*******************written by anjali garg**********************//

function UnCheckAll(val,frm)          
{
	if(val == 1)
	{ 
		frm.checked = false;
	}
	else
	{
		for (i=0; i < val; i++) 
		{
			frm[i].checked = false;
		}
	}
}
//this is CheckSubmit() function to check whether any record is selected or not
//*********************Added by Anjali************************//
function CheckSubmit(RecordCount, theField)
{
	var statusFlag = 0; //keeps track that atleast one record is selected to change the status
	if(RecordCount == 1)
	{ 
		if(theField.checked == true)
				statusFlag = 1;
			else
				theField.checked = false;
	}
	else
	{
		for (i=0; i < RecordCount; i++) 
		{
			if(theField[i].checked == true)
				statusFlag = 1;
			else
				theField[i].checked = false;
		}
	}
	if(statusFlag == 0)	{
		alert("Please select atleast one record to change status.");
		return false;
	}
	return true;
}
//===============================//
//==This function is modified by Anajli as per required form field==//
function chkFrmRemind() {
	var frm2=document.reminder;
	if(frm2.address_book_id.value=='Not Available' && frm2.reminder_username.value=='') {
		alert("Please check other option and enter name of the Person.");
		frm2.reminder_username.focus();
        return false;
	}
	if(chktrim(frm2.reminder_message.value).length <=0) {
		alert("Please enter message to send it as a reminder message in your mail box.");
		frm2.reminder_message.focus();
        return false;
	}
	return true;
 }
 //============================================
 //=========check product_enquiry================//
function chkEnquiry()
{
  var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;	 
   var frm2=document.frmEnquiry;	
   if(chktrim(frm2.company_name.value)=='') {
		alert("Please enter your company name.");
		frm2.company_name.focus();
        return false;
	}
	if(chktrim(frm2.your_name.value)==''){
		alert("Please enter your  name.");
		frm2.your_name.focus();
        return false;
	}
	
	if(chktrim(frm2.email_id.value)==0) {
		alert("Please enter your email.");
		frm2.email_id.focus();
        return false;
	}
	if (!re_mail.test(frm2.email_id.value))	{
			alert( "Enter Your Email-id correctly" );
			frm2.email_id.focus();
			return false;
	}
	
	if(chktrim(frm2.phone_code1.value)==0) {
		alert("Please enter your country code.");
		frm2.phone_code1.focus();
        return false;
	}
	if(chktrim(frm2.phone_code2.value)==0) {
		alert("Please enter your area code.");
		frm2.phone_code2.focus();
        return false;
	}
	if(chktrim(frm2.phone1.value)==0) {
		alert("Please enter your phone number.");
		frm2.phone1.focus();
        return false;
	}	
	if(frm2.country.value==0) {
		alert("Please select your country from the list.");
		frm2.country.focus();
        return false;
	}	
	if(chktrim(frm2.enq_text.value)==0) {
		alert("Please enter your requirements.");
		frm2.enq_text.focus();
        return false;
	}
	return true;
}

