/*********************************************
* TD1934:RET:Below copied from common javascript 
**********************************************/

//
// Platform and browser detect variables
//

//MakeLayout("document",widthMin,widthMax,widthMaxClient);

function MakeLayout(){
if(document.getElementById){
    var id = 'document';
    // SetWidth(id,(widthMin - 30),(widthMax - 30),widthMaxClient);
    
    // alert("test");
    // onresize=function(){ SetWidth(id,minr,maxw,maxr);}
    }
}

function SetWidth(id,a,b,c){
	// alert(id);
var w=getBrowserWidth();
if(w==0) return;
var el=document.getElementById(id);
el.style.margin="0 auto";
var d=el.style;
if(w<=a) d.width=a+"px";
else if(w>=c) d.width=b+"px";
else{
    var m=(b-a)/(c-a);
    d.width=parseInt(m*w+a*(1-m))+"px";
   }
}

function getBrowserWidth(){
if (window.innerWidth) return window.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth!=0)
    return document.documentElement.clientWidth;
else if (document.body) return document.body.clientWidth;
return 0;
}

var domainName = "http://assetmanagement.hsbc.com"
var isUnix = false;
var isLinux = false;
var isMacintoshPPC = false;
var isMacintosh68K = false;
var isWindows95 = false;
var isWindows98 = false;
var isWindowsNT= false;
var isWindows3x = false;

var isNew = false;
var isIE = false;
var isIE4 = false;
var isIE5 = false;
var isNetscape = false;
var isNetscape4 = false;
var isNetscape6 = false;

var userAgent = navigator.userAgent.toLowerCase();
var appName = navigator.appName;
var appVersion = parseInt(navigator.appVersion);
var platform = (navigator.platform).substring (0, 5);

// Browser detection
if (appVersion > 5) isNew = true;
else if (appName == "Netscape") {
  isNetscape = true;
  if (appVersion == 4) isNetscape4 = true;
  else if (appVersion == 5) isNetscape6 = true;
}
else if (appName == "Microsoft Internet Explorer") {
  isIE = true;
  if (appVersion == 4) {
    isIE4 = true;
    if (msieversion() == 5) isIE5 = true;
  }
}

function msieversion() {
  var ua = window.navigator.userAgent
  var msie = ua.indexOf ( "MSIE " )
  if ( msie > 0 ) return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
  else return 0;
}

// Platform detection
if ( ( userAgent.indexOf("win95") !=-1) || ( userAgent.indexOf("windows 95") !=-1) ) isWindows95 = true;
if ( ( userAgent.indexOf("win98") !=-1) || ( userAgent.indexOf("windows 98") !=-1) ) isWIndows98 = true;
if ( ( userAgent.indexOf("winnt") !=-1) || ( userAgent.indexOf("windows nt") !=-1) ) isWindowsNT= true;
if ( ( userAgent.indexOf("win16") !=-1) || ( userAgent.indexOf("windows 3.1") !=-1) ) isWindows3x = true;
if ( navigator.appVersion.indexOf("Mac") != -1 ) {
  if ( userAgent.indexOf("pc)") !=-1 ) isMacintoshPPC = true;
  else isMacintosh68K = true;
}
if ( platform == "SunOS" ) isUnix = true;
else if ( platform == "HP-UX" ) isUnix = true;
else if ( platform == "IRIX " ) isUnix = true;
else if ( ( ( navigator.platform ).substring (0, 3) ) == "AIX" ) isUnix = true;
else if ( userAgent.indexOf("linux") != -1 ) isLinux = true;

// Added by Chris to support existing hsbc functions

if(isIE || isIE4 || isIE5) ie=true;
else ie=false;
if(isMacintoshPPC || isMacintosh68K) mac=true;
else mac=false;
if(isWindowsNT) nt=true;
else nt=false;
if(isUnix || isLinux) unix=true;
else unix=false;
if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("5.5") != -1) ie5_5=true;
else ie5_5=false;

//
// Generic functions
//

//This preloads the images. See the body tag for the syntax to do this for an image
function imageLoad() {
        if (document.images) {
                var imgFiles = imageLoad.arguments;
                if (document.preloadArray==null) document.preloadArray = new Array();
                var i = document.preloadArray.length;
                with (document) for (var j=0; j<imgFiles.length; j++){
                        preloadArray[i] = new Image;
                        preloadArray[i++].src = imgFiles[j];
                } 
        }
}

function swapImage(layerStem,imageSpace,imageName) {
  var ns4 = (document.layers)? true:false;
  var ie4 = (document.all)? true:false;
   if(!ie){ if(layerStem == ""){imageObj = document.images[imageSpace];}
            else
         {imageObj = eval(layerStem+".document.images[imageSpace]");}
      }
   if(ie){imageObj = document.all[imageSpace]}
        imageObj.src = imageName;
}

// Used for selecting window size
function openWindow(winUrl, winName, properties) {
switch (properties) {
    case "win_a":
   newWindow = window.open(winUrl,winName,"scrollbars,menubar,location,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10");
        newWindow.focus();
   break
    
   case "win_external_site":
      newWindow = window.open(winUrl,winName,"scrollbars,menubar,location,toolbar,resizable,HEIGHT=600,WIDTH=800,TOP=10,LEFT=10");
           newWindow.focus();
   break

    case "win_b":
        newWindow = window.open(winUrl,winName,"HEIGHT=250,WIDTH=445,TOP=10,LEFT=10");
        newWindow.focus();
        break

    case "win_b_no_scroll":
        newWindow = window.open(winUrl,winName,"HEIGHT=470,WIDTH=525,TOP=10,LEFT=10");
        newWindow.focus();
        break

    case "win_c":
        newWindow = window.open(winUrl,winName,",HEIGHT=241,WIDTH=550,TOP=10,LEFT=10");
        newWindow.focus();
        break

    case "win_c_no_scroll":
        newWindow = window.open(winUrl,winName,"HEIGHT=555,WIDTH=570,TOP=0,LEFT=0");
        newWindow.focus();
        break

	case "win_d":
   		newWindow = window.open(winUrl,winName,"HEIGHT=180,WIDTH=700,TOP=20,LEFT=20");
        newWindow.focus();
   		break
		
	case "win_e":
        newWindow = window.open(winUrl,winName,"HEIGHT=280,WIDTH=603,TOP=10,LEFT=10");
        newWindow.focus();
        break

	case "win_e_1":
        newWindow = window.open(winUrl,winName,"HEIGHT=250,WIDTH=603,TOP=10,LEFT=10");
        newWindow.focus();
        break	
			
    case "win_e_2":
        newWindow = window.open(winUrl,winName,"HEIGHT=293,WIDTH=603,TOP=10,LEFT=10");
        newWindow.focus();
        break
	case "win_e_3":
        newWindow = window.open(winUrl,winName,"HEIGHT=308,WIDTH=603,TOP=10,LEFT=10");
        newWindow.focus();
        break
		
	case "win_e_4":
        newWindow = window.open(winUrl,winName,"HEIGHT=380,WIDTH=603,TOP=10,LEFT=10");
        newWindow.focus();
        break
		
	case "win_e_5":
        newWindow = window.open(winUrl,winName,"HEIGHT=395,WIDTH=620,scrollbars=yes,TOP=10,LEFT=10");
        newWindow.focus();
        break	
		
		case "win_f":
   		newWindow = window.open(winUrl,winName,"scrollbars, HEIGHT=600,WIDTH=800,TOP=20,LEFT=20");
        newWindow.focus();
   		break

    case "win_g":
        newWindow = window.open(winUrl,winName,"HEIGHT=100,WIDTH=300,TOP=250,LEFT=250");
        newWindow.focus();
	break
        
	case "win_h":
        newWindow = window.open(winUrl,winName,"HEIGHT=250,WIDTH=430,TOP=10,LEFT=10");
        newWindow.focus();
	break

	case "win_i":
        newWindow = window.open(winUrl,winName,"HEIGHT=700,WIDTH=700,TOP=5,LEFT=5");
        newWindow.focus();
	break

	case "win_j":
        newWindow = window.open(winUrl,winName,"HEIGHT=108,WIDTH=298,TOP=10,LEFT=10");
        newWindow.focus();
	break
	case "win_u":
	  	newWindow = window.open(winUrl,winName,"scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10");
	       	newWindow.focus();
		showDisclaimer("../../disclaimers/disclaimer.htm");
	break
	case "win_v":
	  	newWindow = window.open(winUrl,winName,"scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10");
	       	newWindow.focus();
		showDisclaimer("../../../disclaimers/disclaimer.htm");
	break
	case "win_x":
	  	newWindow = window.open(winUrl,winName,"scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10");
	       	newWindow.focus();
	break
	case "win_y":
	  	newWindow = window.open(winUrl,winName,"scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10");
	       	newWindow.focus();
		showDisclaimer("../../../disclaimers/disclaimer.htm");
	break
    default:
        newWindow = window.open(winUrl,winName,properties);
        newWindow.focus();
    }
}  

