function updateTextAreaCounter(textAreaName, countername, lengthMin, lengthMax) { /* dated 12th Jan 2012 Pramod*/
	
	textAreaValue=document.getElementById(textAreaName).value;
	
	textLength = textAreaValue.length;
	
	document.getElementById(countername).value = textLength;
	
    if (textLength>lengthMax) {
    	alert("Your text exceed "+lengthMax+" characters");
    	document.getElementById(textAreaName).value=textAreaValue.substr(0,textLength-1);
        document.getElementById(textAreaName).focus();
        return false;
	}	
}


function isNumberKey(evt) {

	var charCode = (evt.which) ? evt.which : event.keyCode;
	
	if (charCode!=46) {
		
		if (charCode > 31 && (charCode < 48 || charCode > 57)) {
			return false;
		}
		else {
			return true;
		}
	}
}

function checkemail(emailcheck) {
	var testresults;
	//var str=document.validation.emailcheck.value
	var str=emailcheck.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	{
		//testresults=true
		return true;
	}
	else{
	alert("Please input a valid email address!")
	emailcheck.focus();
	//testresults=false
	return false;
	}
	//return (testresults)
}

function showBusDesc() {

	if(document.myform.busMember.options[document.myform.busMember.selectedIndex].value == "Y") {

		document.getElementById('busTy').style.display="";
		document.getElementById('busDesc').style.display="";		
	}
	
	if(document.myform.busMember.options[document.myform.busMember.selectedIndex].value == "N") {

		document.getElementById('busTy').style.display="none";
		document.getElementById('busDesc').style.display="none";		
	}	
}

function changeshow() {
	
	if(document.getElementById("busMember").value=='N' || document.getElementById("busMember").value=="")
	 {
		
		document.getElementById("busTy").style.display='none';
		document.getElementById("busDesc").style.display='none';
	 }
	else {
		
		document.getElementById("busTy").style.display='';
		document.getElementById("busDesc").style.display='';
	}
}

function IfEmailExists(email_id) {
	 if(email_id==''){

		document.getElementById("user_exits").innerHTML="";
		document.getElementById("user_available").value=0;
		return false;
	 }
	 
	 
  xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	url='user_check.php?email='+email_id;
	xmlHttp.onreadystatechange=FindEmail;	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null)
}



function FindEmail() { 
	
	if (xmlHttp.readyState==4)
	 {
		hmtlcode = xmlHttp.responseText;
		if(hmtlcode>0){
		document.getElementById("user_exits").innerHTML="<font style='color:#FF0000;'>E-mail ID Already Exists</font>";
		document.getElementById("user_available").value=0;
		}else{
		document.getElementById("user_exits").innerHTML="<font style='color:#0EB41D;'>E-mail ID Available</font>";		
		document.getElementById("user_available").value=1;		
		}	
		document.getElementById("user_exits").value=hmtlcode;
	} 
}


function updateFields(countryValue){ 
	
	if(countryValue!='') {
		
		var myarray=countryValue.split("^");
		if(myarray[0]=='IN'){
			document.getElementById("state").style.display='none';
			document.getElementById("state_list").style.display='block';
			document.getElementById("state_mandatory").style.display='block';			
			document.getElementById("state").value=document.getElementById("state_list").value;
		}
		
		else {
			document.getElementById("state").style.display='block';
			document.getElementById("state_list").style.display='none';
			document.getElementById("state_mandatory").style.display='none';			
			document.getElementById("state").value='';
		}
		
		document.getElementById('ph_ccode').value=myarray[1];
		
	}
	
	else {

		document.getElementById("state").style.display='block';
		document.getElementById("state_list").style.display='none';
		document.getElementById('ph_ccode').value='ISD';
	}	

}

