//****************************
// default.js
//****************************
//Rollover javascript

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];}
}
//Rollover javascript

var jsvFontSize = 100;
var jsvFMax = 120;
var jsvFMin = 100;
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;
var jsvContractIconUrl = "../images/contact_close.gif";
var jsvExpandIconUrl = "../images/contact_open.gif";
var jsvRotationStop = false;
var jsvTimeoutId;

//
// setFontSize
//
// Retrieves cookie value and applies to font size
//
function setFontSize()
{
	var tempSize = getCookie("fontSize");
	if((tempSize != null) && (tempSize >= 100) && (tempSize <= 120))
	{
		jsvFontSize = tempSize;
	}
	else
	{
		setCookie("fontSize", 100, "", "/");
	}
	document.body.style.fontSize = jsvFontSize + "%";
}
//
// changeFontSize(bool increment)
//
// changes document font size and records size value in cookie
//
function changeFontSize(increment)
{
	if(increment)
	{
		jsvFontSize=parseInt(jsvFontSize) + parseInt(10);
	}
	else
	{
		jsvFontSize=parseInt(jsvFontSize) - parseInt(10);
	}

	if(jsvFontSize > jsvFMax)
	{
		jsvFontSize = jsvFMax;
	}
	if(jsvFontSize < jsvFMin)
	{
		jsvFontSize = jsvFMin;
	}
	switch(jsvFontSize)
	{
		case 100:
			document.body.style.fontSize = "1em";
			break;
		case 110:
			document.body.style.fontSize = "1.10em";
			break;
		case 120:
			document.body.style.fontSize = "1.20em";
			break;
	}
	setCookie('fontSize', jsvFontSize, "", "/");
}
//
// incrementFontSize
//
function incrementFontSize()
{
	changeFontSize(true);
}
//
// decrementFontSize
//
function decrementFontSize()
{
	changeFontSize(false);
}
//
// Sets a Cookie with the given name and value.
//
// name       Name of the cookie
// value      Value of the cookie
// [expires]  Expiration date of the cookie (default: end of current session)
// [path]     Path where the cookie is valid (default: path of calling document)
// [domain]   Domain where the cookie is valid
//              (default: domain of calling document)
// [secure]   Boolean value indicating if the cookie transmission requires a
//              secure transmission
//
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

//
// Gets the value of the specified cookie.
//
// name  Name of the desired cookie.
//
// Returns a string containing value of specified cookie,
//   or null if cookie does not exist.
//
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function jsfToggleMenu(self)
{
	var n = self;
	var childImg = n.childNodes[0];
	var parentUl = jsvIsIE?n.parentElement:n.parentNode;
	var childUl = parentUl.childNodes[3];
	
	
	if(childUl.style.display == "block" || childUl.style.display == "")
	{
		childUl.style.display = "none";
		childImg.src = jsvExpandIconUrl;
		childImg.alt = "Expand";
		childImg.title = "Expand";
	}
	else
	{
		childUl.style.display = "block";
		childImg.src = jsvContractIconUrl;
		childImg.alt = "Reduce";
		childImg.title = "Reduce";
	}
}

function jsfToggleAll(state)
{
	lists = document.getElementsByTagName('ul');
	//alert(lists[1].id);
	//alert(lists[1].parentElement.parentElement.tagName);
	for(i=0;i<lists.length;i++)
	{
		if((jsvIsIE&&lists[i].parentElement.parentElement.tagName=="UL")||lists[i].parentNode.parentNode.tagName=="UL")
		{
			lists[i].style.display=state;
		}
		if(lists[i].parentNode.childNodes[0].tagName=="A")
		{
			//alert(lists[i].parentNode.childNodes[0].childNodes[0].tagName);
		}
		
		if((jsvIsIE&&lists[i].parentElement.childNodes[0].childNodes[0].tagName=="IMG")||lists[i].parentNode.childNodes[0].tagName=="A")
		{
			if(imgNode = jsvIsIE?lists[i].parentElement.childNodes[0].childNodes[0]:lists[i].parentNode.childNodes[0].childNodes[0])
			{
				if(state=='block')
				{
					imgNode.src = jsvContractIconUrl;
					imgNode.alt = "Reduce";
					imgNode.title = "Reduce";
				}
				else
				{
					imgNode.src = jsvExpandIconUrl;
					imgNode.alt = "Expand";
					imgNode.title = "Expand";
				}
			}
		}
	}
}

function jsfExpandAll()
{
	jsfToggleAll('block');
	jsfSwapjsfShowAlljsfHideAll();
}

function jsfCollapseAll()
{
	jsfToggleAll('none');
	jsfSwapjsfShowAlljsfHideAll();
}

function jsfSwapjsfShowAlljsfHideAll()
{
	if(jsfShowAllDiv = document.getElementById("jsIdShowAll"))
	{
		jsfShowAllDiv.style.display = jsfShowAllDiv.style.display=="block"?"none":"block";
	}
	
	if(jsfHideAllDiv = document.getElementById("jsIdHideAll"))
	{
		jsfHideAllDiv.style.display = jsfHideAllDiv.style.display=="block"?"none":"block";
	}
}

function jsfExpandAllLink()
{
	jsfExpandAll()
	if(document.getElementById("jsIdExpandAll"))
	{
			document.getElementById("jsIdExpandAll").style.display = "none";
	}
	if(document.getElementById("jsIdCollapseAll"))
	{
			document.getElementById("jsIdCollapseAll").style.display = "block";
	}
}

function jsfCollapseAllLink()
{
	jsfCollapseAll()
	if(document.getElementById("jsIdExpandAll"))
	{
			document.getElementById("jsIdExpandAll").style.display = "block";
	}
	if(document.getElementById("jsIdCollapseAll"))
	{
			document.getElementById("jsIdCollapseAll").style.display = "none";
	}
}


function jsfShowHide(id)
{
	divObj = document.getElementById("jsIdShowHideDiv"+id);
	imgObj = document.getElementById("jsIdShowHideImg"+id);
	if(divObj.style.display=="none")
	{
		divObj.style.display = 'block';
		imgObj.src = jsvContractIconUrl;
	}
	else
	{
		divObj.style.display = 'none';
		imgObj.src = jsvExpandIconUrl;
	}
}