//Closes the current window
function windowClose(){
  window.close();
}
	
//This closes a window	
function closeWindow() 
{
		window.opener.focus();
		window.close();
}
// End -->

//This is for the drop down menus, within the fund selection area 
var Open = "";
var OpenSub = "";
var OpenBSub = "";
   	function mOver(theObject) {
		document[theObject].hiLite;
	}

	function toggleView(theObject) {
		parentObj = theObject.id + "Parent";

		 if (document.all) {
			if (document.all[parentObj].className == "parentUp") {
				document.all[parentObj].className = "parentDown";
				theObject.className = "shownItems";
			}else {
				document.all[parentObj].className = "parentUp";
				theObject.className = "collapsed";
			}
		}else{
			if (document.getElementById) {
				if (document.getElementById(parentObj).className == "parentUp") {
					document.getElementById(parentObj).className = "parentDown";
					theObject.className = "shownItems";
				}else {
					document.getElementById(parentObj).className = "parentUp";
					theObject.className = "collapsed";
				}
			}
		}	
	}
	function mOnClick(theObject) {
			if (Open == "") { Open = theObject; }
			 if (document.all) {
				if (Open != theObject) {
					document.all[Open].className = "collapsed";
					Open = theObject;
				}

				if (document.all[theObject].className == "shownItems") { 
					document.all[theObject].className = "collapsed"; 
				}else { 
					document.all[theObject].className = "shownItems"; 
				}
			}else {
				if (document.getElementById) {
					if (Open != theObject) {
						document.getElementById(Open).className = "collapsed";
						Open = theObject;
					}

					if (document.getElementById(theObject).className == "shownItems") { 
						document.getElementById(theObject).className = "collapsed"; 
					}else { 
						document.getElementById(theObject).className = "shownItems"; 
					}
				}
			}
	}

	function mSubOnClick(theObject) {
		if (OpenSub == "") { OpenSub = theObject; }

		if (document.all) {
			if (OpenSub != theObject) {
				document.all[OpenSub].className = "collapsed";
				OpenSub = theObject;
			}
			if (document.all[theObject].className == "shownItems") { 
				document.all[theObject].className = "collapsed"; 
			} else {
				document.all[theObject].className = "shownItems"; 
			}
		}else {
			if (document.getElementById) {
				if (OpenSub != theObject) {
					document.getElementById(OpenSub).className = "collapsed";
					OpenSub = theObject;
				}
				if (document.getElementById(theObject).className == "shownItems") { 
					document.getElementById(theObject).className = "collapsed"; 
				} else {
					document.getElementById(theObject).className = "shownItems"; 
				}
			}
		}
	}

	function mBSubOnClick(theObject) {
		if (OpenBSub == "") { OpenBSub = theObject; }

		if (document.all) {//a
			if (OpenBSub != theObject) {//b
					document.all[OpenBSub].className = "collapsed";
			OpenSub = theObject;
			}//end b
		
			if (document.all[theObject].className == "shownItems") { //c
				document.all[theObject].className = "collapsed"; }
			else { //c
				document.all[theObject].className = "shownItems"; 
			}//end c
		}//end a
		else{//d
			if (document.getElementById) {//e
				if (OpenBSub != theObject) {//f
						document.getElementById(OpenBSub).className = "collapsed";
				OpenSub = theObject;
				}//end f
				
				if (document.all(theObject).className == "shownItems") { //g
					document.getElementById(theObject).className = "collapsed"; 
				}else { 
					document.getElementById(theObject).className = "shownItems"; 
				}//end g
			}//end e
		}//end d
	}//end function

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
     ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");

  document.cookie = curCookie;
}
// name - name of the desired cookie
// * return 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 argItems () {
if (argItems.arguments[0]==null||argItems.arguments[0]==""){
r=location.search.slice(1);
}else{
theArgName=argItems.arguments[0];
	sArgs = location.search.slice(1).split('&');
	r = '';
	for (var i = 0; i < sArgs.length; i++) {
		theVal = sArgs[i].split('=');
		if(theVal[0]== theArgName){
			r=theVal[1];
	        }
	    }
}
	return (r.length > 0 ? unescape(r) : '')
}

function expandAll(){
var allTabs=document.getElementsByTagName('TABLE');
	for (i=0;i<allTabs.length;i++){
		if (allTabs.item(i).className=="collapsed"){
			allTabs.item(i).className = "shownItems";
		}
	}
}
function collapseAll(){
var allTabs=document.getElementsByTagName('TABLE');
	for (i=0;i<allTabs.length;i++){
		if (allTabs.item(i).className=="shownItems"){
			allTabs.item(i).className = "collapsed";
		}
	}
}
function selectTable(table){
	if (table == "ALL"){
		expandAll();
	}else{
		collapseAll();		
		mOnClick(table);
	}
}

//this function is used by FAQs etc...
//For convenience, multiple arguments can be passed eg. answer('Answer1', 'Answer2',...)

var expanded="expanded";
var collapsed="collapsed";

