var tc=0;
var sc=1;
var en=2;
function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }
function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }
function jump(pdest){
	var sURI, pdest;
	//alert(pdest);
	
	if(isInteger(pdest)){
		dest=pdest;
	}else{
		dest=parseInt(pdest);
	}
	
	if (dest == 10)
		dest = 12;
	
	sURI = mainlink[dest] ; 
	//sURI = mainlink[1] ; //temp hardcode
	
	if (sURI.indexOf('?') > 0) {
		//sURI += '&lang=en';
	} else {
		//sURI += '?lang=en';
	}
	document.location.href=sURI;
}
function sitemap(dest){
	var sURI;
	
	sURI = langPath+"sitemap/index.html"
	
	if (sURI.indexOf('?') > 0) {
		//sURI += '&lang=en';
	} else {
		//sURI += '?lang=en';
	}
	document.location.href=sURI;
}
function goURL(dest){
	var sURI;
	
	switch(dest) {
		case 1: sURI ='http://www.imh.org.hk' ; break;
		case 2: sURI= 'http://www.ha.org.hk/cph' ; break;
		case 3: sURI ='http://www.ha.org.hk' ; break;
	}
	
	eval("nw = window.open(sURI, 'document','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=800,height=300')");
	if ( nw.focus != null)
	{nw.focus();}

	//document.location.href=sURI;
}
function language(lang) {
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
	var switchSc='/sc/';
	var TempCurrpath = currentPath.split("#");
	currentPath = TempCurrpath[0];

	if(lang=="graphic"){
		currentPath=currentPath.replace('/text', "");
	}else if(lang=="textonly"){
		currentPath=currentPath.replace(switchEn, '/text'+switchEn);
		currentPath=currentPath.replace(switchTc, '/text'+switchTc);
		currentPath=currentPath.replace(switchSc, '/text'+switchSc);
	}else if(lang==0){
		currentPath=currentPath.replace(switchEn, switchTc);
		currentPath=currentPath.replace(switchSc, switchTc);
		//currentPath=currentPath.replace(gb_urlPath, "");
	}else if(lang==1){
		currentPath=currentPath.replace(switchTc, switchSc);
		currentPath=currentPath.replace(switchEn, switchSc);
	}else if(lang==2){
		currentPath=currentPath.replace(switchTc, switchEn);
		currentPath=currentPath.replace(switchSc, switchEn);
		//currentPath=currentPath.replace(gb_urlPath, "");
	}
	location.href=currentPath;
}
function FormSubmit(e, iType){
	var sURI = 'search.asp?lang=en&keyword=' + document.searchform.keyword.value;
	if (iType == 0) {
		sURI += '&zone=web'
		e.href = sURI;
	} else {
		sURI = 'searchTemp.asp?lang=en&keyword=' + document.searchform.keyword.value;
		sURI += '&zone=music'
		document.forms.searchform.action = sURI;
		document.forms.searchform.submit();
	}
}
function goSearch(keyword){
	sURI = langPath+"search/index.asp?keyword=" + keyword;
	location.href=sURI ;
}