function lowerCase(formn,fieldname) {
	var frmObj = eval('document.'+formn+'.'+fieldname);		

	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	var string;
	//var searchVars=new Array("In","Suchas","Such","As","Like","If","This","For","Is","Am","Are","That","Fine");	
	//var ReplaceVars=new Array("in","suchas","such","as","like","if","this","for","is","am","are","that","fine");	
	
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else {
				tmpChar = tmpStr.substring(index, index+1);
				if ((tmpChar == " " || tmpChar == ",") && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
		         }
		     }
		}
	}
	
	/*for (index = 0; index < searchVars.length; index++)  {
		string=tmpStr.replace(/ +searchVars[index]+ /gi, +' '+ReplaceVars[index]+' ');
		alert(string);
		tmpStr=string;
	}*/
	
	results=tmpStr.replace(/ In /gi,' in ');
	results=results.replace(/ Am /gi,' am ');
	results=results.replace(/ Are /gi,' are ');
	results=results.replace(/ Is /gi,' is ');
	results=results.replace(/ This /gi,' this ');
	results=results.replace(/ That /gi,' that ');
	results=results.replace(/ Like /gi,' like ');
	results=results.replace(/ Suchas /gi,' suchas ');
	results=results.replace(/ Such /gi,' such ');
	results=results.replace(/ As /gi,' as ');
	results=results.replace(/ From /gi,' from ');
	results=results.replace(/ Fine /gi,' fine ');
	results=results.replace(/ If /gi,' if ');
	results=results.replace(/ For /gi,' for ');
	results=results.replace(/ And /gi,' and ');
	results=results.replace(/ Have /gi,' have ');
	results=results.replace(/ With /gi,' with ');
	results=results.replace(/ The /gi,' the ');
	results=results.replace(/ A /gi,' a ');
	results=results.replace(/ To /gi,' to ');
	results=results.replace(/ Of /gi,' of ');
	results=results.replace(/ Upto /gi,' upto ');
	results=results.replace(/ Also /gi,' also ');
	results=results.replace(/ Other /gi,' other ');
	results=results.replace(/ Or /gi,' or ');
	results=results.replace(/ Per /gi,' per ');
	results=results.replace(/ All /gi,' all ');
	results=results.replace(/ Amongst /gi,' amongst ');	
	results=results.replace(/ Among /gi,' among ');			
	results=results.replace(/ Also /gi,' also ');				
	
	frmObj.value=results;
}

function emailThisPage(rUrl) {
		
    var target = document.location;

  	var win = window.open(''+rUrl+'/email_with_us.php?sendurl=' + target, 'notice', 'width=600,height=500,location=no,toolbar=no,status=no,resizable=no,scrollbars=yes');
  	win.focus();
}