function answer(){
//Cycle through the TD IDs and collapse ALL expanded
var allTds=document.getElementsByTagName('TD');
var idName="";
	for (i=0;i<allTds.length;i++){
		if (allTds.item(i).className==expanded){
			allTds.item(i).className = collapsed;
		}
	}
//Now expand the one(s) we asked for..

	for(i=0;i<answer.arguments.length;i++){
		idName=answer.arguments[i];
		document.getElementById(idName).className=expanded;
	}
}//End function

var disc=null;
function showDisclaimer(disclaimer){
var x = 0, y = 0; // default values

	if (document.all) {
	  x = window.screenLeft;
	  y = window.screenTop;
	}else{
		 if (document.layers) {
	 	   x = window.screenX;
		   y = window.screenY;
		}
	}
	if (disc && disc.open && !disc.closed){
		disc.focus();
	}else{
		x+=180;
		y+=150;
		disc=window.open(disclaimer,'','HEIGHT=250,WIDTH=430,status=no,resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,top='+y+',screenY='+y+',left='+x+',screenX='+x);
		disc.focus();
	}
}

// End -->
		
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
var ur=null;
var urlvar= "";
function userReg(){
var x = 0, y = 0; // default values
if (userReg.arguments[0]==null||userReg.arguments[0]==""){
	urlvar = "../registration_form.htm";
}else{
	urlvar = userReg.arguments[0];
}
if (document.all) {
  x = window.screenLeft;
  y = window.screenTop;
}
else if (document.layers) {
  x = window.screenX;
  y = window.screenY;
}
if (ur && ur.open && !ur.closed){
	ur.focus();
}else{
	ur=window.open(urlvar,'','width=500,height=550,status=no,resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,top='+y+',screenY='+y+',left='+x+',screenX='+x);
	ur.focus();
}
}

var ea=null;
function emailAlert(reg){
var x = 0, y = 0; // default values

if (document.all) {
  x = window.screenLeft;
  y = window.screenTop;
}else{
	 if (document.layers) {
	  x = window.screenX;
	  y = window.screenY;
	}
}
if (ea && ea.open && !ea.closed){
	ea.focus();
}else{
	ea=window.open(reg,'','width=500,height=400,status=no,resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,top='+y+',screenY='+y+',left='+x+',screenX='+x);
	ea.focus();
}
}

// Previous link
function prev_page() {
	if (history.length > 0)
	{history.back()}
} 

// Terms and conditions
var Issued = "© 2002 Issued in the UK by HSBC Asset Management (Hong Kong) Limited. Regulated by the Financial Services Authority."

var selVisibility="visible";
var selDisplay="block";

function showLayer(myLayer,myLayers,myArea){
// alert("showLayer " + myLayer + " " + myLayers + " " + myArea);

	var myAreaRef = myArea;
	var mySwitch = 'off';
	if (myLayer == 1){
		mySwitch = 'on';
	}
	switchLayer(myAreaRef,mySwitch);
	
	var i = 1;
	while (i < myLayers ){
		// alert(myLayer);
		mySwitch = 'off';
		myAreaRef = myArea + i;
		if (i == (myLayer - 1)){
			mySwitch = 'on';
		}
		switchLayer(myAreaRef,mySwitch);
		
		i++;
	}
}

function switchLayer(myAreaRef,mySwitch){
// alert("myAreaRef: " + myAreaRef + "mySwitch " + mySwitch);

if (mySwitch == "on"){
	// alert("on");
	document.getElementById(myAreaRef).style.visibility="visible";
	document.getElementById(myAreaRef).style.display="block";
}
else
{
	// alert("off");
	document.getElementById(myAreaRef).style.visibility="hidden";
	document.getElementById(myAreaRef).style.display="none";
}
}

function transitionWindow(url){
	// alert(url);
	
	window.open(url,"def","Height=300,width=400");
}

function editWindow(url){
	// alert(url);
	
	//window.open(url,"def","Height=600,width=600");
	window.location=url;
}

var dm = new Array()
dm['HSBC Monthly Income Inc'] = ['HSBC Monthly Income Inc', 'MDMI']
dm['HSBC Income Inc'] = ['HSBC Income Inc','CPINC']
dm['HSBC UK Growth & Income Inc']  = ['HSBC UK Growth & Income Inc', 'CPUKII'] 
dm['HSBC Balanced Inc']  = ['HSBC Balanced Inc', 'MDBAL']
dm['HSBC Corporate Bond Inc']  = ['HSBC Corporate Bond Inc','MDCRP']
dm['HSBC Gilt & Fixed Interest Inc']  = ['HSBC Gilt & Fixed Interest Inc','MDGFI']
dm['HSBC Household Names Inc']  = ['HSBC Household Names Inc','MDHSE']
dm['HSBC British Inc']  = ['HSBC British Inc','MDBT']
dm['HSBC UK Growth Inc']  = ['HSBC UK Growth Inc','CPCAP']
dm['HSBC UK Smaller Companies Inc']  = ['HSBC UK Smaller Companies Inc','CPUKSM']
dm['HSBC American Growth Inc']  = ['HSBC American Growth Inc','CPNA']
dm['HSBC Asian Inc']  = ['HSBC Asian Inc','CPFESS']
dm['HSBC European Growth Inc']  = ['HSBC European Growth Inc','CPESS']
dm['HSBC Hong Kong Growth Inc']  = ['HSBC Hong Kong Growth Inc','WAHK']
dm['HSBC Japan Growth Inc']  = ['HSBC Japan Growth Inc','WAJG']
dm['HSBC Japanese Smaller Companies Inc']  = ['HSBC Japanese Smaller Companies Inc','WAJSC']
dm['HSBC FTSE 100 Index Fund Inc']  = ['HSBC FTSE 100 Index Fund Inc','MDFTOD']
dm['HSBC FTSE 250 Index Fund Inc']  = ['HSBC FTSE 250 Index Fund Inc','CPFTI']
dm['HSBC FTSE All Share Index Fund Inc']  = ['HSBC FTSE All Share Index Fund Inc','CPUKI']
dm['HSBC American Index Inc']  = ['HSBC American Index Inc','CPAI']
dm['HSBC European Index Inc']  = ['HSBC European Index Inc','CPEI']
dm['HSBC Japan Index Inc']  = ['HSBC Japan Index Inc','CPJI']
dm['HSBC Pacific Index Inc']  = ['HSBC Pacific Index Inc','CPPI']

function openChart(identifier){
var url = "http://webfund5.finexprestel.com/hsbc/ameuchart.wsp?";
var arg1 = "ameuref=true"
var arg2 = "&refCode=" + dm[identifier][1]
var arg3 = "&refName=" + escape(dm[identifier][0])

url = url + arg1 + arg2 + arg3
openWindow(url, 'Chart', 'win_f')
}

function showMe(fund,iType){
	var iUrl = "http://illustration.keydata.tv/servlet/uk.keydata.satellite.HSBCServlet?fund=" + fund + "&wrapper=oeic&type=" + iType;
	openWindow(iUrl,'CSI','win_i');
	}

