var google_adnum = 0; /* only insert this line for your first ad unit */
/*this variable is being used in google adds*/
function checkSearch() {
      if (document.searchForm.ss.value=="")
           {
                   alert("Please enter your search string");
                   document.searchForm.ss.focus();
                   return false;
           } else {
                   return true;
           }
}

function checkSearch1() {
      if (document.searchForm1.ss.value=="")
           {
                   alert("Please enter your search string");
                   document.searchForm1.ss.focus();
                   return false;
           } else {
                   return true;
           }
}

function validateit(theForm) {
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value)))
	{
		alert("Invalid Email ID. Kindly enter the correct ID.");
		theForm.email.focus();
		return (false);
	}
}


function checkData1 ()
{
	if (document.form2.search.value.length < 3){
	    alert("Enter at least three characters for search.");
	    document.form2.search.focus();
	    return false;
	}
	else{
		return true;
	}

}

function checkData ()
{
	if (document.form1.choice[0].checked) {
		document.form1.action = "http://www.indiamart.com/cgi/AT-eximsearch.cgi";
	}
	else {
	    document.form1.action = "http://www.indiamart.com/cgi/AT-india2search.cgi";
	}
	if (document.form1.search.value.length < 3){
	    alert("Enter at least three characters for search.");
	    document.form1.search.focus();
	    return false;
	}
return true;

}

function popupSample(url) {
     windowTop=(screen.top);
     windowLeft=screen.width-640;
     var faqs=window.open(url,'Faqs','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=620,height=500,top='+windowTop+',left='+windowLeft);
     faqs.focus();
}

function getblank(this1)  {
	if (this1.value = "Your e-mail here") {
		this1.value = "";
	}
    return true;
}

function on_submit()
{
        if(form1.Phrase.checked)
                valKashi = "+"+form1.SearchFieldValue1.value+"+";
        else
                valKashi = form1.SearchFieldValue1.value;

        out = " "; // replace this
        add = "+"; // with this
        temp = "" + valKashi; // temporary holder

        while (temp.indexOf(out)>-1)
        {
                pos= temp.indexOf(out);
                temp = "" + (temp.substring(0, pos) + add +
                temp.substring((pos + out.length), temp.length));
        }
        form1.SearchFieldValue.value = temp;
}

