var jsvMaxcharLengthArray = Array();

var jsvIsIE501 = navigator.userAgent.indexOf("MSIE 5.01") > 0 ? true : false;
var jsvIsNN6 = navigator.userAgent.indexOf("Netscape6") > 0 ? true : false;
var jsvIsIE=document.all&&navigator.userAgent.indexOf("Opera")==-1;

//Event.observe(window, 'load', pws_jsfInit, false);

function pws_jsfTogglePage(self)
{
	if (jsvIsIE) 
	{
		var container = self.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
		var element1 = container.nextSibling;
		var element2 = element1.nextSibling;
		
		self.parentElement.parentElement.className="selected";
		if (self.parentElement.parentElement.nextSibling != null)
			self.parentElement.parentElement.nextSibling.className="";
		if (self.parentElement.parentElement.previousSibling != null)
			self.parentElement.parentElement.previousSibling.className="";
		
		
		if (element1.style.display == "none")
		{
			element1.style.display = "";
			element2.style.display = "none";
		} else {
			element1.style.display = "none";
			element2.style.display = "";
		}
	} else {
		var container = self.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
		var element1 = container.nextSibling.nextSibling;
		var element2 = element1.nextSibling.nextSibling;
		
		self.parentNode.parentNode.className="selected";
		if (self.parentNode.parentNode.nextSibling.nextSibling != null)
			self.parentNode.parentNode.nextSibling.nextSibling.className="";
		if (self.parentNode.parentNode.previousSibling.previousSibling != null)
			self.parentNode.parentNode.previousSibling.previousSibling.className="";
		
		if (element1.style.display == "none")
		{
			element1.style.display = "";
			element2.style.display = "none";
		} else {
			element1.style.display = "none";
			element2.style.display = "";
		}
	}
}