var multif=null;
function MultiFiles(filename){
	if (multif && multif.open && !multif.closed){
		multif.close();
	}
		multif = window.open(filename,'popup','width=400,height=120,status=yes');
		multif.focus();
}
var cf = null;

function switchCommonContent(winUrl) {
	// alert(application);
	// alert(winUrl);
	var position = winUrl.indexOf("/",23);
	
	//  alert(position);
	// /imuk/generated/pages/imuk/
	// /imi/generated/pages/imi/
	var newLocation = "/" + application + "/generated/pages/" + application + "" + winUrl.substring(position,winUrl.length);
	window.location =  newLocation;
	// alert(newLocation);
}

function setJourney(path) {
	setCookie("path",path,null,"/");
	
	// alert("Setting " + path);
}

function showJourneyLHS()
{
	var path = getCookie("path");
	// alert("Now entering " + path);
}

/* this script requires the tacObjects.js script to be available
*  as it calls the array aTacs found there 
*/ 
function redirectMe(){
	tacPage = ""; //variable for the associated TAC page to the current URL
	areaNumber = null ; //declare the area value for the iteration
	var mylocation = document.location.href ; //get the current location
	
	var isQuestionmark = mylocation.indexOf("?"); //is there a questionmark
	cookieName = "TACAgree" ; //Cookie name
	
	if ( isQuestionmark != -1){ // true if the charater ? exists in the URL.Used to remove any request params
		var arrayMyLocation = mylocation.split("?") ;
		mylocation = arrayMyLocation[0] ;
	}
	
	// This if statement excludes the terms and conditions page
	// alert(termsConditionsExclusion);
		
	// alert(mylocation);
	if (termsConditionsExclusion.test(mylocation)){
		// alert("break");
		return;
	}	
		
	//loop through the aTacs array looking for matches for the current URL
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
		//test if the RexExp variable matches the string mylocation
		if( aTacs[ii].tacRegEx.test( mylocation ) ) {
			tacPage = aTacs[ii].tacPath ;
			areaNumber = ii ;
			//alert("tacPage =" +tacPage) ;
			break ;
		}
	}
	
	//having got the tacPage if one exists, decide whether we need to go there by examining the cookie data
	var tacCookieVal = getCookieValue() ;
	
	//no cookie exists so we send them to the TAC page to have one generated	
	if ( tacCookieVal == "" && tacPage != ( null || "" )){
		var tacPageWithParams ;
		if ( mylocation.indexOf( "generated" )  != -1 ){ //do we need to slice
			// alert("make relative for TeamSite");
			tacPageWithParams = tacPage + "?srcpage=" + mylocation.slice( mylocation.indexOf( "generated" ) ) ;
		}else{
			tacPageWithParams = tacPage + "?srcpage=" + mylocation  ;
		}

		// alert("redirectMe()>1> no cookie and a tacPage has been assigned,\ngoing to tacPageWithParams: " + tacPageWithParams) ;
		document.location.href =  tacPageWithParams  ;
	}else{
		//create an array of the areas in the cookie
		var arrayCrumbs = tacCookieVal.split("::") ;
		//alert("redirectMe()>> areaNumber: " + areaNumber + "\n" + "arrayCrumbs.length: " + arrayCrumbs.length + "\n" + "tacPage:" + tacPage );
		
		//check to see whether the area has been accepted
		//sanity check
		if ( areaNumber != null && arrayCrumbs.length > 0 ){
			//if the cookie info is false go to tacPage remembering to add the srcpage parameter
			if ( arrayCrumbs[ areaNumber ] != "true" ){
				var tacPageWithParams = tacPage + "?srcpage=" + mylocation ;
				//alert( "redirectMe()>3> going to: " + tacPageWithParams ) ;
				document.location.href = tacPageWithParams ;
			}else{//if they have already seen the TAC
				//alert("redirectMe()>4> already seen the tac as  arrayCrumbs[ areaNumber ] = " +  arrayCrumbs[ areaNumber ]) ;
			}
		}
	}
}//end of redirectMe

/* returns the string value of a cookie and removes the session id
*   if any is present
*/
function getCookieValue() {
//alert("getCookieValue() >> pre-cookie check: " +  document.cookie ) ;
  var search = "TACAgree=" ;
  var returnString = "";
  if (document.cookie.length > 0) {
    var offset = document.cookie.indexOf(search)
    // check to see if cookie exists
    if (offset != -1) { 
      offset += search.length
      //set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value avoiding sessionId
      if (end == -1){
      	end = document.cookie.length;
      } 
      returnString=unescape(document.cookie.substring(offset, end)) ;
    }
  	//alert( "getCookieValue>> returnString is " + returnString );
  	return returnString ;
  }else{ 
  	//alert( "getCookieValue>> cookie length == 0, so returning an empty string");
      return "" ;
  }
}//end of getCookieValue

/* sets the appropriate cookie when the user
*   accepts the T and Cs
*/
function acceptTACsXXX(){
	//set location of referrer page
	var originPage = document.referrer ;
	
	//if document.referrer is empty (MSIE6) use the parameter provided
	if ( originPage == ( null || "" ) ){
		var qString = document.location.search ;
		if ( document.location.href.indexOf( "generated" )  != -1 ){ //do we need to slice
			var firsthalf = document.location.href.split( "generated" )[0] ;
			//var aQuerySplit = qString.split("=") ;
			//originPage = firsthalf + aQuerySplit[1] ;
			originPage = firsthalf + qString.substring(qString.indexOf('='));
			//alert("acceptTACs()>1> originPage: " + originPage ) ;
		}else{
			//originPage =  qString.split("=")[1] ;
			originPage = qString.substring(qString.indexOf('='));
			//alert("acceptTACs()>2> originPage: " + originPage ) ;
		}
	}//end of MSIE workaround
	
	//loop through the aTacs array looking for matching area to the origin url
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
		if( aTacs[ii].tacRegEx.test( originPage ) ) {
			tacPage = aTacs[ii].tacPath ;
			areaNumber = ii ;
			break ;
		}
	}

	//get Cookie
	var strNewCookieVal = getCookieValue() ;
	//create an array of the areas in the cookie
	var arrayNewCrumbs = strNewCookieVal.split("::") ;
	var strUpdatedCrumbs = "" ;
	//now loop through and set this area to true leaving the others alone if they are undefined
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
	    if ( ii != areaNumber ){
	    	//not our area so leave alone but correct undefined/null errors
	    	if ( arrayNewCrumbs[ii] == ( "true" || "false" ) ){
	    		strUpdatedCrumbs += arrayNewCrumbs[ii] ;
		}else{
			strUpdatedCrumbs += "false" ;
		}  	
	    }else{
	    	strUpdatedCrumbs += "true" ;
	    }
	    //alert("acceptTACs()>> aTacs.length " + (aTacs.length-1) + "\n" + "ii " + ii ) ;
	    //append 
	    if ( ii < ( aTacs.length-1 ) ){
	        strUpdatedCrumbs += "::" ;	
	    } 
	}
	//set cookie and return to the refering page
	var finalCookieString = "TACAgree=" +  escape( strUpdatedCrumbs ) + "; path=/;"  ;
	document.cookie = finalCookieString ;
	document.location.href = originPage ;
}//end of acceptTACs

