var tagTemp=1;
function tagChange(id, str){
	document.getElementById("searchTag_"+tagTemp).className="unsel";
	tagTemp=id;
	document.getElementById("searchTag_"+tagTemp).className="onsel";
	document.getElementById("stext").innerHTML=str;
	 seatype=document.getElementById('msgtype');
	var f = document.getElementById("searchform");
	if (id ==1){ 
		f.name="searchform1";
		f.action="./tradeleads/tradeleadsSearchResult.php";
		seatype.value="Sell";
		document.getElementById("one").style.display="inline-block";
		document.getElementById("two").style.display="none";
		document.getElementById("three").style.display="none";
		document.getElementById("four").style.display="none";
	}
		if (id ==2){
		f.name="searchform2";
		f.action="./tradeleads/tradeleadsSearchResult.php";
		seatype.value="Buy";
		document.getElementById("one").style.display="none";
		document.getElementById("two").style.display="inline-block";
		document.getElementById("three").style.display="none";
		document.getElementById("four").style.display="none";
	}
	if (id ==3){
		f.name="searchform3";
		f.action="./products/productsSearchResult.php";
		seatype.value="";
		document.getElementById("one").style.display="none";
		document.getElementById("two").style.display="none";
		document.getElementById("three").style.display="inline-block";
		document.getElementById("four").style.display="none";
	}
	if (id ==4){ 
		f.name="searchform4";
		f.action="./company/companySearchResult.php";
		seatype.value="";
		document.getElementById("one").style.display="none";
		document.getElementById("two").style.display="none";
		document.getElementById("three").style.display="none";
		document.getElementById("four").style.display="inline-block";
	}


}

//search keywrod
function set_action() {
  	var f = document.getElementById("searchform");
  if (f.name=="searchform1"){ 
    var str = Trim(f.keyword.value);
	if (str.length<2)
	{
		 alert("Minimum Two Words !");
		 f.keyword.focus;
		 return false;
	}
  }else if (f.name=="searchform2"){
    var str = Trim(f.keyword.value);
	if (str.length<2)
	{
		 alert("Minimum Two Words !");
		 f.keyword.focus;
		 return false;
	}
  }else if (f.name=="searchform3"){
    var str = Trim(f.keyword.value);
	if (str.length<2)
	{
		 alert("Minimum Two Words !");
		 f.keyword.focus;
		 return false;
	}
  }	
	return true;
}


function showSites(){	
	document.getElementById("otherSites").className="display";
}
function hideSites(){
	document.getElementById("otherSites").className="hidden";
}
function changeBg(obj){
	obj.style.backgroundColor=="#dbe0b8"?obj.style.backgroundColor="white":obj.style.backgroundColor="#dbe0b8";
}

//
function Ltrim(str) {
        var pattern = new RegExp("^[\\s]+","gi");
        return str.replace(pattern,"");
}
function Rtrim(str) {
        var pattern = new RegExp("[\\s]+$","gi");
        return str.replace(pattern,"");
}
function Trim(str) {
        return Rtrim(Ltrim(str));
}

function goURL(theURL){
	top.location.href=theURL;	
}
