/*********************************************
* TD941:RET:Below copied from common javascript 
**********************************************/

/********************************************
* 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";
var aTacs = [] ;

/********************************************
* 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();
	}
}
		
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]+"'");
}

/********************************************
* Previous link
********************************************/
function prev_page() {
	if (history.length > 0)
	{history.back()}
} 

function makeBabies(withMe){
	//alert("making babies with " + withMe);
	var does_exist = true;
	var baby_val = 0;
	var my_baby = "";

	//Now we must open the immediate offspring of this selection.
	while(does_exist){
		baby_val++;
		my_baby = withMe + "." + baby_val;
		if (!document.getElementById(my_baby) || document.getElementById(my_baby)==null||document.getElementById(my_baby)=="undefined"){
			does_exist=false;
		}else{
			document.getElementById(my_baby).style.visibility=selVisibility;
			document.getElementById(my_baby).style.display=selDisplay;
		}
	}

}

function informBrothers(myBruvva){
	//alert("informing brothers of " + myBruvva);
	var does_exist = true;
	var bruvva_val = 0;
	var my_bruvva = "";

	//Now we must open the brothers of this selection
	while(does_exist){
		bruvva_val++;
		my_bruvva = myBruvva + "." + bruvva_val;
		if (!document.getElementById(my_bruvva) || document.getElementById(my_bruvva)==null||document.getElementById(my_bruvva)=="undefined"){
			does_exist=false;
		}else{
			document.getElementById(my_bruvva).style.visibility=selVisibility;
			document.getElementById(my_bruvva).style.display=selDisplay;
		}
	}

}

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 splitIndexParam = paramLoc.indexOf("/", startIndex ) ;
	var paramPage = unescape( paramLoc.substring(splitIndexParam) ) ;	
	var originPage = currentWebApp + paramPage ;

/*
	alert("acceptTACs\r\n"
		+"currentWebApp=" + currentWebApp + "\r\n" 
		+"paramLoc=" + paramLoc + "\r\n" 
		+"startIndex" + startIndex +"\r\n"
		+"splitIndexParam=" + splitIndexParam + "\r\n" 
		+"paramPage=" + paramPage + "\r\n" 
		+"originPage=" + originPage + "\r\n" 
	) ;
*/

	//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 ;
}
	

/********************************************
* TD914:RET: End copied from common javascript 
********************************************/	
			
					



//Constants showing which tool to open
var TOOL_OVERVIEW = 'overview';
var TOOL_ILLUSTRATION  = 'illustration';	// used in function illustration(code)
var TOOL_REASONSWHY = 'reasonswhy';
var TOOL_CHART = 'charts';
var svWindow = null;

var ls = "levelSelecter";			// used in function menuMake(sId)

var FOFdm = new Array()				// used in function openFOFChart(identifier)
FOFdm['OGGFGBP'] = ['HSBC Global Grth Fund of Funds Inc', 'MDGGI']
FOFdm['OGTHGBP'] = ['HSBC Growth Fund of Funds Inc','MDGFF']
FOFdm['OINCFGBP']  = ['HSBC Income Fund of Funds Inc', 'MDIFF'] 

var FP_INCLUDE_DIR = "/site/include/products_and_prices/";

// rebrand08 changes

// used in function redirectMe()
// var termsConditionsExclusion= new RegExp(/Terms_Conditions|terms_and_conditions|pages\/index|microsites\/t_and_c/);
var termsConditionsExclusion= new RegExp(/services\/tandc|Terms_Conditions|terms_and_conditions|pages\/index|microsites\/t_and_c/);
var destTacHost;
var bounceURL;
var intermediariesTac;
var institutionsTac;
var individualsTac;
var charityTac;
var dcmicro_advisorsTac;
var dcmicro_employersTac;
var dcmicro_membersTac;
var dcmicro_focusTac;

// 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

