//base function
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() {
if(parseInt(navigator.appVersion) == 5){
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){
   obj=document.getElementById(args[i]);v=args[i+2];
v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;
   }
  }
  else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
 }
 }
else{
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("##")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0C
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0C
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//end
if(location.href.search('devprj.com')!=-1){
	if(loca.search('publications')!=-1){
		live_path = loca.replace('/publications/','/');
	}else{
		live_path = loca.replace((eval('/\\\/'+lang+'\\\//')),'/');
	}
}else{
	live_path = "http://"+location.host+"/elderly/";
}

function menu(){
	document.write('<table width="198" border="0" cellspacing="0" cellpadding="0">'+
              '<tr> '+
                '<td class="spacer"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a1"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="'+live_path+'chinese/index.htm" class="sidelink">主頁</a></td>'+
              '</tr>'+
              '<tr>'+ 
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a2"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\';MM_showHideLayers(\'layeraboutus\',\'\',\'show\');navmenu_over();hideother(\'layeraboutus\');setpost(\'a2\',\'layeraboutus\')" onMouseOut="bgColor=\'#CC835F\';navmenu_out()" width="100%" bgcolor="#CC835F">'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
				'<tr>'+
				'<td width="100%"><a href="'+live_path+'chinese/background.htm" class="sidelink">關於我們</a></td>'+
				'<td><img src="'+live_path+'chinese/images/arrow.gif"></td>'+
				'</tr>'+
				'</table>'+
				'</td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a3"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\';MM_showHideLayers(\'layerhealthexp\',\'\',\'show\');navmenu_over();hideother(\'layerhealthexp\');setpost(\'a3\',\'layerhealthexp\')" onMouseOut="bgColor=\'#CC835F\';navmenu_out()" width="100%" bgcolor="#CC835F">'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
				'<tr>'+
				'<td width="100%"><a href="'+live_path+'chinese/healthinfo/commondiseases.htm" class="sidelink">長者健康速遞</a></td>'+
				'<td><img src="'+live_path+'chinese/images/arrow.gif"></td>'+
				'</tr>'+
				'</table>'+
				'</td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a4"></td>'+
              '</tr>'+
              '<tr> '+
               '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="'+live_path+'publications/cpublicationstext.htm#a" class="sidelink">長者健康專訊</a></td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a5"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\';MM_showHideLayers(\'layereshe\',\'\',\'show\');navmenu_over();hideother(\'layereshe\');setpost(\'a5\',\'layereshe\')" onMouseOut="bgColor=\'#CC835F\';navmenu_out()" width="100%" bgcolor="#CC835F">'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
				'<tr>'+
				'<td width="100%"><a href="'+live_path+'publications/cpublicationstext.htm#b" class="sidelink">健康教育資源</a></td>'+
				'<td><img src="'+live_path+'chinese/images/arrow.gif"></td>'+
				'</tr>'+
				'</table>'+
				'</td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a6"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\';MM_showHideLayers(\'layeresesp\',\'\',\'show\');navmenu_over();hideother(\'layeresesp\');setpost(\'a6\',\'layeresesp\')" onMouseOut="bgColor=\'#CC835F\';navmenu_out()" width="100%" bgcolor="#CC835F">'+
				'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
				'<tr>'+
				'<td width="100%"><a href="'+live_path+'chinese/foreword-c.htm" class="sidelink">護老資源</a></td>'+
				'<td><img src="'+live_path+'chinese/images/arrow.gif"></td>'+
				'</tr>'+
				'</table>'+
				'</td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a7"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="javascript:ecardc()" class="sidelink">電子賀咭</a></td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a8"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="'+live_path+'chinese/addressntel.htm" class="sidelink">聯絡我們</a></td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a9"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="'+live_path+'chinese/hotline.htm" class="sidelink">電話熱線</a></td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a10"></td>'+
              '</tr>'+
              '<tr> '+
                '<td onMouseOver="bgColor=\'#B05C3E\'" onMouseOut="bgColor=\'#CC835F\';hideother(\'non\')" width="100%" bgcolor="#CC835F"><a href="'+live_path+'chinese/clink.htm" class="sidelink">相關網站</a></td>'+
              '</tr>'+
              '<tr> '+
                '<td class="spacer" bgColor="#B05C3E"><img src="'+live_path+'chinese/images/spacer.gif" width="1" height="1" name="a10"></td>'+
              '</tr>'+
              '<tr> '+
                '<td>&nbsp;</td>'+
              '</tr>'+
            '</table>');
	}



function banner(){
	document.write('<a href="http://www.dh.gov.hk/index.html" target="_blank"><img src="'+live_path+'chinese/images/banner_dh.gif" alt="香港特別行政區政府 壎芵p" border="0"></a>');

}


//show layer

var navmenuout = true;
var navmenutimeoutID = 1;

function showHideDiv(divId, state) {
  d = document.getElementById(divId);
  if (state == 'hide') {
    d.style.visibility="hidden"; 
    //d.style.display='none';
  } else {
    d.style.visibility="visible"; 
    //d.style.display='';
  }
}

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;


function setpost(img, layerid){
	tmp_img = getImage(img);	
	tmp_y = getImagePageTop(tmp_img);
	tmp_x = getImagePageLeft(tmp_img);

//alert(layerid);
	if(isMinIE4){
		obj = eval(layerid);
		obj.style.posLeft = tmp_x + 198;
		obj.style.posTop = tmp_y;		
	}else{
		document.getElementById(layerid).style.left = tmp_x + 198;
		document.getElementById(layerid).style.top = tmp_y;
	}	
}

function getImage(name) {

  if (isMinNS4) {
    return findImage(name, document);
  }
  if (isMinIE4)
    return eval('document.all.' + name);
  return null;
}

function findImage(name, doc) {

  var i, img;

  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageTop(img) {

  var y, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  if (isMinIE4) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
    return y;
  }
  return -1;
}

function getImagePageLeft(img) {

  var x, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  if (isMinIE4) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
    return x;
  }
  return -1;
}


//script for new menu
function navmenu_over() {
navmenuout = false ;
clearTimeout(navmenutimeoutID);
}

function navmenu_out() {
navmenuout = true ;
navmenutimeoutID = setTimeout("autohide_menu()","300");
}

function autohide_menu() {
if (navmenuout == true) {
  showHideDiv('layeraboutus'   ,'hide');
  showHideDiv('layerhealthexp'   ,'hide');
  showHideDiv('layereshe'   ,'hide');
  showHideDiv('layeresesp'   ,'hide');
}
}

function hideother(layername) {
if (layername != 'layeraboutus'){
  showHideDiv('layeraboutus','hide');
}
if (layername != 'layerhealthexp'){
  showHideDiv('layerhealthexp','hide');
}
if (layername != 'layereshe'){
  showHideDiv('layereshe','hide');
}
if (layername != 'layeresesp'){
  showHideDiv('layeresesp','hide');
}

}