function bookmarksite(){
	var titleVar = document.title;
	
	var urlVar = document.location;
	
	// firefox
	if (window.sidebar) {
		window.sidebar.addPanel(titleVar, urlVar, "");
	}
	// opera
	else if(window.opera && window.print) { 
		var elem = document.createElement('a');
		elem.setAttribute('href',urlVar);
		elem.setAttribute('title',titleVar);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	// ie
	else  {
		window.external.AddFavorite(urlVar,titleVar)
	}	
}

function firefoxAlert(pageurl) {
	
	if(navigator.appName=="Microsoft Internet Explorer") {
		
		pageurl.style.behavior='url(#default#homepage)';pageurl.setHomePage('http://Chemical-Industry-India.com ');
	}
	else {
		alert('To set Chemical-Industry-India.com as your home page in Firefox, click and drag the button to the "Home" icon in your browser.');
	}
	return false;
} 

function valid_inquery(id1) {
	
	var member_typ = document.getElementById('mem_typ').value;
	
	 if (chktrim(id1.subject.value).length ==0) {
        alert("Enter Inquery Subject");
        id1.subject.focus();
        return false;
     } 
     
      if (chktrim(id1.detail_req.value).length ==0) {
        alert("Enter Inquery Detail");
        id1.detail_req.focus();
        return false;
     }    
	
	
	
	if(member_typ!=1) {
		
		 if (chktrim(id1.your_name.value).length ==0) {
			  alert("Enter Your Name");
			 id1.your_name.focus();
			 return false;
			 
		 }  
		 
		  if (chktrim(id1.email.value).length ==0) {
			  alert("Enter Your Email");
			 id1.email.focus();
			 return false;
			 
		 } 
		 
		 if (id1.email.value.indexOf('@') == -1) {
			alert("Error in e-mail address");
			id1.email.focus();
			return false;
		}
		
		if (id1.email.value.indexOf('.') == -1) {
			alert("Error in e-mail address");
			id1.email.focus();
			return false;			
		}
		
		if (id1.email.value.indexOf('@') != id1.email.value.lastIndexOf('@')) {
			alert("Please Specify One E-mail address only");
			id1.email.focus();
			return false;
		}
		
		if (chktrim(id1.comp_name.value).length ==0) {
			  alert("Enter Your Company Name");
			 id1.comp_name.focus();
			 return false;
			 
		 }
		 
		 if (chktrim(id1.country.value).length ==0) {
			  alert("Enter Your Country");
			 id1.country.focus();
			 return false;
			 
		 }
		 
		 if (chktrim(id1.address.value).length ==0) {
			  alert("Enter Your Address");
			 id1.address.focus();
			 return false;
			 
		 }
	}
	else {
		
		
		 if (chktrim(id1.user_name.value).length ==0) {
	        alert("Enter Your Email Id");
	        id1.user_name.focus();
	        return false;
	     } 
	     
		if (chktrim(id1.user_name.value).length == 0) {
			alert("E-mail address can't be left blank");
			id1.user_name.focus();
			return false;			
		}
		
		if (id1.user_name.value.indexOf('@') == -1) {
			alert("Error in e-mail address");
			id1.user_name.focus();
			return false;
		}
		
		if (id1.user_name.value.indexOf('.') == -1) {
			alert("Error in e-mail address");
			id1.user_name.focus();
			return false;			
		}
		
		if (id1.user_name.value.indexOf('@') != id1.user_name.value.lastIndexOf('@')) {
			alert("Please Specify One E-mail address only");
			id1.user_name.focus();
			return false;
		}
		
		if (chktrim(id1.pass_word.value).length ==0) {
	        alert("Enter Your Password");
	        id1.pass_word.focus();
	        return false;
	     }
	     
	     if (chktrim(id1.pass_word.value).length < 6) {
	        alert("Enter Your Password with atleast 6 character");
	        id1.pass_word.focus();
	        return false;
	     } 	 		
	}
		
	
}

function search_validate() {
	if (document.getElementById('sk').value=="" || document.getElementById('sk').value=="Search Keyword(s)") {
		alert("Please Enter Search your Keyword(s)");
		document.getElementById('sk').focus();
		return false;
	}
}

function newsletter_validate(formname) {
	if (chktrim(formname.email_id.value).length == 0) {
	  alert("Please Enter Your E-mail ID.");
	  formname.email_id.focus();
	  return false;
	}
	if (chktrim(formname.email_id.value).indexOf('@') == -1) {
	  alert("Error in Email-Id");
	  formname.email_id.focus();
	  return false;
	}
	if (chktrim(formname.email_id.value).indexOf('.') == -1) {
	  alert("Error in Email-Id");
	  formname.email_id.focus();
	  return false;
	}
	if (chktrim(formname.email_id.value).indexOf('@') !=  chktrim(formname.email_id.value).lastIndexOf('@')) {
	  alert("Please Specify One Email-Id only");
	  formname.email_id.focus();
	  return false;
	}  
}

function join_now_validation(formname) {
	
	if (formname.name=="join_now" || formname.name=="signup" || formname.name=="index") {
		if (chktrim(formname.user_name.value).length == 0) {
			alert("Email ID can't be left blank");
			formname.user_name.focus();
			return false;
		}
		if (chktrim(formname.user_name.value).indexOf('@') == -1) {
			alert("Error in Email ID");
			formname.user_name.focus();
			return false;
		}
		if (chktrim(formname.user_name.value).indexOf('.') == -1) {
			alert("Error in Email ID");
			formname.user_name.focus();
			return false;
		}
		if (chktrim(formname.user_name.value).indexOf('@') !=  chktrim(formname.user_name.value).lastIndexOf('@')) {
			alert("Please Specify One Email ID only");
			formname.user_name.focus();
			return false;
		}  
		if (chktrim(formname.pass_word.value).length==0) {
			alert("Enter Your Password ");
			formname.pass_word.focus();
			return false; 
		}
		if (chktrim(formname.pass_word.value).length <6) {
			alert("Password must be 6 characters ");
			formname.pass_word.focus();
			return false;
		}
	}
	if (formname.name=="join_now") {
		if (chktrim(formname.confirmpassword.value).length <6) {
			alert("Re-enter Password must be 6 characters ");
			formname.confirmpassword.focus();
			return false;
		}
		if ((chktrim(formname.pass_word.value)) != (chktrim(formname.confirmpassword.value))) {
			alert("Your Password & Re-enter password dosn't match");
			formname.pass_word.focus();
			return false;
		}
		if (chktrim(formname.comp_name.value).length==0) {
			alert("Enter Your Company / Organization Name ");
			formname.comp_name.focus();
			return false; 
		}
		
		var chks = document.getElementsByName('bus_ty[]');
		var hasChecked = false;
		
		for (var i = 0; i < chks.length; i++) {
			if (chks[i].checked) {
				hasChecked = true;
				break;
			}
		}
		if (!hasChecked) {
			alert("Please Select Nature of Business.");
			chks[0].focus();
			return false;
		}
		
		if (chktrim(formname.prod_desc.value).length==0) {
			alert("Please Enter Product Keywords, You Offer ");
			formname.prod_desc.focus();
			return false; 
		}
		if (chktrim(formname.your_name.value).length==0) {
			alert("Please Enter Your Name ");
			formname.your_name.focus();
			return false; 
		}
		if (chktrim(formname.street_address.value).length==0) {
			alert("Please Enter Street Address ");
			formname.street_address.focus();
			return false; 
		}
		if (chktrim(formname.country.value).length==0) {
			alert("Please Select Your Country ");
			formname.country.focus();
			return false; 
		}
		if (chktrim(formname.ph_ccode.value).length==0) {
			alert("Please Enter Phone Country Code ");
			formname.ph_ccode.focus();
			return false; 
		}
		if (chktrim(formname.ph_acode.value).length==0) {
			alert("Please Enter Phone Area Code ");
			formname.ph_acode.focus();
			return false; 
		}
		if (chktrim(formname.ph_number.value).length==0) {
			alert("Please Enter Phone Number ");
			formname.ph_number.focus();
			return false; 
		}
		if (chktrim(formname.captcha.value).length==0) {
			alert("Please Enter Text From The Image");
			formname.captcha.focus();
			return false; 
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function openwin (file,Iwidth,Iheight) {
      var newWin1=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 member_login_valid(id1){	
	
   	if (chktrim(id1.user_name.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	id1.user_name.focus();
      	return false;
   	}
   	if (id1.user_name.value.indexOf('@') == -1) {
      	alert("Error in e-mail address");
      	id1.user_name.focus();
      	return false;
   	}
   	if (id1.user_name.value.indexOf('.') == -1) {
      	alert("Error in e-mail address");
      	id1.user_name.focus();
      	return false;
   	}
   	if (id1.user_name.value.indexOf('@') != id1.user_name.value.lastIndexOf('@')) {
      	alert("Please Specify One E-mail address only");
      	id1.user_name.focus();
      	return false;
   	} 
   	if (chktrim(id1.pass_word.value).length == 0) {
      	alert("Password can't be left blank");
      	id1.pass_word.focus();
      	return false;
   	}  	
	
	
}


function valid_edit_profile(id1){
	
	if (chktrim(id1.your_name.value).length == 0) {
      	alert("Your Name can't be left blank");
      	id1.your_name.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.comp_name.value).length == 0) {
      	alert("Company Name can't be left blank");
      	id1.comp_name.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.address.value).length == 0) {
      	alert("Address can't be left blank");
      	id1.address.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.c_phone.value).length == 0) {
      	alert("Country Code can't be left blank");
      	id1.c_phone.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.a_phone.value).length == 0) {
      	alert("Area Code can't be left blank");
      	id1.a_phone.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.n_phone.value).length == 0) {
      	alert("Phone Number can't be left blank");
      	id1.n_phone.focus();
      	return false;
   	}	
	
}

function numbersonly(e){
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode!=8){
		if (unicode<48||unicode>57) 
		return false
	}
}

