﻿<!--
function addFavourite() {
	theURL = location.href;
	theTitle = document.title;
	if (window.external) {
		window.external.AddFavorite(theURL, theTitle);
	} else if( window.sidebar && window.sidebar.addPanel ) { 
		if (navigator.userAgent.lastIndexOf("Netscape") != -1) { 
			window.sidebar.addPanel(theTitle, theURL, '');
		}else{ 
			window.sidebar.addPanel(theTitle, theURL, '');
		} 
	}
}

function changeLanguage() {
	var url = location.href;
	location.href = url.replace("eng", "chi");
}

function changeCustomerLeft(section, over) {
	if (over == 1) {
		MM_findObj('leftBg_' + section).className = color+'SubMenuOver';
		MM_findObj('leftIcon_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/point_'+subSection+'_02.gif';
		//alert(subSection);
	} else {
		MM_findObj('leftBg_' + section).className = color+'SubMenu';
		MM_findObj('leftIcon_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/point_'+subSection+'_01.gif';
	}
}

function changeLeftBtn(section, over) {
	if (over == 1) {
		if (thisSection == 5 && section == 1) {
			MM_findObj('leftBg_' + section).className = classMenuName+thisSection+"b";
		} else {
			MM_findObj('leftBg_' + section).className = classMenuName+thisSection;
		}
		MM_findObj('leftIcon_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/point_red_02.gif';
	} else {
		MM_findObj('leftBg_' + section).className = 'subMenuBg';
		MM_findObj('leftIcon_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/point_red_01.gif';
	}
}

function changeBtn(section, over, color) {
	if (over == 1) {
		MM_findObj('btnLeft_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/btn_left_'+color+'.gif';
		MM_findObj('btnRight_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/btn_right_'+color+'.gif';
		MM_findObj('btnBg_' + section).className = 'btn'+color+'';
		MM_findObj('btnLink_' + section).className = 'btn'+color+'10px';
		MM_findObj('btnBot_' + section).className = 'btnBot'+color+'';
	} else {
		MM_findObj('btnLeft_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/btn_left_gray.gif';
		MM_findObj('btnRight_' + section).src = 'http://www.chinalightandpower.com.hk/CLP/common/images/common/btn_right_gray.gif';
		MM_findObj('btnBg_' + section).className = 'btngray';
		MM_findObj('btnLink_' + section).className = 'btngray10px';
		MM_findObj('btnBot_' + section).className = 'btnBot';		
	}	
}

function changeMainNav(section, over) {
	if (over == 1) {
		MM_findObj('navTopLine_' + section).className = 'navTopLineOver';
		MM_findObj('navLeftLine_' + section).className = 'navLeftLineOver' + (section+1);
	} else {
		MM_findObj('navTopLine_' + section).className = 'navTopLine';
		MM_findObj('navLeftLine_' + section).className = 'navLeftLine';
	}
}

function changeMenuNav(section, over) {
	if (over == 1) {
		MM_findObj('subMenuBg_' + section).className = 'subMenuBgOver';
	} else {
		MM_findObj('subMenuBg_' + section).className = 'subMenuBg';
	}
}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function whiteBg_DoFSCommand(command, args) {
	if (command == "hide") {
		if (isInternetExplorer) {
			MM_findObj('bg').style.display = 'none';
			MM_findObj('countrySelect').style.visibility = 'visible';
		} else {
	   		document.all['bg'].style.visibility = "hidden";
			document.all['countrySelect'].style.visibility = 'visible';
		}
	}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub whiteBg_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call whiteBg_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function flashBanner_DoFSCommand(command, args) {
/*
	var temp1Obj = isInternetExplorer ? document.all.whiteBg : document.whiteBg;
	if (command == "close")
	{
		//temp1Obj.Play();
		//temp1Obj.GotoFrame(2);
		temp1Obj.Play();
		if (temp1Obj.IsPlaying()) { 
			//alert("movie is playing");
		} else {
			temp1Obj.GotoFrame(2);
			temp1Obj.Play();
		}
	}
*/
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub flashBanner_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call flashBanner_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

function flashOff(step) {
/*
	if (step == 0) {
		MM_findObj('whiteBg').Play();
		//MM_findObj('whiteBg').SetVariable("goMovie", 1);
		//if(window.whiteBg) window.document["whiteBg"].SetVariable("goMovie", 1);
		//if(document.whiteBg) document.whiteBg.SetVariable("goMovie", 1);
	} else if (step == 1) {
		MM_findObj('bg').style.display = 'none';
	}
*/
}

function changeHeight() {
	//alert(document.body.scrollHeight);
	if (MM_findObj('flashBg').height < document.body.scrollHeight) {
		MM_findObj('flashBg').height = document.body.scrollHeight;
	} else {
		MM_findObj('flashBg').height = document.body.offsetHeight;
	}
}

function changeHomeSubMenuPos() {
/*
	if (navigator.userAgent.indexOf("Opera")==-1 && navigator.userAgent.indexOf("Netscape")==-1) {
		changeMenuPos('subMenu_'+0,'',subNavPosArray[0], 'subMenu_'+1,'',subNavPosArray[1], 'subMenu_'+2,'',subNavPosArray[2], 'subMenu_'+3,'',subNavPosArray[3], 'subMenu_'+4,'',subNavPosArray[4], 'subMenu_'+5,'',subNavPosArray[5], 'subMenu_'+6,'',subNavPosArray[6], 'subMenu_'+7,'',subNavPosArray[7],'bg','',0, 'banner','',0);
	} else {
		changeMenuPos('subMenu_'+0,'',subNavPosArray[0], 'subMenu_'+1,'',subNavPosArray[1], 'subMenu_'+2,'',subNavPosArray[2], 'subMenu_'+3,'',subNavPosArray[3], 'subMenu_'+4,'',subNavPosArray[4], 'subMenu_'+5,'',subNavPosArray[5], 'subMenu_'+6,'',subNavPosArray[6], 'subMenu_'+7,'',subNavPosArray[7], 'banner','',0);
	}
	//alert(document.body.offsetHeight+" & "+document.body.scrollHeight);
*/
}

function changeSubMenuPos() {
/*
	changeMenuPos('subMenu_'+0,'',subNavPosArray[0], 'subMenu_'+1,'',subNavPosArray[1], 'subMenu_'+2,'',subNavPosArray[2], 'subMenu_'+3,'',subNavPosArray[3], 'subMenu_'+4,'',subNavPosArray[4], 'subMenu_'+5,'',subNavPosArray[5], 'subMenu_'+6,'',subNavPosArray[6], 'subMenu_'+7,'',subNavPosArray[7]);
*/	
}

function changeMenuPos() {
	winWidth = 770;
	scrollerWidth = 17;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			var obj,objLeft,args=changeMenuPos.arguments;
			var innerH = document.body.offsetHeight;
			var outerH = document.body.scrollHeight;
			//alert(winW);
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			var obj,objLeft,args=changeMenuPos.arguments;
			var innerH = document.body.scrollHeight;
			var outerH = document.body.offsetHeight;
			//alert(winW);
		}
		//alert("args0: "+args[0]);
		for (i=0; i<(args.length-2); i+=3) {
			if ((obj=MM_findObj(args[i]))!=null) {
				obj=MM_findObj(args[i]);
				objLeft=Number(args[i+2]);
			}
			//alert(objLeft);
			if (navigator.appName=="Netscape") {
				if (outerH > innerH) {
					if (winW<winWidth) {
						theObjLeft = objLeft;
					} else {
						theObjLeft = (winW-winWidth)/2 + objLeft;
					}
				} else {
			if (winW<winWidth+scrollerWidth) {
				theObjLeft = objLeft;
			} else {
				theObjLeft = (winW-winWidth-scrollerWidth)/2 + objLeft;
			}
				}
			} else{
				if (winW<winWidth+scrollerWidth) {
					theObjLeft = objLeft;
				} else {
					theObjLeft = (winW-winWidth-scrollerWidth)/2 + objLeft;
				}
			}
			obj.style.left = theObjLeft;
		}
	}
}

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','strong','a','span','li','ul');
var startSz;

function getFontSize() {
	if (document.cookie.indexOf("fontSize") < 0) {
		startSz = 0;
	} else {
		var startStr = document.cookie.indexOf("fontSize") + 9;
		var endStr = document.cookie.indexOf(";", startStr);
		if (endStr == -1) {
			endStr = document.cookie.length;
		}
		startSz = unescape(document.cookie.substring(startStr, endStr));
		
		//alert(startSz);
		changeFontSize("tableContent",0,0);
		//changeFontSize("titleContent",0,1);
	}
}

var lineHeightArray = new Array('18px','20px','22px','24px');

function changeFontSize( trgt, inc, type ) {
	
	//Specify spectrum of different font sizes:
	//var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
	if (type == 1) {
		var szs = new Array('x-small','small','medium','large');
	} else {
		var szs = new Array('xx-small','x-small','small','medium');
		var smallSzs = '100%';
	}
	if (!document.getElementById) return
	var d = document,cEl = null,sz = eval(startSz),i,j,cTags;
	if (type == 0) {
		sz += inc;
	}
	if ( sz < 0 ) sz = 0;
	if ( sz > (szs.length-1) ) sz = (szs.length-1);
	startSz = sz;
	//alert(sz);
	
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	cEl.style.fontSize = szs[ sz ];
		
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) {
		//	cTags[ j ].style.fontSize = smallSzs;
			cTags[ j ].style.fontSize = szs[ sz ];
		//	cTags[ j ].style.lineHeight = lineHeightArray[ sz ];
		//	alert(cTags[ j ].style.lineHeight);
		//	cTags[ j ].style.lineheight += sz;
		}
	}
	if (type == 0) {
		//document.cookie = "fontSize=" + sz;
		setCookie("fontSize", sz, nd, cpath, cdomain);
		//alert(document.cookie);
	}
	
}

nd= new Date();
nd.setTime (nd.getTime()+(365*24*60*60*1000));
//cdomain = (location.domain) ? location.domain : null;
cdomain = (location.domain) ? location.domain : null;
cpath = "/";

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function NewWindow(mypage, myname, w, h, scroll,resizable) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+','
win = window.open(mypage, myname, winprops)
win.self.focus()
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_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_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 IsNull(org_str_array, result_str){
  var i ;
  
  if (result_str == null){
	  result_str = "" ;
  }
  
  if (org_str_array== null){
	  return result_str ;
  }else{
	  if (org_str_array.length == 0){
		  org_str_array[0] = result_str;
	  }
	  for (i=0; i<org_str_array.length; i++){
		if (org_str_array[i] == null){
			org_str_array[i] = result_str ;
		}
	  }
	  return org_str_array ;
  }
}

//version3
function IsNullObject(org_str_array){
 if (org_str_array != null){
  return false ;
 }
 else{
  return true ;
 }
}
function IsNullString(org_str_array){
 if (org_str_array != null){
  return org_str_array ;
 }
 else{
  return "" ;
 }
}
function mailpage()
{
	var mail_str ;
	mail_str = "mailto:?subject=The Link to CLP Power Website" ;
	mail_str += "&body=You have received the link to CLP Power Website, please click the following link to access the information:%0A%0A" ;
	mail_str += escape(window.location.href); 
	window.location.href = mail_str;
}
-->
