function URLEncode(logo){ // ฟังก์ชันสำหร้บเข้ารหัส 
 var SAFECHARS = "0123456789" +     // Numeric
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
     "abcdefghijklmnopqrstuvwxyz" +
     "-_.!~*'()";     // RFC2396 Mark characters
 var HEX = "0123456789ABCDEF"; 
 var plaintext = logo;
 var encoded = "";
 for (var i = 0; i < plaintext.length; i++ ) {
  var ch = plaintext.charAt(i);
     if (ch == " ") {
      encoded += "+";    // x-www-urlencoded, rather than %20
  } else if (SAFECHARS.indexOf(ch) != -1) {
      encoded += ch;
  } else {
      var charCode = ch.charCodeAt(0);
   if (charCode > 255) {
       alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.n" +
              "(URL encoding only supports 8-bit characters.)n" +
        "A space (+) will be substituted." );
    encoded += "+";
   } else {
    encoded += "%";
    encoded += HEX.charAt((charCode >> 4) & 0xF);
    encoded += HEX.charAt(charCode & 0xF);
   }
  }
 } // for
 return encoded;
}
function za_google(){
 with(document.zabi_google){
   var site_search;
   var y_logo=URLEncode(you_logo.value);
   if(sitesearch[0].checked==true){
    site_search=sitesearch[0].value;
   }else{
    site_search=sitesearch[1].value;   
   }
   var za_go="http://www.google.co.th/custom?domains="+domains.value+"&q="+q.value+"&sitesearch="+site_search+"&sa=Google+Search&client=pub-6089800167772571&forid=1&ie=tis-620&oe=tis-620&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Aleft%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BLH%3A48%3BLW%3A210%3BL%3A"+y_logo+"%3BS%3Ahttp%3A%2F%2F"+domains.value+"%2F%3BLP%3A1%3BFORID%3A1%3B&hl=th";
	   window.open(za_go,"");  // เปิดหน้าต่างใหม่ใฃ้คำสั่งนี้
	//	top.location.href=za_go; // เปิดหน้าต่างปัจจุบันใ้ช้้คำสั่งนี้
 }
}