// Language directory
var chi_path= "/chi/"
var eng_path= "/eng/"
var sim_path= "/sim/"


/*
Check if the simplified Chinese version, the update the alt tag value by calling the button.js
*/
if (location.href.toString().search('/sim/') != -1) {
	atgb = 1;
} else {
	atgb = 0;
}

function changeVer(lang) {

	org_path=window.location.href;
	des_path="";

	if (isSim()) {
		if (lang == 'c') {
			des_path = org_path.replace(sim_path,chi_path);
		}	
		if (lang == 'e') {
			des_path = org_path.replace(sim_path,eng_path);
		}	
	}

	if (isChi()) {
		if (lang == 's') {
			des_path = org_path.replace(chi_path,sim_path);
		}	
		if (lang == 'e') {
			des_path = org_path.replace(chi_path,eng_path);
		}	
	}

	if (isEng()) {
		if (lang == 'c') {
			des_path = org_path.replace(eng_path,chi_path);
		}	
		if (lang == 's') {
			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;
}