/********************************************
* TD1934:RET: End copied from common javascript 
********************************************/	


// used in function redirectMe()
// rebrand changes 2008
// var termsConditionsExclusion= new RegExp(/site\/index|\/tandc|site\/[Ll]ogin|site\/404/);
var termsConditionsExclusion= new RegExp(/site\/index|\/tandc|site\/[Ll]ogin|\/404/);

// the RegExp variable "tacTegEx" is a string-ish type but with certain differences,
// the variable is not quoted(' or ") and is surrounded by a forward 
// slash (e.g./matcher/). Forward slashes (/) and other special characters used
// by regular expressions should be escaped by adding a back slash (so / is \/)
// in the variable, as shown below

// rebrand08 changes
var siteTac;
var destTac;
var bounceURL;
// build the services tandc url
destTac = location.protocol + "//" + location.host + "/site/services/tandc/index";

// select siteTac based on hostname
switch (location.hostname) {
	case "services.assetmanagement.hsbc.co.je":
		siteTac = "http://www.assetmanagement.hsbc.com/gam/controller.html?tnc=ukInternational?returnurl=" + destTac;
		break;
	case "assetmanagement-uatje.hibm.hsbc":
		siteTac = "http://qa.assetmanagement.hsbc.btctest.com/gam/controller.html?tnc=ukInternational?returnurl=" + destTac;		
		break;
	default:
		siteTac = "http://amiplt01d.uk.hibm.hsbc:7161/bounceback.htm?returnurl=" + destTac;		
		break;
}
// old URL
// var siteTac = "/site/tandc/index";

aTacs = [
	new tac( new RegExp(/site/) , siteTac )
];

/********************************************
* Platform and browser detect variables
********************************************/
var isUnix = false;
var isLinux = false;
var isMacintoshPPC = false;
var isMacintosh68K = false;
var isWindows95 = false;
var isWindows98 = false;
var isWindowsNT= false;
var isWindows3x = false;

var isNew = false;
var isIE = false;
var isIE4 = false;
var isIE5 = false;
var isNetscape = false;
var isNetscape4 = false;
var isNetscape6 = false;

var userAgent = navigator.userAgent.toLowerCase();
var appName = navigator.appName;
var appVersion = parseInt(navigator.appVersion);
var platform = (navigator.platform).substring (0, 5);

// Browser detection
if (appVersion > 5) isNew = true;
else if (appName == "Netscape") {
	isNetscape = true;
  	if (appVersion == 4) isNetscape4 = true;
  	else if (appVersion == 5) isNetscape6 = true;
}
else if (appName == "Microsoft Internet Explorer") {
  	isIE = true;
  	if (appVersion == 4) {
    		isIE4 = true;
    		if (msieversion() == 5) isIE5 = true;
  	}
}

// Platform detection
if ( ( userAgent.indexOf("win95") !=-1) || ( userAgent.indexOf("windows 95") !=-1) ) isWindows95 = true;
if ( ( userAgent.indexOf("win98") !=-1) || ( userAgent.indexOf("windows 98") !=-1) ) isWIndows98 = true;
if ( ( userAgent.indexOf("winnt") !=-1) || ( userAgent.indexOf("windows nt") !=-1) ) isWindowsNT= true;
if ( ( userAgent.indexOf("win16") !=-1) || ( userAgent.indexOf("windows 3.1") !=-1) ) isWindows3x = true;
if ( navigator.appVersion.indexOf("Mac") != -1 ) {
  if ( userAgent.indexOf("pc)") !=-1 ) isMacintoshPPC = true;
  else isMacintosh68K = true;
}
if ( platform == "SunOS" ) isUnix = true;
else if ( platform == "HP-UX" ) isUnix = true;
else if ( platform == "IRIX " ) isUnix = true;
else if ( ( ( navigator.platform ).substring (0, 3) ) == "AIX" ) isUnix = true;
else if ( userAgent.indexOf("linux") != -1 ) isLinux = true;

// Added by Chris to support existing hsbc functions
if(isIE || isIE4 || isIE5) ie=true;
else ie=false;
if(isMacintoshPPC || isMacintosh68K) mac=true;
else mac=false;
if(isWindowsNT) nt=true;
else nt=false;
if(isUnix || isLinux) unix=true;
else unix=false;
if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("5.5") != -1) ie5_5=true;
else ie5_5=false;

var disc=null;
var selVisibility="visible";
var selDisplay="block";

/********************************************
* Generic functions
********************************************/

function msieversion() {
  	var ua = window.navigator.userAgent
  	var msie = ua.indexOf ( "MSIE " )
  	if ( msie > 0 ) return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
  	else return 0;
}

//MakeLayout("document",widthMin,widthMax,widthMaxClient);
function MakeLayout(){	
	if(document.getElementById){
    		var id = 'document';
    		// SetWidth(id,(widthMin - 30),(widthMax - 30),widthMaxClient);
    		// alert("test");
    		// onresize=function(){ SetWidth(id,minr,maxw,maxr);}
    	}
}

function SetWidth(id,a,b,c){	
	// alert(id);
	var w=getBrowserWidth();
	if(w==0) return;
	var el=document.getElementById(id);
	el.style.margin="0 auto";
	var d=el.style;
	if(w<=a) d.width=a+"px";
	else if(w>=c) d.width=b+"px";
	else{
    		var m=(b-a)/(c-a);
    		d.width=parseInt(m*w+a*(1-m))+"px";
   	}
}

function getBrowserWidth(){
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth!=0)
    		return document.documentElement.clientWidth;
	else if (document.body) return document.body.clientWidth;
	return 0;
}
/********************************************
* This preloads the images. See the body tag for the syntax to do this for an image
********************************************/
function imageLoad() {
        if (document.images) {
                var imgFiles = imageLoad.arguments;
                if (document.preloadArray==null) document.preloadArray = new Array();
                var i = document.preloadArray.length;
                with (document) for (var j=0; j<imgFiles.length; j++){
                        preloadArray[i] = new Image;
                        preloadArray[i++].src = imgFiles[j];
                } 
        }
}

function swapImage(layerStem,imageSpace,imageName) {
	var ns4 = (document.layers)? true:false;
  	var ie4 = (document.all)? true:false;
   	if(!ie){ 
   		if(layerStem == ""){imageObj = document.images[imageSpace];}
        	else
        	{imageObj = eval(layerStem+".document.images[imageSpace]");}
      	}
   	if(ie){imageObj = document.all[imageSpace]}

        imageObj.src = imageName;
}