function jsfHideAll()
{
	for(i=01;i<20;i++)
	{
		iStr = i<10?"0"+i:i;
		if(divObj = document.getElementById("jsIdShowHideDiv"+iStr))
		{
			imgObj = document.getElementById("jsIdShowHideImg"+iStr);
			divObj.style.display = "none";
			imgObj.src = jsvExpandIconUrl;
		}
	}
	jsfSwapjsfShowAlljsfHideAll();
}

function jsfShowAll()
{
	for(i=01;i<20;i++)
	{
		iStr = i<10?"0"+i:i;
		if(divObj = document.getElementById("jsIdShowHideDiv"+iStr))
		{
			imgObj = document.getElementById("jsIdShowHideImg"+iStr);
			divObj.style.display = "block";
			imgObj.src = jsvContractIconUrl;
		}
	}
	jsfSwapjsfShowAlljsfHideAll();
}

function jsfAutoSwap()
{
	if(jsvRotationStop==false)
	{
		if(document.getElementById("jsMainBanner01").style.display == "block")
		{
			document.getElementById("jsMainBanner01").style.display = "none";
			document.getElementById("jsMainBanner02").style.display = "block";
			document.getElementById("jsMainBanner03").style.display = "none";
			setTimeout("jsfAutoSwap()", 6000);
			return;
		}
		if(document.getElementById("jsMainBanner02").style.display == "block")
		{
			document.getElementById("jsMainBanner01").style.display = "none";
			document.getElementById("jsMainBanner02").style.display = "none";
			document.getElementById("jsMainBanner03").style.display = "block";
			setTimeout("jsfAutoSwap()", 6000);
			return;
		}
		if(document.getElementById("jsMainBanner03").style.display == "block")
		{
			document.getElementById("jsMainBanner01").style.display = "block";
			document.getElementById("jsMainBanner02").style.display = "none";
			document.getElementById("jsMainBanner03").style.display = "none";
			setTimeout("jsfAutoSwap()", 6000);
			return;
		}
	}
}

function jsfHomepageBannerSwap(swapSection)
{
	switch(swapSection)
	{
		case 1:
			document.getElementById("jsMainBanner01").style.display = "block";
			document.getElementById("jsMainBanner02").style.display = "none";
			document.getElementById("jsMainBanner03").style.display = "none";
			break;
		case 2:
			document.getElementById("jsMainBanner01").style.display = "none";
			document.getElementById("jsMainBanner02").style.display = "block";
			document.getElementById("jsMainBanner03").style.display = "none";
			break;
		case 3:
			document.getElementById("jsMainBanner01").style.display = "none";
			document.getElementById("jsMainBanner02").style.display = "none";
			document.getElementById("jsMainBanner03").style.display = "block";
			break;
	}
	clearTimeout(jsvTimeoutId);
	jsvTimeoutId = setTimeout("jsfAutoSwapStart()", 10000);
	jsvRotationStop = true;
}

function jsfAutoSwapStart()
{
	jsvRotationStop = false;
	jsfAutoSwap();
}

//
// trigger onLoad function (jsfOnLoad)
//
function jsfOnLoad()
{
	setFontSize();
	if(document.getElementById("jsIdShowHideDiv03") || document.getElementById("jsIdShowHideDiv01"))
	{
		for(i=01;i<20;i++)
		{
			iStr = i<10?"0"+i:i;
			if(divObj = document.getElementById("jsIdShowHideDiv"+iStr))
			{
				jsfShowHide(iStr);
			}
		}
	}
	
	if(document.getElementById("jsSiteMap"))
	{
		jsfCollapseAll()
	}
	
	if(hpBanner02 = document.getElementById("jsMainBanner02"))
	{
		hpBanner02.style.display = 'none';
		document.getElementById("jsMainBanner01").style.display = "block";
		setTimeout("jsfAutoSwap()", 5000);
	}
	
	if(hpBanner03 = document.getElementById("jsMainBanner03"))
	{
		hpBanner03.style.display = 'none';
	}
	
	if(pageOptions = document.getElementById("jsIdPageOptions"))
	{
		pageOptions.style.display = 'block';
	}
	
	if((hideAllDiv = document.getElementById("jsIdHideAll")) && (showAllDiv = document.getElementById("jsIdShowAll")))
	{
		hideAllDiv.style.display = "none";
		showAllDiv.style.display = "block";
	}
}

function submitForm (formName, elementName, commandName) {
	document.forms[formName].all[elementName].name = commandName;
	document.forms[formName].submit();
}

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);

function printThis()
{
	if (pr)
	{
		window.print();
	}
	else if (da && !mac)
	{
		vbPrintPage();
	}
	else
	{
		if(mac)
		{
			alert("Please press your Print button on your iMac computer to print.");
		}
		else
		{
			alert("Sorry, your browser doesn't support this feature.");
		}
	}
}

if (da && !pr && !mac) with (document)
{
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	writeln('Sub window_onunload');
	writeln('  On Error Resume Next');
	writeln('  Set WB = nothing');
	writeln('End Sub');
	writeln('Sub vbPrintPage');
	writeln('  OLECMDID_PRINT = 6');
	writeln('  OLECMDEXECOPY_DONTPROMPTUSER = 2');
	writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	writeln(' On Error Resume Next');
	writeln(' WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DOTPROMPTUSER');
	writeln('End Sub');
	writeln('<' + '/SCRIPT>');
}

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


//****************************
// closewin.js
//****************************
var alertTimer;
var alertwin;

var accHistoryPrintTimer;
var accHistoryPrintWin;

var openPdfFileTimer;
var openPdfFileWin;

function closewin()
{
	killSession();

	if (alertwin)
	{
		alertwin.close();
		alertwin = null;
		clearTimeout(alertTimer);
	}
		
	closeAll();
}

function closewin()
{
	killSession();

	if (alertwin)
	{
		alertwin.close();
		alertwin = null;
		clearTimeout(alertTimer);
	}

	if(accHistoryPrintWin)
	{
	 	accHistoryPrintWin.close();
		accHistoryPrintWin = null;
	 	clearTimeout(accHistoryPrintTimer);
	}

	if(openPdfFileWin)
	{
	 	openPdfFileWin.close();
		openPdfFileWin = null;
	 	clearTimeout(openPdfFileTimer);
	}

	closeAll();
}