function pws_getElementsByName_iefix(tag, name)
{
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function pws_contractAll()
{
	var togs, contents;
	
	if (jsvIsIE)
	{
		togs = pws_getElementsByName_iefix("div", "reduceToggle");
		contents = pws_getElementsByName_iefix("div", "content");
	}
	else
	{
		togs = document.getElementsByName("reduceToggle");
		contents = document.getElementsByName("content");
	}
	
	for (i=0; i<togs.length; i++)
	{
		togs[i].style.display = "none";
		contents[i].style.display = "none";
	}
}

function pws_jsfToggleMenu(self)
{
	if (jsvIsIE) 
	{
		if (self.parentElement.parentElement.children[0].style.display == "none")
		{
			self.parentElement.parentElement.children[0].style.display = "";
			self.parentElement.parentElement.children[1].style.display = "none";
			self.parentElement.parentElement.parentElement.children[1].children[1].style.display = "none";
		} else {
			self.parentElement.parentElement.children[0].style.display = "none";
			self.parentElement.parentElement.children[1].style.display = "";
			self.parentElement.parentElement.parentElement.children[1].children[1].style.display = "";
		}
	} else {
		if (self.parentNode.parentNode.childNodes[1].style.display == "none")
		{
			self.parentNode.parentNode.childNodes[1].style.display = "";
			self.parentNode.parentNode.childNodes[3].style.display = "none";
			self.parentNode.parentNode.parentNode.childNodes[3].childNodes[3].style.display = "none";
		} else {
			self.parentNode.parentNode.childNodes[1].style.display = "none";
			self.parentNode.parentNode.childNodes[3].style.display = "";
			self.parentNode.parentNode.parentNode.childNodes[3].childNodes[3].style.display = "";
		}
	}
}

function pws_jsfInit()
{
	pws_jsfBalanceTables();
}

function pws_jsfBalanceTables()
{
	tables = document.getElementsByClassName("jsBalanceColumns");
	//exit if there is only one table
	if(tables.length<2)
	{
		return;
	}
	var firstTRFound;
	//count all letters in cells get maxium for each column
	for(a=0;a<tables.length;a++)
	{
		firstTRFound = false;
		//find TBODY
		for(b=0;b<tables[a].childNodes.length;b++)
		{
			if(tables[a].childNodes[b].nodeName=="TBODY")
			{
				//get first TR
				for(c=0;c<tables[a].childNodes[b].childNodes.length;c++)
				{
					if(tables[a].childNodes[b].childNodes[c].nodeName=="TR"&&!firstTRFound)
					{
						firstTRFound = true;
						pws_jsfCollectCellTextLength(tables[a].childNodes[b].childNodes[c]);
					}
				}
			}
		}
	}
	//convert values into percentages
	columnWidthArray = pws_jsfConvertValuesToPercentage(jsvMaxcharLengthArray);
	
	for(a=0;a<tables.length;a++)
	{
		firstTRFound = false;
		//find TBODY
		for(b=0;b<tables[a].childNodes.length;b++)
		{
			if(tables[a].childNodes[b].nodeName=="TBODY")
			{
				//get first TR
				for(c=0;c<tables[a].childNodes[b].childNodes.length;c++)
				{
					if(tables[a].childNodes[b].childNodes[c].nodeName=="TR"&&!firstTRFound)
					{
						//set column widths
						firstTRFound = true;
						pws_setColumnWidths(columnWidthArray,tables[a].childNodes[b].childNodes[c]);
						
					}
				}
			}
		}
	}
}

function pws_jsfConvertValuesToPercentage(theArray)
{
	totalValue = 0;
	for(f=0;f<theArray.length;f++)
	{
		totalValue+=theArray[f];
	}
	percArray = Array();
	for(f=0;f<theArray.length;f++)
	{
		percArray.push(Math.round(theArray[f]/totalValue*100));
	}
	return percArray;
}

function pws_setColumnWidths(widthArray,row)
{
	cell = 0;
	for(g=0;g<row.childNodes.length;g++)
	{
		if(row.childNodes[g].nodeName=="TD"||row.childNodes[g].nodeName=="TH")
		{
			if (row.childNodes[g].colSpan != null && row.childNodes[g].colSpan > 1)
			{
				var tempLength = 0;
				for (i=0; i<row.childNodes[g].colSpan; i++)
				{
					tempLength += widthArray[cell+i];
				}
				row.childNodes[g].style.width=tempLength+"%";
//				row.childNodes[g].style.width=(widthArray[cell]*row.childNodes[g].colSpan)+"%";
				cell+=row.childNodes[g].colSpan;
			}
			else
			{
				row.childNodes[g].style.width=widthArray[cell]+"%";
				cell++;
			}
		}
	}
}

function pws_jsfCollectCellTextLength(row)
{
	if(row==null)
	{
		return;	
	}
	firstPass = jsvMaxcharLengthArray.length==0?true:false;
	
	cell = 0;
	//go through each td/th
	for(d=0;d<row.childNodes.length;d++)
	{
		//find TD or TH
		if((row.childNodes[d].nodeName=="TD"||row.childNodes[d].nodeName=="TH"))
		{
			for(e=0;e<row.childNodes[d].childNodes.length;e++)
			{
				//find text node
				if(row.childNodes[d].childNodes[e].nodeType==3)
				{
					//alert(row.childNodes[d].childNodes[e].nodeValue);
					if(firstPass)
					{
						if (row.childNodes[d].colSpan != null && row.childNodes[d].colSpan > 1)
						{
							for (x=0; x<row.childNodes[d].colSpan; x++)
							{
								jsvMaxcharLengthArray.push((pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue)/row.childNodes[d].colSpan));
							}
						}
						else
						{
							jsvMaxcharLengthArray.push(pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue));
						}
					}
					else
					{
						
						if (row.childNodes[d].colSpan != null)
						{
							for (x=0; x<row.childNodes[d].colSpan; x++)
							{
								jsvMaxcharLengthArray[cell+x] = jsvMaxcharLengthArray[cell+x]<(pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue) / row.childNodes[d].colSpan)?(pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue) / row.childNodes[d].colSpan):jsvMaxcharLengthArray[cell+x];
							}
							cell+=row.childNodes[d].colSpan;
						} 
						else
						{
							jsvMaxcharLengthArray[cell] = jsvMaxcharLengthArray[cell]<pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue)?pws_getStringDisplayLength(row.childNodes[d].childNodes[e].nodeValue):jsvMaxcharLengthArray[cell];
							cell++;
						}
					}
				}
			}
		}
	}
	//find the next row in the table and recurse
	pws_jsfCollectCellTextLength(pws_getNextSibling(row,"TR"));
}


function pws_getStringDisplayLength(theString)
{
	theLength = 0;
	for(i=0;i<theString.length;i++)		
	{
		theLength+=(pws_getCharDisplayLength(theString.charAt(i)));
	}
	return theLength;
}

function pws_getCharDisplayLength(theChar)
{
	switch(theChar)
	{
		case 'i':
		case 'j':
		case 'i':
		case 'j':
		case '.':
		case ',':
			return 1;
		case 'f':
		case 'r':
		case 't':
			return 3;
		case 'k':
		case 's':
		case 'J':
			return 4;
		case 'i':
		case 'j':
		case 'l':
		case 'I':
		case '.':
		case ',':
		case 'f':
		case 'r':
		case 't':
		case 'k':
		case 's':
		case 'J':
		case 'a':
		case 'b':
		case 'c':
		case 'd':
		case 'e':
		case 'g':
		case 'h':
		case 'n':
		case 'o':
		case 'p':
		case 'q':
		case 'u':
		case 'v':
		case 'x':
		case 'Y':
		case 'z':
		case 'E':
		case 'F':
		case 'L':
		case 'P':
		case 'T':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
		case '(':
		case ')':
		case '/':
			return 5;
		case 'B':
		case 'C':
		case 'D':
		case 'H':
		case 'K':
		case 'N':
		case 'R':
		case 'S':
		case 'U':
		case 'V':
		case 'X':
		case 'Z':
		case '0':
		case '%':
			return 6;
		case 'm':
		case 'A':
		case 'G':
		case 'M':
		case 'O':
		case 'Q':
		case 'Y':
			return 8;
		case 'w':
		case 'W':
			return 11;
		default:
			return 0;
	}
}