function countWords(form1,wordcount,inputString){
		
	document.getElementById(wordcount).value = inputString.length+1;
	
	if(inputString.length > 1000){
		
		alert("Please Enter Detail upto 2 word ");
		
		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 chkLen1() {
	
	document.form1.chrlen.value=document.form1.detail_req.value.length;
    if (document.form1.detail_req.value.length>1000) {
    	alert("your text exceed 1000 characters");
        document.form1.detail_req.focus();
        return false;
	}
}
function enquiryValid(id1) {

   	if (chktrim(id1.subject.value).length==0) {
      	alert("Enter Subject/Inquiry For");
	  	id1.subject.focus();
      	return false;
   	}
   	
	if (chktrim(id1.detail_req.value).length<10 || chktrim(id1.detail_req.value).length>1000){
    	if (id1.detail_req.value.length>1000){
    		alert("Your Requirement Details [ maximum 1000 characters ] ");
		}
		else {
    		alert("Please enter your Requirement Details [ minimum 10 characters ] ");
		}
        id1.detail_req.focus();
        return (false);
	}
	
	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter your name");
	  	id1.your_name.focus();
      	return false;
   	}
   	
   	if(!checkemail(id1.username)) {
	   	id1.username.focus();
	   	return false;
   	}
   	
   	if (chktrim(id1.address.value).length==0) {
      	alert("Enter Street Address");
      	id1.address.focus();
      	return false;
   	}
	var country_id=id1.country.value;	 
	if (country_id=="")  {                                                
	   	                                                                  
	  	alert("Select your Country");                                      
	  	id1.country.focus();                                               
	  	return false;                                                         		
	}                                                                     
	if(country_id=='IN^91') {   	
		if (chktrim(id1.state_list.value).length==0) {
			alert("Select Your State");
			id1.state_list.focus();
			return false;
		}  
	} 	

    //either phone OR mobile is mandatory
    if (chktrim(id1.ph_number.value)=="Phone No(s)" && chktrim(id1.mobile_phone.value)=="Mobile No(s)") {
	    alert("Either phone OR mobile is mandatory");
	    id1.ph_acode.focus();
	    return false;
	}
     
   	if (chktrim(id1.ph_number.value)!="Phone No(s)"){
	   	
		if (!parseInt(id1.ph_acode.value)) {
	        alert("Incorrect Phone - Area Code");
	        id1.ph_acode.focus();
	        return false;
	    }
	    	   	
	   	if (isNaN(id1.ph_number.value) || (id1.ph_number.value.length<5 || id1.ph_number.value.length>8)) {
	      	alert("Enter a valid phone number, e.g. 011-25052123");
		  	id1.ph_number.focus();
	      	return false;
  		}
   	}
   	
   	if (chktrim(id1.mobile_phone.value)!="Mobile No(s)" && isNaN(id1.mobile_phone.value)) {
      	alert("Enter a valid mobile number");
	  	id1.mobile_phone.focus();
      	return false;
	}
   	
	if (country_id=='IN^91' && chktrim(id1.mobile_phone.value)!="Mobile No(s)" && (id1.mobile_phone.value.length > 10)) {
      	alert("Enter a valid 10 digit mobile number");
	  	id1.mobile_phone.focus();
      	return false;
	}
	
   	if (chktrim(id1.ph_number.value)!="Phone No(s)" && isNaN(id1.ph_number.value)) {
	      	alert("Enter a valid phone number.");
		  	id1.ph_number.focus();
	      	return false;
   	} 
   	
     
   	if(id1.meminfo_status.value=="N") {
	
		if(id1.busMember.options[id1.busMember.selectedIndex].value=='') {
			 
			alert("Select Your Business Type");
			id1.busMember.focus();
			return false;
		}
		 
		if(id1.busMember.options[id1.busMember.selectedIndex].value=='Y') {
			
		   	if (chktrim(id1.comp_name.value).length==0) {
		      	alert("Enter Company Name");
		      	id1.comp_name.focus();
		      	return false;
		   	}
			
			if(!id1.mfg_catg.checked && !id1.exp_catg.checked && !id1.sup_catg.checked) {
			   	alert("Select Nature of Business");
			   	id1.mfg_catg.focus();
			   	return false;
		   	}
			
			if (chktrim(id1.product_desc.value).length<50 || chktrim(id1.product_desc.value).length>1000){
		   		alert("Please Enter Your Product Description[ 50 - 1000 characters ] ");
		        id1.product_desc.focus();
		        return (false);
			}
			 
		 }
 	}
   	
	if (id1.captcha.value.length==0) {
	
		alert("Please Enter Confirmation Code or Captcha");
		id1.captcha.focus();
		return false;
	}
}
function inquiryNow() {
    var pp=1;
    dml=document.form2;
    len=dml.elements.length;
    var i=0;
    for(i=0; i<len; i++) {

       if (document.form2.elements[i].type == "checkbox" && document.form2.elements[i].checked==true) {
          pp=2;
       }
    }
    if (pp==1) {
      alert("You have not selected any party.\n\nPlease select the parties && then proceed");
    }
    else {
      document.form2.target="";
      document.form2.submit();
    }
}


function checkAll(val) {

   	dml=document.form2;
   	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;
        	}
     	}   
   	}
}