function killSession()
{
/*	if (window.event)
	{
		if (window.event.clientX < 0 && window.event.clientY < 0)
	      {
	            window.open(contextRoot + "/servlet/com.hsbc.ebank.app.hib.base.KillSessionServlet", "KillSession", "width=1,height=1,resizable=no,menubar=no,toolbar=no,directories=no,location=no,scrollbars=no,status=no, fullscreen=no, titlebar=no, alwaysRaised=no, hotkeys=no");
	      }
	}
*/
}

function killSession(url)
{
    if (window.event)
    {
        if ((window.event.clientX < -5000 && window.event.clientY < -5000) || 
            (window.event.clientX > 5000 && window.event.clientY > 5000))
        {
            window.open(url, "KillSession", "width=1,height=1,top=30000,left=30000,resizable=no,menubar=no,toolbar=no,directories=no,location=no,scrollbars=no,status=no, fullscreen=no, titlebar=no, alwaysRaised=no, hotkeys=no");
        }
    }
}

//****************************
// disablecontrol.js
//****************************
 /*P2G1002*/ var ifSubmitForm = "no";
 /*P2G1016*/ var contextRoot  = "/P2G_PortalWeb";
 /*P2G1016*/ var contextPath  = "/hubpib";
var message="\u5C0D\u4E0D\u8D77\uFF0C\u5728\u60A8\u4F7F\u7528 HSBC Direct \u7684\u670D\u52D9\u6642\uFF0C\u4E0D\u80FD\u4F7F\u7528\u6B64\u9805\u529F\u80FD\u3002";
 

document.oncontextmenu = function(){return false}

function getkey(e)
{
    if (window.event)
        return window.event.keyCode;
    else if (e)
        return e.which;
    else
        return null;
}

if (navigator.appName == "Netscape")
{
   document.onkeypress = function(e) {
   	var c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;	

	// orginal code
   	//if (c == 116) {
	//	alert(message);
	//	return false;
	//}
	
	var key = "", keychar = "";
	key = getkey(window.event);

	if (key != null) {
		keychar = String.fromCharCode(key);
	}
	
   	if (c == 116 && keychar== "") {
		alert(message);
		return false;
	}	
   }
}
else {
	document.onkeydown = function(){
		if(window.event && window.event.keyCode == 116) 
        	{ // Capture and remap F5
			window.event.keyCode = 505;
  		}

		if(window.event && window.event.keyCode == 505) {
			alert(message);
			return false; 
		}
	}
}
//
// ifSubmitFormNoFrame - a no frame version of the ifSubmitForm flag
//
var ifSubmitFormNoFrame = false;


//Reset the Flag that control double click prevention and ensure http request sent one after one
if(parent != null && parent.ifSubmitForm != null) 
{ 
	parent.ifSubmitForm = "no";
} 

//Turn the control flag on to prevent double click and multiple http request at a time
function setHttpReqCrtlFlg()
{
	if(parent != null && parent.ifSubmitForm != null)
	{
		parent.ifSubmitForm = "yes";
	}
}

//When hyperlink is clicked, set control flag and replace location
function chgLocation(link)
{
	setHttpReqCrtlFlg();
	location.replace(link);
	return;
}

/*P2G1016 - new function - removed */
/* no longer used in portal */ 	
function goToNewLocation(link)
{
	//For usage of this function, the context root must be already included inside the link.
	//If the context root is not known at runtime, use chgLocation(link) method.
/*	setHttpReqCrtlFlg();
	location.replace(link);
	return;
*/
}


/*P2G1016 - new function*/	
/* no longer used in portal */
function goToNewLocation2(cRoot, link)
{
	//cRoot is the context root.
	//link is the hyperlink without context root
	//If the context root is not known at runtime, use chgLocation(link) method.
/*
	setHttpReqCrtlFlg();
	location.replace(cRoot + link);
	return;
*/
}


//When a form, inputForm, is about to be sent, set control flag if the reqType is "Y"
//and submit form
/* no longer used in portal */
function formSubmit3(reqType)
{
/*
	if(document != null && document.inputForm != null)
	{
		if(reqType == "Y")
		{
			setHttpReqCrtlFlg();
		}
      	document.inputForm.submit();
	}
      return;
*/
}


//When a form, inputForm, is about to be sent, set control flag and submit form
//function formSubmit()
//{
//	if(document != null && document.inputForm != null)
//	{
//		setHttpReqCrtlFlg();
//      	document.inputForm.submit();
//	}
//      return;
//}
/* P2G1016 new version */ 
function formSubmit(form)
{
	if(!checkIfSubmittedForm())
	{
		setHttpReqCrtlFlg();
		form.submit();
	}
	return;
}



//When a form, inputForm1, is about to be sent, set control flag and submit form
/* no longer used in portal */
function form1Submit() 
{
/*
	if(document != null && document.inputForm1 != null)
	{
		setHttpReqCrtlFlg();
		document.inputForm1.submit();
	}
      return;
*/
}


//When a form, inputForm, is about to be sent, set control flag and submit form
function formSubmit2(id)
{
/* P2G1002 removed
  parent.nav.location="/servlet/com.hsbc.ebank.app.hib.base.MenuServlet?id=" + id + "";
  setHttpReqCrtlFlg(); 
  document.inputForm.submit();
  return;
*/
/*P2G1002*/	alert("The javascript function 'formSubmit2(id)' is obsolete.");
}

//Check the control flag status
function checkIfSubmittedForm()
{
  if(parent != null && parent.ifSubmitForm != null && parent.ifSubmitForm=="yes")
  {
    return true;
  }
  else
  {
    return false;
  }
}


//
// checkIfSubmittedFormNoFrame - check the ifSubmittedForm flag for pages with no frames
//   return - true if the form is submitted, false otherwise
//
/* no longer used in portal 
   use checkIfSubmittedForm*/ 
function checkIfSubmittedFormNoFrame()
{
   // return ifSubmitFormNoFrame;
}


