
var IE4=(document.all) ? 1:0;
var NS4=(document.all) ? 0:1;

function GenericLayerObject(elementId) {

	this.element=(IE4)? document.all[elementId].style : document.getElementById(elementId).style;

	this.name=elementId+"Var";
	eval(this.name + "=this");
	this.left=Left;
	this.top=Top;
	this.moveTo=MoveTo; 
	this.moveBy=MoveBy; 
	this.setInvisible=SetInvisible;
	this.setVisible=SetVisible;
}
 
function Left() {
	return (NS4)? this.element.left : this.element.pixelLeft;
}

function Top() {
	return (NS4)? this.element.top : this.element.pixelTop;
}

function MoveTo(x, y) {

	this.element.left=x;
	this.element.top=y;
}

function MoveBy(x, y) {

	this.element.left=this.element.left+x;
	this.element.top=this.element.top+y;
}

function SetVisible() {

	this.element.visibility="visible";
}

function SetInvisible() {

	this.element.visibility="hidden";
}


/*
** Use the above defined layer object
*/

var current_layer_idx=0;
var layer_array=new Array();

function GetCurrentLayerName() {

	var layer_name = 'layer_array[' + current_layer_idx + ']';
	return layer_name;
}

function GetCurrentLayerID() {

	var layer_id="layer" + current_layer_idx;
	return layer_id;
}

function CreateCurrentLayerObj() {

	var layer_name=GetCurrentLayerID();
	layer_array[current_layer_idx]=new GenericLayerObject(layer_name);
}

function SwapNextLayer() {

	current_layer_idx++;
}

function GetCurrentLayerObj() {

	return layer_array[current_layer_idx];
}

function OpenCurrentLayerTag(){

	if (IE4){
		document.write("<div id='" + GetCurrentLayerID() + "' style='position:absolute;z-index:2;width:0;height:0'>");
	} else {
		document.write("<div id='" + GetCurrentLayerID() + "' style='position:relative;z-index:2;width:0;height:0'>");
	}
}

function CloseCurrentLayerTag() {

	document.write("</div>");
}


/*
** SECTION - MENU REQUIREMENT: EXPAND SELECTED MENU SECTION
*/

function checkKey() {

	if (event.keyCode == 17 || event.keyCode == 18 || event.keyCode == 116 || event.keyCode == 142) {

            event.keyCode = 0;
            event.returnValue = false;
   	}
}

function menu_class (menu_type, menu_link, menu_over_icon, menu_out_icon) {
	this.menu_type=menu_type;
	this.menu_link=menu_link;
	this.menu_over_icon=menu_over_icon;
	this.menu_out_icon=menu_out_icon;
}

function link_page_class (original_page, related_page) {
	this.original_page=original_page;
	this.related_page=related_page;
}

var array_index=0;
var menu_array = new Array();

var link_page_index=0;
var link_page_array = new Array();

/* 
**	ONLY Modified Place for menu is here
**	GROUP => PAGE GROUP 
**	PAGE => PAGE 
*/
menu_array[array_index++]=new menu_class('GROUP','abt_message_c.html', 'img_c/b_01_o.gif','img_c/b_01.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_message_c.html', 'img_c/b_01sub01_o.gif','img_c/b_01sub01.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_director_c.html', 'img_c/b_01sub02_o.gif','img_c/b_01sub02.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_overview_c.html', 'img_c/b_01sub03_o.gif','img_c/b_01sub03.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_milestone_c.html', 'img_c/b_01sub04_o.gif','img_c/b_01sub04.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_achievement_c.html', 'img_c/b_01sub05_o.gif','img_c/b_01sub05.gif');
menu_array[array_index++]=new menu_class('PAGE','abt_award_c.html', 'img_c/b_01sub06_o.gif','img_c/b_01sub06.gif');
// link_page_array[link_page_index++]=new link_page_class('abt_award_c.html', 'abt_award_c.html');
// link_page_array[link_page_index++]=new link_page_class('abt_award_c.html', 'abt_award2_c.html');

menu_array[array_index++]=new menu_class('GROUP','business01_c.html', 'img_c/b_03_o.gif','img_c/b_03.gif');
menu_array[array_index++]=new menu_class('PAGE','business01_c.html', 'img_c/b_03sub01_o.gif','img_c/b_03sub01.gif');
menu_array[array_index++]=new menu_class('PAGE','business02_c.html', 'img_c/b_03sub02_o.gif','img_c/b_03sub02.gif');
menu_array[array_index++]=new menu_class('PAGE','business03_c.html', 'img_c/b_03sub03_o.gif','img_c/b_03sub03.gif');
menu_array[array_index++]=new menu_class('PAGE','business04_c.html', 'img_c/b_03sub04_o.gif','img_c/b_03sub04.gif');

menu_array[array_index++]=new menu_class('GROUP','news_release_c.html', 'img_c/b_04_o.gif','img_c/b_04.gif');
// menu_array[array_index++]=new menu_class('PAGE','news_release_c.html', 'img_c/b_04sub01_o.gif','img_c/b_04sub01.gif');
// link_page_array[link_page_index++]=new link_page_class('news_release_c.html', 'news_release_c.html');
// menu_array[array_index++]=new menu_class('PAGE','news_activity_c.html', 'img_c/b_04sub02_o.gif','img_c/b_04sub02.gif');

