
function trim_keyword(value)
{return value.replace(/^\s+|\s+$/g,"");}
function getCategoryEnmForUrl(sTar)
{sTar=sTar.replace(/\'s/g,"s");sTar=sTar.replace(/[/()+:,&]/g,"_");sTar=sTar.replace(/__*/g,"_");sTar=sTar.replace(/^-*/g,"");return sTar;}
function getKeywordForUrl(sTark)
{sTark=sTark.replace(/[ "]/g,"_");sTark=sTark.replace(/__*/g,"_");sTark=escape(sTark);return sTark;}
function isKwdValid(kwd){var isValid=true;if(kwd.length>150){alert("You can enter up to 150 letters for your keyword.");isValid=false;}else if(kwd.indexOf(">")>-1||kwd.indexOf("<")>-1){alert("Please do not enter these signs <  ,  >  in the keyword.");isValid=false;}
return isValid;}
function redirect(url){
  var f=document.forms["GNBsearchForm"];
  f.target="_blank";f.action=url;f.submit();
  //if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var referLink=document.createElement('a');referLink.href=url;document.body.appendChild(referLink);referLink.click();}else{f.target="_blank";f.action=url;f.submit();}
}
function SearchGNB()
{var f=document.forms["GNBsearchForm"];var keyword=f.keyword.value;var category=f.category.value;var category_enm=f.category.options[f.category.selectedIndex].text;var l_path;if(keyword.length<1)
{alert('Please input a keyword.');f.keyword.focus();return false;}
else
{keyword=trim_keyword(keyword);if(keyword.length<1)
{alert('Pleas input a keyword.');f.keyword.focus();return false;}
if(!isKwdValid(keyword))
return false;}
var re=/^[\x20-\x7e]*$/g;if(!keyword.match(re))
{alert("Sorry. The keywords you have input is not in English.\nPlease input keywords in English only.");f.keyword.focus();return false;}
keyword=getKeywordForUrl(keyword);category_enm=getCategoryEnmForUrl(category_enm);if(keyword.length>0&&category.length>1)
l_path=category_enm+'--'+category+'/1/'+keyword+'.html';else if(keyword.length>0&&category.length<2)
l_path=keyword+'.html';if(f.st.value=='0')
{redirect('http://www.ec21.com/ec-market/'+l_path);return false;}
else if(f.st.value=='1')
{redirect('http://www.ec21.com/offers/'+l_path);return false;}
else if(f.st.value=='2')
{redirect('http://importer.ec21.com/buy_leads/'+l_path);return false;}
else if(f.st.value=='3')
{redirect('http://www.ec21.com/companies/'+l_path);return false;}
return false;}
function SearchX(form){
	with (form)
	{if (keyword.value == ""){alert("Please Enter your keyword..");keyword.focus();return false;}
  sgubun_select(form);submit();}}
function sgubun_select(form){
	with (form){if ( sgubun.options[sgubun.selectedIndex].value == "1" )action="/search/ProductSearch.jsp";
		else if ( sgubun.options[sgubun.selectedIndex].value == "2" )action="/search/OfferSearch.jsp";
		else if ( sgubun.options[sgubun.selectedIndex].value == "3" )action="/search/CompanySearch.jsp";
		else{ alert('select selection partition.'); return false;}}}
function sendHomeInquiry(inquiry)
{var URL="http://www.ec21.com/global/basic/SendInquiry.jsp?inq_data="+inquiry;open_win(URL,830,400);}
function open_win(URL,WIDTH,HEIGHT)
{var Opt='toolbar=1,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width='+WIDTH+',height='+HEIGHT;win_name=window.open(URL,"aa",Opt);if(win_name)
win_name.focus();}
