var aCharSetGlobal = { "ko":1,"ja":1,"de":1,"it":1,"it":1,"cn":1,"tw":1,"fr":1,"es":1,"pt":1 };
var _wm;

function getCode()
{ 
  var aCode = _wm.iso639sys.split("-");
  
  if ( aCode[1] ) {
	  if (  aCode[0] == "zh" ) {
            if (aCode[1]=="tw" || aCode[1]=="hk")
    		    return "tw";
            else    
    		    return "cn";
	  }
	  else
  	  	    return aCode[0];
  }
  else {
	  if (  aCode[0] == "zh" ) 
            return "cn";
      else  
            return aCode[0];
  }    
}
  
function setCharSetDocument() {
// _wm.iso639sys = "zh-sg";
// _wm.iso639sys = "fr";
// _wm.iso639sys = "es";


    var iso639 = getCode();

    var html_code = "en";
    var lang = location.href;
    var idx = lang.lastIndexOf("/");
    lang = lang.substring(idx+1);

    re = /main_([a-z]+)\.html/
    
    if (re.test(lang)) {
        re.exec(lang);
        html_code = RegExp.$1;
    }
    else 
        html_code = "en";
    var aCharSet;
    if (typeof(aCharSetUser)=="undefined") {aCharSet=aCharSetGlobal}
    else { aCharSet = aCharSetUser };  
    if ( iso639 != html_code ) {
        if (aCharSet[iso639]) {
            location.replace("main_"+iso639+".html");
        }    
        else {   
            if (html_code != "en")         
                location.replace("main.html");
        }    
    }
}

try {
    _wm = parent._wm;
    if ( _wm.bIsland ) {
        setCharSetDocument();
    }    
} catch(e) {
//alert("debug::errorcode::"+e);
} finally {
}