function feedbackValid(id1) {
   	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter your name");
	  	id1.your_name.focus();
      	return false;
   	}
   	if (chktrim(id1.email.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	id1.email.focus();
      	return false;
   	}
  	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		
	if(reg.test(id1.email.value) == false) {

  		alert('Invalid Email Address');
  		id1.email.focus();
  		return false;
	}
   	
   	
   	
   	if (chktrim(id1.detail_req.value).length<10 || chktrim(id1.detail_req.value).length>1000){
    	if (id1.detail_req.value.length>1000){
    		alert("Your Requirement Details [ maximum 1000 characters ] ");
		}
		else {
    		alert("Please enter your Requirement Details [ minimum 10 characters ] ");
		}
        id1.detail_req.focus();
        return (false);
	}
	   	
}

function listingValid(id1) {
	
   	if (chktrim(id1.comp_name.value).length==0) {
      	alert("Enter Company / Organization Name ");
	  	id1.comp_name.focus();
      	return false;
   	}
   	
   	if(!id1.mfg_catg.checked && !id1.exp_catg.checked && !id1.sup_catg.checked) {
	   	alert("Select Nature of Business");
	   	id1.mfg_catg.focus();
	   	return false;
   	}
   	
	if (chktrim(id1.product_desc.value).length<10 || chktrim(id1.product_desc.value).length>1000){
		
    	if (id1.product_desc.value.length>1000){
    		alert("Enter your product(s) details [ maximum 1000 characters ] ");
		}
		else {
    		alert("Enter your product(s) details [ minimum 10 characters ] ");
		}
        id1.product_desc.focus();
        return (false);
	}

	
   	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter Your Name ");
	  	id1.your_name.focus();
      	return false;
   	}   	    	 	
   	
  	if (id1.username.value.length == 0) {
 		alert("Enter E-mail Address");
		id1.username.focus();
		return false;
  	}
  	
  	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		
	if(reg.test(id1.username.value) == false) {

  		alert('Invalid Email Address');
  		id1.username.focus();
  		return false;
	}		
   	
	if(id1.user_available.value==0) {
		alert("E-mail ID already exists. Please provide a new one. ");
		id1.username.focus();
		return false;
	}

   	
   	
   	if (chktrim(id1.address.value).length ==0) {
      	alert("Enter Street Address");
      	id1.address.focus();
      	return false;
   	}
   	
   	var country_id=id1.country.options[id1.country.selectedIndex].value;	 

   	if (country_id=="")  {
	   	
      	alert("Select your Country");
      	id1.country.focus();
      	return false;
   	}
   	
   if (country_id=='IN^91') {
	   
	   if (chktrim(id1.state_list.value).length==0) {
	      	alert("Select Your State");
		  	id1.state_list.focus();
	      	return false;
	   	}  
  } 	

    if (chktrim(id1.ph_number.value)=="Phone No(s)" && chktrim(id1.mobile_phone.value)=="Mobile No(s)") {
	    alert("Either phone OR mobile is mandatory");
	    id1.ph_acode.focus();
	    return false;
	}
     
   	if (chktrim(id1.ph_number.value)!="Phone No(s)") {
	   	
		if (!parseInt(id1.ph_acode.value)) {
			
	        alert("Incorrect Phone - Area Code");
	        id1.ph_acode.focus();
	        return false;
	    }
	    	   	
	   	if (isNaN(id1.ph_number.value)) {
	      	alert("Enter a valid phone number, e.g. 011-23456789");
		  	id1.ph_number.focus();
	      	return false;
  		}
   	}
   	
	
   	 if (chktrim(id1.mobile_phone.value)!="Mobile No(s)" && isNaN(id1.mobile_phone.value)) {
		alert("Enter a valid mobile number");
		id1.mobile_phone.focus();
		return false;
	}
   	
   	if (chktrim(id1.ph_number.value)!="Phone No(s)" && isNaN(id1.ph_number.value)) {
		alert("Enter a valid phone number.");
		id1.ph_number.focus();
	    return false;
   	} 
   	
   	if (id1.captcha.value.length==0) {
	
		alert("Please Enter Confirmation Code or Captcha");
		id1.captcha.focus();
		return false;
	}   	
   
}