function pws_getNextSibling(object,siblingNodeName)
{
	if(object.nextSibling!=null)
	{
		if(object.nextSibling.nodeName==siblingNodeName)
		{
			return object.nextSibling;
		}
		else
		{
			return pws_getNextSibling(object.nextSibling,siblingNodeName);
		}
	}
}

function pws_hbap_popupWin(helpUrl ,widthSize, heightSize) {
var search_string=location.search;
var rs_url="";
var wedTrends_unit = "";
var reg = /WT.mc_id/;
	if(search_string == null || search_string.length == 0){
		rs_url = helpUrl;
	}
	else{
		var mat_index = search_string.search(reg);
		if (mat_index >= 0) {
			var temp = search_string.substring(mat_index);	
			var index_and = temp.search(/&/);
			if(index_and > 0){
				wedTrends_unit = temp.substring(0, index_and);			
			} else {
				wedTrends_unit = temp;			
			}	
			if (helpUrl.indexOf("?") > 0) {	
				rs_url=helpUrl + "&" + wedTrends_unit ;
			} else {
				rs_url=helpUrl + "?" + wedTrends_unit ;
			}
		
		}else {
			rs_url = helpUrl;
		}	
	}
   if(widthSize != null && heightSize != null){   
   	var popWin = window.open(rs_url,"onlinehsbc","width="+widthSize+",height="+heightSize);   	
   } else {   
   	var popWin = window.open(rs_url);
   }	 
	popWin.focus();		
}

function pws_show_TandC(loc,windoc) {

if(loc==null || windoc==null) {
	return ;
}

var urlpath=loc.hash;

if ( (urlpath == null) || (urlpath == "")) {
	return;
}
<!--urlpath must have at least one word after "#"-->
if ( urlpath.length < 2) {
	return;	
}
var id = urlpath.substring(1);
var show_postfix="_s";
var hide_postfix="_h";
var content_postfix="_c";



if ((windoc.getElementById(id+show_postfix)!= null) && (windoc.getElementById(id+hide_postfix)!= null)
		 && (windoc.getElementById(id+content_postfix)!= null) ){

	if ((windoc.getElementById(id+show_postfix).style!= null) && (windoc.getElementById(id+hide_postfix).style!= null)
			&& (windoc.getElementById(id+content_postfix).style!= null) ) {
			
			if ( (windoc.getElementById(id+show_postfix).style.display!= null) 
				&& (windoc.getElementById(id+hide_postfix).style.display!= null) 
				&& (windoc.getElementById(id+content_postfix).style.display!= null) ) {
				
				windoc.getElementById(id+show_postfix).style.display = "none";
				windoc.getElementById(id+hide_postfix).style.display = "";
				windoc.getElementById(id+content_postfix).style.display = "";
				
			}
	}
}



}

function pws_digitalOrder_en(formname, cookievalue)
{
	pws_popupNewBrowser('', 'yes', 'no', 'yes', 'no', 'no', 'yes', screen.width, screen.height*0.88);

	pws_setCookie('FromWebSite', cookievalue, '/', '.hsbc.com.hk', 'true', 0);

	document.forms[formname].action = 'https://www.ebanking.hsbc.com.hk/1/2/logon?LANGTAG=en&COUNTRYTAG=US';
	document.forms[formname].submit();	
}

function pws_digitalOrder_zh(formname, cookievalue)
{
	pws_popupNewBrowser('', 'yes', 'no', 'yes', 'no', 'no', 'yes', screen.width, screen.height*0.88);

	pws_setCookie('FromWebSite', cookievalue, '/', '.hsbc.com.hk', 'true', 0);

	document.forms[formname].action = 'https://www.ebanking.hsbc.com.hk/1/2/logon?LANGTAG=zh&COUNTRYTAG=HK';
	document.forms[formname].submit();	
}


function pws_popupNewBrowser(url, status, location, scroll, mbar, toolbar, resize, width, height, winname)
{
	!winname? winname='nb':winname=winname;
	nb=window.open(url, winname, 'status=' + status + ',location=' + location + ',scrollbars=' + scroll + ',menubar=' + mbar + ',toolbar=' + toolbar + ',resizable=' + resize + ',height=' + height + ',width=' + width + ',left=20,top=20');
	nb.focus();
}

