//	
//	Javascript document
//	Author:	Alex TW Lam
//	Date:	14/07/2005
//

$globalPrefix = 'http://www.ipd.gov.hk/ipr';

// 
// Purposes: Boolean functions by language detection 
// Action: Interpreting the language component of the path
// 

function showLangNav(){
	var $nav;
	if (inSC()){
		$nav = document.getElementById("scNav");
	}else if (inTC()){
		$nav = document.getElementById("tcNav");
	}else if (inEN()){
		$nav = document.getElementById("enNav");
	}
	
	if ($nav != null){
		return $nav.style.visibility = 'visible';
	}
}

function goSC(){
	return redirect($globalPrefix + '/gb' + getURLSuffix());
}

function goEN(){
	return redirect($globalPrefix + '/eng' + getURLSuffix());
}

function goTC(){
	return redirect($globalPrefix + '/chi' + getURLSuffix());
}

function getURLSuffix(){
	$suffix = '';
	$pattern = '^' + $globalPrefix + "/(?:gb|chi|eng)" + "(.*)$";
	$regx = new RegExp($pattern);
	$regx.exec(location.toString())  
	return RegExp.$1;
}

function inSC(){
	$pattern = '^' + $globalPrefix + "/gb";
	$regx = new RegExp($pattern);
	return $regx.test(location);
}

function inTC(){
	$pattern = '^' + $globalPrefix + "/chi";
	$regx = new RegExp($pattern);
	return $regx.test(location);
}

function inEN(){
	$pattern = '^' + $globalPrefix + "/eng";
	$regx = new RegExp($pattern);
	return $regx.test(location);
}

function redirect(URLStr) { location = URLStr; }
