//url function
function search(str_param){
	//location.href="/reo/" + str_param + '/search.htm';;	
	location.href= "http://search2.info.gov.hk";
}

function sitemap(ver){
	location.href= '/' + ver + '/sitemap.asp';
}

function contactus(ver){
	location.href= '/' + ver + '/contact.asp';
}

function faq(ver){
	location.href= '/' + ver + '/faq.asp';
}

function related(ver){
	location.href= '/' + ver + '/related.asp';
}



function lang(fr_ver , to_ver){
	
	link = location.href;
	fr_ver1 = fr_ver;
	fr_ver = '/' + fr_ver + '/';
	
	english = "/en/";
	chinese = "/ch/";
	gb = "/gb/";
	
	if (to_ver == "en"){
		if (is_contain_ver(fr_ver1)){
			link = link.replace('ver='+ fr_ver1, 'ver='+ to_ver);
		}
		link = link.replace (fr_ver, english);
		parent.location.href = link;
	}else if (to_ver == "ch"){
		if (is_contain_ver(fr_ver1)){
			link = link.replace('ver='+ fr_ver1, 'ver='+ to_ver);
		}
		link = link.replace (fr_ver, chinese);
		parent.location.href = link;
	}else if (to_ver == "gb"){
		if (is_contain_ver(fr_ver1)){
			link = link.replace('ver='+ fr_ver1, 'ver='+ to_ver);
		}
		link = link.replace (fr_ver, gb);
		parent.location.href = link;
	}
}

function is_contain_ver(ver){
	str_url = location.href;
	str_query = "&ver=" + ver;
	if (str_url.indexOf(str_query) == -1){
		return false;
	}else{
		return true;
	}
}



function textonly(ver){
	link = location.href;
	english = "/en/";
	chinese = "/ch/";
	gb = "/gb/";

	if (ver == "en"){
		link = link.replace (english, "/en/text/");
		parent.location.href = link;
	}else if (ver == "ch"){
		link = link.replace (chinese, "/ch/text/");
		parent.location.href = link;
	
	}else if (ver == "gb"){
		link = link.replace (gb, "/gb/text/");
		parent.location.href = link;
	}
}

// general functions
function win_popup(str_url,str_winname,int_width,int_height,str_feature){
	if (!str_feature){
		str_feature = 'toolbars='	+ 'no'
		+ ',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;
}


function geturlparam(name) {
	var strParam = window.location.search
	
	idx1 = strParam.indexOf(name + "=")
	if (idx1 == -1)	return ""

	idx1 = idx1 + name.length + 1
	idx2 = strParam.indexOf("&", idx1)

	if (idx2 != -1)
		len = idx2 - idx1
	else
		len = strParam.length

	return unescape(strParam.substr(idx1, len))
}	


//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;
}

// String functions
function is_valid_length(str_param, int_length){
	if ((str_param.length > int_length ) || (str_param.length == 0 )){
		return false;
	}
	return true;
}

//Popup
function openwin(img,wh,ht)
{
var img
var pop1 = window.open("","staff","width=750, height=380,left=0,top=0,resizable=no,status=no,menubar=no,scrollbars=no,location=no, directories=no, toolbar=no");
pop1.focus();
pop1.document.write("<html><head><title>The Duty Lawyer Service - Staff</title>");
pop1.document.write("</head>");
pop1.document.write("<body bgcolor=#FFFFFF style='margin-left: 0px;margin-top: 0px;'>");
pop1.document.write("<img src=../../images/"+img+".jpg width="+wh+" height="+ht+" border=0>");
pop1.document.write("<p align=center><font size=2><a href='javascript: window.close()'>Close Window</a></font></p><br>");
pop1.document.write("</body></html>");
}
//Popup (chinese)
function openwinc(img,wh,ht)
{
var img
var pop1 = window.open("","staff","width=750, height=380,left=0,top=0,resizable=no,status=no,menubar=no,scrollbars=no,location=no, directories=no, toolbar=no");
pop1.focus();
pop1.document.write("<html><head><title>The Duty Lawyer Service - Staff</title>");
pop1.document.write("</head>");
pop1.document.write("<body bgcolor=#FFFFFF style='margin-left: 0px;margin-top: 0px;'>");
pop1.document.write("<img src=../../images/"+img+".jpg width="+wh+" height="+ht+" border=0>");
pop1.document.write("<p align=center><font size=2><a href='javascript: window.close()'>Ãö ³¬ µø µ¡</a></font></p><br>");
pop1.document.write("</body></html>");
}
//