// select siteTac based on hostname
switch (location.hostname) {
	case "services.assetmanagement.hsbc.co.uk":
		bounceURL = "http://www.assetmanagement.hsbc.com/gam/controller.html?tnc=";
		destTacHost = "?returnurl=" + location.protocol + "//" + location.host;			
		intermediariesTac = bounceURL + "ukAdvisers" + destTacHost + "/site/services/tandc/intermediaries";
		institutionsTac = bounceURL + "ukInstitutions" + destTacHost + "/site/services/tandc/institutions";
		individualsTac = bounceURL + "ukIndividuals" + destTacHost + "/site/services/tandc/individuals";
		//dcmicro_advisorsTac = bounceURL + "ukDcAdvisers" + destTacHost + "/site/services/tandc/dc_advisors";
		//dcmicro_employersTac = bounceURL + "ukDcEmployers" + destTacHost + "/site/services/tandc/dc_employers";
		//dcmicro_membersTac = bounceURL + "ukDcEmployees" + destTacHost + "/site/services/tandc/dc_members";		
		//dcmicro_focusTac = bounceURL + "ukDcFocus " + destTacHost + "/site/services/tandc/dc_focus";
		dcmicro_advisorsTac = "/site/microsites/t_and_c/dc_advisors.html" ;
		dcmicro_employersTac = "/site/microsites/t_and_c/dc_employers.html" ;
		dcmicro_membersTac = "/site/microsites/t_and_c/dc_members.html" ;
		dcmicro_focusTac = "/site/microsites/t_and_c/dc_focus.html" ;
			
		break;
		
	case "assetmanagement-uatuk.hibm.hsbc":
		//bounceURL = "http://amtmst05l:7060/bounceback.htm?returnurl=";
		//bounceURL = "http://qa.assetmanagement.hsbc.btctest.com/uk/default.html?returnurl=";
		bounceURL = "http://qa.assetmanagement.hsbc.btctest.com/gam/controller.html?tnc=";
		destTacHost = "?returnurl=" + location.protocol + "//" + location.host;			
		intermediariesTac = bounceURL + "ukAdvisersQA" + destTacHost + "/site/services/tandc/intermediaries";
		institutionsTac = bounceURL + "ukInstitutionsQA" + destTacHost + "/site/services/tandc/institutions";
		individualsTac = bounceURL + "ukIndividualsQA" + destTacHost + "/site/services/tandc/individuals";
		//dcmicro_advisorsTac = bounceURL + "ukDcAdvisers" + destTacHost + "/site/services/tandc/dc_advisors";
		//dcmicro_employersTac = bounceURL + "ukDcEmployers" + destTacHost + "/site/services/tandc/dc_employers";
		//dcmicro_membersTac = bounceURL + "ukDcEmployees" + destTacHost + "/site/services/tandc/dc_members";		
		//dcmicro_focusTac = bounceURL + "ukDcFocus " + destTacHost + "/site/services/tandc/dc_focus";		
		dcmicro_advisorsTac = "/site/microsites/t_and_c/dc_advisors.html" ;
		dcmicro_employersTac = "/site/microsites/t_and_c/dc_employers.html" ;
		dcmicro_membersTac = "/site/microsites/t_and_c/dc_members.html" ;
		dcmicro_focusTac = "/site/microsites/t_and_c/dc_focus.html" ;
		
		break;
		
	default:
		bounceURL = "http://amtmst05l:7060/bounceback.htm?returnurl=";
		destTacHost = location.protocol + "//" + location.host;		
		intermediariesTac = bounceURL + destTacHost + "/site/services/tandc/intermediaries";
		institutionsTac = bounceURL + destTacHost + "/site/services/tandc/institutions";
		individualsTac = bounceURL + destTacHost + "/site/services/tandc/individuals";
		//dcmicro_advisorsTac = bounceURL + destTacHost + "/site/services/tandc/dc_advisors";
		//dcmicro_employersTac = bounceURL + destTacHost + "/site/services/tandc/dc_employers";
		//dcmicro_membersTac = bounceURL + destTacHost + "/site/services/tandc/dc_members";		
		//dcmicro_focusTac = bounceURL + destTacHost + "/site/services/tandc/dc_focus";
		dcmicro_advisorsTac = "/site/microsites/t_and_c/dc_advisors.html" ;
		dcmicro_employersTac = "/site/microsites/t_and_c/dc_employers.html" ;
		dcmicro_membersTac = "/site/microsites/t_and_c/dc_members.html" ;
		dcmicro_focusTac = "/site/microsites/t_and_c/dc_focus.html" ;
				
		break;
		
}
// old urls
// TD689 
// var intermediariesTac = "/site/microsites/t_and_c/intermediaries.html" ;
// var institutionsTac = "/site/microsites/t_and_c/institutions.html" ;
// var individualsTac = "/site/microsites/t_and_c/individuals.html" ;
// var charityTac = "/site/microsites/t_and_c/charities.html" ;
// var dcmicro_advisorsTac = "/site/microsites/t_and_c/dc_advisors.html" ;
// var dcmicro_employersTac = "/site/microsites/t_and_c/dc_employers.html" ;
// var dcmicro_membersTac = "/site/microsites/t_and_c/dc_members.html" ;