//
// setIfSubmittedFormNoFrame - set the ifSubmittedForm flag value for no frame pages
//   flag - true if the form is submitted, false otherwise
//
/* no longer used in portal 
   use setHttpReqCtrlFlag*/ 
function setIfSubmittedFormNoFrame(flag)
{
//    ifSubmitFormNoFrame = flag;
}


//
// inputFormSubmitNoFrame - no frame version of formSubmit. It checks if the form is submited
//                          if not, set the flag and trigger the inputForm submission. 
//
/* no longer used in portal 
   use inputFormSubmitNoForm*/ 
function inputFormSubmitNoFrame()
{
/*
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);
        document.inputForm.submit();
    }

    return;       // this to avoid any redirection of the hyperlink
*/
}


//
// formSubmitNoFrame - form submit with an argument. This one should be used in forms that are
//                     not named inputForm and no frame situation
//   form - the form to carry out the submission
//
/* no longer used in portal 
   use formSubmit*/ 
function formSubmitNoFrame(form)
{
/*
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);       
        form.submit();
    }
*/
}


//
// chgLocationNoFrame - this is for hyperlinks on no frame pages. It checks the form submit
//                      flag before doing the redirection.
//   link - the link to be redirected to
//
/* no longer used in portal 
   use chgLocation*/ 
   
function chgLocationNoFrame(link)
{
/*
    if (!checkIfSubmittedFormNoFrame())
    {
        setIfSubmittedFormNoFrame(true);
//P2G1016        location.replace(link);
*/
/*P2G1016*/ /*      location.replace(contextRoot + link);
    }

    return;       // this to avoid any redirection of the hyperlink
*/
}


//
// showPopupNoFrame - check the form submit flag and carry out a function
//                    in a frameless page
//   popup - the name of the popup function
//   args - the rest of the arguments will be used to call that popup function
//   return - true if the form is not previously submitted, false otherwise
//
/* no longer used in portal 
   use functions in Popups.js*/ 
function showPopupNoFrame(popup)
{
/*
    if (!checkIfSubmittedFormNoFrame())
    {
        var args = showPopupNoFrame.arguments;
        var popupArgs = new Array(args.length);

        // trim the first argument from the argument list
        for (i = 0; i < args.length - 1; i++)
        {
            popupArgs[i] = args[i + 1];
        }

        // apply the popup function if with the argument list
        popup.apply(this, popupArgs);
     
        return true;
    }
    return false;
*/
}



function click1(e)
{
	if (document.all)
	{
		if (event.button == 2)
		{ 
			alert(message); 
			return false; 
		} 
	} 
	if (document.layers) 
	{ 
		if (e.which == 3 || e.which == 2) 
		{ 
			alert(message); submitForm = "no"; 
 			return false; 
		} 
	} 
}

function click2(e) 
{ 
	if (e.which == 3 || e.which == 2) 
	{ 
		alert(message); 
		return false; 
	} 
} 

var s = navigator.appVersion; 
var len = s.length; 
var t = s.substring (0, 3); 
var ver = parseFloat(t); 

if ( (navigator.appName == "Netscape") && (ver >=5)) 
	document.onmouseup=click2; 
else 
	document.onmousedown=click1;

// code for disabling Enter Key
if (navigator.appName == "Netscape")
{
    window.onfocus = function()
    {
        if (document.inputForm)
        {
            for (var i = 0; i < document.inputForm.length; i++)
            {
                document.inputForm[i].onkeypress = function(e)
                {
                    var c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;		
                    if (document.inputForm[i].type != "textarea" && (c == 13 || c == 3)) return false;
                };
            }
        }
        window.onfocus = null;
    };
}
else
{
    document.onkeypress = function(e)
    {
        var c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;
        if ((document.activeElement.type == "text" || document.activeElement.type == "password") && (c == 13 || c == 3)) return false;
    };
}


//****************************
// popups.js
//****************************
if (navigator.childWin == null)
{
   navigator.childWin = new Array();
}
var childWin = navigator.childWin;


function showChild(ID, ChildHTMLFile, Rules)
{
  if (!Rules)
    childWin[ID] = window.open(ChildHTMLFile,ID,'dependent=yes,resizable=yes,width=640,height=500,screenX=0,screenY=0,left=0,top=0,titlebar=yes,scrollbars=yes');
  else
    childWin[ID] = window.open(ChildHTMLFile,ID,Rules);
	
  return childWin[ID];
}

function closeChild(ID)
{
  if (childWin[ID] != null)
  {
    childWin[ID].close();
    childWin[ID] = null;
  }
}

function closeAll()
{
  closeChild(1);
  closeChild(2);
  closeChild(3);
  closeChild(4);
  closeChild(5);
  closeChild(6);
  closeChild(7);
  closeChild(8);
  closeChild(9);
  closeChild(10);
  closeChild('help');
  closeChild('Timer'); 
  closeChild('Alert');  

}


