function switchLang(from,to) {
	var currentStr = window.location.href;
	currentStr = currentStr.replace("/" + from + "/", "/" + to + "/");
	currentStr = currentStr.replace("lang=" + from, "lang=" + to);
	window.location.href = currentStr;
}

function getBrowserClientWidth() {
	if (typeof(window.innerWidth) == 'number') {
		// Non-IE
		return window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
	    //IE 4 compatible
		return document.body.clientWidth;
	}
	return 0;
}

function getBrowserClientHeight() {
	if (typeof(window.innerHeight) == 'number') {
		// Non-IE
		return window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
	    //IE 4 compatible
		return document.body.clientHeight;
	}
	return 0;
}

function getParamString() {	// cody.ng 2006.12.18
	var url = location.href;
	var pos = url.indexOf("?");
	if (pos <= 0)
		return "";
	return url.substring(pos + 1, url.length);
}


function getParamStringToArray() { // cody.ng 2006.12.18, ps: the key is in lower case
	var ps = getParamString();
	if (ps == "")
		return;
	var psArray = ps.split("&");

	var arr = new Array();
	for (var i = 0; i < psArray.length; i++) {
		var chunk = psArray[i];
		if (chunk != "") {
			var pair = chunk.split("=");
			if (pair.length == 2) {
				arr[pair[0].toLowerCase()] = pair[1];
			}
		}
	}		
	return arr;
}

function getPageMappingName()  // kenneth.hcoi 2007.01.09, get page mapping name
{
	return getQueryVariable("page");
}

function getPageId()  // kenneth.hcoi 2007.01.09, get page id 
{
	return getQueryVariable("id");
}

function getQueryVariable(variable) { // kenneth.hcoi 2007.01.09, get and parmeter value by "variable"
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return escape(pair[1]);
    }
  }
  return "";
}