/********************************************
* Used for selecting window size
********************************************/
function openWindow(winUrl, winName, properties) {

	var features;
	var disclaimer;

	switch (properties) {

   case "win_a":
	     features  = "scrollbars,menubar,location,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10";
		  break;	   
   case "win_external_site":
        features = "scrollbars,menubar,location,toolbar,resizable,HEIGHT=600,WIDTH=800,TOP=10,LEFT=10";
 		  break
   case "win_b":
        features = "HEIGHT=250,WIDTH=445,TOP=10,LEFT=10";
  		  break
   case "win_b_no_scroll":
        features = "HEIGHT=470,WIDTH=525,TOP=10,LEFT=10";
    	  break
   case "win_c":
        features = "HEIGHT=241,WIDTH=550,TOP=10,LEFT=10";
        break
   case "win_c_no_scroll":
        features = "HEIGHT=555,WIDTH=570,TOP=0,LEFT=0";
        break
	case "win_d":
   	  features = "HEIGHT=180,WIDTH=700,TOP=20,LEFT=20";
   	  break
	case "win_e":
        features = "HEIGHT=280,WIDTH=603,TOP=10,LEFT=10";
        break
	case "win_e_1":
        features = "HEIGHT=250,WIDTH=603,TOP=10,LEFT=10";
        break	
   case "win_e_2":
        features = "HEIGHT=293,WIDTH=603,TOP=10,LEFT=10";
        break
	case "win_e_3":
        features = "HEIGHT=308,WIDTH=603,TOP=10,LEFT=10";
        break
	case "win_e_4":
        features = "HEIGHT=380,WIDTH=603,TOP=10,LEFT=10";
        break
	case "win_e_5":
        features = "HEIGHT=395,WIDTH=620,scrollbars=yes,TOP=10,LEFT=10";
        break
	case "win_f":
        features = "scrollbars, HEIGHT=600,WIDTH=800,TOP=20,LEFT=20";
        break
   case "win_g":
        features = "HEIGHT=100,WIDTH=300,TOP=250,LEFT=250";
			break
	case "win_h":
        features = "HEIGHT=250,WIDTH=430,TOP=10,LEFT=10";
	     break
	case "win_i":
      features = "HEIGHT=700,WIDTH=700,TOP=5,LEFT=5";
      break
	case "win_j":
      features = "HEIGHT=108,WIDTH=298,TOP=10,LEFT=10";
      disclaimer = "../../disclaimers/disclaimer.htm";
	   break
	case "win_u":
	  	features = "scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10";
		disclaimer = "../../disclaimers/disclaimer.htm";
		break
	case "win_v":
	  	features = "scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10";
		disclaimer = "../../../disclaimers/disclaimer.htm";
		break
	case "win_x":
	  	features = "scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10";
		break
	case "win_y":
	  	features = "scrollbars,menubar,toolbar,resizable,HEIGHT=500,WIDTH=700,TOP=10,LEFT=10";
	     disclaimer = "../../../disclaimers/disclaimer.htm";
		break
    default:
         features = properties;
    }

	if (winName != ""){
		//the line is duplicated as otherwise get automation errors when opening pdfs
 		 window.open("/blank.htm",winName,features);
		 newWindow = window.open("/blank.htm",winName,features);
 		 //td1653-brokessl window.open("about:blank",winName,features);
		 //td1653-brokessl newWindow = window.open("about:blank",winName,features);
	  if(window.focus)
	  {
		  	newWindow.focus();
	  }
  	  if(winUrl != "")
			newWindow.location.href = winUrl;
	 }
	else{
	  	if(winUrl != "")
		  	newwindow= window.open(winUrl,"",features);
	}		
   if (disclaimer){
    	  	showDisclaimer(disclaimer);
 	}
}


/********************************************
* Closes the current window
********************************************/
function windowClose(){
	window.close();
}

/********************************************	
* This closes a window	
********************************************/
function closeWindow() 
{
	window.opener.focus();
	window.close();
}

/********************************************
* name - name of the cookie
* value - value of the cookie
* [expires] - expiration date of the cookie (defaults to end of current session)
* [path] - path for which the cookie is valid (defaults to path of calling document)
* [domain] - domain for which the cookie is valid (defaults to domain of calling document)
* [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
* * an argument defaults when it is assigned null as a placeholder
* * a null placeholder is not required for trailing omitted arguments
********************************************/
function setCookie(name, value, expires, path, domain, secure) {
  	var curCookie = name + "=" + escape(value) +
     	((expires) ? "; expires=" + expires.toGMTString() : "") +
      	((path) ? "; path=" + path : "") +
      	((domain) ? "; domain=" + domain : "") +
      	((secure) ? "; secure" : "");

  	document.cookie = curCookie;
}

/********************************************
* name - name of the desired cookie
* * return 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 argItems () {
	if (argItems.arguments[0]==null||argItems.arguments[0]==""){
	r=location.search.slice(1);
	}else{
		theArgName=argItems.arguments[0];
		sArgs = location.search.slice(1).split('&');
		r = '';
		for (var i = 0; i < sArgs.length; i++) {
			theVal = sArgs[i].split('=');
			if(theVal[0]== theArgName){
				r=theVal[1];
	        	}
	    	}
	}
	return (r.length > 0 ? unescape(r) : '')
}

function showDisclaimer(disclaimer){
	var x = 0, y = 0; // default values
	if (document.all) {
		x = window.screenLeft;
	  	y = window.screenTop;
	}else{
		if (document.layers) {
	 		x = window.screenX;
		   	y = window.screenY;
		}
	}
	if (disc && disc.open && !disc.closed){
		disc.focus();
	}else{
		x+=180;
		y+=150;
		disc=window.open(disclaimer,'','HEIGHT=250,WIDTH=430,status=no,resizable=no,toolbar=no,menubar=no,location=no,scrollbars=no,top='+y+',screenY='+y+',left='+x+',screenX='+x);
		disc.focus();
	}
}
		
/********************************************
* Previous link
********************************************/
function prev_page() {
	if (history.length > 0)
	{history.back()}
} 

function showLayer(myLayer,myLayers,myArea){
	var myAreaRef = myArea;
	var mySwitch = 'off';
	if (myLayer == 1){
		mySwitch = 'on';
		
	}
	switchLayer(myAreaRef,mySwitch);
	
	var i = 1;
	while (i < myLayers ){
		// alert(myLayer);
		mySwitch = 'off';
		myAreaRef = myArea + i;
		if (i == (myLayer - 1)){
			mySwitch = 'on';
		
		}
		switchLayer(myAreaRef,mySwitch);
		i++;
	}
}

function switchLayer(myAreaRef,mySwitch){
	if (mySwitch == "on"){
		document.getElementById(myAreaRef).style.visibility="visible";
		document.getElementById(myAreaRef).style.display="block";
	}else{
		document.getElementById(myAreaRef).style.visibility="hidden";
		document.getElementById(myAreaRef).style.display="none";
	}
}

function transitionWindow(url){	
	window.open(url,"def","Height=300,width=400");
}

function editWindow(url){
	window.location=url;
}

