var leftNav={

	seperater:"###",

	accesskey:{
		"Home":"1",
		"Insurance solutions":"2",
		"Mirror funds":"3",
		"Customer services":"4",
		"About Zurich":"5",
		"Careers":"6"
	},

	data:["",{
	
	
	
		"Home":["index.htm"],
	
	
		"Insurance solutions":["insurancesolutions.htm",{
			"Introduction":["insurancesolutions.htm"],
			"Your life stage":["is_yourlifestage.htm",{
				"Starting out":["is_yourlifestage_startingout.htm"],
				"Settling down":["is_yourlifestage_settlingdown.htm"],
				"Parenthood":["is_yourlifestage_parenthood.htm"],
				"Getting established":["is_yourlifestage_gettingestablished.htm"],
				"Prime of life":["is_yourlifestage_primeoflife.htm"]
			}],
			"Individual life insurance":["is_lifeinsurance_overview.htm",{
				"Life protection & savings":["is_lifeinsurance_lifeprotectionandsavings.htm"],
				"Life protection & investment":["is_lifeinsurance_lifeprotectionandinvestment.htm"],
				"Life protection & hospital cash":["is_lifeinsurance_lifeprotectionandhospitalcash.htm"],
				"Family protection":["is_lifeinsurance_familyprotection.htm"],
				"Retirement":["is_lifeinsurance_retirement.htm"],
				"Target savings":["is_lifeinsurance_targetsavings.htm"],
				"Children education":["is_lifeinsurance_educationfund.htm"],
				"Female care":["is_lifeinsurance_femalecare.htm"],
				"Senior care":["is_lifeinsurance_seniorcare.htm"],
				"Critical illness":["is_lifeinsurance_criticalillness.htm"],
				"Medical insurance":["is_lifeinsurance_medicalinsurance.htm"],
				"Accident protection":["is_lifeinsurance_accidentanddisability.htm"],
				"Inflation beater":["is_lifeinsurance_inflationbeater.htm"]
			}],
			"Individual general insurance":["is_generalinsurance_overview.htm",{
				"Personal accident":["is_generalinsurance_personalaccident.htm"],
				"In-patient medical":["is_generalinsurance_inpatientmedical.htm"],
				"Hospital cash":["is_generalinsurance_hospitalcash.htm"],
				"Home contents":["is_generalinsurance_homecontents.htm"],
				"Fine art and specie":["is_generalinsurance_fineartspecie.htm"],
				"Domestic helper":["is_generalinsurance_domestichelper.htm"],
				"Travel":["is_generalinsurance_travel.htm"],
				"China medical card":["is_generalinsurance_chinamedicalcard.htm"],
				"Study tour / Exchange program":["is_generalinsurance_studytour.htm"],
				"Motor":["is_generalinsurance_motor.htm"],
				"Pleasure craft":["is_generalinsurance_helmsmancraft.htm"],
				"Golf":["is_generalinsurance_golf.htm"],
				"Personal liability":["is_generalinsurance_personalliability.htm"]
			}],
			"Commercial insurance":["is_companyinsurance_overview.htm",{
				"Group personal accident":["is_companyinsurance_grouppersonalaccident.htm"],
				"Group life":["is_companyinsurance_grouplife.htm"],
				"Office":["is_companyinsurance_officemultirisk.htm"],
				"Shop":["is_companyinsurance_retailmultirisk.htm"],
				"Professional liability solutions":["is_companyinsurance_proliability.htm"],
				"Other insurance plans":["is_companyinsurance_otherinsuranceplans.htm"]
			}],
			"Resources":["is_resources_usefulinformation.htm",{
				"Useful links":["is_resources_usefulinformation.htm"]
			}]
		}],
		
		
		"Investment services":["investmentfunds.htm",{
		   "Unit price update":["if_fundpriceupdate_main.asp",{
				"Active Insurance Series":["if_fundpriceupdate.asp?fsrc=z"],
				"Classic Active Insurance Series":["if_fundpriceupdate.asp?fsrc=es"],
				"Toolbox":["if_fundsToolBox.asp"]
			}],
			"Investment choices performance & particulars":["if_fundsperformance.asp",{
				"Investment commentary":["if_investmentcommentary.htm"],
				"Investment factbook":["if_monthlyfundfactbook.htm"],
				"Quarterly bulletin":["if_quarterlybulletin.htm"]
			}],
			"Risk profiler":["if_riskprofiler.htm"],
			"Underlying fund managers":["if_fundmanagers.htm"],
			"Investment education":["if_investmenteducation.htm"]
		}],
		
		
		"Customer services":["customerservices.htm",{
			"Life policy services":["cs_lifepolicyservices.htm",{
				"EziNet":["cs_lifepolicyservices_ezinet.htm"],
				"Claims":["cs_lifepolicyservices_claims.htm"],
				"Alteration":["cs_lifepolicyservices_alteration.htm"],
				"Lost policy":["cs_lifepolicyservices_lostpolicy.htm"],
				"24-hour international assistant service":["cs_lifepolicyservices_24houremergency.htm"]
			}],
			"General insurance policy services":["cs_nonlifepolicyservices.htm",{
				"Claims":["cs_nonlifepolicyservices_claims.htm"],
				"Lost policy":["cs_nonlifepolicyservices_lostpolicy.htm"],
				"Medical network":["cs_nonlifepolicyservices_medicalnetwork.htm"],
				"24-hour emergency assistance":["cs_nonlifepolicyservices_24houremergency.htm"]
			}],

			"Zurich Dual Currency Credit Card":["cs_zurichdualcurrencycreditcard.htm"],
			"MPF online service centre":["cs_mpfonlineservicecentre.htm"],
			"E-card":["cs_ecard.htm"],
			"E-newsletter":["cs_enewsletter.htm"],
			"Contact":["cs_contact.htm",{
				"General enquiries / suggestions":["cs_contact_generalenquiries.asp"],
				"Product enquiries":["cs_contact_productenquiries.asp"]
			}]
		}],
		
		
		"About Zurich":["aboutzurich.htm",{
			"Corporate information":["az_corporateinformation_overview.htm",{
				"Overview":["az_corporateinformation_overview.htm"],
				"Business achievements":["az_corporateinformation_businessachievements.htm"],
				"Service philosophy":["az_corporateinformation_servicephilosophy.htm"],
				"Zurich network":["az_corporateinformation_zurichnetwork.htm"]
			}],
			"Zurich at a glance":["az_zurichglance.htm"],
			"Corporate updates":["az_whatsnew.htm"],
			"Product news":["az_productnews.htm"],
			"Media releases":["az_mediacentre.htm"],
			"Branding & advertising":["az_brandcampaign.htm",{
				"Zurich HelpPoint":["az_brandcampaign.htm"],
				"Recruitment campaign":["az_brandcampaign_rc.htm"]
			}],
			"Professional consultants":["az_professionalconsultants_commitment.htm",{
				"Commitment":["az_professionalconsultants_commitment.htm"],
				"Role & character":["az_professionalconsultants_roleandcharacter.htm"],
				"Professional training":["az_professionalconsultants_professionaltraining.htm"],
				"Team spirit":["az_professionalconsultants_teamspirit.htm"],
				"Monthly awards":["az_professionalconsultants_monthlyawards.htm"],
				"VIP Class":["az_professionalconsultants_vipclass.htm"]							
			}],
			"Corporate citizenship":["az_corporatecitizenship.htm"]
		}],
		
		
		"Careers":["az_careers.htm",{
			"Corporate vacancy":["az_careers.htm"],
			"Consultant vacancy":["az_careers_consultantvacancy_careerinzurich.htm",{
				"Career in Zurich":["az_careers_consultantvacancy_careerinzurich.htm", {"Career Path":["az_careers_consultantvacancy_careerinzurich_careerpath.htm"], "Income Projection":["az_careers_consultantvacancy_careerinzurich_incomeprojection.htm"], "Career online application":["az_careers_consultantvacancy_careeronlineapplication.asp"],"Written test schedule":["az_careers_consultantvacancy_careerinzurich_writtentestschedule.htm"]}],
				"News & Events":["az_careers_consultantvacancy_newsandevents.htm", {"Event online enrollment":["az_careers_consultantvacancy_careereventenrollment.asp"]}],
				"Zurich Academy":["az_careers_consultantvacancy_recruitmentcentre_zurichacademy.htm"],
				"New Advisor Development Centre":["az_careers_consultantvacancy_recruitmentcentre.htm"],
				"Contact Us":["az_careers_consultantvacancy_recruitmentcentre_contactus.asp"]
			}]
		}]
		  
	}],


	akalist:{
		"Corporate News":"Zurich News"
	}

}
	