menu_array[array_index++]=new menu_class('GROUP','ir_announ_c.html', 'img_c/b_02_o.gif','img_c/b_02.gif');
menu_array[array_index++]=new menu_class('PAGE','ir_announ_c.html', 'img_c/b_02sub01_o.gif','img_c/b_02sub01.gif');
menu_array[array_index++]=new menu_class('PAGE','ir_04circular_c.html', 'img_c/b_02sub04_o.gif','img_c/b_02sub04.gif');
menu_array[array_index++]=new menu_class('PAGE','ir_report_c.html', 'img_c/b_02sub03_o.gif','img_c/b_02sub03.gif');
menu_array[array_index++]=new menu_class('PAGE','ir_press_c.html', 'img_c/b_02sub02_o.gif','img_c/b_02sub02.gif');
// menu_array[array_index++]=new menu_class('PAGE','ir_circular_c.html', 'img_c/b_02sub04_o.gif','img_c/b_02sub04.gif');
// menu_array[array_index++]=new menu_class('PAGE','ir_ipo_c.html', 'img_c/b_02sub05_o.gif','img_c/b_02sub05.gif');

menu_array[array_index++]=new menu_class('GROUP','javascript:window.open(\'http://www.careertimes.com.hk/english/search/summary_multi_cpj.asp?company_id=00013236,00019338,00024234,00024236,00026078,00029511,00031898,00033569&sortby=date_desc\',\'\',\'width=742,height=500,toolbar=yes,location=no,status=yes,menubar=no,scrollbars=yes\');void(0);', 'img_c/b_06_o.gif','img_c/b_06.gif');

menu_array[array_index++]=new menu_class('GROUP','contact_c.html', 'img_c/b_05_o.gif','img_c/b_05.gif');

/*
for (var i=0; i<menu_array.length; i++) {
	menu_item = menu_array[i];
	alert(menu_item.menu_type + '::' + menu_item.menu_link + '::' + menu_item.menu_over_icon + '::' + menu_item.menu_out_icon);
}
*/

function JsLib_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.JsLib_p) d.JsLib_p=new Array();
    var i,j=d.JsLib_p.length,a=JsLib_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.JsLib_p[j]=new Image; d.JsLib_p[j++].src=a[i];}}
}

