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;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  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.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
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 loadImages(){
   MM_preloadImages(
  '/newimages/menu_employer_on.gif','menu_employer_on.gif',
  '/newimages/menu_candidates_off.gif','/newimages/menu_candidates_on.gif',
  '/newimages/menu_genuine_articles_off.gif', '/newimages/menu_genuine_articles_on.gif',
  '/newimages/menu_training_off.gif', '/newimages/menu_training_off.gif',
  '/newimages/menu_management_off.gif', '/newimages/menu_management_on.gif',
  '/newimages/menu_job_search_off.gif','/newimages/menu_job_searcH_on.gif'
  );
}

function GetStyle(name) {
   if (document.getElementById)
      return document.getElementById(name).style;
   else if (document.all)
      return document.all[name].style;
   else {
      var el = document.layers[name];
      if (el != null)   return el;
      for (var i=0; i<document.layers.length; i++) {
         el = document.layers[i].document.layers[name];
         if (el != null)   return el;
      }//end-for-i
   }//end-if  
}//end-func-GetStyle

function styleRoll(span, vis) {
   var el = GetStyle(span);
   var state = vis? 'visible':'hidden';
   el.visibility = state;
}//end-func-styleRoll

function GetObj(name) {
   if (document.getElementById)
      return document.getElementById(name);
   else if (document.all)
      return document.all[name];
}//end-func-GetObj

function classRoll(span,cls) {
        theObj = GetObj(span);
        if(theObj) {
                theObj.className = cls;
        }
}

function View2(winname,theURL,top,left,width,height)
{
        msgWindow = window.open(theURL,winname,'menubar=no,scrollbars=yes,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

        if (msgWindow.opener == null)
                msgWindow.opener = self;

}

function goAuditForm(lang) {
	var mapping = new Array();
	mapping['eng'] = 'en';
	mapping['hkg'] = 'ch';
	View2('','http://www.hkyaf.com/audit5/index_'+mapping[lang]+'.phtml',50,50,800,650);
}

function goAuditFormP(lang) {
        var mapping = new Array();
        mapping['eng'] = 'en';
        mapping['hkg'] = 'ch';
        View2('','http://www.hkyaf.com/audit4/index_'+mapping[lang]+'.phtml',50,50,800,650);
}

function showMap(lang) {
	var top = 50;
	var left = 50;
	var width = 750;
	var height = 370;
        msgWindow = window.open('/map'+lang+'.html','Map','menubar=no,scrollbars=no,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

        if (msgWindow.opener == null)
                msgWindow.opener = self;
	msgWindow.focus();
}

function viewTable(lang) {
        var top = 50;
        var left = 50;
        var width = 550 + 50;
        var height = 700;
        msgWindow = window.open('/website/event/timetable_'+lang,'Event','menubar=no,scrollbars=yes,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

        if (msgWindow.opener == null)
                msgWindow.opener = self;
}

function viewKeyword(path) {
        var top = 50;
        var left = 50;
        var width = 550 + 50;
        var height = 500;
        msgWindow = window.open(path,'','menubar=no,scrollbars=yes,toolbar=no,location=no,titlebar=no,resizable=no,status=no,screenX=0,top='+top+',screenY=0,left='+left+',width='+width+',height='+height+'');

        if (msgWindow.opener == null)
                msgWindow.opener = self;
}

function parent_url_control(url){ 
window.opener.location.href = url;
window.opener.focus(); 
}

function styleRoll(span, vis) {
   var el = GetStyle(span);
   var state = vis? 'visible':'hidden';
   el.visibility = state;
   if(state == 'visible') el.zIndex = 1; else el.zIndex = -1;
}//end-func-styleRoll

function goTo(part){
	var link = "/jobs/" + part + "/page1/";
	window.location = link;
}

function changeTab(switchOn, visible, thumb){
        var ifile = new Array();
        ifile["hitab1"] = "/newimages/home_tab_business_on.gif";
        ifile["hitab2"] = "/newimages/home_tab_facilities_on.gif";
        ifile["hitab3"] = "/newimages/home_tab_article_on.gif";
	styleRoll(ctab,0);
	ctab = visible;
	cImg = switchOn;
	styleRoll(ctab,1);
        document.getElementById('hitab1').src = "/newimages/home_tab_business_off.gif";
        document.getElementById('hitab2').src = "/newimages/home_tab_facilities_off.gif";
        document.getElementById('hitab3').src = "/newimages/home_tab_article_off.gif";
        document.getElementById(switchOn).src = ifile[switchOn];
/*
	styleRoll(cThumb,0);
	cThumb = thumb;
	styleRoll(cThumb,1);
*/
}

function checkImg(section){
	var ifile2 = new Array();
	ifile2["hitab1"] = new Array();
        ifile2["hitab1"]["on"] = "/newimages/home_tab_business_on.gif";
        ifile2["hitab1"]["off"] = "/newimages/home_tab_business_off.gif";
	ifile2["hitab2"] = new Array();
        ifile2["hitab2"]["on"] = "/newimages/home_tab_facilities_on.gif";
        ifile2["hitab2"]["off"] = "/newimages/home_tab_facilities_off.gif";
	ifile2["hitab3"] = new Array();
        ifile2["hitab3"]["on"] = "/newimages/home_tab_article_on.gif";
        ifile2["hitab3"]["off"] = "/newimages/home_tab_article_off.gif";

	if(section == cImg){
		document.getElementById(section).src = ifile2[section]["on"];
	}
	else{
		document.getElementById(section).src = ifile2[section]["off"];
	}
} 

function changeNewsYear(){
	var year = document.getElementById('newsyear').value;
	if(year != 'latest'){
		var location = "/news/"+year+"/page1/";
	}
	else{
		var location = "/news/page1/";
	}
	window.location = location;
}

function changeOverPic(picName,id,fname){
	if(ctab != id){
		MM_swapImage(picName,'','/newimages/home_tab_'+fname+'_over.gif','1');
	}
}

var winImage;
function showImage(file,width,height,bgcolor,center,popup){
                if(bgcolor=='') bgcolor='FFFFFF';
                content = "<HTML>\n";
                content += "<HEAD>\n";
                content += "<SCRIPT language=\"JavaScript\" src=\"/common.js\"></SCRIPT>";
                content += "</HEAD>\n";
                content += "<BODY TOPMARGIN=0 LEFTMARGIN=0 BGCOLOR=#"+bgcolor+">\n";
                if(center=='Y') content += "<CENTER>\n";
                content += "<IMG SRC='"+file+"' BORDER=0>";
                if(center=='Y') content += "</CENTER>\n";
                content += "</BODY>\n";
                content += "</HTML>\n";
                if(popup=='Y'){
                        winWidth = width+20;
                        winHeight = height+10;
                        if(winHeight>700) winHeight = 700;
                        args='top=20,left=200,screenX=0,screenY=0,width='+winWidth+',height='+winHeight+',scrollbars=yes,resizable=yes,status=no';
                }else{
                        if ((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)<=4)) {
                                winWidth = screen.availWidth;
                                winHeight = screen.availHeight
                        }else{
                                winWidth = screen.Width;
                                winHeight = screen.Height;
                        }
                        args='top=0,left=0,screenX=0,screenY=0,width='+winWidth+',height='+winHeight+',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
                }
                if(winImage) winImage.close();
                winImage=window.open("","",args);
                winImage.document.write(content);
                winImage.opener=self;
                winImage.focus();
}

