//Åã¥Ü¦¸­¶¥ªÃä·j´M
function showSearch(SearchEnglishPath){
	if (SearchEnglishPath == null) {
			SearchEnglishPath = "http://search.post.gov.tw/search/internet/english/eng_postal_search.asp"
	}
	keyWordSize = document.all ? 20 : 20;
	document.write('<form name="formSearch" method="POST" action="' + SearchEnglishPath + '" onsubmit="return sendMsg1()" target="_new"><img src="images/search.gif" width="51" height="19"><img src="images/tra.gif" width="2" height="5"><input name="wg_query" type="text" size="' + keyWordSize + '"  >&nbsp;&nbsp;<img src="images/go.gif" border="0" onClick="sendMsg();" style="cursor:hand"></form>');
}

function sendMsg()
{
	// Check
	if( validateInput( document.formSearch.wg_query ) )
	{
	
	  var wg_query=document.formSearch.wg_query.value;
	
	 	window.open('http://search.post.gov.tw/search/internet/english/eng_postal_search.asp?wg_query='+wg_query,'search','width=650,height=450,toolbar=no,directories=no,scrollbars=yes,resize=yes,menubar=no');
	}
}

function sendMsg1()
{

	// Check
	return validateInput( document.formSearch.wg_query );
	
}


function validateInput( field )
{
	var tempS = field.value;
	
	var retStr = "";
	for( var i=0; i<tempS.length; i++ )
	{
		var tempC = tempS.substr(i,1);
		if( tempC.match( /[^a-z0-9._%\-\s,\\:]/gim ) == null )
			retStr += tempC;
	}
	
	field.value = retStr;
	
	if( field.value.length == 0 )
	{
		alert("Please enter an english keyword");
		return false;
	}
	else
		return true;
	
	/*
	if( wg_query.match( /[^a-z0-9._%\-\s,\\:]/gim ) != null )
	{
		alert( 'Please type english words!!' );
		return false;
	}
	*/
}