function JsLib_swapImgRestore() { //v3.0
  var i,x,a=document.JsLib_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function JsLib_swapImgRestore_2() { //v3.0
  var i,x,a2=document.JsLib_sr2; for(i=0;a2&&i<a2.length&&(x=a2[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function JsLib_findObj(n, d) { //v4.01
  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=JsLib_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function JsLib_swapImage() { //v3.0
  var i,j=0,x,a=JsLib_swapImage.arguments; document.JsLib_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=JsLib_findObj(a[i]))!=null){document.JsLib_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function JsLib_swapImage_2() { //v3.0
  var i,j=0,x,a2=JsLib_swapImage_2.arguments; document.JsLib_sr2=new Array; for(i=0;i<(a2.length-2);i+=3)
   if ((x=JsLib_findObj(a2[i]))!=null){document.JsLib_sr2[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a2[i+2];}
}

function find_file_rootdoc(in_filename) {


	for (j=0; j<link_page_array.length; j++) {
		var link_page_item = link_page_array[j];
		//alert(in_filename + '::' + link_page_item.related_page);
		if (link_page_item.related_page==in_filename) {
			return link_page_item.original_page;
		}
	}
	return in_filename
}


function getFileNameFromFullPath(full_filename) {

	var last_idx = 0;
	var last_idx_1 = full_filename.lastIndexOf('\\');
	var last_idx_2 = full_filename.lastIndexOf('/');
	if (last_idx_1 >= last_idx_2) {
		last_idx = last_idx_1;
	} else {
		last_idx = last_idx_2;
	}
	
	return full_filename.substring(last_idx+1,(full_filename.length));
}

/*
var fname = getFileNameFromFullPath(document.URL);
alert(fname);
*/

// check expanded group
var expanded_group = 0;
var cur_group = 0;
var cur_filename = getFileNameFromFullPath(document.URL);
for (i=0; i<menu_array.length; i++) {
	var menu_item = menu_array[i];
	if (menu_item.menu_type =='GROUP') {
		cur_group++;
	}
	//alert(cur_filename);
	if (find_file_rootdoc(cur_filename) == getFileNameFromFullPath(menu_item.menu_link)) {
		expanded_group = cur_group;
	}
}
//alert(expanded_group);
document.writeln("<table width=142 border=0 cellspacing=0 cellpadding=0>");
cur_group=0;
for (i=0; i<menu_array.length; i++) {

	var menu_item = menu_array[i];
	if (menu_item.menu_type =='GROUP') {
		cur_group++;
	}

	//alert(menu_item.menu_type + '::' + menu_item.menu_link + '::' + menu_item.menu_over_icon + '::' + menu_item.menu_out_icon);
	//alert(getFileNameFromFullPath(menu_item.menu_link));

	if (menu_item.menu_type=="GROUP") {
	
		if (cur_group==expanded_group) {
		
			document.writeln("<tr>");
			document.writeln("<td><a href=" + menu_item.menu_link + " onMouseOver=JsLib_swapImage('but_" + String(i) + "','','" + menu_item.menu_over_icon + "',1) onMouseOut=JsLib_swapImgRestore()>  <img src='" + menu_item.menu_over_icon + "' name='but_0"+ String(i) + "' width=142 height=35 border=0 id=but_"+ String(i) + "></a></td>");
			document.writeln("</tr>");	
			
		} else {
		
			/*
			** Add layer submenu if this group is unselected
			*/

			var curLayerName=GetCurrentLayerName();

			//alert("<td><a href=" + menu_item.menu_link + " onMouseOver=\"JsLib_swapImage('but_" + String(i) + "','','" + menu_item.menu_over_icon + "',1);" + curLayerName + ".setVisible();\" " + " onMouseOut=\"JsLib_swapImgRestore();" + curLayerName + ".setInvisible();\" " + "><img src='" + menu_item.menu_out_icon + "' name='but_0"+ String(i) + "' width=142 height=42 border=0 id=but_"+ String(i) + "></a>");


			document.writeln("<tr>");
			document.write("<td><a href=" + menu_item.menu_link + " onMouseOver=\"JsLib_swapImage('but_" + String(i) + "','','" + menu_item.menu_over_icon + "',1);" + curLayerName + ".setVisible();\" " + " onMouseOut=\"JsLib_swapImgRestore();" + curLayerName + ".setInvisible();\" " + "><img src='" + menu_item.menu_out_icon + "' name='but_0"+ String(i) + "' width=142 height=35 border=0 id=but_"+ String(i) + "></a>");

			OpenCurrentLayerTag();


			var pitem_link='';
			var pitem_on_img='';
			var pitem_off_img='';			

			document.write("<table border=0 cellspacing='0' cellpadding='0'>");

			// loop over whole menu_array for related subitems
			var submenu_item=0;
			for (subcount=i+1; subcount < menu_array.length; subcount++) {
				submenu_item = menu_array[subcount];
				if (submenu_item.menu_type =='GROUP') {
					break;
				}

				document.writeln("<tr>");
				document.write("<td><a href='" + submenu_item.menu_link + "' onMouseOver=\"JsLib_swapImage('b_sub_x" + String(subcount) +"','','" + submenu_item.menu_over_icon + "',1);" + " JsLib_swapImage_2('but_" + String(i) + "','','" + menu_item.menu_over_icon + "',1);" + curLayerName + ".setVisible();  \" onMouseOut=\"JsLib_swapImgRestore();JsLib_swapImgRestore_2();" + curLayerName + ".setInvisible(); \"><img src='" + submenu_item.menu_out_icon + "' name='b_sub_x" + String(subcount) + "' width=122 height=26 border=0 id='b_sub_x" + String(subcount) + "'></a></td>");

				//document.writeln("<td><a href='" + menu_item.menu_link + "' onMouseOver=JsLib_swapImage('b_sub" + String(i) +"','','" + menu_item.menu_over_icon + "',1) onMouseOut=JsLib_swapImgRestore()><img src='" + menu_item.menu_out_icon + "' name='b_sub" + String(i) + "' width=142 height=26 border=0 id='b_sub" + String(i) + "'></a></td>");

				document.writeln("</tr>");
			}
			submenu_item=0;

			document.write("</table>");

			CloseCurrentLayerTag();

			document.write("</td>");
			document.writeln("</tr>");

			CreateCurrentLayerObj();

			var curLayerObj=GetCurrentLayerObj();
			if (NS4){curLayerObj.moveBy('142px','-35px');}
			curLayerObj.setInvisible();

			SwapNextLayer();
		}
		
	} else if  (menu_item.menu_type=="PAGE" && cur_group==expanded_group) {

		if (find_file_rootdoc(cur_filename)==getFileNameFromFullPath(menu_item.menu_link)) {
		
			document.writeln("<tr>");
			document.writeln("<td><a href='" + menu_item.menu_link + "' onMouseOver=JsLib_swapImage('b_sub" + String(i) +"','','" + menu_item.menu_over_icon + "',1) onMouseOut=JsLib_swapImgRestore()><img src='" + menu_item.menu_over_icon + "' name='b_sub" + String(i) + "' width=142 height=26 border=0 id='b_sub" + String(i) + "'></a></td>");
			document.writeln("</tr>");		

		} else {

			document.writeln("<tr>");
			document.writeln("<td><a href='" + menu_item.menu_link + "' onMouseOver=JsLib_swapImage('b_sub" + String(i) +"','','" + menu_item.menu_over_icon + "',1) onMouseOut=JsLib_swapImgRestore()><img src='" + menu_item.menu_out_icon + "' name='b_sub" + String(i) + "' width=142 height=26 border=0 id='b_sub" + String(i) + "'></a></td>");
			document.writeln("</tr>");	
		}
	}
}

document.writeln("</table>");