
eGuide_SearchBoxInit();

function eGuide_SearchBoxInit(){
	var base_URL	= "http://www.eGuideGlobal.com/SearchBox/";
	document.eGuideSearchBox_boxColor = (typeof(document.eGuideSearchBox_boxColor) == "undefined") ? "#ffffff" : document.eGuideSearchBox_boxColor;
	document.write("<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" bgcolor=\"" + document.eGuideSearchBox_boxColor + "\" >");
	document.write("<form id=\"eGuide_FrmSearchHome\" method=\"get\" onsubmit=\"return eGuide_SubmitSearch()\">");
	document.write("<tr>");
	document.write("<td width=\"40\">");
	document.write("<img src=\"" + base_URL + "eGuideLogo.gif\" width=\"40\" height=\"26\">");
	document.write("</td>");
	document.write("<td style=\"font-family:arial;font-size:10px;font-weight:bold;color:" + document.eGuideSearchBox_txtColor + "\">");
	document.write("Search for");
	document.write("<br/>Product / Company");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr valign=\"top\">");
	document.write("<td colspan=\"2\">");
	document.write("<input type=\"text\" name=\"keyword\" size=\"20\" style=\"font-family:arial;font-size:10px;width:110px;\">");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td colspan=\"2\">");
	document.write("<select name=\"ctryURL\" style=\"font-family:arial;font-size:9px;width:72px\">");
	document.write("<option value=\"http://www.eguide.asia\" selected>Asia</option>");
	document.write("<option value=\"http://www.eguide.com.sg\">Singapore</option>");
	document.write("<option value=\"http://www.eguide.com.my\">Malaysia</option>");
	document.write("<option value=\"http://www.eguide.co.th\">Thailand</option>");
	document.write("<option value=\"http://www.eguidevietnam.com\">Vietnam</option>");
	document.write("<option value=\"http://www.eguideindonesia.com\">Indonesia</option>");
	document.write("</select>");
	document.write("<input type=\"submit\" value=\"Find It\" style=\"font-family:arial;font-size:9px;width:39px;color:" + document.eGuideSearchBox_btnColor + "\">");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td colspan=\"2\" style=\"font-family:arial;font-size:10px;color:" + document.eGuideSearchBox_txtColor + "\">");
	document.write("</td>");
	document.write("</tr>");
	document.write("<input type=\"hidden\" name=\"searchbox_id\" value=\"" + document.eGuideSearchBox_ID + "\"/>");
	document.write("</form>");
	document.write("</table>");
}

function eGuide_SubmitSearch(){
	thisFormObj 	= document.getElementById("eGuide_FrmSearchHome");
	with(thisFormObj) {
		var idxCtry 	= ctryURL.selectedIndex;
		var vCtryURL	= ctryURL.options[idxCtry].value;
		var vKeyword	= eGuide_TrimStr(keyword.value);
	}
	if (vKeyword.length > 2) {
		open(vCtryURL + "/search.asp?key=" + escape(vKeyword), "eguidesearchwin");
		return false;
	}
		return false;
}


function eGuide_TrimStr(sStr){
	var retStr   = "" ;
	var lLoop = true;
	var first = -1;
	var last  = sStr.length;
	for(var i=0; i < sStr.length && lLoop; i++){
		if(sStr.charAt(i) != " ") lLoop = false;
		else	first = i;
	}
	lLoop = true;
	for(var i=sStr.length-1; i>= 0 && lLoop; i--){
		if(sStr.charAt(i) != " ") lLoop = false;
		else	last = i;
	}
	for(var i=first+1; i<last; i++)
		retStr += sStr.charAt(i);
	return (retStr);
}