aTacs = [ 	new tac( new RegExp(/Intermediaries\/Public/) , intermediariesTac ),
		new tac( new RegExp(/Institutions\/Public/) , institutionsTac ),
		new tac( new RegExp(/Individuals\/Public/) , individualsTac )
//		new tac( new RegExp(/dcpension\/advisers/) , dcmicro_advisorsTac ),
//		new tac( new RegExp(/dcpension\/employers/) , dcmicro_employersTac ),
//		new tac( new RegExp(/dcpension\/members/) , dcmicro_membersTac ),
//		new tac( new RegExp(/dcpension\/focus/) , dcmicro_focusTac )
	     ] ;
;

// Terms and conditions
/* var Issued = "© 2002 Issued in the UK by HSBC Asset Management (Hong Kong) Limited. Regulated by the Financial Services Authority." */

var cf = null;			// used in function custFact(item,bespokeFundType)
var expanded="expanded";	// used in function answer()
var collapsed="collapsed";
var ur=null;			// used in function userReg()
var urlvar= "";
var ea=null;			// used in function emailAlert(reg)
var multif=null;		// used in function MultiFiles(filename)
var Open = "";			// used in function mOnClick(theObject)
var OpenSub = "";		// used in function mSubOnClick(theObject)
var OpenBSub = "";		// used in function mBSubOnClick(theObject)

var dm = new Array()		// used in function openChart(identifier)
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 Greater China Inc']  = ['HSBC Greater China 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']
dm['HSBC Asia Freestyle A']  = ['HSBC Asia Freestyle A','HZ73']

//GIF codes
dm['WY69'] = ['GIF Asia Ex Japan Eq AC $','WY69']
dm['WY64'] = ['GIF Asia Ex Jap Eq Sm AC $','WY64']
dm['WY75'] = ['GIF Asia Freestyle AC $','WY75']
dm['HZ64'] = ['GIF As Pac ExJap Eq Hi Div AC$','HZ64']
dm['HU41'] = ['GIF Brazil Equity AC $','HU41']
dm['HV93'] = ['GIF BRIC Freestyle M1C $','HV93']
dm['WY59'] = ['GIF Chinese Equity AC $','WY59']
dm['H161'] = ['GIF Emerging Europe Eq AC','H161']
dm['H168'] = ['GIF Euro Corporate Bond AC','H168']
dm['HO26'] = ['GIF Euro Credit Bond AC','HO26']
dm['HZ80'] = ['GIF Euro Inv Gr Corp Bd AC','HZ80']
dm['WY89'] = ['GIF Euro Inv Grade Bd AC','WY89']
dm['WY94'] = ['GIF Euro Reserve AC','WY94']
dm['WY98'] = ['GIF Euroland Eq AC','WY98']
dm['H185'] = ['GIF Euroland Val Creatn M1C','H185']
dm['WY60'] = ['GIF Europe Ex UK Equity AC','WY60']
dm['HO36'] = ['GIF European Hi Yield Bd AC','HO36']
dm['HO41'] = ['GIF Gbl Emg Mkt Bd AC $','HO41']
dm['HO46'] = ['GIF Gbl Emg Mkt Eq AC $','HO46']
dm['H267'] = ['GIF Gbl Equity AC $','H267']
dm['H131'] = ['GIF Global Equity SRI AC $','H131']
dm['HO52'] = ['GIF Gbl Equity Tech AC $','HO52']
dm['HO57'] = ['GIF Gbl Ex Euroland Eq AC','HO57']
dm['HV89'] = ['GIF Gbl Inv Grade Bd AC $','HV89']
dm['HO61'] = ['GIF Gbl Inv Grade Bd Hdgd AC $','HO61']
dm['HO68'] = ['GIF Hong Kong Equity AC $','HO68']
dm['WY58'] = ['GIF Indian Equity AC $','WY58']
dm['HO86'] = ['GIF Japanese Equity AC ¥','HO86']
dm['H249'] = ['GIF Korea Equity AC $','H249']
dm['HQ15'] = ['GIF Pan Eurpn Eq Sm Cyes AC','HQ15']
dm['WY61'] = ['GIF Pan European Eq AC','WY61']
dm['HO97'] = ['GIF Pan Eurpn Govt Bond AC','HO97']
dm['HV97'] = ['GIF Pan Eurpn Eq Hi Div AC','HV97']
dm['HQ18'] = ['GIF Singapore Equity AC $','HQ18']
dm['H259'] = ['GIF Sterling Inv Grade Bd PD £','H259']
dm['DS52'] = ['GIF Thai Equity AC $','DS52']
dm['H228'] = ['GIF Turkish Convergence AC','H228']
dm['HQ28'] = ['GIF UK Equities AC £','HQ28']
dm['HV92'] = ['GIF UK Freestyle M1D £','HV92']
dm['WY57'] = ['GIF US Equity AC $','WY57']
dm['HQ34'] = ['GIF US Dollar Inv Grde Bd AC $','HQ34']
dm['HQ41'] = ['GIF US Dollar Reserve AC $','HQ41']
dm['HQ53'] = ['GIF US Index AC $','HQ53']


