function emailThisPage(rUrl) {
	
    var target = document.location;

  	var win = window.open(''+rUrl+'/email_with_us.htm?sendurl=' + target, 'notice', 'width=600,height=500,location=no,toolbar=no,status=no,resizable=no,scrollbars=yes');
  	win.focus();
}

function addToFavorite(){
	
	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://www.indianyellowpages.com');
	}
	else {
		alert('To set Indianyellowpages.com as your home page in Firefox, click and drag the button to the "Home" icon in your browser.');
	}
	return false;
}
function catg_search1(chk1) {

	if ( chktrim(chk1.term.value).length <=1 || ( chktrim(chk1.term.value).length >=1 && chk1.term.value=="Enter Keywords here...")) {
		alert("Enter Product / Services Keyword(s)");
		chk1.term.focus();
		return false;
	}
	if (chk1.busty.options[chk1.busty.selectedIndex].value == "") {
		alert("Select a Searching Category");
		chk1.busty.focus();
		return false;
	}
	return true;
}

function vanity_search(chk1) {	
   if (chktrim(chk1.srch_kword.value)=="" || chk1.srch_kword.value=="Enter Keywords Here . . .") {
      alert("Enter Product / Services Keyword(s)");
      chk1.srch_kword.focus();
	  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; 
}


/* 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'; 
	 }
}

////////////////////////////////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.frmenq.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 enquiryValid(loginChk, formChk) {
	if (document.frmenq.detail_req.value.length<10 || document.frmenq.detail_req.value.length>1000){
    	if (document.frmenq.detail_req.value.length>1000){
    		alert("Your Requirement Details [ maximum 1000 characters ] ");
		}
		else {
    		alert("Please enter your Requirement Details [ minimum 10 characters ] ");
		}
        document.frmenq.detail_req.focus();
        return (false);
	}

	if (loginChk=="Y") {
		pp = chk_login(document.frmenq);		
		if (pp==false) {		
			return false;
		}
		
	}
	else if (formChk=="Y") {
		pp = guestMemValid(document.frmenq);//
		if (pp==false) {		
			return false;
		}
		else {
	   		if (document.frmenq.bus_ty.options[document.frmenq.bus_ty.selectedIndex].value=="")  {
		   		alert("select Nature of Business Type");
		   		document.frmenq.bus_ty.focus();
		   		return false;
	   		}	   			   			   		
   		}
		document.frmenq.id4.value="Send Inquiry";		
	}
	else {
		var pp="true";		
	}
	
	if (pp !=false || pp=="true") {		
		document.frmenq.submit();
	}
}

function return_value_length(formName, fldNameLen, fldNameVal) {
	box1 = eval('document.' + formName + '.' + fldNameLen);
	box2 = eval('document.' + formName + '.' + fldNameVal);		
	box2.value=box1.value.length;
}

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  : chk_login(param)
  Objective : To validate existing Member Login Form
  @param    : Form Object
  Output    :
  	True    : If all fields are correct
    False   : If any field value is found incorrect */
	
function chk_login(objfrm) {
	   
	if (objfrm.user_name.value.length == 0) {
      alert("E-mail ID can't be left blank");
      objfrm.user_name.focus();
      return false;
   }
      
   if (objfrm.user_name.value.indexOf('@') == -1) {
      alert("Error in Email ID");
      objfrm.user_name.focus();
      return false;
   }
   if (objfrm.user_name.value.indexOf('.') == -1) {
      alert("Error in Email ID");
      objfrm.user_name.focus();
      return false;
   }
   if (objfrm.user_name.value.indexOf('@') !=  objfrm.user_name.value.lastIndexOf('@')) {
      alert("Please Specify One Email ID only");
      objfrm.user_name.focus();
      return false;
   }
        		
   if (objfrm.pass_word.value.length==0) {
      alert("Enter Your Password ");
      objfrm.pass_word.focus();
      return false; 
   }   
   return true;
}

/*Function isValid(param) 
  Objective: To check object value is allow or not
  @param   :  Object
  Output   :
  	True   : If value is allowed to enter
  	False  : If value is not allowed to enter */
  
function isValid(obj){
	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(param) 
  Objective : To validate Join now form
  @param    : Form Object
  Output    :
  	True    : If all fields are correct
    False   : If any field value is found incorrect */

function guestMemValid (objfrm) {
	if (chktrim(objfrm.your_name.value).length==0) {
      	alert("Enter your name");
	  	objfrm.your_name.focus();
      	return false;
   	}
   	//To check .net .com etc words in name field
     
    if(!isValid(objfrm.your_name))
   		return false;
   	
   	if (chktrim(objfrm.username.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	objfrm.username.focus();
      	return false;
   	}
   	if (objfrm.username.value.indexOf('@') == -1) {
      	alert("Error in e-mail address");
      	objfrm.username.focus();
      	return false;
   	}
   	if (objfrm.username.value.indexOf('.') == -1) {
      	alert("Error in e-mail address");
      	objfrm.username.focus();
      	return false;
   	}
   	if (objfrm.username.value.indexOf('@') != objfrm.username.value.lastIndexOf('@')) {
      	alert("Please Specify One E-mail address only");
      	objfrm.username.focus();
      	return false;
   	}   	
   	//To check indiamart, Alibaba etc words in email field
   	if(isProhibited(objfrm.username)) {
	   	return false; 	
   	}
   	
   	if (chktrim(objfrm.comp_name.value).length ==0) {
      	alert("Enter Company Name");
      	objfrm.comp_name.focus();
      	return false;
   	}
   	
   	if (chktrim(objfrm.address.value).length ==0) {
      	alert("Enter Street Address");
      	objfrm.address.focus();
      	return false;
   	}
	
   	//To check .net .com etc words in address field
    if(!isValid(objfrm.address)) {
	    return false;
    } 	
   	
   		
   	if (objfrm.country.options[objfrm.country.selectedIndex].value=="")  {
      	alert("Select your Country");
      	objfrm.country.focus();
      	return false;
   	}  	   	
     	 			
	if (objfrm.ph_ccode.value.length ==0) {
        alert("Enter Phone Number - Country Code");
        objfrm.ph_ccode.focus();
        return false;
     }
     if (!parseInt(objfrm.ph_acode.value)) {
        alert("Incorrect Phone - Area Code");
        objfrm.ph_acode.focus();
        return false;
     }
     if (chktrim(objfrm.ph_number.value).length ==0) {
        alert("Enter Phone Number");
        objfrm.ph_number.focus();
        return false;
     }   
}

/*Function  : isProhibited(param) 
  Objective : To check object value is allow or not
  @param    : Object
  Output    :
  	True    : If value is not allowed to enter
  	False   : If value is allowed to enter */
  	
function isProhibited(obj){
	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("Usage of "+invalidstr[i]+" is Prohibited on this site.") 
			obj.focus();
			return true;		
		}
	}
	return false;
}//end of isProhibited()