//=======================================================================================
//			script
//=======================================================================================

var fn={
	
	init:function(page){
		// Do not wait for image load
//		DOMReady.init(function(){fn.renderTopNav(page);fn.renderLeftNav(page)});

		if (window.addEventListener){
		
			window.addEventListener("load", function(){try{
				fn.renderTopNav(page);
				if (typeof(page)=="string") fn.renderLeftNav(page);
				if (typeof(page)=="string") fn.renderBreadcrumb(page);
				document.getElementById("contentArea").style.display="table";
				document.getElementById("footer").style.visibility="visible";
			}catch(e){}}, false); 
		} else if (window.attachEvent){
			window.attachEvent("onload", function(){try{
				fn.renderTopNav(page);
				if (typeof(page)=="string") fn.renderLeftNav(page);
				if (typeof(page)=="string") fn.renderBreadcrumb(page);
				document.getElementById("contentArea").style.display="block";
				document.getElementById("footer").style.visibility="visible";
			}catch(e){}});
		}
	},


	renderTopNav:function(path){
		var ackey="";
		var url="";
		var clsFirst="";
		var cls="";
		var div=document.getElementById("div_tabNav");
		var objc = String(path).split(leftNav.seperater);
		var cnt=0;
		var td=[];

		for(var key in leftNav.data[1]){
			if (typeof(key)=="string"){
				try{
					if (typeof(leftNav.accesskey[key])!="undefined"){
						ackey=' accesskey="'+leftNav.accesskey[key]+'"';
					}else{
						ackey="";
					}
				}catch(e){
					ackey="";
				}
				if (cnt==0){
					clsFirst=' firstCell';
				}else{
					clsFirst='';
				}
				if (key==objc[0]){
					cls="tabSelected";
				}else{
					cls="tabNormal";
				}
				url=leftNav.data[1][key][0];

				td[cnt]='<td class="'+cls+clsFirst+'" nowrap><a href="'+url+'" class="'+cls+'"'+ackey+' title="'+key+'">'+key+'</a></td>';

				cnt++;
			}
		}
		var outtext="";
		var outtext_b="";
		for (var i=0;i<td.length;i++){
			outtext+='<td class="navSeperator"><img src="images/cp.gif" width="1" height="1" alt="" border="0"></td>';
			outtext+=td[i];
		}
		outtext+='<td class="navSeperator"><img src="images/cp.gif" width="1" height="1" alt="" border="0"></td>';
		outtext+='<td class="tabNormal" nowrap style="width:100%;"><span class="tabNormal" style="float:right;"><img src="images/cp.gif" alt="" border="0" width="1" height="1">&nbsp;</span></td>';
		outtext+='<td class="navSeperator"><img src="images/cp.gif" width="1" height="1" alt="" border="0"></td>';

		outtext_b='<td class="tabBg" colspan="'+(td.length*2+3)+'"><img src="images/cp.gif" alt="" width="1" height="10" border="0"></td>';

		div.innerHTML='<table width="910" cellspacing="0" cellpadding="0" border="0" id="tabNav" summary=""><tr>'+outtext+'</tr><tr>'+outtext_b+'</tr></table>';

		div.style.visibility='visible';
	},


	renderLeftNav:function(path){
		var objc = String(path).split(leftNav.seperater);
		var group=leftNav.data[objc[0]];
		var outtext='';
		
		if (!document.getElementById("leftNavCont")){
			return(false);
		}
		while (objc.length>3){
			objc.splice(3,1);
		}

		objc[0]=fn.mapaka(objc[0]);
		for(var k in leftNav.data[1][objc[0]][1]){
			if (leftNav.data[1][objc[0]][1][k].length==1){
				//no child
				outtext+=fn.buildCell(k, leftNav.data[1][objc[0]][1][k][0], 0, k==objc[objc.length-1]);
			}else{
				//have child
				if (k!=objc[1]){
					//closed
					outtext+=fn.buildCell(k, leftNav.data[1][objc[0]][1][k][0], 1, k==objc[objc.length-1]);
				}else{
					//opened
					outtext+=fn.buildCell(k, leftNav.data[1][objc[0]][1][k][0], 1.5, k==objc[objc.length-1]);
					for(var m in leftNav.data[1][objc[0]][1][k][1]){
						outtext+=fn.buildCell(m, leftNav.data[1][objc[0]][1][k][1][m], 2, m==objc[objc.length-1]);
					}
				}
			}
		}
		
	

		document.getElementById("leftNavCont").innerHTML='<table width="180" cellspacing="0" cellpadding="0" border="0" summary="" id="leftNav">					<colgroup><col class="px5"/><col class="px12"/><col class="px8"/><col class="px12"/><col class="px138"/></colgroup>'+outtext+'</table>';

		if (objc[0]!=""){

			var trs=document.getElementById("leftNavCont").getElementsByTagName("tr");
			var tds_f=trs[1].getElementsByTagName("td");
			var tds_l=trs[trs.length-1].getElementsByTagName("td");
			tds_f[tds_f.length-1].className=tds_f[tds_f.length-1].className.replace("navText", "navTextFirst");
			tds_l[tds_l.length-1].className=tds_l[tds_l.length-1].className.replace("navText", "navTextLast");
		}

		document.getElementById("leftNavCont").style.display="block";

		return(true);
		
	},



	renderBreadcrumb:function(path, filename){
		var objc = String(path).split(leftNav.seperater);
		var outtext='';
		
		if (!document.getElementById("breadCrumb")){
			return(false);
		}

		
		var loc=""+document.location;
		loc=loc.split("?");
		loc=loc[0].split("#");
		loc=loc[0].split("/");
		loc=loc[loc.length-1];

		if (filename) loc=filename;

		var root=leftNav.data;

		var rootfn="";
		for (var i=0;i<objc.length;i++){
			objc[i]=fn.mapaka(objc[i]);
			root=root[1][objc[i]];
			rootfn=root[0];

		
			if ((i!=objc.length-1)||((breadCrumb_hideH1)&&(rootfn!==loc))){
				var mlink=rootfn;
				if (mlink.indexOf(".asp")>0){
					mlink="javascript:urlChk('"+mlink+"');";
				}
				outtext+='<a href="'+mlink+'">'+objc[i]+'</a> > ';
			}else{
				outtext+=objc[i];
			}
		}
		
	
		if ((breadCrumb_hideH1)&&(rootfn!==loc)){
			var e=document.getElementsByTagName("h1");
			if (e){
				outtext+=e[0].innerHTML;
			}	
		}

		if (objc.length==1){outtext="";}

		document.getElementById("breadCrumb").innerHTML=outtext;
		document.getElementById("breadCrumb").style.display="block";

	},


	mapaka:function(str){
		if (leftNav.akalist[str]){
		
			return(leftNav.akalist[str]);
		}else{
		
			return(str);
		}
	},
	

	buildCell:function(text, mlink, type, selected){
		var outtext="";
		if (text=="") return("");
		if(typeof(mlink)=="object"){mlink=mlink[0];}
		if (mlink.indexOf(".asp")>0){
			mlink="javascript:urlChk('"+mlink+"');";
		}

		switch(type){

			case 0:
				// level 1, no child
				outtext+='<tr class="leftNavBg1">';
				outtext+='<td class="px5"></td>';
				outtext+='<td class="px12"><a title="" href="'+mlink+'"><img width="1" height="1" border="0" alt="" src="images/cp.gif"/></a></td>';
				outtext+='<td class="navText px158" colspan="3"><a title="'+text+'" class="navText'+((selected)?'Selected':'')+'" href="'+mlink+'">'+text+'</a></td>';
				outtext+='</tr>';
			break;

			case 1:
				// level 1, childed, closed
				outtext+='<tr class="leftNavBg1">';
				outtext+='<td></td>';
				outtext+='<td valign="top"><a title="'+text+'" href="'+mlink+'"><img width="12" height="20" border="0" alt="" src="images/twisty_white_right.gif"/></a></td>';
				outtext+='<td class="navText" colspan="3"><a title="'+text+'" class="navText" href="'+mlink+'">'+text+'</a></td>';
				outtext+='</tr>';
			break;

			case 1.5:
				// level 1, childed, opened
				outtext+='<tr class="leftNavBg1">';
				outtext+='<td></td>';
				outtext+='<td valign="top"><a title="'+text+'" href="'+mlink+'"><img width="12" height="20" border="0" alt="" src="images/twisty_white_down.gif"/></a></td>';
				outtext+='<td class="navText" colspan="3"><a title="'+text+'" class="navText'+((selected)?'Selected':'')+'" href="'+mlink+'">'+text+'</a></td>';
				outtext+='</tr>';
			break;

			case 2:
				// level 2
				outtext+='<tr class="leftNavBg2">';
				outtext+='<td colspan="2"></td>';
				outtext+='<td><a title="" href="'+mlink+'"><img width="12" height="20" border="0" alt="" src="images/'+((selected)?'current_pointer':'cp')+'.gif"/></a></td>';
				outtext+='<td class="navText px138" colspan="2"><a title="'+text+'" class="navText'+((selected)?'Selected':'')+'" href="'+mlink+'">'+text+'</a></td>';
				outtext+='</tr>';
			break;
		}
//console.log(text+" > "+outtext);

		outtext='<tr><td colspan="5"><img width="1" height="1" border="0" alt="" src="images/cp.gif"/></td></tr>'+outtext;


		return(outtext);
	},


	autoNav:function(filename){
		var loc=""+document.location;

		loc=loc.split("?");
		loc=loc[0].split("#");
		loc=loc[0].split("/");
		loc=loc[loc.length-1];

		if (filename) loc=filename;


		var nav="";

		try{
			nav=fn.treeDig(leftNav.data, loc, false);
			if (nav==""){
				nav=fn.treeDig(leftNav.data, loc, true);
			}
			if (nav.indexOf){
				nav=(nav.indexOf(leftNav.seperater)==0)?nav.substring(leftNav.seperater.length,nav.length):nav;
			}
		}catch(e){
		}

		return(nav);
	},
	
	
	treeDig:function(tree, filename, looseFind){
		if (tree.length==1){
			if (looseFind){
				return(fn.locComp(tree[0], filename));
			}else{
				return(tree[0]==filename);
			}
		}else{
			for (var k in tree[1]){
				var res=fn.treeDig(tree[1][k], filename, looseFind);
				if (res===true){
					return(leftNav.seperater+k);
				}else{
					if ((res!==false)&&(res!=="")){
						return(leftNav.seperater+k+res);
					}
				}
			}

			if (looseFind){
				return(fn.locComp(tree[0], filename));
			}else{
				return(tree[0]==filename);
			}
		}
	},


	
	locComp:function(refname, filename){
		if (filename===refname){
			return(true);
		}else{
			var ary_filename=filename.split(".");
			var ary_refname=refname.split(".");
			var tex_filename=ary_filename[0].split("_");
			tex_filename.splice(tex_filename.length-1,1);
			var t=tex_filename.join("_");
			if (t==ary_refname[0]){
				return(true);
			}else{
				return(false);
			}
		}
	}
	
}


