// Select Language
function switchlang() {
  if(big5()) {
     //ÁcÅéÂà´«¦¨Â²Åé
     var matchexp = new RegExp ("http://gate.tycool.com:82/gate/big5/([^/]+)([^?]*)([?]?[^?]*)", "i");
     var domain = window.location.href.replace(matchexp, "$1");
     var pathname = window.location.href.replace(matchexp, "$2");
     var search = window.location.href.replace(matchexp, "$3");
    location.href="ht"+"tp://"+domain+pathname+search;
    return false;
  } else {
    //Â²ÅéÂà´«¦¨ÁcÅé
    location.href="ht"+"tp://gate.tycool.com:82/gate/big5/"+location.hostname+location.pathname+location.search;
    return false;
  }
}

function big5() {
  var matchexp = new RegExp ("http:\/\/gate\.tycool\.com:82\/gate\/big5\/(.+)", "i");
  if(matchexp.test(window.location.href)){
    return true;
  } else {
    return false;
  }
}

function j2gb(url) {
  if(location.hostname=="gate.tycool.com") {
    location.href="ht"+"tp://"+url; return false;
  } else {
    return false;
  }
}

// Select City
function getCookie(cookieName) {
  var cookieString = document.cookie;
  var start = cookieString.indexOf(cookieName + '=');
  // ¥[¤Wµ¥¸¹ªº­ì¦]¬OÁ×§K¦b¬Y¨Ç Cookie ªº­ÈùØ¦³
  // »P cookieName ¤@¼Ëªº¦r²Å¦ê¡C
  if (start == -1) // §ä¤£¨ì
    return null;
  start += cookieName.length + 1;
  var end = cookieString.indexOf(';', start);
  if (end == -1) return unescape(cookieString.substring(start));
  return unescape(cookieString.substring(start, end));
}

// Generic Select List Box
function select_listbox(ctl_name,ctl_value){
  var checked = false;
  if (ctl_name) {
  for(var i=0;i<ctl_name.length;i++){
    if(ctl_name[i].value==ctl_value){
      ctl_name[i].selected = true;
      checked = true;
    }
  }

  if (!checked&&ctl_name.length>0){
    ctl_name[0].checked =true;
  }
  }
}
