
function checkData(Form,isframe)
{
        var str='';
        Form.ss.value = Form.ss.value.replace(/^\s+/g, '').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")
                {
                        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,"\\\\?\\\\&","?");
			if(isframe ==1)
			{
				parent.window.location = str;
			}
			else
			{
                        	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,"\\\\?\\\\&","?");

                        if(isframe ==1)
			{
				parent.window.location = str;
			}
			else
			{
                        	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,"\\\\?\\\\&","?");

                        if(isframe ==1)
			{
				parent.window.location = str;
			}
			else
			{
                        	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 = "http://tenders.indiamart.com/tenders-search.pl?"+str;
                        str = myReplace(str,"\\\\?\\\\&","?");

                        if(isframe ==1)
			{
				parent.window.location = str;
			}
			else
			{
                        	window.location = str;
			}
                        return false;
                }
        }
}

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