//=================================================================
//              Check DOM ready
//=================================================================
var DOMReady={
	done:false,
	clearID:0,
	fn:[],
	init:function(){
		for(var i=0;i<arguments.length;i++){
			if (typeof(arguments[i])=="function") {
				DOMReady.fn.push(arguments[i]);
			}else{
				continue;
			}
		}
		if (DOMReady.done) {
			for (var i = 0; i < this.fn.length; i++) {
				DOMReady.fn[i]();
			}
			DOMReady.done=false;
		}else {
			DOMReady.Interval();
		}
	},
	Interval:function(){
		DOMReady.clearID=window.setInterval(DOMReady.check,20);
	},
	check:function(){
		if (DOMReady.done) {
			clearInterval(DOMReady.clearID);
			DOMReady.init();
		}else{
			if (document.body && document && document.getElementsByTagName && document.getElementById) {
				DOMReady.done=true;
			}
		}
	}
}



//================================================
//    main
//================================================


breadCrumb_hideH1=(typeof(breadCrumb_hideH1)=="undefined")?false:breadCrumb_hideH1;

try{
	fn.init(pageNav);
}catch(e){

	var navText=fn.autoNav();
//	if (navText!=""){
		fn.init(navText);
//	}else{
		//console.log("can not determine nav");
//	}
}