function pws_setCookie(name, value, path, domain, secure, expires)
{
    document.cookie = name + '=' + escape(value) +
    ((path) ? '; path=' + path : '') +
    ((domain) ? '; domain=' + domain : '') +
    ((secure) ? ';secure' : '')+
    ((expires) ? ';expires=' + expires.toGMTString() : '') ;
}

function pws_logon_en() {
	pws_popupNewBrowser('https://www.ebanking.hsbc.com.hk/1/2/logon?LANGTAG=en&COUNTRYTAG=US', 'yes', 'no', 'yes', 'no', 'no', 'yes', screen.width, screen.height*0.88);
}

function pws_logon_zh() {
	pws_popupNewBrowser('https://www.ebanking.hsbc.com.hk/1/2/logon?LANGTAG=zh&COUNTRYTAG=HK', 'yes', 'no', 'yes', 'no', 'no', 'yes', screen.width, screen.height*0.88);
}

function pws_popupPdf(pdfUrl ,windowName, winProperties) {

var targetUrl=it_fullContextPath.substring(0,it_fullContextPath.length-1) + pdfUrl;
var hsbcheader='\n'
+ '    <html>\n'
+ '	    <script language="JavaScript" src="' + wt_header_url +'"><\/script>\n'
+ '	    <SCRIPT LANGUAGE="JavaScript">\n'
+ '		HSBC.SITE.rgn="HBAP";\n'
+ '		HSBC.SITE.subrgn="AMH";\n'
+ '		HSBC.SITE.cnty="HKSAR";\n'
+ '	        HSBC.SITE.ent="HSBC";\n'
+ '             HSBC.LOG.dcsuri="' + pdfUrl + '";\n'
+ '		HSBC.SITE.brand="HSBC";\n'
+ '  	  	HSBC.DCS.ID="dcsur62uf00000s5nnzq4hvrl_6i5x";\n'
+ '    <\/SCRIPT>\n'
+ '    <script language="JavaScript" src="' + wt_footer_url + '"><\/SCRIPT>'
+ '     <body onload="window.location=\'' + targetUrl + '\';"><\/body>'
+ '    </html>\n'
+ '    \n';

   var popWin;
   if(winProperties != null && winProperties.length>0){   
   	popWin = window.open('','_blank',winProperties);   		
   } else {   
   	popWin = window.open('');   	
   }
  	popWin.document.write(hsbcheader);
   	popWin.document.close(); 	
	popWin.history.go(0); 
	popWin.focus();		 
	
}

function pws_transitPage(transitType, formname, fieldname, targetUrl,  width, height, winname){
	switch(transitType){
		case "TransitPulldown":
			if(formname == null || formname == "") {
				alert("Invalid parameters for TransitPage('transitType',???,'fieldname', 'targetUrl', 'width', 'height')");
			} else if(fieldname == null || fieldname == ""){
				alert("Invalid parameters for TransitPage('transitType','formname',???, 'targetUrl', 'width', 'height')");
			} else{
				var idx = document.forms[formname].elements[fieldname].selectedIndex;
				var v = document.forms[formname].elements[fieldname][idx].value;
				if(v != ""){					
					if (v.indexOf("?targetPage=") > 0){
						!winname? winname="nb":winname=winname;
						nb=window.open(v, winname, "status=no,location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,height=" + height + ",width=" + width + ",left=20,top=20");
						nb.focus();
					}else{
						alert("Please specify the target page using '?targetPage='.");
					}
					
				}
		
			}
			break;
		case "TransitClickOn":
		
			if(targetUrl == null || targetUrl == ""){
				alert("Invalid parameters for TransitPage('transitType','formname','fieldname', ???, 'width', 'height')");
			}else{
					if (targetUrl.indexOf("?targetPage=") > 0){
						!winname? winname="nb":winname=winname;
						nb=window.open(targetUrl, winname, "status=no,location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,height=" + height + ",width=" + width + ",left=20,top=20");
						nb.focus();
					}else{
						alert("Please specify the target page using '?targetPage='.");
					}				
			}
			break;
				
		default:
			break;	
		
	}
}

function pws_transitPage_Close()
{
	self.close();
}

function pws_targetPage(){
var search_string=location.search;
var target_page = "";
var indicator = "targetPage=";
var target_ind = search_string.indexOf(indicator);
if( target_ind > 0){
	temp = search_string.substring(indicator.length + 1);	
	var index_and = temp.search(/&/);
	if(index_and > 0){
		target_page = temp.substring(0, index_and) + "?" + temp.substring((index_and+1), temp.length);
	} else {
		target_page = temp;
	}
	
}else{
	target_page = "http://www.hsbc.com";
}
var openwin = window.open(target_page);
openwin.focus();
}

//originally default.js
var jsContractImgUrl = "../_images/en/contact_close.gif";
var jsExpandImgUrl = "../_images/en/contact_open.gif"; 