function bannerValid(id1) {
   	if (chktrim(id1.comp_name.value).length==0) {
      	alert("Enter Company / Organization Name ");
	  	id1.comp_name.focus();
      	return false;
   	}
   	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter Your Name ");
	  	id1.your_name.focus();
      	return false;
   	}   	    	 	
   	if (chktrim(id1.email.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	id1.email.focus();
      	return false;
   	}
   	if (id1.email.value.indexOf('@') == -1) {
      	alert("Error in e-mail address");
      	id1.email.focus();
      	return false;
   	}
   	if (id1.email.value.indexOf('.') == -1) {
      	alert("Error in e-mail address");
      	id1.email.focus();
      	return false;
   	}
   	if (id1.email.value.indexOf('@') != id1.email.value.lastIndexOf('@')) {
      	alert("Please Specify One E-mail address only");
      	id1.email.focus();
      	return false;
   	}   	
   	
   	if (chktrim(id1.address.value).length ==0) {
      	alert("Enter Address");
      	id1.address.focus();
      	return false;
   	}
   	if (id1.country.options[id1.country.selectedIndex].value=="")  {
      	alert("Select your Country");
      	id1.country.focus();
      	return false;
   	}
	if (id1.ph_ccode.value.length ==0) {
        alert("Enter Phone Number - Country Code");
        id1.ph_ccode.focus();
        return false;
     }
     if (!parseInt(id1.ph_acode.value)) {
        alert("Incorrect Phone - Area Code");
        id1.ph_acode.focus();
        return false;
     }
     if (chktrim(id1.ph_number.value).length ==0) {
        alert("Enter Phone Number");
        id1.ph_number.focus();
        return false;
     }   
	if (chktrim(id1.detail_req.value).length<10 || chktrim(id1.detail_req.value).length>1000){
    	if (id1.product_desc.value.length>1000){
    		alert("Enter your requirement(s) details [ maximum 1000 characters ] ");
		}
		else {
    		alert("Enter your requirement(s) details [ minimum 10 characters ] ");
		}
        id1.detail_req.focus();
        return (false);
	}
     
}

