
var root = "/hkcee2007/";


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;
}

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_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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 loginSubmitForm() {
	var d = document.form1;
	d.submit();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  thepop = window.open(theURL,winName,features);
  thepop.focus();
}

	function salespopup() {
		salespop = window.open('../sales.asp','salespop','width=650,height=450');
	}

//**************************************************
//				Highlight item common variable
//**************************************************
	var f = top.window;
	var gp = "";

	headHighLightColor = "#660000";
	headNoHighLightColor = "#AA0000";

	itemHighLightColor = "#FFCC00";
	itemNoHighLightColor = "#FFEA95";

// ************************************************
//			Highlight Function
// ************************************************
function groupFile(p, head, f) {
	this.p = p;
	this.head = head;
	this.f = f;
}

function initHighLight() {
	var fileprefix ;
	var lc = f.location.pathname;
	var filen = lc.substring(lc.lastIndexOf("/")+1, lc.length);
	filen  = filen.replace(".asp", "");
	if (filen.indexOf("_") != -1) {
		fileprefix = filen.substring(0, filen.indexOf("_"));
	} else {
		fileprefix = filen;
	}
//	alert(fileprefix);


	var head = lc.substring(lc.lastIndexOf("/")+1, lc.length);
	head = head.replace(".asp", "");
	var temp = lc.replace("/" + filen, "");
	var p = temp.substring(temp.lastIndexOf("/")+1, temp.length);
	p = p.replace(".asp", "");
	if (p == "hkcee2007") {
		p = "";
	}

	if (p+head == "lteabout") {
		parent.content.document.getElementById("lte_about").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "ltetrc_logon") {
		parent.content.document.getElementById("lte_trc").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "ltelink") {
		parent.content.document.getElementById("lte_link").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "leabout") {
		parent.content.document.getElementById("le_about").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "letrc_logon") {
		parent.content.document.getElementById("le_trc").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "lelink") {
		parent.content.document.getElementById("le_link").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "skillabout") {
		parent.content.document.getElementById("skill_about").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "skilltrc_logon") {
		parent.content.document.getElementById("skill_trc").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "gramabout") {
		parent.content.document.getElementById("gram_about").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "cepabout") {
		parent.content.document.getElementById("cep_about").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "cep_logon") {
		parent.content.document.getElementById("cep_trc").style.backgroundColor=itemHighLightColor;
	}
	if (p+head == "overview") {
		parent.content.document.getElementById("overviewpaper1_overview").style.backgroundColor=itemHighLightColor;
	}

/*
	for (i=0;i<gp.length;i++) {
		if (p == gp[i].p) {
			if (head == gp[i].head) {
*/
//				headIDPrefix = eval(gp[i].p +gp[i].head);
/*				parent.left_menu.document.getElementById(gp[i].p +gp[i].head).style.backgroundColor=headHighLightColor;
			}

			for (j=0;j<gp[i].f.length;j++) {
				if (fileprefix == gp[i].f[j]) {
*/
//					itemIDPrefix = eval(p + "_" + gp[i].f[j]);
/*					parent.content.document.getElementById(p + "_" + gp[i].f[j]).style.backgroundColor=itemHighLightColor;

					if (gp[i]) {
					parent.content.document.getElementById("SubMenu" + i).style.display = "none";
					} else {
					parent.left_menu.document.getElementById("index").style.backgroundColor=headHighLightColor;
					parent.content.document.getElementById("SubMenu1").style.display = "none";
					parent.content.document.getElementById("SubMenu2").style.display = "none";
					parent.content.document.getElementById("SubMenu3").style.display = "none";
					parent.content.document.getElementById("SubMenu4").style.display = "none";
					}
*/
/*
				}
			}
		}
	}
*/
	for (i=0;i<gp.length;i++) {
		if (p == gp[i].p) {
			if (head == gp[i].head) {
				headIDPrefix = eval(gp[i].p +gp[i].head);
				headIDPrefix.style.backgroundColor=headHighLightColor;
			}

			for (j=0;j<gp[i].f.length;j++) {
				if (fileprefix == gp[i].f[j]) {
					itemIDPrefix = eval(p + "_" + gp[i].f[j]);
					itemIDPrefix.style.backgroundColor=itemHighLightColor;
				}
			}
		}
	}
}

// menu
var currentMenu = 0;


function ShowSubMenu(id) {
e = parent.content.document.getElementById("SubMenu" + id);
d = parent.content.document.getElementById("SubMenu" + currentMenu);

if (e.style.display == "")
  {
     e.style.display = "none";
     currentMenu = 0;
  }
  else
  {
     if (currentMenu != 0) {
     d.style.display = "none";
     }
     e.style.display = "";
     currentMenu = id;
  }
}

function shows(id) {
e = parent.content.document.getElementById("SubMenu" + id);
d = parent.content.document.getElementById("SubMenu" + currentMenu);
if (e.style.display = "")
  {
     e.style.display = "none";
     currentMenu = 0;
  }
  else
  {
     if (currentMenu != 0) {
     d.style.display = "none";
     }
     e.style.display = "";
     currentMenu = id;
  }
}

function db_full_view(imgname) {
	MM_openBrWindow('photo_pop.asp?im=' + imgname,'fullview','left=0,top=0,width=800,height=600,toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=0,resizable=0');
}
function db_full_view2(imgname) {
	MM_openBrWindow('photo_pop.asp?im=' + imgname,'fullview2','left=0,top=0,width=800,height=600,toolbar=0,location=0,statusbar=0,menubar=0,scrollbars=1,resizable=0');
}

// Image auto resize
var arImages=new Array();
function Preload() {
	var temp = Preload.arguments; 
	for(x=0; x < temp.length; x++) {
		arImages[x]=new Image();
		arImages[x].src=Preload.arguments[x];
	}
	DetectImageSize(image_1);
}

function DetectImageSize(picName){
	width=picName.width+10;
	height=picName.height+55;
	resizeOuterTo(width, height);
}

function resizeOuterTo(w,h) {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			top.outerWidth=w-2;
			top.outerHeight=h-3;
	}
	else top.resizeTo(w,h);
	}
}