function jsfExplorerShowHide(id)
{
	imgObj=null;
	divObj=null;
	classObj=null;
	
	if(document.getElementById("jsIdExplorerShowHideDiv"+id))
	{
		divObj = document.getElementById("jsIdExplorerShowHideDiv"+id);
	}
	if(document.getElementById("jsIdExplorerShowHideClass"+id))
	{
		classObj = document.getElementById("jsIdExplorerShowHideClass"+id);
	}
	if(document.getElementById("jsIdShowHideImg"+id))
	{
		imgObj = document.getElementById("jsIdShowHideImg"+id);
	}
	if(divObj.style.display=="none")
	{
		if(divObj)
		{
			divObj.style.display = 'block';
		}			
		if(classObj)
		{	
			classObj.className="expanded";
		}
		if(imgObj)
		{
			imgObj.src = jsExpandImgUrl;
		}
	}
	else
	{
		if(divObj)
		{
		divObj.style.display = 'none';
		}
		if(classObj)
		{
		classObj.className = classObj.className.replace("expanded", "");
		}
		if(imgObj)
		{
			imgObj.src = jsContractImgUrl;
		}
	}
}

reelImages = new Array("../_images/en/img_reel_01.jpg","../_images/en/img_reel_02.jpg");
reelCaptions = new Array("Caption 1 goes here Lorem ipsum dolor sit amet, consectetuer adipiscing elit.","Caption 2 goes here Lorem ipsum dolor sit amet, consectetuer adipiscing elit.");
var reelCount = 0;
var imageCaption

function jsfShowReelLoad(){
	if (document.getElementById('imageNavigator')){
		reel = document.getElementById('imageNavigator');
		reel.style.display = 'block';
		imageCaption = document.getElementById('imageCaption');
		imageCaption.innerHTML = reelCaptions[0];
		imageCaption.style.display = 'block';
	}

}


function jsfMoveReel(direction){
	
	
	

	var imageReel = document.getElementById('imageReel');

	if (direction == "next"){
		
		
		if (reelCount < (reelImages.length - 1)) {
			
			imageReel.src = reelImages[++reelCount];		
			
			imageCaption = document.getElementById('imageCaption');
			imageCaption.innerHTML = reelCaptions[reelCount];
			imageReel.alt = reelCaptions[reelCount];
		
		
			reelLinkPrev = document.getElementById('reelPrev');
			
			reelLinkPrev.className = "";
			
			/*reelLinkPrev.class = "";*/
			reelLinkNext = document.getElementById('reelNext');
			if (reelCount == (reelImages.length - 1)) {
				

				reelLinkNext.className = "hide";
				/*reelLinkNext.class = "hide";*/
			} else {
				reelLinkNext.className = "";
				/*reelLinkNext.class = "";*/
			}	
		}
	}
	
	if (direction == "prev"){
		if (reelCount > 0) {
			imageReel.src = reelImages[--reelCount];
			 
			imageCaption = document.getElementById('imageCaption');
			imageCaption.innerHTML = reelCaptions[reelCount];
			imageReel.alt = reelCaptions[reelCount];
			
			reelLinkNext = document.getElementById('reelNext');
			reelLinkNext.className = "";
		/*	reelLinkNext.class = "";*/
		
		reelLinkPrev = document.getElementById('reelPrev');
		if (reelCount == 0) {
				
				reelLinkPrev.className = "hide";
				/*reelLink.class = "hide";*/
			} else {
				reelLinkPrev.className = "";
				/*reelLink.class = "";*/
			}	
		}
	}
}

		function Init_Items_Array()
		{
			var arrayToReturn = new Array();
			
			//get hold of the wrapping node
			var wrapperNode = document.getElementById( this.mainContainerEleId );
						
			//find the divs within the wrapping node
			var divsArray = wrapperNode.getElementsByTagName( "div" );
			
			var itemsArrayCount = 0;
			
			//go through the array and inspect the class name
			for( var i=0; i<divsArray.length; i++ )
			{
				if( divsArray[i].className == 'rotatorItem' )
				{
					arrayToReturn[itemsArrayCount] = divsArray[i];
					itemsArrayCount++;
				}
			}
			
			return arrayToReturn;
		}

		function Show( itemPosition )
		{
			//add one to the current position so we can use this number in the nav
			this.intCurrentPosition = itemPosition;
									
			//go through the global array of rotation items
			for( var i=0; i<this.objItemsArray.length; i++ )
			{
				if( i != itemPosition )
				{
					this.objItemsArray[i].style.display = "none";
				}
				else
				{
					this.objItemsArray[i].style.display = "block";
				}
			}
			
			//draw the nav
			this.drawNav();
		}

		//writes the navigation for the rotation items
		function Draw_Nav()
		{
			//find the element and the span within it
			var navList = document.getElementById( this.navEleId ).getElementsByTagName( "A" );
			var prevItem = navList[0];
			var nextItem = navList[1];
			if( this.intCurrentPosition+1<this.objItemsArray.length && this.intCurrentPosition-1>=0 )//when you can go forwards and backwards
			{
				prevItem.className = "";
				nextItem.className = "";
			}
			else if( this.intCurrentPosition+1<this.objItemsArray.length )//if it is the first element change the previus button to class="hide"
			{
				//console.log( "Can go forward" );
				prevItem.className = "hide";
				nextItem.className = "";
			}
			else if( this.intCurrentPosition-1>=0 )//if it is the last element change the next button to class="hide"
			{
				//console.log( "Can go backwards" );
				prevItem.className = "";
				nextItem.className = "hide";
			}
			else //only one image in reel
			{
				prevItem.className = "hide";
				nextItem.className = "hide";
			}
		}
		
		function Do_Forward()
		{
			this.intCurrentPosition+1<this.objItemsArray.length?this.show( this.intCurrentPosition+1 ):this.show( this.intCurrentPosition );
			return false;
		}
		
		function Do_Back()
		{
			this.intCurrentPosition-1>=0?this.show( this.intCurrentPosition-1 ):this.show( this.intCurrentPosition );
			return false;
		}
		
		function ItemRotatorObj( intCurrentPosition, mainContainerEleId, navEleId, prevId, nextId )
		{
			//init obj properties
			this.intCurrentPosition = intCurrentPosition;
			this.mainContainerEleId = mainContainerEleId;
			this.navEleId = navEleId;
			this.prevId = prevId;
			this.nextId = nextId;
			
			//assign methods to class
			this.initItemsArray = Init_Items_Array;
			this.show = Show;
			this.doForward = Do_Forward;
			this.doBack = Do_Back;
			this.drawNav = Draw_Nav;
			
			//init the array using a class method
			this.objItemsArray = this.initItemsArray();
			
			//do the stuff for first load
			this.show( 0 );
			
			//show the nav
			document.getElementById( this.navEleId ).style.display = "block";
		}
		
		//global vars
		var myItemRotatorObj;
		

