

   function dosubmit(formName){
   		//formSubmit(formName);
       	document.forms[formName].submit();  
   }
   
   function dosubmit(formName,action){
      	document.forms[formName].action=action;
      	//formSubmit(formName);
       	document.forms[formName].submit();  
       	window.status="Searching...";
   }
   
   function doLocation(action){
   	window.location=action;
   }
   
   function getKeyword_and_dosubmit(inputId,formName,action){
   //alert('in traditional dosubmit')
       	var origin_k=document.getElementById(inputId).value;
    		var encoding_k=Url.encode(origin_k);
    		if(encoding_k!=-1){
	    		//alert(encoding_k)
	    		var m_action=action+"&searchText="+encoding_k;
					dosubmit(formName,m_action);
					window.status="Searching...";
				}
   }
   
   
   function urlEncode(url){
	   var tmpArr1=url.split("?");
	   var tmpArr2=tmpArr1[1].split("&");
	   var encodingParam="",encodingUrl="";
	   
	   for(var i=0;i<tmpArr2.length;i++){
	   	var tmpArr3=tmpArr2[i].split("=");
	   	//alert(tmpArr3[1])
	   	var encoding_p = Url.encode(tmpArr3[1]);
	   	//alert(encoding_p)
	   	encodingParam+=tmpArr3[0]+"="+encoding_p+"&";
	   	//alert(encodingParam)
	   }
	   encodingUrl=tmpArr1[0]+"?"+encodingParam;
	   //alert(encodingUrl)  
	   return encodingUrl;
   }
   
   function urlEncode_and_doLocation(url){
	   window.location =urlEncode(url);
   }
   
   function urlEncode_and_winOpen(url,width,height){
	   var condition="width="+ width+",height="+height+",left=0,top=100,screenX=0,screenY=100,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes";
	   window.open(url,'mywindow',condition);
   }
   
   function getKeyword_and_doLocation(inputId,action){
   //alert("in traditional location")
      var origin_k=document.getElementById(inputId).value;
   		var encoding_k=Url.encode(origin_k);
   		//alert(encoding_k)
   		if(encoding_k!=-1){
   	  	window.location=action+"&searchText="+encoding_k;
   	  }
   }
   
   function clear_checked_withinResult(){
   alert(getElementById("product_wtr_chk_id").checked)
   alert(getElementById("biz_wtr_chk_id").checked)
   alert(getElementById("news_wtr_chk_id").checked)
   alert(getElementById("tradeEvents_wtr_chk_id").checked)
   alert(getElementById("companyName_wtr_chk_id").checked)
   
   	getElementById("product_wtr_chk_id").checked=false;
   	getElementById("biz_wtr_chk_id").checked=false;
   	getElementById("news_wtr_chk_id").checked=false;
   	getElementById("tradeEvents_wtr_chk_id").checked=false;
   	getElementById("companyName_wtr_chk_id").checked=false;
   }
   
	function windowOpen(action,width,height){
		var condition="width="+ width+",height="+height+",left=0,top=100,screenX=0,screenY=100,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes";
		window.open(action,'mywindow',condition);
	}

	function pageMapper(member_type,web_open,DOMAIN_NAME,DOMAIN_NAME_FLAG,NEXT_PAGE){
		if((member_type=="8")&&(web_open=="1"))
		{
			var open_action="http://";
			var website_name=".taiwantrade.com.tw";
			if(DOMAIN_NAME_FLAG=="1"){
			
				open_action=open_action+DOMAIN_NAME+website_name;
			}
			else if(DOMAIN_NAME_FLAG=="0")
			{
				open_action=open_action+"www"+website_name+"/"+DOMAIN_NAME;
			}
			window.open(open_action,'mywindow','width=850,height=650,left=0,top=100,screenX=0,screenY=100,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');
		}
		else
		{
			window.location=NEXT_PAGE;
		}
	}
	
		function isOpenNewPage(member_type,web_open,DOMAIN_NAME,DOMAIN_NAME_FLAG){
		
			var open_action="http://";
			var website_name=".taiwantrade.com.tw";
			if(DOMAIN_NAME_FLAG=="1"){
			
				open_action=open_action+DOMAIN_NAME+website_name;
			}
			else if(DOMAIN_NAME_FLAG=="0")
			{
				open_action=open_action+"www"+website_name+"/"+DOMAIN_NAME;
			}
			window.open(open_action,'mywindow','width=850,height=650,left=0,top=100,screenX=0,screenY=100,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');
			window.history.back();

	}
	
	function openNewComPage(action){
		var open_action=action;
		window.open(open_action,'mywindow','width=850,height=650,left=0,top=100,screenX=0,screenY=100,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes');
		window.history.back();
	}
	
	function home_searchBar_setSearchText_and_display(searchName,searchText_id,searchserv_actionUrl,from_index){
	if(from_index!=1){
			if(document.getElementById(searchText_id).value==""){
				document.getElementById("bix_err_id").style.display = "block";
			}
			else{
				var tmp_searchserv_actionUrl = searchserv_actionUrl+"&searchText="+document.getElementById(searchText_id).value;
				home_searchBar_display(searchName,tmp_searchserv_actionUrl,from_index);
				document.getElementById("bix_err_id").style.display = "none";
			}
		}
		else{
			home_searchBar_display(searchName,tmp_searchserv_actionUrl,from_index);
		}
	}
	
	function home_searchBar_setSearchText_doAsIndex_and_display(searchName,searchText_id,searchserv_actionUrl,from_index,inputText){
		if(document.getElementById(searchText_id).value==""||document.getElementById(searchText_id).value==inputText ){
			home_searchBar_display(searchName,searchserv_actionUrl,"1");
		}
		else{
			var tmp_searchserv_actionUrl = searchserv_actionUrl+"&searchText="+document.getElementById(searchText_id).value;
			home_searchBar_display(searchName,tmp_searchserv_actionUrl,from_index);
		}
	}
	
	function home_searchBar_display(searchName,searchserv_actionUrl,from_index){
		var product_div=document.getElementById("product_Bar");
		var bizExchange_div=document.getElementById("bizExchange_Bar"); 
		var news_div=document.getElementById("news_Bar"); 
		var tradeEvents_div=document.getElementById("tradeEvents_Bar"); 
		var companyName_div=document.getElementById("companyName_Bar"); 
		
		product_div.style.display = "none";
		bizExchange_div.style.display = "none";
		news_div.style.display = "none";
		tradeEvents_div.style.display = "none";
		companyName_div.style.display = "none";
		document.getElementById(searchName).style.display = "block";
		if(from_index!="1"){
			doLocation(searchserv_actionUrl);
		}
	}
	
	
	
	function bringValue2AnotherSelect(formName,optionValue,nextUrl){
		var m_action=nextUrl+"&biz_continent="+optionValue.value;
		dosubmit(formName,m_action);
	}
	
	function onEnter(elementID){
		if(event.keyCode==13){
			document.getElementById(elementID).onclick();
		}
	}
	
	function onEnter(elementID,e){
		var keynum
		if(window.event) // IE
		{
		keynum = e.keyCode
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
		keynum = e.which
		}
		if(keynum==13){
			document.getElementById(elementID).onclick();
			return false;
		}
	}

	function download_lock(msg){
	window.event.returnValue=false; //將滑鼠右鍵事件取消
	alert(msg);
}

	function eliminateTag(str){
		str = str.replace(/<.*?>/," ");
		str = str.replace(/<\/.*?>/," ");
		str = str.replace(/&lt;.*?&gt;/," ");
		str = str.replace(/&lt;\/.*?&gt;/," ");
		return str;
	}

var Url = {

    // public method for url encoding
    encode : function (string) {
    	string = eliminateTag(string);

    	//var regExp=/[@|+|*|.|-]/g
    	var regExp=/[*]/g

			var tmp_rKeyword = escape(this._utf8_encode(string));
			var rNum = tmp_rKeyword.search(regExp);
			//document.write(rNum)
			if(rNum!=-1){
				document.getElementById("keyword_err_id").style.display = "block";
				return -1;
			}
			else{
				document.getElementById("keyword_err_id").style.display = "none";
				return tmp_rKeyword;
			}
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }
}


	function getElement(elementId){
		return document.getElementById(elementId);
	}