//function switchCommonContent(winUrl) {
//	var position = winUrl.indexOf("/",23);
//	var newLocation = "/" + application + "/generated/pages/" + application + "" + winUrl.substring(position,winUrl.length);
//	window.location =  newLocation;
//}

function setJourney(path) {
	setCookie("journeypath",path,null,"/");
}

function showJourneyLHS(){
	var path = getCookie("journeypath");
}


/********************************************
* returns the string value of a cookie and removes the session id
*   if any is present
*******************************************/
function getCookieValue() {
	//alert("getCookieValue() >> pre-cookie check: " +  document.cookie ) ;
  	var search = "TACAgree=" ;
  	var returnString = "";
  	if (document.cookie.length > 0) {
    		var offset = document.cookie.indexOf(search)
    		// check to see if cookie exists
    		if (offset != -1) { 
      			offset += search.length
      			//set index of beginning of value
      			end = document.cookie.indexOf(";", offset);
      			// set index of end of cookie value avoiding sessionId
      			if (end == -1){
      				end = document.cookie.length;
      			} 
      		returnString=unescape(document.cookie.substring(offset, end)) ;
    	}
  	return returnString ;
  	}else{ 
      		return "" ;
  	}
}//end of getCookieValue

/********************************************
* sets the appropriate cookie when the user
*   accepts the T and Cs
*******************************************/
function acceptTACs(){
	var splitString = "site" ;
	var currentLoc = document.location.href ;
	var splitIndex = currentLoc.indexOf("/", 9 );
	var currentWebApp = currentLoc.substring(0, splitIndex);
	//we cannot split by = and only use [1] as this ignores any appended parameters
	//var paramLoc = document.location.search.split("=")[1] ;
	var paramLoc = document.location.search.substring(document.location.search.indexOf('='));
	var startIndex = 15 ;
	var originPage;
	
	//Amend for the case where no paramLoc parameter is sent through - return to referrer page when set, otherwise stay on same page.
	if (!paramLoc == (null || "")){
		var splitIndexParam = paramLoc.indexOf("/", startIndex ) ;
		var paramPage = unescape( paramLoc.substring(splitIndexParam) ) ;	
		originPage = currentWebApp + paramPage ;
	}else {
		originPage = document.referrer;	
		if ( originPage == ( null || "" ) ){
			originPage=currentLoc;
		}
	}
 

	//loop through the aTacs array looking for matching area to the origin url
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
		if( aTacs[ii].tacRegEx.test( originPage ) ) {
			tacPage = aTacs[ii].tacPath ;
			areaNumber = ii ;
			break ;
		}
	}
	var strNewCookieVal = getCookieValue() ;
	//create an array of the areas in the cookie
	var arrayNewCrumbs = strNewCookieVal.split("::") ;
	var strUpdatedCrumbs = "" ;
	//now loop through and set this area to true leaving the others alone if they are undefined
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
	    if ( ii != areaNumber ){
	    	if ( arrayNewCrumbs[ii] == ( "true" || "false" ) ){
	    		strUpdatedCrumbs += arrayNewCrumbs[ii] ;
		}else{
			strUpdatedCrumbs += "false" ;
		}  	
	    }else{
	    	strUpdatedCrumbs += "true" ;
	    }
	    if ( ii < ( aTacs.length-1 ) ){
	        strUpdatedCrumbs += "::" ;	
	    } 
	}
	//set cookie and return to the refering page
	var finalCookieString = "TACAgree=" +  escape( strUpdatedCrumbs ) + "; path=/;"  ;
	document.cookie = finalCookieString ;
	document.location.href = originPage ;
}//end of acceptTACs


/*
* Sets up the JavaScript Object array for the Terms and Conditions
*/
function tac ( tacRegEx , tacPath ){
	this.tacRegEx =  tacRegEx  ;
	this.tacPath = tacPath ;
}
	
function changeCase(tmpStr) {
	var index;
	var tmpChar;
	var preString;
	var postString;
	var strlen;
	tmpStr = tmpStr.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			}
			else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	return tmpStr;
}

/* this script requires the array aTacs
*/ 
function redirectMe(){
	
	var bodyTag = document.getElementsByTagName("body")[0] ;
	tacPage = ""; //variable for the associated TAC page to the current URL
	areaNumber = null ; //declare the area value for the iteration
	var mylocation = document.location.href ; //get the current location
	cookieName = "TACAgree" ; //Cookie name
	
	
	/****** Removed to ensure that the location parameters are passed in*********	
	var isQuestionmark = mylocation.indexOf("?"); //is there a questionmark
	if ( isQuestionmark != -1){ // true if the charater ? exists in the URL.Used to remove any request params
		var arrayMyLocation = mylocation.split("?") ;
		mylocation = arrayMyLocation[0] ;
	}
	********************************/

	// This if statement excludes the terms and conditions page
	if (termsConditionsExclusion.test(mylocation)){
		//alert("break due to exclusions list");
		bodyTag.style.visibility = 'visible' ;
		return;
	}

	//loop through the aTacs array looking for matches for the current URL
	for ( var ii = 0 ; ii < aTacs.length ; ii++ ){
		//test if the RexExp variable matches the string mylocation
		if( aTacs[ii].tacRegEx.test( mylocation ) ) {
			tacPage = aTacs[ii].tacPath ;
			areaNumber = ii ;
			//alert("tacPage =" +tacPage) ;
			break ;
		}
	}
	
	//having got the tacPage if one exists, decide whether we need to go there by examining the cookie data
	var tacCookieVal = getCookieValue() ;
	var strTeamSiteSplit = "iw-mount" ;
	
	//no cookie exists so we send them to the TAC page to have one generated	
	if ( tacCookieVal == "" && tacPage != ( null || "" )){
		
		var tacPageWithParams ;
		if ( mylocation.indexOf( strTeamSiteSplit )  != -1 ){ //do we need to allow for Teamsite
			// alert("make relative for TeamSite");
			tacPageWithParams = tacPage + "?srcpage=" + escape( mylocation.slice( mylocation.indexOf( strTeamSiteSplit ) ) ) ;
		}else{
			tacPageWithParams = tacPage + "?srcpage=" + escape( mylocation ) ;
		}
		// alert("redirectMe()>1> no cookie and a tacPage has been assigned,\ngoing to tacPageWithParams: " + tacPageWithParams) ;
		//bodyTag.style.visibility = 'hidden' ;
		//alert("redirect 1") ;
		document.location.href =  tacPageWithParams  ;
		return
	}else{
		//create an array of the areas in the cookie
		var arrayCrumbs = tacCookieVal.split("::") ;
		//check to see whether the area has been accepted
		if ( areaNumber != null && arrayCrumbs.length > 0 ){
			//if the cookie info is false go to tacPage remembering to add the srcpage parameter
			if ( arrayCrumbs[ areaNumber ] != "true" ){
				var tacPageWithParams = tacPage + "?srcpage=" + escape( mylocation ) ;
				document.location.href = tacPageWithParams ;
				return ;
			}else{//if they have already seen the TAC
				bodyTag.style.visibility = 'visible' ;
				//alert("alright") ;
				return ;
				//alert("redirectMe()>4> already seen the tac as  arrayCrumbs[ areaNumber ] = " +  arrayCrumbs[ areaNumber ]) ;
			}
		}else{
			bodyTag.style.visibility = 'visible' ;
		}
	}
}//end of redirectMe

