var livedomainname = "www.cacs.icac.hk";
var previewname = "wcms.cacs.icac.hk/preview";
var translationserver = "sc.icac.org.hk";
var translationdomainname = translationserver + "/TuniS/";
//+livedomainname;


var domainname = "";
var locapath = document.location.href
if(locapath.toString().search(livedomainname)!= -1 )
{
	domainname = livedomainname;
}
else if (locapath.toString().search(previewname)!= -1 )
{
	domainname = previewname;
}
else{
	domainname ="192.168.1.157/demo/icac";
}


var atlang,domname,sitepath,atgb,atindex,org_part;

	sc_path = "tc/";
	tc_path = "tc/";
	en_path = "en/";
	atgb = false;
	atindex = false;

if (locapath.toString().search('/TuniS/')!= -1){
	atgb = true;
	org_path_start = locapath.indexOf("/TuniS/") +7;
	org_path_end = locapath.length;
	sitepath = locapath.substring(org_path_start, org_path_end);
}else{
	atgb = false;
	sitepath = locapath.substring(7,locapath.length);
}

if (locapath.toString().search('/en/')!= -1){
	atlang = "en";
	org_part = en_path;
}else
if (locapath.toString().search('/tc/')!= -1){
	atlang = "tc";
	org_part = tc_path;
}


function jsmenu(value){
	url = value;
	if (url != "null"){
		parent.location = url;
	}
}
function jump2(patt){
	if (top.location){
		currenturl = top.location.href + "";
	}else{
		;
	}
	newstr = currenturl + "";
	nexturl = "";
	patt = "/" + patt +"/";
	if (currenturl.indexOf("/en/") != -1){
		srcpatt = /\/en\//i;
	}else if (currenturl.indexOf("/tc/") != -1){
		srcpatt = /\/tc\//i;
	}else if (currenturl.indexOf("/sc/") != -1){
		srcpatt = /\/sc\//i;
	}
	nexturl = newstr.replace(srcpatt, patt);
	top.location.href = nexturl;
}

function open_window(url){
	mywin = window.open(url,'win','toolbar=0,location=0,directories=1,status=0,menubar=0,scrollbars=1,resizable=1,width=350,height=350');
}


function chglang(lang)
{
	filepath = locapath.replace("en", "tc");

	if (lang=="sc")
		filepath = filepath.replace("http://", "http://"+translationdomainname);

	document.location.href= filepath;
}


/*
	function chglang(lang)
	{
		if (atgb)
	
		filepath = locapath.replace("http://"+translationdomainname, "");
		if (lang!="tc")
		{
			filepath = filepath.replace("tc", "en");
		}
		base_path = "http://" + domainname;
		window.location =  base_path+filepath;
	}
	else 
	{
		if (lang!="sc")
		{
			jump2(lang);
		}
		else 
		{
			filepath = locapath.replace("http://", "");

			if (atlang!="tc")
			{
				filepath = filepath.replace("en", "tc");
			}
			base_path ="http://"+translationdomainname; 
			window.location =  base_path+filepath;
		}
	}*/

function showlangbar()
{
	document.write('<span class="verdana_11pt_white_link"><a  class="verdana_11pt_white_link" href="javascript:chglang(\'tc\');">繁</a> |');
	document.write('<a class="verdana_11pt_white_link" href="javascript:chglang(\'sc\');">简</a> |</span>');
}
