function vanity_search(chk1) {
	if (chktrim(document.srchForm.srch_kword.value)=="" || document.srchForm.srch_kword.value=="Enter Keywords Here . . .") {
		alert("Enter Product / Services Keyword(s)");		
		document.srchForm.focus();
		return false;
	}
}

function show_url(var1, site_ty) {
	if (site_ty=="live") {
  		popupWin = window.open('http://www.exportersindia.com/members/show-url.php?id=wwwicon&member_id='+var1+'', 'newwin', 'menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');
	}
	else if (site_ty=="live1") {
  		popupWin = window.open('http://66.36.253.143/members/show-url.php?id=wwwicon&member_id='+var1+'', 'newwin', 'menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');
	}	
	else {
  		popupWin = window.open('http://192.168.1.106/members/show-url.php?id=wwwicon&member_id='+var1+'', 'newwin', 'menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');		
	}
}


function openwin1(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'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 openwin4(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin4','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 vanity_inquire_now() {
    var pp=1;
    dml=document.form1;
    len=dml.elements.length;
    var i=0;
    for(i=0; i<len; i++) {
       if (dml.elements[i].type == "checkbox" && dml.elements[i].name != "checked_1"  && dml.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.form1.submit();
    }
}

/* to view the existing user form or non-existing user form in category section like (agriculture)*/
function showme(val) {
	 if(val=="e") {
		document.getElementById('exis_div').style.display = 'block'; 
		document.getElementById('newmem_div').style.display = 'none'; 				
	 }
	 else if(val=="n") {
		
		document.getElementById('exis_div').style.display = 'none'; 
		document.getElementById('newmem_div').style.display = 'block'; 
	 }
}

function chk_charlen(var1, var2) {
	box1 = eval('document.' + var1 + '.' + var2)
	box2 = eval('document.' + var1);
	box2.char_len.value=box1.value.length;
}

function chk_login(chk2) { //this function is for when member searches the party and he not logged in or a guest member.somesh
   if (chk2.user_name.value.length == 0) {
      alert("E-mail ID can't be left blank");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('@') == -1) {
      alert("Error in Email ID");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('.') == -1) {
      alert("Error in Email ID");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('@') !=  chk2.user_name.value.lastIndexOf('@')) {
      alert("Please Specify One Email ID only");
      chk2.user_name.focus();
      return false;
   }  
   //To check 'india mart,alibaba etc. words
	if(isProhibited(chk2.user_name)) {
   		return false;
	}
   if (chk2.pass_word.value.length==0) {
      alert("Enter Your Password ");
      chk2.pass_word.focus();
      return false; 
   }   
}

function isProhibited(obj){  //function to validate indiamart,india mart,alibaba,ali baba,tradeindia,trade-india in your name,company name etc field in search and join now pages.somesh
	var objval=obj.value;
	invalidstr=new Array("indiamart","india mart", "alibaba","ali baba","tradeindia", "trade-india");
	for(i=0;i<invalidstr.length;i++){
		if (chktrim(objval).toLowerCase().indexOf(chktrim(invalidstr[i]).toLowerCase())>=0){	
			alert("Please use Email ID other than "+invalidstr[i]+".") 
			obj.focus();
			return true;		
		}
	}
	return false;
}//end of isProhibited()

function enquiryValid (loginChk, formChk, chkTy) {
	if (chkTy!="N") {
		/*if (document.form1.kword.value.length<5 || document.form1.kword.value.length>100){
	    	if (document.form1.kword.value.length>100){
	    		alert("Your Inquiry Subject [ maximum 100 characters ] ");
			}
			else {
	    		alert("Enter your Inquiry Subject [ minimum 5 characters ] ");
			}
	        document.form1.kword.focus();
	        return (false);
		}*/		

		if (document.form1.detail_req.value.length<10 || document.form1.detail_req.value.length>1000){
	    	if (document.form1.detail_req.value.length>1000){
	    		alert("Your Requirement Details [ maximum 1000 characters ] ");
			}
			else {
	    		alert("Please enter your Requirement Details [ minimum 10 characters ] ");
			}
	        document.form1.detail_req.focus();
	        return (false);
		}
	}
	if (loginChk=="Y") {
		pp = chk_login(document.form1);
		document.form1.id3.value="Send Inquiry";
	}
	else if (formChk=="Y") {
		pp = guestMemValid(document.form1);		
		if (pp==false) {		
			return false;
		}
		else {
	   		if (document.form1.bus_ty.options[document.form1.bus_ty.selectedIndex].value=="")  {
		   		alert("select Nature of Business Type");
		   		document.form1.bus_ty.focus();
		   		return false;
	   		}
	   		if (document.form1.bus_ty.options[document.form1.bus_ty.selectedIndex].value!="x" && document.form1.comp_name.value.length==0) {	   		
				alert("Enter Company Name");	
		   		document.form1.comp_name.focus();
		   		return false;		   		
	   		}	   		
	   		if (document.form1.bus_ty.options[document.form1.bus_ty.selectedIndex].value!="x") {
	   			if (document.form1.product_desc.value.length<10) {
		   			alert("Enter Products/Services Detail ");		   			
	   				document.form1.product_desc.focus();
		   			return false;	 			
	   			}
	   			else if (document.form1.product_desc.value.length>350) {
		   			alert("Enter Products/Services Detail not exceed 350 characters");	
	   				document.form1.product_desc.focus();
		   			return false;		   			
	   			}
	
	   		}
   		}		
		document.form1.id4.value="Send Inquiry";		
	}
	else {
		var pp="true";
	}
	if (pp !=false || pp=="true") {
		if (chkTy=="N" && formChk=="N") {
			document.form1.id1.value="checkLogin";					
		}
		else if (chkTy=="N" && loginChk=="N") {
			document.form1.id1.value="newUser";					
		}			
		document.form1.submit();
	}
}

function isValid(obj){ //function to validate hotmail,gmail etc in your name,company name etc field in search and join now pages.somesh
	var objval=obj.value;
    invalidstr = new Array("hotmail", "gmail", "indiatimes", "rediffmail", "yahoo", ".com", ".net",".org", ".co.in", ".co.cn", ".co.ca", ".gov", ".co.uk");
		 		
	for(i=0;i<invalidstr.length;i++){
		if (chktrim(objval).toLowerCase().indexOf(chktrim(invalidstr[i]).toLowerCase())>=0){	
			alert("Please don't use "+invalidstr[i]+".") 
			obj.focus();
			return false;		
		}
	}
	return true;
}

function guestMemValid (id1) { //function when member search the party and he is not logged in or a guest member.somesh
	
   	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter your name");
	  	id1.your_name.focus();
      	return false;
   	}
   	 //To check .net .com etc words in name field
    if(!isValid(id1.your_name)) {
   		return false;
	}
   	 //To check .net .com etc words in Email ID field
    if(isProhibited(id1.username)) {
   		return false;
	}
	if (chktrim(id1.username.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	id1.username.focus();
      	return false;
   	}
   	if (id1.username.value.indexOf('@') == -1) {
      	alert("Error in e-mail address");
      	id1.username.focus();
      	return false;
   	}
   	if (id1.username.value.indexOf('.') == -1) {
      	alert("Error in e-mail address");
      	id1.username.focus();
      	return false;
   	}
   	if (id1.username.value.indexOf('@') != id1.username.value.lastIndexOf('@')) {
      	alert("Please Specify One E-mail address only");
      	id1.username.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(!isValid(id1.comp_name)) {
   		return false;
	}*/
   	if (id1.country.options[id1.country.selectedIndex].value=="")  {
      	alert("Select your Country");
      	id1.country.focus();
      	return false;
   	}
   	
   	if (chktrim(id1.address.value).length ==0) {
      	alert("Enter Street Address");
      	id1.address.focus();
      	return false;
   	}
   	//To check .net .com etc words in address field
   	if(!isValid(id1.address)) {
   		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;
     }        
}
function checkAll(val) {
   	dml=document.form1;
   	len=dml.elements.length;
   	var i=0;
   	for (i=0; i<len; i++) {
     	if (document.form1.elements[i].type == "checkbox") {
        	if (val == 1) {
           		dml.elements[i].checked=true;
        	} 
			else {
           		dml.elements[i].checked=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; 
}

////////////////////////////////ajax chk//////////////
var xmlHttp 
function Check_Availability1(url, displayitem) {	
	xmlHttp=GetXmlHttpObject();
	//document.getElementById(displayitem).innerHTML="Loading............";
	if (xmlHttp==null) {	
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url =url+"&sid="+Math.random();		
	xmlHttp.onreadystatechange=function stateChanged() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {			
			if(xmlHttp.responseText.length>0) {			
				document.getElementById("txtHint").innerHTML=xmlHttp.responseText;							
				if (xmlHttp.responseText=="<font color=red>incorrect Email ID</font>" || xmlHttp.responseText=="<font color=red>Email ID already exist.</font>") {			
					document.form1.username.focus();
					document.getElementById('txtHint').style.display = 'block'; 
					return false;
				}
			}
			else {
				document.getElementById("txtHint").innerHTML="";
				document.getElementById('txtHint').style.display = 'none'; 
			}
		}
	};
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject() {	
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
return xmlHttp;
}


function toggleDiv( element ) {		
	//var e = $(element);    
	var e = document.getElementById(element);
	if(element=="div_activity_log") {
		document.getElementById('div_activity_log').style.display = 'block'; 
		document.getElementById('div_activity_log1').style.display = 'block'; 
		document.getElementById('div_dropdowns').style.display = 'none';			
		document.getElementById('div_dropdowns1').style.display = 'none'; 
	}
	else if(element=="div_dropdowns") {
		document.getElementById('div_dropdowns').style.display = 'block'; 
		document.getElementById('div_dropdowns1').style.display = 'block'; 
		document.getElementById('div_activity_log').style.display = 'none';	
		document.getElementById('div_activity_log1').style.display = 'none'; 
	}
	else {
		document.getElementById('div_activity_log').style.display = 'block'; 
		document.getElementById('div_activity_log1').style.display = 'block'; 
		document.getElementById('div_dropdowns').style.display = 'none';			
		document.getElementById('div_dropdowns1').style.display = 'none';  		
	}
}

function valid_feedback_form(chk1) {
   if (chktrim(chk1.your_name.value).length==0) {
      alert("Enter Your Name");
      chk1.your_name.focus();
      return false;
   }
   if (chktrim(chk1.username.value).length == 0) {
      alert("E-mail address can't be left blank");
      chk1.username.focus();
      return false;
   }
   if (chk1.username.value.indexOf('@') == -1) {
      alert("Error in e-mail address");
      chk1.username.focus();
      return false;
   }
   if (chk1.username.value.indexOf('.') == -1) {
      alert("Error in e-mail address");
      chk1.username.focus();
      return false;
   }
   if (chk1.username.value.indexOf('@') != chk1.username.value.lastIndexOf('@')) {
      alert("Please Specify One E-mail address only");
      chk1.username.focus();
      return false;
   }  
   if (chk1.subject.options[chk1.subject.selectedIndex].value == "x") {
      alert("Select Subject");
      chk1.subject.focus();
      return false;
   }
   if (chktrim(chk1.comments.value).length<10) {
      alert("Enter Your Comments");
      chk1.comments.focus();
      return false;
   }
}

function setWidth() {
	var screenWidth=screen.width;
	if(screenWidth>=1024) {
		document.getElementById('body').style.width='990px';
	}
	else {
		document.getElementById('body').style.width='770px';
	}	
}