if (window.addEventListener)
{
	window.addEventListener("load", jsfOnLoad, false);
}
else
{
	if (window.attachEvent)
	{
		window.attachEvent("onload", jsfOnLoad);
	}
	else
	{
	if (document.getElementById)
		{
			window.onload = jsfOnLoad;
		}
	}
}


function show()
{
self.location = document.form2.navigation1.value;
return false;
}


function jsfOnLoad()
{
	
	for(i=1;i<20;i++)
	{
		if(divObj = document.getElementById("jsIdExplorerShowHideDiv"+i))
		{
			jsfExplorerShowHide(i);
		}
	}
	if( document.getElementById( "jsRotationHolder" ) )
	{
		myItemRotatorObj = new ItemRotatorObj( 0, "jsRotationHolder", "jsRotationNav", "reelPrev", "reelNext" );
	}
	
	jsfShowReelLoad(); 
}

function showtip(id)
{
if(id.selectedIndex==2)
{
document.getElementById('s1').style.visibility='visible';
}
else
{
document.getElementById('s1').style.visibility='hidden';

}
}

/***************************************************************************************************************
* Function		: pulldownRedirect(popup, formfield01, formfield02, formfield03, formfield04, formfield05)
* Description	: Load another page in a popup window or in the current window, where the URL of the target page
*					  is determined by concatenating the values of at most 5 pull down menus' selected options
* Parameter Usage : popup : determine either load the new URL in a popup window or in the current window,
*						if equals to "PIBLogonWindow", load in a popup window using the "PIBLogonWindow" function
*						if equals to "fixedWindow", load in a popup window using the "fixedWindow" function
*						if equals to "newBrowser", load in a popup window using the "newBrowser" function
*						if equals to "nopopup" or anything else, load in the current window
*                   formfield01 to formfield05: pull down menu field name and their corresponding form names linked with a dot "."
*																the values of the selection options of the pull down
*																menus are concatenated to form the target URL
* Side effect			: N/A
* Amendment History	:
* Date      By             Description
* ---------	------------   --------------------------------------------------------------------------------
*
***************************************************************************************************************/
function pulldownRedirect(popup, formfield01, formfield02, formfield03, formfield04, formfield05) {
	var currentFormFieldPair, formName, fieldName;
	var fieldValue01 = "", fieldValue02 = "", fieldValue03 = "", fieldValue04 = "", fieldValue05 = "", finalURL = "";
	
	var formfields = new Array(5);
	var fieldValues = new Array(5);
	
	formfields[0] = formfield01;
	formfields[1] = formfield02;
	formfields[2] = formfield03;
	formfields[3] = formfield04;
	formfields[4] = formfield05;
	
	for (lpcnt = 0; lpcnt < formfields.length; lpcnt++) {
		if (typeof formfields[lpcnt] != "undefined" && formfields[lpcnt] != "") {
			currentFormFieldPair = formfields[lpcnt].split(".");
			formName = currentFormFieldPair[0];
			fieldName = currentFormFieldPair[1];
			if (document.forms[formName][fieldName].options[document.forms[formName][fieldName].selectedIndex].value != "")
				fieldValues[lpcnt] = document.forms[formName][fieldName].options[document.forms[formName][fieldName].selectedIndex].value;
		}
	}
	
	for (lpcnt = 0; lpcnt < formfields.length; lpcnt++) {
		if (typeof fieldValues[lpcnt] != "undefined")
			finalURL = finalURL + fieldValues[lpcnt];
	}
	popup = popup.toLowerCase();
	switch(popup)
	{
		case "piblogonwindow":
				PIBLogonWindow(finalURL);
			break;
			
		case "fixedwindow":
				fixedWindow(finalURL);
			break;
			
		case "newbrowser":
				newBrowser(finalURL);
			break;
				
		default:
			location = finalURL;
	}
}

