//if(location.href.toString().search('ccc') != -1){
//	var domain_url2 = 'ht'+'tp://ccc.emsd.com';
//}
//else if(location.href.toString().search('www0.emsd.gov.hk') != -1)
//{
//	var domain_url2 = 'ht'+'tp://www0.emsd.gov.hk';
//}
//else
//{
//	var domain_url2 = 'ht'+'tp://www.emsd.gov.hk';
//}
//alert(domain_url2);

//if(location.href.toString().search('search.info.gov.hk') != -1){
//	selectedSection=13;
//	selectedSubSection=0;
//}

//var title = new Array()
//title[1] = "更改電線顏色代碼簡介";
//title[2] = "技術指引";
//title[3] = "業界培訓";
//title[4] = "宣傳資訊";
//title[5] = "常見問題";
//title[6] = "相關網址";

//var left_menu_img_path='/tc/images/';
//var topOffSet=163+8; //position + icon top
//var leftOffSet=0;

//function getTitle() {
	//generate the menu to the buffer variable
//	var scriptBuffer='';
//	scriptBuffer+='<title>';
//	scriptBuffer+='新電線顏色代碼';
//	if (mainTopicNo!=''&&mainTopicNo!=0) {
//		scriptBuffer+=' - ';
//		scriptBuffer+=title[mainTopicNo];
//	}
//	if (subTopic!='' && subTopic!=0) {
//		scriptBuffer+=' - ';
//		scriptBuffer+=subTitle[mainTopicNo][subTopic];
//	}
//	scriptBuffer+='</title>';
//	return scriptBuffer;
//}

//only using in chineses verison for replace the dummy space between the character
//function replaceSpace(str) {
//	var retStr=str;
//	for (var i=0; i<str.length-1; i++) {
//		retStr = retStr.replace(' ','');
//	}
//	return retStr;
//}

//change to text only version
function textSwitch() {
       goPath=document.location.pathname;
       
	if(location.href.toString().search('search.info.gov.hk') != -1){
		if (location.href.toString().search('mode=176') != -1) { //change to English version
			goPath=location.href.replace("mode=176", "mode=16");
		}
		if (location.href.toString().search('mode=177') != -1) { //change to traditional chinese version
			goPath=location.href.replace("mode=177", "mode=15");
		}
		document.location=goPath;
		//alert(goPath);
	}else{
  	var arrayEle = new Array()
	arrayEle = goPath.split('/');
	document.location = goPath.substring(0,goPath.lastIndexOf('/')-2)+'text/'+ 
	arrayEle[arrayEle.length-2]+'/'+arrayEle[arrayEle.length-1];
	//document.location = arrayEle[arrayEle.length-1];
	}
}

//switch language version

var chi_str = document.URL.toString(); 

if(chi_str.search('/gb/') != -1){ 
	chi_str = chi_str.substring( chi_str.indexOf('/gb/')+4, chi_str.length ); 
} 
else {
	chi_str = chi_str.substring( 7, chi_str.length ); 
}

function langSwitch(lang) {
	var goPath;
	var pagePath=document.location.pathname;

	if(location.href.toString().search('search.info.gov.hk') != -1){
		if (lang=='en') { //change to English version
			goPath=location.href.replace("mode=177", "mode=176");
		}
		if (lang=='tc') { //change to traditional chinese version
			goPath=location.href.replace("mode=176", "mode=177");
		}
		if (lang=='sc') { //change to simplified chinese version
//			if(location.href.toString().search('westcom') != -1){
//				goPath= 'ht'+'tp://ccc.emsd.com/'+ chi_str.replace("mode=176", "mode=177");
//			}else{
				goPath= 'ht'+'tp://sc.info.gov.hk/gb/'+ chi_str.replace("mode=176", "mode=177");
//			}
		}
	}else{
//		if(location.href.toString().search('ccc') != -1)
//			var translationServer='ht'+'tp://ccc.emsd.com/gb/';
//		else
			var translationServer='http://sc.info.gov.hk/gb/';
	
		if (lang=='en') { //change to English version
//			goPath='/en'+pagePath.substring(3,pagePath.length);
			goPath=pagePath.replace("tc/", "en/");
		}
		if (lang=='sc') { //change to simplified chinese version
//			goPath='/tc'+pagePath.substring(3,pagePath.length);
			goPath=pagePath.replace("tc/", "sc/");
			/* goPath=translationServer+location.host+goPath; */
		}
	}
	//alert(goPath);
	document.location=goPath;
}

