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);
		
		if (link.indexOf('#top') != -1){
		link = link.replace ('#top','');
		}
		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);
		if (link.indexOf('#top') != -1){
		link = link.replace ('#top','');
		}
		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;
	}
}




// 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'
		+ ',top='			+ '0'
		+ ',left='			+ '0' 
	}else
	{
		str_feature = 'toolbars='	+ 'no'
		+ ',width=' 			+ int_width
		+ ',height=' 			+ int_height
		+ ',scrollbars='		+ 'no'
		+ ',resizable='			+ 'no'
		+ ',screenX='			+ '0'
		+ ',screenY='			+ '0'
		+ ',status='			+ 'no'
		+ ',top='			+ '129'
		+ ',left='			+ '0' 
	}
	
	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))
}	

/*
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
var login = Get_Cookie("login_name");
if (login != null){
	}else{
	window.location = "/index.asp";
}
*/
