
function LangToEng() {	// Call function to change language in English
	
	var url = window.location.href; // dynamic path
	
	// detect existing language and change the directory to English
	if (url.match(/sim/)=='sim')	{
		detect_lang = "/sim/";		
	}
	else if(url.match(/chn/)=='chn')	{
		detect_lang = "/chn/";
	}
	else	{
		window.top.location.reload(true);
		//window.top.location.href = '#'; 	// Fill in the URL to replace the # sign to redirect to .
	}	
		// change other language to English
		var eng = "/eng/"
		change = url.replace(detect_lang, eng);
		window.top.location.href = change;
}


function LangToChn() {	// Call function to change language in Traditional Chinese
	
	var url = window.location.href; // dynamic path
	
	// detect existing language and change the directory to Traditional Chinese
	if (url.match(/eng/)=='eng')	{
		detect_lang = "/eng/";
		//alert(detect_lang);
	}
	else if(url.match(/sim/)=='sim')	{
		detect_lang = "/sim/";
	}
	else	{
		window.top.location.reload(true);
		//window.top.location.href = '#'; 	// Fill in the URL to replace the # sign to redirect to .
	}	
		// change other language to Traditional Chinese
		var chn = "/chn/"
		change = url.replace(detect_lang, chn);
		window.top.location.href = change;
}


function LangToSim() {	// Call function to change language in Simplified Chinese
	
	var url = window.location.href; // dynamic path
	
	// detect existing language and change the directory to Simplified Chinese
	if (url.match(/eng/)=='eng')	{
		detect_lang = "/eng/";		
	}
	else if(url.match(/chn/)=='chn')	{
		detect_lang = "/chn/";
	}
	else	{
		window.top.location.reload(true);
		//window.top.location.href = '#'; 	// Fill in the URL to replace the # sign to redirect to .
	}	
		// change other language to Simplified Chinese
		var sim = "/sim/"
		change = url.replace(detect_lang, sim);
		window.top.location.href = change;
}


