// Language directory
var chi_path= "/tc_chi/"
var eng_path= "/english/"
var sim_path= "/sc_chi/"


/*
Check if the simplified Chinese version, the update the alt tag value by calling the button.js
*/
if (location.href.toString().search('/sc_chi/') != -1) {
	atgb = true;
} else {
	atgb = false;
}

function chglang(lang){

	org_path=window.location.href;
	des_path="";

	if (isSim()) {
		if (lang == 'tc') {
			des_path = org_path.replace(sim_path,chi_path);
		}	
		if (lang == 'en') {
			des_path = org_path.replace(sim_path,eng_path);
		}	
	}

	if (isChi()) {
		if (lang == 'sc') {
			des_path = org_path.replace(chi_path,sim_path);
		}	
		if (lang == 'en') {
			des_path = org_path.replace(chi_path,eng_path);
		}	
	}

	if (isEng()) {
		if (lang == 'tc') {
			des_path = org_path.replace(eng_path,chi_path);
		}	
		if (lang == 'sc') {
			des_path = org_path.replace(eng_path,sim_path);
		}	
	}

	window.location.href = des_path;
}

function isEng() {
	return (location.href.toString().indexOf(eng_path) != -1) ? true : false;
}

function isChi() {
	return (location.href.toString().indexOf(chi_path) != -1) ? true : false;
}

function isSim() {
	return (location.href.toString().indexOf(sim_path) != -1) ? true : false;
}

function displaytcsc(){
	if (atgb){
		document.write("<a href=\"javascript:chglang('tc')\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('topbtnlang02','','../images/general/top_over_20.gif',1)\">");
		document.write("<img name=\"topbtnlang02\" border=\"0\" src=\"../images/general/top_20.gif\" alt=\"繁體中文\"></a>");	
	}else{
		document.write("<a href=\"javascript:chglang('sc')\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('topbtnlang02','','../images/general/top_over_04.gif',1)\">");
		document.write("<img name=\"topbtnlang02\" border=\"0\" src=\"../images/general/top_04.gif\" alt=\"簡體中文\"></a>");
	}


}