function toggleView(theObject) {
	parentObj = theObject.id + "Parent";

	if (document.all) {
		if (document.all[parentObj].className == "parentUp") {
			document.all[parentObj].className = "parentDown";
			theObject.className = "shownItems";
		}else {
			document.all[parentObj].className = "parentUp";
			theObject.className = "collapsed";
		}
	}else{
		if (document.getElementById) {
			if (document.getElementById(parentObj).className == "parentUp") {
				document.getElementById(parentObj).className = "parentDown";
				theObject.className = "shownItems";
			}else {
				document.getElementById(parentObj).className = "parentUp";
				theObject.className = "collapsed";
			}
		}
	}	
}

function mOnClick(theObject) {
	if (Open == "") { Open = theObject; }
	if (document.all) {
		if (Open != theObject) {
			document.all[Open].className = "collapsed";
			Open = theObject;
		}
		if (document.all[theObject].className == "shownItems") { 
			document.all[theObject].className = "collapsed"; 
		}else { 
			document.all[theObject].className = "shownItems"; 
		}
	}else {
		if (document.getElementById) {
			if (Open != theObject) {
				document.getElementById(Open).className = "collapsed";
				Open = theObject;
			}
			if (document.getElementById(theObject).className == "shownItems") { 
				document.getElementById(theObject).className = "collapsed"; 
			}else { 
				document.getElementById(theObject).className = "shownItems"; 
			}
		}
	}
}

function mSubOnClick(theObject) {
	if (OpenSub == "") { OpenSub = theObject; }

	if (document.all) {
		if (OpenSub != theObject) {
			document.all[OpenSub].className = "collapsed";
			OpenSub = theObject;
		}
		if (document.all[theObject].className == "shownItems") { 
			document.all[theObject].className = "collapsed"; 
		} else {
			document.all[theObject].className = "shownItems"; 
		}
	}else {
		if (document.getElementById) {
			if (OpenSub != theObject) {
				document.getElementById(OpenSub).className = "collapsed";
				OpenSub = theObject;
			}
			if (document.getElementById(theObject).className == "shownItems") { 
				document.getElementById(theObject).className = "collapsed"; 
			} else {
				document.getElementById(theObject).className = "shownItems"; 
			}
		}
	}
}
function mBSubOnClick(theObject) {
	if (OpenBSub == "") { OpenBSub = theObject; }
	if (document.all) {//a
		if (OpenBSub != theObject) {//b
			document.all[OpenBSub].className = "collapsed";
			OpenSub = theObject;
		}//end b
		
		if (document.all[theObject].className == "shownItems") { //c
			document.all[theObject].className = "collapsed"; }
		else { //c
			document.all[theObject].className = "shownItems"; 
		}//end c
	}//end a
	else{//d
		if (document.getElementById) {//e
			if (OpenBSub != theObject) {//f
				document.getElementById(OpenBSub).className = "collapsed";
				OpenSub = theObject;
			}//end f

			if (document.all(theObject).className == "shownItems") { //g
				document.getElementById(theObject).className = "collapsed"; 
			}else { 
				document.getElementById(theObject).className = "shownItems"; 
			}//end g

		}//end e
	}//end d
}//end function

function expandAll(){
	var allTabs=document.getElementsByTagName('TABLE');
	for (i=0;i<allTabs.length;i++){
		if (allTabs.item(i).className=="collapsed"){
			allTabs.item(i).className = "shownItems";
		}
	}
}
function collapseAll(){
	var allTabs=document.getElementsByTagName('TABLE');
	for (i=0;i<allTabs.length;i++){
		if (allTabs.item(i).className=="shownItems"){
			allTabs.item(i).className = "collapsed";
		}
	}
}
function selectTable(table){
	if (table == "ALL"){
		expandAll();
	}else{
		collapseAll();		
		mOnClick(table);
	}
}

/********************************************
*   Process the accept or decline of the
*   terms and conditions form
*******************************************/
function processTerms2( newLocation ){
	var myAccept = document.getElementById("optionAccept");
	var myDecline = document.getElementById("optionDecline");
	if ( myAccept.checked == myDecline.checked){
		alert("Please 'DECLINE' or 'ACCEPT' the terms!");
	}
	else{
		if(myAccept.checked){
			acceptTACs();
		}else{
			window.location = newLocation;
		}
	}
}

function processTerms( ){
	processTerms2( '/site/index' );
}

// Start functions for secure home page

	function setCookieAndOpenWindow(site,openLocation)
	{
		document.cookie = "sr_tc_accept=true; path=/;";
		
		// Open window with securities research page
		
		openSecuritiesResearchWindow(openLocation);
		
		//
		
		var f = document.getElementById("sr_tc_accept_form");
		f.action = "/site/client/secure/research/index";
		f.submit();
	}

	function returnToSecureHome(site)
	{
		var f = document.getElementById("sr_tc_accept_form");
		f.action = "/site/client/secure/index";
		f.submit();
	}

	function openSecuritiesResearchWindow(url)
	{
		var w;
		w = window.open(url,"HSBCSR","scrollbars=yes, status=yes, toolbar=yes, menubar=yes, location=yes, width=800, height=600, resizable=yes",true);
		w.focus();
	}

// End functions for secure home page

// Start functions for login page

	function lowerIt()
	{
		var un = document.getElementById("j_username");
		var pw = document.getElementById("j_password");
		
		un.value = un.value.toLowerCase()
		pw.value = pw.value.toLowerCase()
		
		return true;
	}

// End functions for login page

// in javascript.js
//function MM_goToURL() { //v3.0
//  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
//  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
//}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;
  
  for (i=0; i<(args.length-2); i+=3) {
  	if ((obj=MM_findObj(args[i]))!=null) { 
  		v=args[i+2];
    		if (obj.style) { 
    			obj=obj.style; 
    			v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
    		}
    		obj.visibility=v; 
    	}
    }
    
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//TEMP ADDED UNTIL FUNCTION IN COMMON JAVASCRIPT.JS
function component_49_search_submit(searchform) {
	var qs = "" + searchform.search.value;
	qs = qs.replace(/\s{2,}/g, " ").replace(/^\s{1,}/, "").replace(/\s{1,}$/, "");  // eliminate multiple spaces, trim leading and trailing whitespace
	//alert("Search field is '" + qs + "'");
	if (qs == "") {
		return false;
	} else {
		searchform.search.value = qs;
		return true;
	}
} 


/************************************************
* Code run on every page to set the country tag
* for WebTrends
************************************************/
try {
	if (HSBC) {
		HSBC.EXT.inv_country = "International";
	}
} catch(e) {
	// nothing;
}