




function menuToggle(element, eventName, handler){
	element = document.getElementById(element);
	if (element.addEventListener) {
	element.addEventListener(eventName, handler, false);
	} else {
	element.attachEvent("on" + eventName, handler);
	}
}
function Jtrim(str)
			{
				var i = 0;
				var len = str.length;
				var j =0;
				
				if ( str == "" ) return( str );
				if (str.length == 0) return( str );
				if(str==null) return( "");
				
				j = len -1;
				var flagbegin = true;
				var flagend = true;

				while (flagbegin == true && i< len)
				{
					if ( str.charAt(i) == " " )
					{
						i=i+1;
						flagbegin=true;
					}
					else
					{
						flagbegin=false;
					}
				}

				while  (flagend== true && j>=0)
				{
					if (str.charAt(j)==" ")
					{
						j=j-1;
						flagend=true;
					}
					else
					{
						flagend=false;
					}
				}

				if ( i > j ) return ("");

				trimstr = str.substring(i,j+1);
				return trimstr;
			}
function searchbtn() {  
			
			
			var keyword = document.search.keyword.value;
			keyword = Jtrim(keyword);
			if(keyword == '')
			{
				alert("Please type the word or words you wish to search for in the Search box. ");
				return;
			}
								
			
			keyword = trantourl(keyword);
			
			var searchtype = document.search.SearchType.value; 
			var url="http://www.wdtrade.com/";
			if(searchtype == "1")
				url += "buy/search/";
			else if(searchtype == "2")
				url += "sell/search/";
			else if(searchtype == "3")
				url += "company/search/";	
			else if(searchtype == "4")
				url += "products/search/";
			
			url += keyword;	
			url +=".aspx";
			
			//document.search.action=url;
			//document.search.target="_self";
			document.location = url;
		
		}
	function DrawImage(ImgD,iwidth,iheight){

	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}else{
			if(image.height>iheight){ 
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
	}
}


	function displayMoreCountry(isMore){
		if(isMore == 1)
		{
			var div = document.getElementById("include_country_divb");
			div.style.display = "none";
		
			div = document.getElementById("include_country_more_divb");
			div.style.display = "";
		}
		else
		{
			var div = document.getElementById("include_country_divb");
			div.style.display = "";
		
			div = document.getElementById("include_country_more_divb");
			div.style.display = "none";
		}
		
	}

function trantourl(str)
		{
		   var strurl = str.replace("  ", "_");
	           strurl = strurl.replace(" ", "_");
			strurl = strurl.replace(">", "");
			strurl = strurl.replace("(", "");
			strurl = strurl.replace(")", "");
			strurl = strurl.replace(":", "");
			
			strurl = strurl.replace("|", "");
			strurl = strurl.replace("/", "_");
			strurl = strurl.replace("%", "_");
			strurl = strurl.replace("-", "_");
			strurl = strurl.replace("&", "");
			strurl = strurl.replace("@", "");
			strurl = strurl.replace("#", "");
			strurl = strurl.replace("!", "");
			strurl = strurl.replace("$", "");
			strurl = strurl.replace("^", "");
			strurl = strurl.replace("*", "");
			strurl = strurl.replace(", ", "_");
			strurl = strurl.replace(",", "_");
			strurl = strurl.replace("\'", "");
			strurl = strurl.replace(" ", "_");
			strurl = strurl.replace(".,","_");
			strurl = strurl.replace(".","");
			strurl = strurl.replace("'","");
			strurl = strurl.replace("__","_");
			return strurl;	
		}	





function displayMoreIncluedKeywordsa(isMore){
			if(isMore == 1)
			{
				var div = document.getElementById("hotkeyword");
				div.style.display = "none";
				
				div = document.getElementById("hotkeywordmore");
				div.style.display = "";
			}
			else
			{
				var div = document.getElementById("hotkeywordmore");
				div.style.display = "none";
				
				div = document.getElementById("hotkeyword");
				div.style.display = "";
			}
				
		}



