function checkData(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 (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(/\+/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")
                {
			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, '+');
                        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;
}