function CheckDataSearch(Form)
{
	 var str='';
	
        Form.ss.value = Form.ss.value.replace(/^\s+/g, '').replace(/\s+$/g, '');
// 	Form.ss.value = Form.ss.value.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 (Form.ss.value.length < 3)
        {
                alert("Enter at least three characters for search.");
                Form.ss.focus();
                return false;
        }
        else
        {
                if(Form.searchfor.value == "comp")
                {
			 //var a = Form.ss.value.replace(/\s+/g, '+');
			  var a = Form.ss.value.replace(/\+/g, ' ');
				a = a.replace(/\s+/g, '+');
			//a = Form.ss.value.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")
                {
			 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")
                {
			var c = Form.ss.value.replace(/\+/g, ' ');
				c = c.replace(/\s+/g, '+');
                        str +='search='+c;
                        //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")
                {
			
			var d = Form.ss.value.replace(/\+/g, ' ');
			d = d.replace(/\s+/g, '+');
			d = d.toLowerCase();
                        str +='ss='+d;
			str = "http://tenders.indiamart.com/search.cgi?"+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;
}
