var scserver = "http"+"://sc.info.gov.hk/gb/";
var locapath = document.location.href

var atlang,domname,sitepath,atgb,atindex,org_part;
	sc_path = "gb/";
	tc_path = "b5/";
	en_path = "eng/";
      atgb = false;
	atindex = false;


if (locapath.toString().search('/gb/')!= -1){
	atgb = true;
	org_path_start = locapath.indexOf("/gb/") +4;
	org_path_end = locapath.length;
	sitepath = locapath.substring(org_path_start, org_path_end);
}else{
	atgb = false;
	sitepath = locapath.substring(7,locapath.length);
}

sitepath = locapath.substring(7,locapath.length);

if (locapath.toString().search('/eng/')!= -1){
	atlang = "en";
	org_part = en_path;
}else
if (locapath.toString().search('/b5/')!= -1){
	atlang = "tc";
	org_part = tc_path;
}else
if (locapath.toString().search('/gb/')!= -1){
	atlang = "sc";
	org_part = sc_path;
}else
if (locapath.toString().search('index.htm')!= -1){
	atlang = "en";
	org_part = "index.htm";
	atindex = true;
}else
if (locapath.toString().search('index.htm')!= -1){
	atlang = "tc";
	org_part = "index.htm";
	atindex = true;
}else

if (locapath.toString().search('index.htm')!= -1){
	atlang = "sc";
	org_part = "index.htm";
	atindex = true;
}



function chglang(lang){

	switch(lang){
				case 'en':
			des_part = en_path;
			des_ind_part = "index.htm";
			base_path = "http"+"://";
			break;
		case 'tc':
			
			des_part = tc_path;
			des_ind_part = "index.htm";
			base_path = "http"+"://";
			break;
		case 'sc':
			//des_part = tc_path;
			des_part = sc_path;
			des_ind_part = "index.htm";
			//base_path = scserver;
			base_path = "http"+"://";
			break;
	}

	if (atindex == true){
		tail = sitepath.replace(org_part, des_ind_part);
	}else{
		tail = sitepath.replace(org_part, des_part);
	}

//alert(base_path+tail)
	window.location =  base_path+tail;

}

function displaytcsc(){
	if (atgb){
		document.write("<a href=\"javascript:chglang('tc')\">");
		document.write("<img name=\"Image36\" border=\"0\" src=\"../gb/images/chinbut.gif\" alt=\"ÁcÅéª©\"></a>");	
	}else{
		document.write("<a href=\"javascript:chglang('sc')\">");
		document.write("<img name=\"Image36\" border=\"0\" src=\"../b5/images/simbut.gif\" alt=\"Â²Ê^ª©\"></a>");
	}


}


