sc_svr = "http://sc.info.gov.hk/gb/";
test_svr = "www0.info.gov.hk";
prod_svr = "www.info.gov.hk";
test_url = "http://www0.admwing.gov.hk";
prod_url = "http://www.admwing.gov.hk";
english = "/eng/";
chinese = "/sc/";
_url = top.location.href;

//url function
function istest(str_url){
	if (str_url.indexOf(test_svr) != -1){
		return true;
	}
	return false;
}


function fso_page(str_url){
	
	if (_url.indexOf(sc_svr) != -1){
		if (istest(_url)){
			link7 = test_url + str_url;	
		}else{
			link7 = prod_url + str_url;
		}
		link7 = link7.replace("sc.info.gov.hk/gb/","");
		top.location.href= link7;
	}else{
		top.location.href= str_url;
	}
		
}



function gb_page(str_url){
	if (istest(_url)){
		link = sc_svr + test_svr + str_url;	
	}else{
		link = sc_svr + prod_svr + str_url;
	}
	top.location.href = link;
	


}

function simp_chinese(){
	link = top.location.href;
/*
	if (link.indexOf(english) != -1){
		link = link.replace(english,chinese); 	
	}
	link = link.replace("http://",sc_svr);	
	//alert(link);
*/
	link = link.replace('/eng/','/sc/');
	link = link.replace('/chi/','/sc/');
	top.location.href = link;

}

function trad_chinese(){
	
	link2 = top.location.href;
/*	
	if (link2.indexOf("http://sc.info.gov.hk/gb/") != -1){
		link2 = link2.replace("sc.info.gov.hk/gb/","");	
	}
	if (link2.indexOf(english) != -1){
		link2 = link2.replace(english,chinese); 	
	}
*/
	link2 = link2.replace('/eng/','/chi/');
	link2 = link2.replace('/sc/','/chi/');
	top.location.href=link2;

}

function stn_english(){
	link2 = top.location.href;
/*	
	if (link2.indexOf("http://sc.info.gov.hk/gb/") != -1){
		link2 = link2.replace("sc.info.gov.hk/gb/","");	
	}
	if (link2.indexOf(chinese) != -1){
		link2 = link2.replace(chinese,english); 	
	}
	if (link2.indexOf('#top') != -1){
		link2 = link2.replace ('#top','');
		}
*/
	link2 = link2.replace('/chi/','/eng/');
	link2 = link2.replace('/sc/','/eng/');
	top.location.href=link2;
}


// general functions
function win_popup(str_url,str_winname,int_width,int_height,str_feature){
	if (!str_feature){
		str_feature = 'toolbars='	+ 'no'
		+ ',top='			+ '100'
		+ ',left='			+ '100'
		+ ',width=' 			+ int_width
		+ ',height=' 			+ int_height
		+ ',scrollbars='		+ 'no'
		+ ',resizable='			+ 'no'
		+ ',screenX='			+ '0'
		+ ',screenY='			+ '0'
		+ ',status='			+ 'no' 
	}
	
	var win = window.open(str_url, str_winname , str_feature);		
	win.focus();
	//return win;
}

// url functions

function getfoldername(){
	 
	 private_str_path = location.href;
	 private_int_len_path = private_str_path.length;
	 private_str_subpath = private_str_path.substring (7,private_int_len_path);
	 private_int_subpathid = private_str_subpath.lastIndexOf("/");
	 private_str_subpath = private_str_subpath.substring(0,private_int_subpathid);
	 private_int_subpathid = private_str_subpath.lastIndexOf("/");
	 private_int_len_path = private_str_subpath.length;
	 private_str_subpath = private_str_subpath.substring (private_str_subpath+1,private_int_len_path);
	 return private_str_subpath;
	 
}

function getfilename(){
	
	private_str_path = location.href;
	private_int_fileid = private_str_path.lastIndexOf("/");
	private_int_filesubid = private_str_path.lastIndexOf(".");
	private_str_filename = private_str_path.substring(private_int_fileid+1,private_int_filesubid);
	return private_str_filename;
}



//swap image functions
function si_over(str_image_name , str_path){
	document[str_image_name].src = str_path;
}

function si_out(str_image_name , str_path){
	document[str_image_name].src = str_path;
}


function tcsc2() {
	document.write("<a href=\"javascript:trad_chinese();\" OnMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage(\'kanhan\',\'\',\'../gb_images/mainbar3_f2.gif\',1)\"><img src=\"../images/mainbar3.gif\" alt=\"繁体版\" name=\"kanhan\" width=\"51\" height=\"19\" border=\"0\"></a>"); 
}