function openFactsheet(sFundFactCode)
{

	if(sFundFactCode.indexOf('oasfs')==0){
		var pdf = "/site/media/pdf/Factsheets/OEIC/oasfsGBP.pdf";
		openWindow(pdf,'ib','win_a');
		return;
	}
	
	//if it is uk freestyle, open a pdf... temp fix until we have the data
	if(sFundFactCode.indexOf('oukfs')==0){
		var pdf = "/site/media/pdf/Factsheets/OEIC/oukfsGBP.pdf";
		openWindow(pdf,'ib','win_a');
		return;	
	}
	// end if for asia freestyle cludge

	//added this for those funds without individual fund pages developed (add a 'NO' parm to the function)...
	if (openFactsheet.arguments.length > 1 && openFactsheet.arguments[1]=='NO'){
		return;
	}
	//added fundTabLocation variable to fix ie error parsing entire href as parameter..
	var fundTabLocation = location.href;
	//  sFundFactCode = unescape(sFundFactCode); 

	sFundFactCode=sFundFactCode.replace(/&/,"%26");
	
	fundTabLocation = fundTabLocation.substring(fundTabLocation.indexOf('/site/'));

	var myPublic = "Public";
   	var j = getJourney();

	j=(j=='')?"Intermediaries":changeCase(j);
	if(j.indexOf('harity')>0)
	{
		j="charityservices";
		myPublic = "public";		
	}	

	if(top.location.href.indexOf('Secure/Funds_Prices')>-1) myPublic = "Secure";

	var FS_DIR = "/site/"+j+"/"+myPublic+"/Funds_Prices/Individual_Fund_Pages/";

  	location.href = FS_DIR + "factsheet?fundCode=" + sFundFactCode + "&loc="+ fundTabLocation;
}
//Brian added this for performance data sorting....
function sortTable(sCol,page){
	if(sCol=='name'){
		location.href="landing_page-en-UK.jsp";
  	}else{
		location.href=page+"_"+sCol+"-en-UK.jsp";
  	}
}


function openScatter(sCode)
{
	var now = new Date();
	var windowName = "scWindow" + now.getTime();
	var left = (screen.width-900);
	var top = (screen.height-600);
	if(left<0){
		left=0;
	}else{
		left=left/2;
	}
	if(top<0){
		top=0;
	}else{
		top=top/2;
	}
	var theURL = 'http://webfund5.finexprestel.com/hsbc/scatterchart.wsp';
	var winOptions = 'title=yes,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,copyhistory=no,width=900,height=600,screenX=0,screenY=0,top='+top+',left='+left+',marginwidth=0,marginheight=0';
	eval(windowName +" = window.open('" + theURL + "','ScatterChart','" + winOptions + "')");
	eval(windowName + ".focus()");
}


