

	var kanhanalias = '/TuniS/';
	var lcimgpath=location.pathname;
	var lcimgpathidx=lcimgpath.indexOf('/en/');
	if (lcimgpathidx<0) {
		if (lcimgpath.indexOf('/chs/')>=0) {
			lcimgpathidx=lcimgpath.indexOf('/chs/');
			lcimgpath=lcimgpath.substring(0,lcimgpathidx+5);
		} else {
			lcimgpathidx=lcimgpath.indexOf('/tc/');
			lcimgpath=lcimgpath.substring(0,lcimgpathidx+4);
		}
	} else {
		lcimgpath=lcimgpath.substring(0,lcimgpathidx+4);
	}
	
	function currentLocale() {
		var loc = window.location;
		var pathtmp = loc.pathname;
		var fromlang = '';
		if (pathtmp.indexOf('/chs/')>=0) fromlang='sc';
		else if (pathtmp.indexOf('/tc/')>=0) fromlang='tc';
		else fromlang='en';
		return fromlang;
	}

		function changeLocale(tolang) {
			var loc = window.location;
			var kanhanserver = 'sc.info.gov.hk';
			var kanhanport = 80;
//			var kanhanalias = '/TuniS/';
			var hostname = '';
			var pathprefix = '';
			var pathsuffix = '';
			var fromlang = '';

			if (tolang=='simpchin') tolang='chs';
			else if (tolang=='tradchin') tolang='tc';
			else tolang='en';

			var pathtmp = loc.pathname;
			var idx = -1;
			fromlang = currentLocale();

			pathtmp = pathtmp.replace('/en/', '/' + tolang + '/');
			pathtmp = pathtmp.replace('/tc/', '/' + tolang + '/');
			pathtmp = pathtmp.replace('/chs/', '/' + tolang + '/');
			window.location = pathtmp;

//			if (pathtmp.indexOf(kanhanalias)>=0) fromlang='sc';
//			else if (pathtmp.indexOf('/tc/')>=0) fromlang='tc';
//			else fromlang='en';
/*			
			if (fromlang==tolang) return;
			
			if (fromlang=='sc') {
				idx = pathtmp.indexOf('/', 1);			// e.g. /TuniS/www.info.gov.hk/jud/tc/intro/cindex.htm
				pathtmp = pathtmp.substring(idx);		//	/www.info.gov.hk/jud/tc/intro/cindex.htm
				idx = pathtmp.indexOf('/', 1);
				hostname = pathtmp.substring(1, idx);	//	www.info.gov.hk
				pathtmp = pathtmp.substring(idx);		//	/jud/tc/intro/cindex.htm
			} else hostname = loc.hostname;
			if ((idx=pathtmp.indexOf('/en/')) < 0 ) idx=pathtmp.indexOf('/tc/');
			pathprefix=pathtmp.substring(0, idx);		//	/jud
			pathsuffix=pathtmp.substring(idx+3);		//	/intro/cindex.htm
			
			var destURL;
			if (tolang=='sc') {
				destURL = loc.protocol + '//' + kanhanserver + ((kanhanport==80)?'':(':'+kanhanport))
								+ kanhanalias + hostname + pathprefix + '/tc' 
								+ pathsuffix + loc.search + loc.hash;
			} else {
				destURL = loc.protocol + '//' + hostname + pathprefix + '/' + tolang + pathsuffix + loc.search + loc.hash;
			}
			window.location = destURL;			
*/
		}
		
	function genEngBut(ImgOver,Img0) {
		var tmp = '';
		if (currentLocale()!='en') {
			tmp = "<a href=\"javascript:changeLocale('eng')\" target=\"_self\" ";
			tmp += "onMouseOver=\"MM_swapImage('EngButImg','','"+lcimgpath+ImgOver+"',1)\" ";
			tmp += "onMouseOut=\"MM_swapImgRestore()\"><img src=\""+lcimgpath+Img0+"\" alt=\"English\" ";
			tmp += "name=\"EngButImg\" width=\"52\" height=\"20\" border=\"0\"></a>";
		}
		document.write(tmp);
	}

	function genTradChinBut(ImgOver,Img0) {
		var tmp = '';
		if (currentLocale()!='tc') {
			tmp = "<a href=\"javascript:changeLocale('tradchin')\" target=\"_self\" ";
			tmp += "onMouseOver=\"MM_swapImage('TradChinButImg','','"+lcimgpath+ImgOver+"',1)\" ";
			tmp += "onMouseOut=\"MM_swapImgRestore()\"><img src=\""+lcimgpath+Img0+"\" alt=\"繁體\" ";
			tmp += "name=\"TradChinButImg\" width=\"52\" height=\"20\" border=\"0\"></a>";
		}
		document.write(tmp);
	}

	function genSimpChinBut(ImgOver,Img0) {
		var tmp = '';
		if (currentLocale()!='sc') {
			tmp = "<a href=\"javascript:changeLocale('simpchin')\" target=\"_self\" ";
			tmp += "onMouseOver=\"MM_swapImage('SimpChinButImg','','"+lcimgpath+ImgOver+"',1)\" ";
			tmp += "onMouseOut=\"MM_swapImgRestore()\"><img src=\""+lcimgpath+Img0+"\" alt=\"简体\" ";
			tmp += "name=\"SimpChinButImg\" width=\"52\" height=\"20\" border=\"0\"></a>";
		}
		document.write(tmp);
	}

	function genEngLegalRefLink() {
		var tmp = '';
		if (currentLocale() =='en') {
			tmp = "<a href=\"http://legalref.judiciary.gov.hk/doc/whats_new/prac_dir/html/forme/eng/index.htm\" target=\"_self\" ";
			tmp += ">Financial Statement (Form E), Financial Dispute Resolution Pilot Scheme, <br>(Practice Direction 15.11 refers)</a>";
		}
		document.write(tmp);
	}

	function genTradChinLegalRefLink() {
		var tmp = '';
		if (currentLocale()=='tc') {
			tmp = "<a href=\"http://legalref.judiciary.gov.hk/doc/whats_new/prac_dir/html/forme/tc/index.htm\" target=\"_self\" ";
			tmp += ">經濟狀況陳述書(表格E) - 解決財務糾紛試驗計劃(實務指示 - 15.11)</a>";
		}
		document.write(tmp);
	}

	function genSimpChinLegalRefLink() {
		var tmp = '';
		if (currentLocale()=='sc') {
			tmp = "<a href=\"http://legalref.judiciary.gov.hk/doc/whats_new/prac_dir/html/forme/simp/index.htm\" target=\"_self\" ";
			tmp += ">经济状况陈述书(表格E) - 解决财务纠纷试验计划(实务指示 - 15.11)</a>";		}
		document.write(tmp);
	}

	function govsearch() {
		var url="http://search.info.gov.hk/cgi-bin/se.cgi?"
		url = addparam(url, "mode",	"1");
		url = addparam(url, "lmode",	"1");
		url = addparam(url, "pq",		"");
		url = addparam(url, "pg",		"");
		url = addparam(url, "pn",		"0");
		url = addparam(url, "qm",		"0");
		url = addparam(url, "la",		"1");
		url = addparam(url, "de",		"0");
		url = addparam(url, "so",		"1");
		url = addparam(url, "ma",		"100");
		url = addparam(url, "nu",		"10");
		url = addparam(url, "ca",		"0");
		url = addparam(url, "ta",		"all");
		url = addparam(url, "fu",		"");
		url = addparam(url, "temp_qu", document.search.temp_qu.value);
		url = addparam(url, "submit",	"Search");
		url = addparam(url, "ft_1", 	"alltype");
		url = addparam(url, "temp_gr_1",	"jud");
		url = addparam(url, "gr_1", 	"jud");
		url = addparam(url, "qu", 	'"'+document.search.temp_qu.value+'"');
		alert(url);
		window.open(url, "searchresult","width=400,height=350,status=no,resizable=no,scrollbars=yes");
		
	}
	function addparam(url, name, value) {
		if (url.charAt(url.length-1)!='?') url = url+'&';
		url = url + escape(name) + '=' + escape(value);
		return url;
	}