function newBrowser(url) {
	nb=window.open(url, "nb", "location,scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700");
    nb.focus();
}

/***************************************************************************************************************
* Function			: LPF_MouseOut()
* Description		: Restore original image when mouse out
* Parameter Usage	: N/A
* Location			: /inah/common/js/inahcommon.js
* Author				: Arnold (Grey Interactive)
* Creation Date	: 16 Jan 2004
* Side effect		: N/A
* Amendment History	:
* Date		By					Description
* ---------	------------	--------------------------------------------------------------------------------
*
*
****************************************************************************************************************
* Remarks - Exactly the same as function LPF_MouseOut() in /hk/personal/common/js/pfscommon.js
***************************************************************************************************************/
function LPF_MouseOut()
{
  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			: LPF_MouseOver_findObj(n, d)
* Description		: Called by LPF_MouseOver() only. It should be used to find object n in document d
* Parameter Usage	: d : current document (optional)
*                   n : object
* Location			: /inah/common/js/inahcommon.js
* Author				: Arnold (Grey Interactive)
* Creation Date	: 16 Jan 2004
* Side effect		: N/A
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
*
*
****************************************************************************************************************
* Remarks - Exactly the same as function LPF_MouseOver_findObj(n, d) in /hk/personal/common/js/pfscommon.js
***************************************************************************************************************/
function LPF_MouseOver_findObj(n, d) {
  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=LPF_MouseOver_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

/***************************************************************************************************************
* Function			: LPF_SwapImage(imgArrayStr)
* Description		: Change the src property of specified images
* Parameter Usage	: imgArrayStr - in the format of "imgName1,imgPath1,imgName2,imgPath2..."
*                   where imgName1, imgName2 ... = name of image to be changed
*                         imgFullpath1, imgFullpath2 ... = path of the image
* Location			: /inah/common/js/inahcommon.js
* Author				: Arnold (Grey Interactive)
* Creation Date	: 13 Feb 2004
* Side effect		: N/A
* Amendment History	:
* Date      By             Description
* ---------	------------   --------------------------------------------------------------------------------
*
*
****************************************************************************************************************
* Remarks - Exactly the same as function LPF_SwapImage(imgArrayStr) in /hk/personal/common/js/pfscommon.js
***************************************************************************************************************/
function LPF_SwapImage(imgArrayStr)
{
	var a = imgArrayStr.split(",");

	if((a.length / 2) != Math.ceil(a.length/2)) {
		alert("Invalid parameters for LPF_SwapImage!\nIt must be in format of imgName1,imgPath1,imgName2,imgPath2...");
	} else {
		var i,imgObj;
		for(i=0;i<a.length;i+=2) {
			if ((imgObj=LPF_MouseOver_findObj(a[i]))!=null){
				imgObj.src=a[i+1];
			}
		}
	}
	a = null;
}

/***************************************************************************************************************
* Function			: LPF_preloadImages(imgarraystr)
* Description		: Preload the images in imgarray
* Parameter Usage	: imgarray - array of image files
* Location			: /inah/common/js/inahcommon.js
* Author				: Kenneth Cheung (Grey Interactive)
* Creation Date	: 12 Feb 2004
* Side effect		: N/A
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
*
*
****************************************************************************************************************
* Remarks - Exactly the same as function LPF_preloadImages(imgarraystr) in /hk/personal/common/js/pfscommon.js
***************************************************************************************************************/
function LPF_preloadImages(imgarraystr) {
	var d=document;
	var imgarray = imgarraystr.split(",");

	if(d.images) {
		if(!d.p) d.p=new Array();
		var i=0,j=d.p.length,a=imgarray;

		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0) {
				d.p[j]=new Image; d.p[j++].src=a[i];
			}
	}
}

/***************************************************************************************************************
* Function				: LPF_MouseOver(imgName, imgOther, imgPath, imgControl)
* Description			: Display another image when mouse over
*							  When user only wants to change one image when mouseover (most mouse over effect is this case), set imgControl to 1
*							  When uesr needs to change two images to the same image when mouseover, set imgControl to 2
*							  If user wants to change the image only when it's currently displaying a specific image, use imgControl = "e"
*							  If user wants to change the image only when it's currently not displaying a specific image, use imgControl = "ne"
*						    (eg see www.hsbc.com.hk/hk/personal/bank/waystobank.htm. There are 3 states for the buttons,
*						     on, off and over. Normally it will show the off state. When user moves mouse over it, it will
*						     change to over state. It will return to off when mouse out. When the user clicks the button,
*						     it will change to on state. When the button is at on state, there will be no image change whether
*						     the user mouseover or mouseout the button)
* Parameter Usage		: imgName		: The name of image
*    	   	           imgPath		: Path of the image for display when mouse over
*  	                 imgOther		: This usage depends on the value of imgControl
*   		              imgControl	: If this is 1, then only change the src of the image with name = imgName to imgPath
*													imgOther will have no use in this case.
*												  If this is 2, imgOther should another image name.
*													Both the imgName and imgOther will change to imgPath
*												  If this is "e", imgOther should be an image src.
*													If imgName's src = imgOther, then change imgName's src to imgPath. Otherwise no change.
*												  If this is "ne", imgOther should be an image src.
*													If imgName's src != imgOther, then change imgName's src to imgPath. Otherwise no change.
*												  Other values will be treated as case 1
* Supported browsers : IE 6, Netscape 7
* Location				: /hk/personal/common/js/pfscommon.js
* Author					: Arnold (Grey Interactive)
* Creation Date		: 6 Feb 2004
* Side effect			: N/A
* Amendment History	:
* Date      By             Description
* ---------	------------   --------------------------------------------------------------------------------
* 04MAR2004 Arnold			Declare parameters
* 12MAR2004 Arnold			Merge this with LPF_SwapImage_Condition()
* 18MAR2004 Arnold			Add description, amended according to IT comment
****************************************************************************************************************
*
*
****************************************************************************************************************
* Remarks - Exactly the same as function LPF_MouseOver(imgName, imgOther, imgPath, imgControl) in
* 				/hk/personal/common/js/pfscommon.js
***************************************************************************************************************/
function LPF_MouseOver(imgName, imgOther, imgPath, imgControl)
{

	switch(imgControl)
	{
		case "1":
			var i,j=0,x;
			document.MM_sr=new Array;
			if ((x=LPF_MouseOver_findObj(imgName))!=null){
				document.MM_sr[j++]=x;
				if(!x.oSrc) x.oSrc=x.src;
				x.src=imgPath;
			}
			break;

		case "2":
			var i,j=0,x;
			document.MM_sr=new Array;
			if ((x=LPF_MouseOver_findObj(imgName))!=null){
				document.MM_sr[j++]=x;
				if(!x.oSrc) x.oSrc=x.src;
				x.src=imgPath;
			}

			if ((x=LPF_MouseOver_findObj(imgOther))!=null){
				document.MM_sr[j++]=x;
				if(!x.oSrc) x.oSrc=x.src;
				x.src=imgPath;
			}
			break;

		case "e":
			var imgSrc = location.protocol + "//" + location.hostname;

			if (!(!location.port || location.port==80)) {
				imgSrc+=":"+location.port;
			}

			if (imgOther.indexOf('/') == 0) {
				imgSrc += imgOther
			} else {
				imgSrc += location.pathname.substr(0,location.pathname.lastIndexOf('/')+1) + imgOther;
			}

			imgObj = LPF_MouseOver_findObj(imgName);
			if (imgObj != null ) {
				if (imgObj.src == imgSrc) {
					imgObj.src = imgPath;
				}
			}
			break;

		case "ne":
			var imgSrc = location.protocol + "//" + location.hostname;

			if (!(!location.port || location.port==80)) {
				imgSrc+=":"+location.port;
			}

			if (imgOther.indexOf('/') == 0) {
				imgSrc += imgOther
			} else {
				imgSrc += location.pathname.substr(0,location.pathname.lastIndexOf('/')+1) + imgOther;
			}

			imgObj = LPF_MouseOver_findObj(imgName);
			if (imgObj != null ) {
				if (imgObj.src != imgSrc) {
					imgObj.src = imgPath;
				}
			}
			break;

		default:
			var i,j=0,x;
			document.MM_sr=new Array;
			if ((x=LPF_MouseOver_findObj(imgName))!=null){
				document.MM_sr[j++]=x;
				if(!x.oSrc) x.oSrc=x.src;
				x.src=a[i+2];
			}
			break;
	}
}