function illustration(code){
//open up client specific information if we have a valid code, otherwise open up the list we have...

	switch (code) {
	    case "AMGR1":
			openSingleView(3328, 1051,TOOL_ILLUSTRATION);
		    break
	    case "AMIN1":
			openSingleView(3332, 1051,TOOL_ILLUSTRATION);
		    break
	    case "ASGR1":
			openSingleView(3329, 1051,TOOL_ILLUSTRATION);
		    break
	    case "BALN1":
			openSingleView(1261, 1051,TOOL_ILLUSTRATION);
		    break
	    case "BRIT1":
			openSingleView(1729, 1051,TOOL_ILLUSTRATION);
		    break
	    case "CBND1":
			openSingleView(3342, 1051,TOOL_ILLUSTRATION);
		    break
	    case "EUGR1":
			openSingleView(3326, 1051,TOOL_ILLUSTRATION);
		    break
	    case "EUIN1":
			openSingleView(3343, 1051,TOOL_ILLUSTRATION);
		    break
	    case "F1001":
			openSingleView(3344, 1051,TOOL_ILLUSTRATION);
		    break
	    case "F2501":
			openSingleView(3322, 1051,TOOL_ILLUSTRATION);
		    break
	    case "FALL1":
			openSingleView(3323, 1051,TOOL_ILLUSTRATION);
		    break
	    case "GILT1":
			openSingleView(1617, 1051,TOOL_ILLUSTRATION);
		    break
	    case "HKGR1":
			openSingleView(3345, 1051,TOOL_ILLUSTRATION);
		    break
	    case "HOUS1":
			openSingleView(1868, 1051,TOOL_ILLUSTRATION);
		    break
	    case "INCM1":
			openSingleView(3327, 1051,TOOL_ILLUSTRATION);
		    break
	    case "JPGR1":
			openSingleView(3347, 1051,TOOL_ILLUSTRATION);
		    break
	    case "JPIN1":
			openSingleView(3316, 1051,TOOL_ILLUSTRATION);
		    break
	    case "JPSC1":
			openSingleView(3346, 1051,TOOL_ILLUSTRATION);
		    break
	    case "MNTH1":
			openSingleView(1503, 1051,TOOL_ILLUSTRATION);
		    break
	    case "PCIN1":
			openSingleView(3321, 1051,TOOL_ILLUSTRATION);
		    break
	    case "UKGR1":
			openSingleView(3320, 1051,TOOL_ILLUSTRATION);
		    break
	    case "GRIN1":
			openSingleView(3333, 1051,TOOL_ILLUSTRATION);
		    break
	    case "UKSC1":
			openSingleView(3325, 1051,TOOL_ILLUSTRATION);
		    break
	    default:
			var iUrl = "http://illustration.keydata.tv/illustrator/satellite/hsbc/HSBCNewIllustrations.htm";
			openWindow(iUrl,'illus','win_i');
	}
}

function openSingleView(fundID, fmgIndex, tool)
{
	var now = new Date();
	var windowName = "svWindow" + now.getTime();
	var left = (screen.width-523)/2;
	var top = (screen.height-540)/2;
	var theURL = 'http://illustration.keydata.tv/servlet/uk.keydata.cdonline.Login?company=1051&fundid=' + fundID + '&fmgindex=' + fmgIndex + '&action=singleview&view=' + tool;
	var winOptions = 'title=yes,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=no,copyhistory=no,width=523,height=540,screenX=0,screenY=0,top='+top+',left='+left+',marginwidth=0,marginheight=0';
	eval(windowName +" = window.open('" + theURL + "','SingleView','" + winOptions + "')");
	eval(windowName + ".focus()");
}

function menuMake(sId){
	if(document.getElementById(ls)){
		document.getElementById(ls).value=sId;
	}else{
		document.write('<input type=\"hidden\" id=\"'+ls+'\" name=\"'+ls+'\" value=\"'+sId+'\">');
	}
}

function custFact(item,bespokeFundType){
	var filename = "/site/jsp/investment_tools/customised_factsheets/bespokeSelect.jsp?bespokeFund=" + item + "&bespokeFundType="+bespokeFundType;
	if (cf && cf.open && !cf.closed){
		cf.close();
	}
	cf = window.open(filename,'popup','width=650,height=650');
	cf.focus();
}


function openFOFChart(identifier){
	var url = "http://webfund5.finexprestel.com/hsbc/ameuchart.wsp?";
	var arg1 = "ameuref=true"
	var arg2 = "&refCode=" + FOFdm[identifier][1]
	var arg3 = "&refName=" + escape(FOFdm[identifier][0])
	url = url + arg1 + arg2 + arg3
	openWindow(url, 'Chart', 'win_f')
}

function applyForJob(jobId,jobDesc,jobLoc){
	document.location.href='/site/generated/pages/common/careers/career_opportunities/vacancies/application_form.jsp?jobId='+jobId+'&jobDesc='+jobDesc+'&jobLoc='+jobLoc;
}