function validSrchSK() {
   	if (chktrim(document.form12.sk.value).length==0) {
      	alert("Enter Product Keyword(s)");
	  	document.form12.sk.focus();
      	return false;
   	}
   	if (document.form12.busTy.options[document.form12.busTy.selectedIndex].value=="")  {   	
      	alert("Select Product Business Catetory Type ");
      	document.form12.busTy.focus();
      	return false;
   	}   	
   	
}

function chkLen1() {
	document.form1.chrlen.value=document.form1.detail_req.value.length;
    if (document.form1.detail_req.value.length>1000) {
    	alert("your text exceed 1000 characters");
        document.form1.detail_req.focus();
        return false;
	}
}
function chkLen2() {
	document.form1.chrlen.value=document.form1.catgDetl.value.length;
}
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 validAddCatg(id1) {
   	if (chktrim(id1.catgName.value).length==0) {
      	alert("Enter Category/Product Name ");
	  	id1.catgName.focus();
      	return false;
   	}
   	if (chktrim(id1.flnm.value).length==0) {
      	alert("Enter File  Name ");
	  	id1.flnm.focus();
      	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 validSponCatg(id1) {
   	if (chktrim(id1.catgName.value).length==0) {
      	alert("Enter Category/Product Name ");
	  	id1.catgName.focus();
      	return false;
   	}
	if (id1.pageTy.options[id1.pageTy.selectedIndex].value=="Y" && chktrim(id1.file_name.value).length==0) {
      	alert("Enter File  Name ");
	  	id1.file_name.focus();
      	return false;
   	}
	if (id1.pageTy.options[id1.pageTy.selectedIndex].value=="" && chktrim(id1.file_name.value).length>0) {
      	alert("Select Page Create Y/N ");
	  	id1.pageTy.focus();
      	return false;
   	}   	 	 	
} 
function inquiry_form_submit(mem_slno,busty,catgID) {
	window.location='/inquiry.htm?msl='+mem_slno+'&b='+busty+'&c='+catgID+'';
}

function site_url(mem_slno) {
  popupWin = window.open('/site-link.php?mem_slno='+mem_slno+'','newwin','menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');
}

function tradelead_link(site_ty, tl_slno) {
	if (site_ty=="EI") {
		url_1 = 'http://www.exportersindia.com/trade/trade-search.php?pty_ids='+tl_slno+'&id=detail&opp=offer';
	}
	else {
		url_1 = 'http://www.indianyellowpages.com/trade-leads/trade-search.php?pty_ids='+tl_slno+'&id=detail&opp=offer';		
	}
  	popupWin = window.open(url_1, 'newwin', 'menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');	
}

function popup(formname,file,Iwidth,Iheight) {
	
	var email_id = document.getElementById('email_id').value;
	
	var newWin1=window.open(file+'&email_id='+email_id,'nWin2','x=0,y=0,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
function manage_email(id1){
	
	if(chktrim(id1.new_email.value).length == 0) {
		alert("E-mail address can't be left blank");
		id1.new_email.focus();
		return false;
	}
	
	if(id1.new_email.value.indexOf('@') == -1) {
		alert("Error in e-mail address");
		id1.new_email.focus();
		return false;
	}
	
	if (id1.new_email.value.indexOf('.') == -1) {
		alert("Error in e-mail address");
		id1.new_email.focus();
		return false;
	}
	
	if (id1.new_email.value.indexOf('@') != id1.new_email.value.lastIndexOf('@')) {
		alert("Please Specify One E-mail address only");
		id1.new_email.focus();
		return false;
	}  
	
	if(chktrim(id1.reason_for_changein_username.value).length == 0) {
		alert("Reason_for Change username can't be left blank");
		id1.reason_for_changein_username.focus();
		return false;
	}
	
}


function search_all()
	   {
		  
		document.frmmember.Search_All.value = "Search All";
		document.frmmember.submit();
		   
	   } 
