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 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;
}
// valid
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('  ',' ');	
	}
	//aaaaaForm.ss.value = Form.ss.value.replace(/[^a-zA-Z0-9 ]/g, '');
	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")
                {
					//aaaaaaaaaa		str +='ss='+escape(Form.ss.value);
						var a = Form.ss.value.replace(/\+/g, ' ');
						a = a.replace(/\s+/g, '+');
						str +='ss='+a;
			
                        //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")
                {
					 //aaaaaaaaaaaaaaa	str +='ss='+escape(Form.ss.value);
					 
					var b = Form.ss.value.replace(/\+/g, ' ');
					b = b.replace(/\s+/g, '+');
					str +='ss='+b;
					//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")
                {
					//aaaaaaaaaa		str +='search='+escape(Form.ss.value);
					
					var c = Form.ss.value.replace(/\+/g, ' ');
					c = c.replace(/\s+/g, '+');
					str +='search='+c;

					str = "http://trade.indiamart.com/search.mp?"+str;
					str = myReplace(str,"\\\\?\\\\&","?");

					window.location = str;
					return false;
                }
				else if(Form.searchfor.value == "tenders")
				{
					//aaaaaaaaaaaaa   str +='ss='+escape(Form.ss.value);
					var d = Form.ss.value.replace(/\+/g, ' ');
					d = d.replace(/\s+/g, '+');

					str +='ss='+d;
					// str += '&searchfor='+Form.searchfor.value;
					// str +='&modid=TDR';
					str +='&cr=td';
					str +='&sr=1';

					str = "http://tenders.indiamart.com/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;
}