function fundOptions(j,f_type,s_option){
	//determine whether selected option (e.g. Performance tab) is available for the selected fund type in the current journey...
	// verbose but concise..
	
	var ret=true; //option is available by default..	
	var isValidFundType=false;

		switch (f_type){
			case "oeic":
				isValidFundType=true;
				   //TD449:Literature, Performance and Tools now invalid for all journeys
					if(s_option=='literature')ret=false;
					if(s_option=='performance')ret=false;
					if(s_option=='tools')ret=false;
	
					if(s_option=='fundfacts')ret=false;
					if (j=="Intermediaries"){
						if(s_option=='fundfacts')ret=false;
					}
					if (j=="Institutions"||j=="charityservices"){
						if(s_option=='fundfacts')ret=false;
					}
					if (j=="Individuals"){
						if(s_option=='performance'||s_option=='tools')ret=false;
					}

				break;
			case "fof":
				isValidFundType=true;
				   //TD449:Literature, Performance and Tools now invalid for all journeys
					if(s_option=='literature')ret=false;
					if(s_option=='performance')ret=false;
					if(s_option=='tools')ret=false;
	
					if (j=="Intermediaries"){
						if(s_option=='fundfacts')ret=false;
					}
					if (j=="Institutions"||j=="charityservices"){
						if(s_option=='fundfacts')ret=false;
					}
					if (j=="Individuals"){

						if(s_option=='performance'||s_option=='tools')ret=false;
					}

				break;
			case "sp":
				isValidFundType=true;
					//TD449:Literature now valid: if(s_option=='literature')ret=false;
					if (j=="Intermediaries"){
						if(s_option=='performance'||s_option=='tools')ret=false;
					}
					if (j=="Institutions"||j=="charityservices"){
						isValidFundType=false;
						ret=false;
					}
					if (j=="Individuals"){
						if(s_option=='performance'||s_option=='tools')ret=false;
					}
					
				break;
			case "offshore":
				isValidFundType=true;
					
					if (j=="Individuals"){
					//	if(s_option=='performance'||s_option=='tools')ret=false;
					if(s_option=='performance')ret=false;
					
						isValidFundType=false;
						ret=false;
					}
				break;
				
				
			case "liquidity":
				isValidFundType=true;
				   //TD449:Literature now invalid for all journeys - only price is valid
				   //TD449: if(s_option !='price')ret=false;
				
					if (j=="Intermediaries"){
						if(s_option!='price' && s_option!='literature')ret=false;
					}
					if (j=="Institutions"||j=="charityservices"){
						if(s_option!='price' && s_option!='literature')ret=false;
					}
					if (j=="Individuals"){
						isValidFundType=false;
						ret=false;
					}
				break;
			case "charity":
				isValidFundType=true;
					if (j=="Intermediaries"){
						if(s_option!='price' && s_option!='literature')ret=false;
					}
					if (j=="Institutions"||j=="charityservices"){
						if(s_option!='price' && s_option!='literature')ret=false;
					}
					if (j=="Individuals"){
						isValidFundType=false;
						ret=false;
					}

				break;
				
				
			case "pooled":
				isValidFundType=true;
					if(s_option!='price' && s_option!='literature')ret=false;
					if (j=="charityservices"){
						isValidFundType=false;
						ret=false;
					}
				break;
			case "libor":
				isValidFundType=true;
					if(s_option!='price' && s_option!='literature')ret=false; //td763
					//td763 if(s_option!='price')ret=false;
					if (j!="Institutions"){
						isValidFundType=false;
						ret=false;
					}
				break;
			case "open":
				isValidFundType=true;
					if(s_option!='price' && s_option!='literature')ret=false; //td763
					if (j!="Intermediaries" && j!='Individuals'){
						isValidFundType=false;
						ret=false;
					}
				break;

			default : 
				ret=false;
				isValidFundType=false;
		}
	if(isValidFundType&&ret)return s_option;
	if(!isValidFundType)return "default"; //not a valid fund type send to default price page (oeic)..
	if(!ret)return "price"; //if fund type ok but selection sucks then send it to the price page
}