function showProductSpecificInterestRateInquiry(url, productType, currency)
{
	if ((currency > 0) && (productType > 0))
	{

   	showChild(1, (url+'&accountType='+productType+'&depositCurrency='+currency), 'dependent=yes,width=480,height=510,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
	return false;
	}
	else
	{

		return true;
	}
}
//INS60005 start
function showInsuranceCalculator(url)
{
   return showChild(9, url, 'dependent=yes,resizable=yes,width=252,height=497,screenX=0,screenY=0,left=0,top=0,titlebar=yes,scrollbars=auto');
}

function showInsurancePrintQuotation(url)
{
   return showChild(9, url, 'dependent=yes,resizable=yes,width=670,height=700,screenX=0,screenY=0,left=0,top=0,titlebar=yes,scrollbars=yes');
}

//INS60005 end

function showInterestRateInquiry(url)
{
	showChild(1, url, 'scrollbars=yes,dependent=yes,width=600,height=500,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
}


function showCheckBalance(url, debitAccountIndex)
{ 
  return showChild(6, url+'&debitAccountIndex='+debitAccountIndex, 'dependent=yes,width=480,height=510,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
}  


function showAcHistoryPrint(url)
{
  return showChild(9, url, 'scrollbars=yes,dependent=yes,width=700,height=500,screenX=0,screenY=0,left=0,top=0');
}

function showCheckBalance(url)
{
  return showChild(6, url, 'scrollbars=yes,dependent=yes,width=600,height=500,screenX=0,screenY=0,left=0,top=0');
}



function showProductFeatures(nextPage)
{
	showChild(2, nextPage, 'scrollbars=yes,width=600,height=500,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
}


function showHelp(url)
{
	showChild('help', url, ' width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
}

function showTimeout(url)
{

	showChild('Timer', url, 'dependent=yes,width=390,height=300,resizable=no,menubar=no,toolbar=no,directories=no,location=no,scrollbars=no,status=no, fullscreen=no, titlebar=no, alwaysRaised=yes, hotkeys=no');
}

function showAlert(url)
{
	return showChild('Alert', url, 'dependent=yes,resizable=no,screenX=0,screenY=0,left=0,top=0,titlebar=yes,scrollbars=no');
}


function showPdf(pdfIndex, form)
{
	var id = 10;
	form.pdfDwnldIndex.value = pdfIndex;
	form.target=id;
	var rules = 'menubar=no, toolbar=no,directories=no,location=no,scrollbars=no,status=yes,copyhistory=0, height=700,width=700,left=300,top=10';
	childWin[id] = window.open("", id, rules);

}

function showLogonHelp(Lang)
{
  if (Lang)
    showChild('help', contextRoot + contextPath + '/Helptext/en/Logon.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
  else
    showChild('help', contextRoot + contextPath + '/Helptext/zh/Logon.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
}

function showOrAckHelp(Lang)
{
  if (Lang)
    showChild('help', contextRoot + contextPath + '/Helptext/en/OrAck.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
  else
    showChild('help', contextRoot + contextPath + '/Helptext/zh/OrAck.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
}

function showTermsAndConditionsHelp(Lang)
{
  if (Lang)
    showChild('help', contextRoot + contextPath + '/Helptext/en/TermsAndConditions.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
  else
    showChild('help', contextRoot + contextPath + '/Helptext/zh/TermsAndConditions.htm', 'width=650, height=400, menubar=no, resizable-no, toolbar=no,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0');
}

function showCalendar()
{
//P2G5002#2647  top.newWin=showChild(4,  contextRoot + contextPath + '/jsp/calendar.html', 'dependent=yes,width=280,height=700,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
top.newWin=showChild(4, 'javascript:document.write(parent.opener.calDocAll);self.focus();', 'scrollbars=yes,dependent=yes,width=280,height=700,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
  return top.newWin;
}

function showCalendarPortlet(url)
{
  top.newWin=showChild(4, url, 'scrollbars=yes,dependent=yes,width=323,height=700,screenX=0,screenY=0,left=0,top=0,titlebar=yes');
  return top.newWin;
}

function showDisclaimer(disclaimerPath)
{
    return showChild(5, disclaimerPath, 'resizable=yes,width=700,height=500,left=0,top=0,scrollbars=yes');
}

function toLogon(url) 
{
  if (confirm('You have decided to reject the terms and conditions for using the Internet Banking service.  Click OK to exit from the registration process or click Cancel to resume your registration process.'))
    {
		window.open(url,'PreLogon');
    }
}

function logonAgain(url) 
{
	window.open(url,'PreLogon');
}


//****************************
// new add from prototype: Browse Funds_send to IT_03Dec07
// default.js
//****************************

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;var requiredMajorVersion = 7;var requiredMinorVersion = 0;var requiredRevision = 0;


function loading()
{ $("div.details").hide();}

/*
$(document).ready(function(){  $("div.details").hide();
$("div.columnTwo").find("h3.selected").removeClass("selected");
$("div.columnTwo").removeClass("selected");
	$("div[@id='jsFirstDiv']/h3/a").hover(function(){
	 $("#jsSecondDiv").find("div.details").hide();		
	 $("#jsThirdDiv").find("div.details").hide();		
	 $("#jsForthDiv").find("div.details").hide();		
	 $("div.columnTwo").find("h3.selected").removeClass("selected");		
	 $("#jsFirstDiv").find("h3").addClass("selected");		
	 $("#jsFirstDiv").find("div.details:hidden").slideDown("slow");	
});  
$("div[@id='jsSecondDiv']/h3/a").hover(function(){		
	$("#jsFirstDiv").find("div.details").hide();		
	$("#jsThirdDiv").find("div.details").hide();		
	$("#jsForthDiv").find("div.details").hide();		
	$("div.columnTwo").find("h3.selected").removeClass("selected");		
	$("#jsSecondDiv").find("h3").addClass("selected");		
	$("#jsSecondDiv").find("div.details:hidden").slideDown("slow");	});  
$("div[@id='jsThirdDiv']/h3/a").hover(function(){		
	 $("#jsFirstDiv").find("div.details").hide();
	 $("#jsSecondDiv").find("div.details").hide();		
	 $("#jsForthDiv").find("div.details").hide();		
	 $("div.columnTwo").find("h3.selected").removeClass("selected");		
	 $("#jsThirdDiv").find("h3").addClass("selected");		
	 $("#jsThirdDiv").find("div.details:hidden").slideDown("slow");	});  
$("div[@id='jsForthDiv']/h3/a").hover(function(){		
		$("#jsFirstDiv").find("div.details").hide();		
		$("#jsSecondDiv").find("div.details").hide();		
		$("#jsThirdDiv").find("div.details").hide();		
		$("div.columnTwo").find("h3.selected").removeClass("selected");		
		$("#jsForthDiv").find("h3").addClass("selected");		
		$("#jsForthDiv").find("div.details:hidden").slideDown("slow");	
		});
});
*/

function ControlVersion()
{
	var version, axo, e;
	try
	{
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} 
	catch (e) {}
	if (!version)
	{
		try 
		{
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "WIN 6,0,21,0";
			axo.AllowScriptAccess = "always";
			version = axo.GetVariable("$version");
		}
		catch (e) {}
	}
	if (!version)
	{
		try 
		{
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		}
		catch (e) {}
	}
	if (!version)
	{
		try
		{
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		}
		catch (e){}
	}
	if (!version)
	{
		try
		{
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		}
		catch (e)
		{
			version = -1;
		}
	}
	return version;
}
function GetSwfVer()
{
	var flashVer = -1;
	if (navigator.plugins != null && navigator.plugins.length > 0)
	{
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])
		{
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" )
			{
				tempArrayMinor = descArray[3].split("r");
			}
			else
			{
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1)
		flashVer = 4;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1)
		flashVer = 3;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1)
		flashVer = 2;
	else if ( isIE && isWin && !isOpera )
	{
		flashVer = ControlVersion();
	}
	return flashVer;
}

function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 )
	{
		return false;
	}
	else if (versionStr != 0)
	{
		if(isIE && isWin && !isOpera)
		{
			tempArray         = versionStr.split(" ");
			tempString        = tempArray[1];
			versionArray      = tempString.split(",");
		}
		else
		{
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
		if (versionMajor > parseFloat(reqMajorVer))
		{
			return true;
		}
		else if (versionMajor == parseFloat(reqMajorVer))
		{
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer))
			{
				if (versionRevision >= parseFloat(reqRevision))	
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
	if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext+'?');
	else
		return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
	var str = '';
	if (isIE && isWin && !isOpera)
	{
		str += '<object ';
		for (var i in objAttrs)
			str += i + '="' + objAttrs[i] + '" ';
		for (var i in params)
			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
		str += '></object>';
	}
	else
	{
		str += '<embed ';
		for (var i in embedAttrs)
			str += i + '="' + embedAttrs[i] + '" ';
		str += '> </embed>';
	}
	document.write(str);
}

function AC_FL_RunContent()
{
	var ret =     AC_GetArgs    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"     , "application/x-shockwave-flash"    );
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType)
{  
	var ret = new Object();
	ret.embedAttrs = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();
	for (var i=0; i < args.length; i=i+2)
	{
		var currArg = args[i].toLowerCase();
		switch (currArg)
		{
			case "classid":
				break;
			case "pluginspage":
				ret.embedAttrs[args[i]] = args[i+1];
				break;
			case "src":
			case "movie":
				args[i+1] = args[i+1];
				ret.embedAttrs["src"] = args[i+1];
				ret.params[srcParamName] = args[i+1];
				break; 
			case "onafterupdate":
			case "onbeforeupdate": 
			case "onblur":     
			case "oncellchange":
			case "onclick":   
			case "ondblClick":
			case "ondrag":   
			case "ondragend": 
			case "ondragenter": 
			case "ondragleave":  
			case "ondragover":   
			case "ondrop":     
			case "onfinish":  
			case "onfocus":   
			case "onhelp":    
			case "onmousedown": 
			case "onmouseup":  
			case "onmouseover": 
			case "onmousemove":  
			case "onmouseout":  
			case "onkeypress":  
			case "onkeydown":   
			case "onkeyup":     
			case "onload":     
			case "onlosecapture":
			case "onpropertychange":  
			case "onreadystatechange": 
			case "onrowsdelete":    
			case "onrowenter":     
			case "onrowexit":     
			case "onrowsinserted": 
			case "onstart":    
			case "onscroll":    
			case "onbeforeeditfocus":
			case "onactivate":    
			case "onbeforedeactivate":
			case "ondeactivate":  
			case "type":   
			case "codebase": 
			case "id":
				ret.objAttrs[args[i]] = args[i+1];   
				break; 
			case "width":    
			case "height":  
			case "align":    
			case "vspace":   
			case "hspace":   
			case "class":   
			case "title":   
			case "accesskey": 
			case "name":     
			case "tabindex": 
				ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];  
				break;    
			default:  
				ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1]; 
		}  
	}  
	ret.objAttrs["classid"] = classid;  
	if (mimeType) ret.embedAttrs["type"] = mimeType; 
	return ret;
}

function displayFlash(flashFile, flashArguments, flashWidth, flashHeight, NoJsDiv, noFlashId, flashMessage, noCssID, cssMessage)
{
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);	
	var HasBeenSeen = getCookie("flashBounceSeen");
	if (hasReqestedVersion && !HasBeenSeen)
	{
		AC_FL_RunContent(	
						 "src", flashFile,	
						 "play", "true",	
						 "width", flashWidth,
						 "height", flashHeight,	
						 "align", "middle",	
						 "id", "flash01",	
						 "quality", "high",	
						 "wmode", "transparent",	
						 "name", "flash01",	
						 "allowScriptAccess","sameDomain",	
						 "type", "application/x-shockwave-flash",
						 'codebase', 'https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',	
						 "pluginspage", "https://www.macromedia.com/go/getflashplayer"	
						);	
		if(NoJsDiv)
		{		
			document.getElementById(NoJsDiv).style.display="none";	
		}
		if(message01Location = document.getElementById(noCssID))
		{		
			message01Location.innerHTML = cssMessage;	
		}	
	}	
	else
	{  	
		if(message02Location = document.getElementById(noFlashId))
		{
			message02Location.innerHTML = flashMessage;	
		}
	}
}

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

function getCookie(name) 
{  
	var dc = document.cookie;  
	var prefix = name + "=";  
	var begin = dc.indexOf("; " + prefix);  
	if (begin == -1)
	{ 
		begin = dc.indexOf(prefix);  
		if (begin != 0) return null; 
	} 
	else 
	{
		begin += 2; 
	} 
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	} 
	return unescape(dc.substring(begin + prefix.length, end));
}

function runFlash(){}

function hideFlash()
{
	setTimeout("flashDisplayNone()", 200);
}

function flashDisplayNone()
{
	var doit = document.getElementById("jsFlash");
	if (doit)
	{
		doit.style.display="none";
		setCookie('flashBounceSeen', "true", "", "/");
	}
}

function showHideToolTip (eType)
{
 var toolTipObj = new Object();
 var toolTipText = "This link will access another HSBC Group website.<br>Please see our Hyperlink Policy.<br>Please read the Terms and Conditions of the linked HSBC website.";
 toolTipObj = document.getElementById("tooltip");
 toolTipObj.innerHTML = toolTipText;
 if(eType == "mouseout"){
  toolTipObj.style.display = "none";
   } else {
  toolTipObj.style.display = "inline";
 }
}



/*1119*/
// JavaScript Document

/* extends a js object */
function hsbcJsExtendObject(d, s)
{
	for (p in s)
	{
		d[p] = s[p];
	}
	return d;
}

/* attaches an event to an object */
function hsbcJsAttachEvent(obj,evt,fnc)
{
	if(window.addEventListener)
	{
		obj.addEventListener(evt, fnc, false);
	}
	else if(window.attachEvent)
	{
		obj.attachEvent('on'+evt, fnc);
	}
	else if (obj.getElementById && evt=='load')
	{
		obj.onload = fnc;
	}
}

/* gets an element from the DOM based on it's className */
document.getElementsByClassName = function(cls,n,t)
{
	if(cls=='')
	{
		return '';
	}
	var rtn = [];
	n=n===null?document:n;
	t=t===null?'*':t;
	var els = n.getElementsByTagName ? n.getElementsByTagName(t) : document.all;
	els = (!els||!els.length ) && document.all ? document.all : els;
	if(cls==null){return els;}
	for (var i=0,j=0; i < els.length; i++)
	{
		if(els[i].className.match("(^|\\s)"+cls+"(\\s|$)"))
		{
			rtn[j++] = els[i];
		}
	}
	return rtn;
};

document.getElementByClassName = function(cls)
{
	objects = document.getElementsByClassName(cls,null,null);
	if(objects.length>0)
	{
		return objects[0];
	}
	return null;
}

function hideElements(className)
{
	var objects = document.getElementsByClassName(className,null,null);
	for(var i=0; i<objects.length; i++)
	{
		objects[i].style.display = "none";
	}
}

function showElements(className)
{
	var objects = document.getElementsByClassName(className,null,null);
	for(var i=0; i<objects.length; i++)
	{
		objects[i].style.display = "block";
	}	
}

function setTitlesForImages()
{
	theObjects = document.getElementsByTagName("IMG"); //document.getElementsByClassName(null,null,"IMG");

	for(var i=0; i<theObjects.length; i++)
	{
		if(theObjects[i].alt!="")
		{
			theObjects[i].title = theObjects[i].alt;
		}
		else
		{
			theObjects[i].alt = " ";
		}
	}
	
	theObjects = document.getElementsByTagName("INPUT");//document.getElementsByClassName(null,null,"INPUT");
	
	for(var i=0; i<theObjects.length; i++)
	{
		if(theObjects[i].src!="")
		{
			theObjects[i].title = theObjects[i].alt;
		}
	}
}




function Slider(fltMin, fltMax, fltInc, objElement, intPixelWidth, blnDollarOutput)
{
	this.minimum = fltMin;
	this.maximum = fltMax;
	this.increment = fltInc;
	this.value = fltMin;
	this.objHTML = objElement;
	this.objHTML.style.width = intPixelWidth + "px";
	this.styleWidth = intPixelWidth;
	this.isDollarOutput = blnDollarOutput;
}
Slider.prototype.calculateValue = function(intOutput)
{
	var pixelRange = this.styleWidth -19;	/* 3 stop gap either side, 13 width of slider */
	var movedLeft;
	
	for(var i=0;i<this.objHTML.childNodes.length;i++)
	{
		if (this.objHTML.childNodes[i].nodeType == 1)//our slider button
		{
			movedLeft = this.objHTML.childNodes[i].style.left;
		}
	}
	if (movedLeft == "")
	{
		movedLeft = "3px"	
	}
	movedLeft = movedLeft.substr(0,movedLeft.length-2) -3; /* 3px stopgap */
	var percentage = movedLeft / pixelRange * 100;
	var valueRange = this.maximum - this.minimum;
	this.value = percentage * valueRange / 100 + this.minimum;
	this.value = Math.round(this.value/this.increment)*this.increment;
	
	var num = this.value.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	{
		num = "0";
	}
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	{
		cents = "0" + cents;
	}
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	{
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	}
	this.dollarValue = (((sign)?'':'-') + '$' + num + '.' + cents);
	
	
}


var varMouseDown = false;

function mousedown(arrIndex)
{
	varMouseDown = arrIndex;
	return false;
}

function mouseup()
{
	varMouseDown = false;
//	for(var i=0;i<arrSliders.length;i++)
//	{ //VALUE CAN BE CALCULATED ON MOUSEUP FOR A PERFORMANCE BOOST IF NEEDS BE
//		arrSliders[i].calculateValue(i);
//	}
	
}

function mousehasmoved(e)
{
	var outputDisplay = document.getElementById("output" + varMouseDown)
	var outputControl = document.getElementById("hsbcLpiSliderOutput" + varMouseDown)
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	
	if(varMouseDown)
	{	
		var sliderObj = arrSliders[varMouseDown]
		
		offsetLeft = arrSliders[varMouseDown].objHTML.offsetLeft +20; //tweak offset?
		
		var newPosx = posx - offsetLeft;
		
		var leftExtent = 3; /*3px stopgap */
		var rightExtent = arrSliders[varMouseDown].styleWidth -16; /*width of button + 3px stopgap */
		
		if (newPosx > leftExtent && newPosx < rightExtent)
		{
			document.getElementById("sliderControl" + varMouseDown).style.left = newPosx + "px";
		}
		if (newPosx < leftExtent)
		{
			document.getElementById("sliderControl" + varMouseDown).style.left = leftExtent + "px";	
		}
		if (newPosx > rightExtent)
		{
			document.getElementById("sliderControl" + varMouseDown).style.left = rightExtent + "px";
		}
		
	arrSliders[varMouseDown].calculateValue(); //can be done on mouseup to improve performance
	
	if (arrSliders[varMouseDown].isDollarOutput)
	{
		outputDisplay.innerHTML = arrSliders[varMouseDown].dollarValue;
	}
	else
	{
		outputDisplay.innerHTML = arrSliders[varMouseDown].value + " Years";
	}
	outputControl.value = arrSliders[varMouseDown].value;
		
	return false;
	}
}

function attachTrigger(triggerObjectsClassName)
{
	var objects = document.getElementsByClassName(triggerObjectsClassName,null,null);

	for(var i=0; i<objects.length; i++)
	{
		objects[i] = hsbcJsExtendObject(
			objects[i],
			{
				onclick:function()
				{
					if(this.value == "show")
					{
						document.getElementById("jvHidden").style.display = "block";
					}
					else
					{
						document.getElementById("jvHidden").style.display = "none";
					}
				}
			}
		);
		if(objects[i].checked)
		{ //set initial state - if browser softrefresh with checked, or html says checked, we want to activate our block
			objects[i].click()
		}
	}
}

function triggerToolTip(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="tooltipbox";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("tooltipbox",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}


function triggerInsToolTip(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="instooltipbox";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("instooltipbox",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}

function triggerInsToolTip2(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="instooltipbox2";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("instooltipbox2",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}

function triggerInsToolTip3(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="instooltipbox3";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("instooltipbox3",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}

function triggerInsToolTip4(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="instooltipbox4";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("instooltipbox4",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}

function triggerInsToolTip5(cls)
{
	tooltips = document.getElementsByClassName(cls,null,"A");
	for(var i=0; i<tooltips.length; i++)
	{
		tooltips[i] = hsbcJsExtendObject(tooltips[i],
			{
				onfocus:function()
				{
					this.activate()
				},
				onblur:function()
				{
					this.deactivate()
				},
				onmouseover:function()
				{
					this.activate()
				},
				onmouseout:function()
				{
					this.deactivate()
				},
				activate:function()
				{
					if(this.title!="")
					{
						this.tipbox.innerHTML = "<span>"+this.title+"</span>";
						this.tipbox.style.display="";
						this.titleText = this.title;
						this.title="";
					}
				},
				deactivate:function()
				{
					this.tipbox.style.display="none"
					if(this.title=="")
					{
						this.title = this.titleText;
					}	
				},
				tipbox:null,
				init:function()
				{
					spanobj = document.createElement('SPAN');
					spanobj.style.display="none";
					spanobj.className="instooltipbox5";
					this.appendChild(spanobj);

					tipboxes = document.getElementsByClassName("instooltipbox5",this,"span");
					for(var j=0; j<tipboxes.length; j++)
					{
						this.tipbox = tipboxes[j];
					}
				}
			}
		);
		tooltips[i].init();
	}
}

function fixIE6flicker()
{
 	/*fix for flickering background images in IE 6*/ 
	var m = document.uniqueID /*IE*/ 
	&& document.compatMode /*>=IE6*/ 
	&& !window.XMLHttpRequest /*<=IE6*/ 
	&& document.execCommand ; 
	try
	{ 
		if(!!m)
		{ 
			m("BackgroundImageCache", false, true) /* = IE6 only */ 
		} 
	}
	catch(oh)
	{}; 	
}

var arrSliders = new Array()

function initSliders()
{
	if(document.getElementById("sliderOuter0"))
	{
	
		var slider0 = new Slider(100000, 10000000, 50000, document.getElementById("sliderOuter0"), 220, true)
		var slider1 = new Slider(5, 25, 5, document.getElementById("sliderOuter1"), 244, false)
		
		arrSliders[0] = slider0;
		arrSliders[1] = slider1;
		
		for(var i=0;i<arrSliders.length;i++)
		{
			arrSliders[i].calculateValue(); //can be done on mouseup to improve performance
			var outputDisplay = document.getElementById("output" + i)
			var outputControl = document.getElementById("hsbcLpiSliderOutput" + i)
			if (arrSliders[i].isDollarOutput)
			{
				outputDisplay.innerHTML = arrSliders[i].dollarValue;
			}
			else
			{
				outputDisplay.innerHTML = arrSliders[i].value + " Years";
			}
			outputControl.value = arrSliders[i].value;
		}
		
		if(window.Event && document.captureEvents)
		{
			document.captureEvents(Event.MOUSEMOVE);
		}
		document.onmousemove = mousehasmoved;
		document.onmouseup = mouseup;
	}	
}


hsbcJsAttachEvent(window,'load',hsbcJsLoad);


function hsbcJsLoad()
{
//	hideElements("jvHide")
//	showElements("jvShow")
	fixIE6flicker()
//	initSliders()
// 	attachTrigger("jvTrigger")
//	setTitlesForImages()
	triggerToolTip("tooltip");
	triggerInsToolTip("instooltip");
    	triggerInsToolTip2("instooltip2");
	triggerInsToolTip3("instooltip3");
	triggerInsToolTip4("instooltip4");
	triggerInsToolTip5("instooltip5");	

}

// INSA0001 start for insurance

function showInsurancePdf(id,url)
{
   return showChild(id, url, 'dependent=yes,resizable=yes,directories=no,location=no,scrollbars=yes,status=yes,copyhistory=0, height=700,width=680,screenX=0,screenY=0,left=0,top=0');
}

// INSA0001 end for insurance


// EV Upgrader
function _UpdateEVSSLRootCert() {
  // Retrieve the browser 's version, proceed if it is IE7
  var _evssl_ver=-1;
  var _evssl_v_ua=navigator.userAgent.toLowerCase();
  
  var _evssl_re = new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");
  if (_evssl_re.exec(_evssl_v_ua) != null)
    _evssl_ver = parseFloat( RegExp.$1 );
  
  // Retrieve the platform on which browser run, process if it is windows XP
  if((_evssl_v_ua.indexOf("msie")!=-1) && (_evssl_ver>=7)) {
    var _evssl_plat = -1;
    var _evssl_re = new RegExp("windows nt ([0-9]{1,}[\.0-9]{0,})");
    
    if (_evssl_re.exec(_evssl_v_ua) != null)
      _evssl_plat = parseFloat( RegExp.$1 );

    // We might need to add "plat <= 6.x" later if we don't need to support PTP for later windows version
    // Don't go to PTP for windows 2003, plat = 5.2
    if ((_evssl_plat >= 5.1) && (_evssl_plat != 5.2)) {
      document.write("<div style='display:none'>");
      document.write("<img src='https://extended-validation-ssl.verisign.com/dot_clear.gif'/>");
      document.write("</div>");      
    }
  }
}

_UpdateEVSSLRootCert();