function openchild_nl(thisurl)
{
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ;
	if (condition == true  )
		CanAnimate = true;
	else
		CanAnimate = false;

	var email_val = document.theForm.email.value;
	var from_site_val = document.theForm.from_site.value;
	var is_window_val = document.theForm.is_window.value;
	var org_referer = document.theForm.org_referer.value;

	var thisurl_string = thisurl + "?email=" + email_val + "&from_site=" + from_site_val + "&is_window=" + is_window_val + "&org_referer=" + org_referer;

	if ( CanAnimate ) {
			msgWindow=window.open( '' ,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=550,height=240,top=0,left=0');
			msgWindow.focus();
			msgWindow.location.href = thisurl_string;
	}
	else {
			msgWindow=window.open( thisurl_string,'subwindow','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=550,height=240,top=0,left=0');
	}
}

function addBookmark(title,url) {
	if (window.sidebar) {
		window.sidebar.addPanel("Tenders.IndiaMART.com - IndiaMART", url,"");
	}
	else if( document.all ) {
		window.external.AddFavorite( url, "Tenders.IndiaMART.com - IndiaMART");
	}
	else if(navigator.appName == 'Netscape') {
		alert('Press (CTRL-D) to bookmark this page.');
	}
	return false;
}

function CheckDataSearch(Form)
{
	var str='';
	Form.ss.value = Form.ss.value.replace(/^\s+/g, '').replace(/\s+$/g, '');
	while(Form.ss.value.indexOf('  ')>0)
	{
		
		Form.ss.value = Form.ss.value.replace('  ',' ');	
	}
	Form.ss.value = Form.ss.value.replace(/[^a-zA-Z0-9 ]/g, '');
	
	var temp=Form.ss.value.replace(/\s/g, '');
	
	if (temp.length < 3)
	{
		alert("Enter at least three characters for search.");
		Form.ss.focus();
		return false;
	}
	else
	{
		if(Form.searchfor.value == "comp")
                {
			str +='ss='+escape(Form.ss.value);
			//str += '&searchfor='+Form.searchfor.value;
			//str += '&modid=DIR';

			str = "http://dir.indiamart.com/cgi/compcatsearch.mp?"+str;
			str = myReplace(str,"\\\\?\\\\&","?");

			window.location = str;
			return false;
                }
                else if(Form.searchfor.value == "product")
                {
			str +='ss='+escape(Form.ss.value);
			//str += '&searchfor='+Form.searchfor.value;
			//str +='&modid=CTL';

			str = "http://catalogs.indiamart.com/cgi/catprdsearch.mp?"+str;
			str = myReplace(str,"\\\\?\\\\&","?");

			window.location = str;
			return false;
                }
                else if(Form.searchfor.value == "offer")
                {
			str +='search='+escape(Form.ss.value);
			//str += '&searchfor='+Form.searchfor.value;
			//str +='&modid=ETO';
			
			//str +='&search='+Form.ss.value;
			str = "http://trade.indiamart.com/search.mp?"+str;
			str = myReplace(str,"\\\\?\\\\&","?");

			window.location = str;
			return false;
                }
		else if(Form.searchfor.value == "tenders")
		{
			str +='ss='+escape(Form.ss.value);
			//str += '&searchfor='+Form.searchfor.value;
			//str +='&modid=TDR';
			str +='&cr=td';
			str +='&sr=1';

			str = "/tenders-search.pl?"+str;
			str = myReplace(str,"\\\\?\\\\&","?");

			window.location = str;
			return false;
		}
	}
}

function myReplace(str, a, b) {
        var re = new RegExp(a, "g");
        var ret = str.replace(re,b);
        return ret;
}

function openchildts(thisurl)
{
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	condition = !(( (browserName.indexOf("Explorer") >=0 ) && (browserVer < 4) ) ||  ((browserName.indexOf("Netscape") >=0 ) && (browserVer < 2) ) ) ;
	if (condition == true  )
	CanAnimate = true;
	else
	CanAnimate = false;

	if ( CanAnimate )
	{
		var windowHeight;
		var windowWidth;
		var windowTop;
		var windowLeft;
		windowHeight=(screen.height*(80/100))*0.85;
		windowWidth=screen.width*(70/100);
		windowTop=(screen.height*(20/100))*0.8;
		windowLeft=screen.width*(28.5/100);

		msgWindow=window.open( '' , 'subwindow', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,top='+windowTop+',left='+windowLeft+',width='+windowWidth+',height='+windowHeight);
		msgWindow.focus();
		msgWindow.location.href = thisurl;
	}
	else
	{
		msgWindow=window.open( thisurl,'subwindow', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=510,height=420');
	}
}

function checkPlan() 
{
	var rtrn_flag='';
	if (document.ModReg.planServ3[0].checked==false && document.ModReg.planServ3[1].checked==false && document.ModReg.planServ3[2].checked==false && document.ModReg.planServ3[3].checked==false && document.ModReg.planServ3[4].checked==false && document.ModReg.planServ3[5].checked==false)
	{
		alert("Please select a plan");
		return false;
	}	
		
	rtrn_flag=chk_glusr_info();
	return rtrn_flag;
}

function chk_glusr_info()
{
	if(document.ModReg.ph_country && document.ModReg.ph_country.value == "") 
	{
		alert ("Please select Phone Country code");
		document.ModReg.ph_country.focus();
		return false;
	}
	if(document.ModReg.ph_no && document.ModReg.ph_no.value == "") 
	{
		alert ("Please select Phone number");
		document.ModReg.ph_no.focus();
		return false;
	}
	if(document.ModReg.add1 && document.ModReg.add1.value == "") 
	{
		alert ("Please select Address");
		document.ModReg.add1.focus();
		return false;
	}
	if(document.ModReg.city_others && document.ModReg.city_others.value == "") 
	{
		alert ("Please select City");
		return false;
	}
	if(document.ModReg.zip && document.ModReg.zip.value == "") 
	{
		alert ("Please select Zip");
		document.ModReg.zip.focus();
		return false;
	}
	return true;
}

function select_city() {
	if(document.ModReg.country_iso.value != '')
	{
		openchild1('/cgi/glusr_cities_popup.pl?C='+document.ModReg.country_iso.value+'&State='+document.ModReg.state.value+'&cityname='+document.ModReg.city_others.value, '300', '500');
	}
}

function select_state() {
	if(document.ModReg.country_iso.value != '')
	{
		openchild1('/cgi/glusr_state_popup.pl?C='+document.ModReg.country_iso.value, '300', '500');
	}
}

function openchild1(thisurl, w, h){

	msgWindow=window.open( thisurl,'Lookup','toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=yes,copyhistory=no, width='+w+', height='+h);
	msgWindow.focus();
}

function popup(url) {
	window.open(url,'Lookup','toolbar=no,location=no,directories=no,payType=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=210');
}

function Check_Login() {
if(document.loginform.usr_name.value == "" ) {
alert("Kindly enter your User Name/E-mail ID.");
document.loginform.usr_name.focus();
return false;
}
else if(document.loginform.usr_name.value.length < 4) {
alert("The User Name should be atleast 4 characters long.");
document.loginform.usr_name.focus();
return false;
}
else if(document.loginform.usr_pass.value == "" ) {
alert("Kindly enter your Password.");
document.loginform.usr_pass.focus();
return false;
}
else if(document.loginform.usr_pass.value.length < 4) {
alert("The Password should be atleast 4 characters long.");
document.loginform.usr_pass.focus();
return false;
}
else {
return true;
}
}
    
function Check_Login1() {
if(document.loginform.usr_name.value == "" ) {
alert("Kindly enter your User Name/E-mail ID.");
document.loginform.usr_name.focus();
return false;
}
else if(document.loginform.usr_name.value.length < 4) {
alert("The User Name should be atleast 4 characters long.");
document.loginform.usr_name.focus();
return false;
}
else if(document.loginform.usr_pass.value == "" ) {
alert("Kindly enter your Password.");
document.loginform.usr_pass.focus();
return false;
}
else if(document.loginform.usr_pass.value.length < 4) {
alert("The Password should be atleast 4 characters long.");
document.loginform.usr_pass.focus();
return false;
}
else {
return true;
}
}