function open_fp(whichOne, area){
	//Fund Centre page openings (for tabs/dd lists)
	var j = getJourney();
	var myPublic = "Public";

	//**** update for secure fund center gubbins
	var fund_prices ="/Funds_Prices/";
	
	if(top.location.href.indexOf('Secure/Funds_Prices')>-1){
		myPublic = "Secure";
		//somebody named it strangely...
		fund_prices ="/Funds_Prices/";
	}
	
	j=(j=='')?"Intermediaries":changeCase(j);


	area= fundOptions(j,whichOne,area);
	if(area=="default"){
		whichOne="oeic"
		area="price";
	}
	if(j.toLowerCase()==('charityservices')){
	//Naming convention for charityservices not like rest of site... Public is 'public' and no capitalisation for journey id.
		myPublic = myPublic=="Public"?"public":myPublic;
		j='charityservices';
	}

	var FP_DIR 			= "/site/"+j+"/" + myPublic + fund_prices;
	var PRICES_DIR 			= "/Price_Yields/landing_page";
	var FF_DIR 			= "/Fund_Facts/landing_page";
	var BASKET_DIR 			= "/Basket/landing_page";
	var LIT_DIR 			= "/Literature/landing_page";
	var PERF_DIR 			= "/Performance/landing_page";
	var RAT_DIR 			= "/Ratings/landing_page";
	var TOOL_DIR 			= "/Tools/landing_page";
	
	var the_dir = PRICES_DIR;  //set to default
	var fp_oeic_dir 	= "OEIC_Funds";
	var fp_charity_dir 	= "Charity_Funds";
	var fp_fof_dir		= "Funds_of_Funds";
	var fp_liquidity_dir	= "Liquidity_Funds";
	var fp_os_dir		= "Offshore_Funds";
	var fp_pooled_pension_dir = "Pooled_Pension_Funds";
	var fp_sp_dir		= "Structured_Products";
	var fp_libor_dir	= "Libor_Funds";
 	var fp_open_dir	= "OpenFunds";	//td809

	var inv_type = "inv_type";
	if(whichOne == null|| whichOne=="")whichOne="oeic";

		switch (whichOne){
			case "oeic":
				whichOne_val = fp_oeic_dir;
				break;
			case "fof":
				whichOne_val = fp_fof_dir;
				break;
			case "offshore":
				whichOne_val = fp_os_dir;
				break;
			case "sp":
				whichOne_val = fp_sp_dir;
				break;
			case "liquidity":
				whichOne_val = fp_liquidity_dir;
				break;
			case "charity":
				whichOne_val = fp_charity_dir;
				break;
			case "pooled":
				whichOne_val = fp_pooled_pension_dir;
				break;
			case "libor":
				whichOne_val = fp_libor_dir;
				break;
			case "open":	//td809
				whichOne_val = fp_open_dir;
				break;
			default : whichOne_val = fp_oeic_dir;
		}
		if(area=='price'){
			the_dir = PRICES_DIR;
		}
		if(area=='fundfacts'){
			the_dir = FF_DIR;
		}
		if(area=='literature'){
			the_dir = LIT_DIR;
		}
		if(area=='performance'){
			the_dir = PERF_DIR;
		}
		if(area=='ratings'){
			the_dir = PRICES_DIR; //RAT_DIR;  - ratings no longer available
		}
		if(area=='tools'){
			the_dir = TOOL_DIR;
		}
		if(area=='basket'){
			the_dir = BASKET_DIR;
		}
		 
		document.location.href = FP_DIR + whichOne_val + the_dir;
}

function getJourney(){
	var j = getCookie("journeypath");
	//make sure it is valid, else set to ''
	if(j==null||j.toLowerCase()!="intermediaries"&&j.toLowerCase()!="individuals"&&j.toLowerCase()!="charityservices"&&j.toLowerCase()!="institutions") j='';
	if(top.location.href.toLowerCase().indexOf(j.toLowerCase())<0){ //current journey has been manually changed in the URL
		var inte_ind = top.location.href.toLowerCase().indexOf('/intermediaries/');
		var inst_ind = top.location.href.toLowerCase().indexOf('/institutions/');
		var char_ind = top.location.href.toLowerCase().indexOf('/charityservices/');
		var indi_ind = top.location.href.toLowerCase().indexOf('/individuals/');
		if(inst_ind>0)j='institutions';
		if(char_ind>0)j='charityservices';
		if(indi_ind>0)j='individuals';
		if(inte_ind>0)j='intermediaries';
	}
	return j;
}

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;
}

function goto_j(s_link){
	//receives a link and translates it to the current journey generated area and send user to it...
	//link should be text after /public e.g. /Support_Literature/Literature/landing_page-en-UK.jsp
	// default journey is Intermediaries...
	
	var j = getJourney();
	var myPublic = "Public";
	var new_href=top.location.href;

	j=(j=='')?"Intermediaries":changeCase(j);
	if(j.indexOf('harity')>0){
		j="charityservices";
		myPublic = "public";
	}
	new_href = "/site/generated/pages/"+j+"/" + myPublic + s_link;
	document.location.href = new_href;
}



/* 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
	
	//alert(mylocation);
	
	/****** 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


//START: Function to set the fund centre prices tabs
function setTabs( ptabArray, plocationArray, ptextArray, phRefArray) {

	document.write("<div id=\"tabdiv\"><ul>");
	for (var i = 0 ; i < plocationArray.length;  i++) {
	
		var classname = "tab_down";

		// work out which class we should be using
		// If the location has a pipe '|' at the end then the href should end with the location not just be found in it
		if( plocationArray[i].charAt(plocationArray[i].length - 1) == "|" )
		{
			var actualLocation = plocationArray[i].substring(0,plocationArray[i].length - 1)
			if( top.location.href.lastIndexOf(actualLocation) ==  (top.location.href.length - actualLocation.length))
			{
				classname = "tab_up";
			}
		}
		else
		{
			if( top.location.href.indexOf(plocationArray[i]) > 0 )
			{
				classname = "tab_up";
			}
		}
		//Make Tabs without hrefs inactive
		if(phRefArray[i]=="")
		{
			classname = "tab_inactive";
		}
		document.write("<li>");
		if(classname=="tab_inactive"){
			document.write("<span id=\""+ptabArray[i]+"_left\" class=\"" + classname + "_left\">&nbsp;</span>");
			document.write("<span id=\""+ptabArray[i]+"\" class=\"" + classname + "\" href=\"" + phRefArray[i] +"\">" + ptextArray[i] + "</span>");
			document.write("<span id=\""+ptabArray[i]+"_right\" class=\"" + classname + "_right\">&nbsp;</span>");
		}
		else
		{
			document.write("<a id=\""+ptabArray[i]+"_left\" class=\"" + classname + "_left\">&nbsp;</a>");
			document.write("<a id=\""+ptabArray[i]+"\" class=\"" + classname + "\" href=\"" + phRefArray[i] +"\">" + ptextArray[i] + "</a>");
			document.write("<a id=\""+ptabArray[i]+"_right\" class=\"" + classname + "_right\">&nbsp;</a>");
		}
		document.write("</li>");
	}

	document.write("</ul></div>");

}


/*
function setTabs(tabIdentifier, tabArray) {
	for (var i = 0 ; i < tabArray.length;  i++) {
			if(document.getElementById(tabArray[i]))
			{
				if (tabIdentifier==tabArray[i]) {
					var tableft = document.getElementById(tabArray[i]+"_left");
					tableft.className = "tab_up_left";

					var tab = document.getElementById(tabArray[i]);
					tab.className = "tab_up";

					var tabright = document.getElementById(tabArray[i]+"_right");
					tabright.className = "tab_up_right";

				} else {
					var tableft = document.getElementById(tabArray[i]+"_left");
					tableft.className = "tab_down_left";

					var tab = document.getElementById(tabArray[i]);
					tab.className = "tab_down";

					var tabright = document.getElementById(tabArray[i]+"_right");
					tabright.className = "tab_down_right";
				}
			}	
	}
}
*/
//END: Function to set the fund centre prices tabs

function openChart(identifier){
	var url = "http://webfund5.finexprestel.com/hsbc/ameuchart.wsp?ameuref=true";
	if(identifier!=null&&identifier!=""){
		var arg2 = "&refCode=" + dm[identifier][1];
		var arg3 = "&refName=" + escape(dm[identifier][0]);
		url = url + 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');
}

//this function is used by FAQs etc...
//For convenience, multiple arguments can be passed eg. answer('Answer1', 'Answer2',...)
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

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();
	}
}

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();
	}
}

function MultiFiles(filename){
	window.name="order_lit";
	//alert(window.name);
	if (multif && multif.open && !multif.closed){
		multif.close();
	}
	multif = window.open(filename,'popup','width=400,height=120,status=yes');
	multif.focus();
}


//This is for the drop down menus, within the fund selection area 
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

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
*******************************************/

// TD1499 - Jason Hunt - 3rd July 2007
// This used to be processTerms, but I needed one that allowed the declining URL 
// to be passed in. Changed processTerms to call this one with the existing declien url.
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' );
}

/************************************************
* Code run on every page to determine if this is
* a microsite/partnership page or not and
* set the WebTrends tag accordingly
*
* flag set on each page that has the URL:
* /site/partnership/<name>/*
* /site/microsite/<name>/*
************************************************/

var microLoc = document.location.href;
var microSplitIndex;
var microName;
var microRun;

try {
	if (HSBC) {
		microRun = "Y";
	} else {
		microRun = "N";
	}
} catch(e) {
	microRun = "N";
}

if (microRun == "Y") {
	if (microLoc.match(/\/partnership\//)) { 		
		microSplitIndex = microLoc.indexOf("/partnership/");
		microName = microLoc.substring(microSplitIndex + 13);
		microSplitIndex = microName.indexOf("/");
		microName = microName.substring(0,microSplitIndex);		
		HSBC.EXT.inv_microsite=microName;
	} else if (microLoc.match(/\/microsites\//)) { 
		microSplitIndex = microLoc.indexOf("/microsites/");
		microName = microLoc.substring(microSplitIndex + 12);
		microSplitIndex = microName.indexOf("/");
		microName = microName.substring(0,microSplitIndex);		
		HSBC.EXT.inv_microsite=microName;
	} else {
		// do nothing
	}
}

/************************************************
* Code run on every page to set the country tag
* for WebTrends
************************************************/
try {
	if (HSBC) {
		HSBC.EXT.inv_country = "UK";
	}
} catch(e) {
	// nothing;
}
