﻿////For hidden some labes in Phase 1
$(document).ready(function(){
	  $("div#footer_1 div.footer_link_1 ul:last").hide();
	});


//For CR-025
/* Not need popup from Feb 1
$(document).ready(function(){
    var strUrl = window.location.href;
	var hadAllAgreeVal=getCookie("AXA.Location.AllWebSiteNotesCookie");
    if( (hadAllAgreeVal != "YES")){
	        var popupUrl = "/html/AXA_PRO/Notes.html";
			if(strUrl.indexOf("/iw-")<=0){
		    window.open(popupUrl,'window','menubar=no, top=0, left=150, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no, location=no, width=800,height=1000');
		SetCookie("AXA.Location.AllWebSiteNotesCookie","YES");
		}
	   }
  });
  */
  
//For CR-028
$(document).ready(function(){
	var currUrl = window.location.href;
		currUrl=currUrl.toLowerCase();
	if(currUrl.indexOf("/chi/")>0){
		$("span#consultant_login a").attr("href","/html/AXA_PRO/chi/cs/coo/consultant_login_chi.html");
	}else{
		$("span#consultant_login a").attr("href","/html/AXA_PRO/eng/cs/coo/consultant_login.html");
		$("div#submenu2 ul  li:nth-child(1) a ").attr("href","https://www1.e-axa.com.hk/awb/changeversion.do?lang=EN&loc=/web/main/login.jsp");
	}
		

});
//For CR-012
// Added by Michael to fix IE issue of last 2 subsections of Investment showing.
$(document).ready(function(){
  // $("#Investment li:nth-child(1)").html("<a href='/html/AXA_PRO/eng/insurance/Investment_linked_insurance/investment_linked_insurance.html?'>Investment Linked Insurance</a>");
   $("#Investment li:nth-child(2)").html("<a href='/html/AXA_PRO/eng/investment/fund_prices.html?'>Fund Prices</a>");
          $("#Investment li:nth-child(3)").hide();
          $("#Investment li:nth-child(4)").hide();
          $("#Investment li:nth-child(5)").hide();
 
   $("#Customer_Service li:nth-child(2)").html("<a href='/html/AXA_PRO/eng/investment/fund_prices.html?'>Fund Prices</a>");		  
   $("#客戶服務 li:nth-child(2)").html("<a href='/html/AXA_PRO/chi/investment/fund_prices_chi.html?'>基金價格</a>");			  

 //  $("#投資 li:nth-child(1)").html("<a href='/html/AXA_PRO/chi/insurance/investment_linked_insurance/investment_linked_insurance_chi.html?'>投資相連壽險</a>");
   $("#投資 li:nth-child(2)").html("<a href='/html/AXA_PRO/chi/investment/fund_prices_chi.html?'>基金價格</a>");
          $("#投資 li:nth-child(3)").hide();
          $("#投資 li:nth-child(4)").hide();
          $("#投資 li:nth-child(5)").hide();
	});



//For switch Language
function changeLanguage(newLanguage){
  	var currUrl = window.location.href;
    var newUrl = "";

    //html/AXA_PRO/eng/career/job description/*.html ¨C link back to itself
	if(currUrl.indexOf("/career/job%20description/")>=0){
		newUrl = currUrl;
	}else{
		newUrl = setLanguageValue(newLanguage,currUrl);
	}
    
	var markindex =newUrl.lastIndexOf('#');
	if(markindex >= 0 && markindex == newUrl.length-1){
       newUrl=newUrl.substring(0,markindex);
	}
    
    window.open(newUrl,'_self');
 }

function setLanguageValue(newLanguage, str)
{ 
    var newUrl = "";
    var sufferUrl = "";
	var allSufferUrl = "";
    var splitStr = str.split("://");
    var prefixStr = splitStr[0] + "://"; //e.g: http:// or https://
    var suffix = splitStr[1];
	var nextUrl = "";
	var pairs=str.split("?")[1];
	if(typeof(pairs)!="undefined"){
		nextUrl = getValue("nextUrl", pairs);
		nextUrl = nextUrl.toLowerCase();
			if(newLanguage == "Chi" || newLanguage == "chi"){
				nextUrl=nextUrl.replace("/eng/","/chi/");
				nextUrl=nextUrl.replace(".html","_chi.html");
			}
			if(newLanguage == "eng"){
				nextUrl=nextUrl.replace("/chi/","/eng/");
				nextUrl=nextUrl.replace("_chi.html",".html");
			}
	} 
	
	if(newLanguage == "Chi" || newLanguage == "chi"){
             if(suffix.indexOf("/eng/")>=0){
                sufferUrl = suffix.replace("/eng/","/Chi/");
             }else{
		sufferUrl = suffix;
             }

        var splitHtmlList = sufferUrl.split(".html");
	    for(var b = 0; b < splitHtmlList.length; b++){
           if(b==0){
               splitHtmlList[0] = splitHtmlList[0] + "_chi.html";  //e.g.   T6_chi.html
		    }
		   allSufferUrl += splitHtmlList[b];
	    }
	}else if(newLanguage == "eng"){
                if(suffix.indexOf("/chi/")>=0){
                sufferUrl = suffix.replace("/chi/","/eng/");
                }else if (suffix.indexOf("/Chi/")>=0)
                {
					sufferUrl = suffix.replace("/Chi/","/eng/");
                }else{
					sufferUrl = suffix;
                }
		var splitHtmlList = sufferUrl.split("_chi.html");
		for(var b = 0; b < splitHtmlList.length; b++){
		   if(b==0){
			   splitHtmlList[0] = splitHtmlList[0] + ".html";  //e.g.   T6.html
			}
		   allSufferUrl += splitHtmlList[b];
		}
	}

	if(newLanguage == "Chi" || newLanguage == "chi"){
        if(allSufferUrl.indexOf("/needs/needs_chi.html")>=0){
			allSufferUrl = allSufferUrl.replace("/needs/needs_chi.html","/needs/financial_needs_landing_chi.html");
		}
        if(allSufferUrl.indexOf("/investment/fund_prices_tab2_chi.html")>=0){
			allSufferUrl = allSufferUrl.replace("/investment/fund_prices_tab2_chi.html","/investment/fundprices_tab2_chi.html");
		}
        if(allSufferUrl.indexOf("/investment/fund_prices_extra_chi.html")>=0){
			allSufferUrl = allSufferUrl.replace("/investment/fund_prices_extra_chi.html","/investment/fundprices_extra_chi.html");
		}
        if(allSufferUrl.indexOf("/cs/inv/fund_prices_tab2_chi.html")>=0){
			allSufferUrl = allSufferUrl.replace("/cs/inv/fund_prices_tab2_chi.html","/cs/inv/fundprices_tab2_chi.html");
		}
        if(allSufferUrl.indexOf("/cs/inv/fund_prices_extra_chi.html")>=0){
			allSufferUrl = allSufferUrl.replace("/cs/inv/fund_prices_extra_chi.html","/cs/inv/fundprices_extra_chi.html");
		}



	}else if(newLanguage == "eng"){
		if(allSufferUrl.indexOf("/needs/financial_needs_landing.html")>=0){
			allSufferUrl = allSufferUrl.replace("/needs/financial_needs_landing.html","/needs/needs.html");
		}
		if(allSufferUrl.indexOf("/career/career_landing.html")>=0){
			allSufferUrl = allSufferUrl.replace("/career/career_landing.html","/career/career.html");
		}
                if(allSufferUrl.indexOf("/investment/fundprices_tab2.html")>=0){
			allSufferUrl = allSufferUrl.replace("/investment/fundprices_tab2.html","/investment/fund_prices_tab2.html");
		}
                if(allSufferUrl.indexOf("/investment/fundprices_extra.html")>=0){
			allSufferUrl = allSufferUrl.replace("/investment/fundprices_extra.html","/investment/fund_prices_extra.html");
		}
                if(allSufferUrl.indexOf("/cs/inv/fundprices_tab2.html")>=0){
			allSufferUrl = allSufferUrl.replace("/cs/inv/fundprices_tab2.html","/cs/inv/fund_prices_tab2.html");
		}
                if(allSufferUrl.indexOf("/cs/inv/fundprices_extra.html")>=0){
			allSufferUrl = allSufferUrl.replace("/cs/inv/fundprices_extra.html","/cs/inv/fund_prices_extra.html");
		}

    
	}

    newUrl = prefixStr + allSufferUrl;
	
	if(nextUrl!=""){
	newUrl = nextUrl;
	}
    return newUrl;
}

 //for popup window in Home page 
 function popupWindow(nextUrl,openType, lang)
 {
	 if(lang=="chi"){
		var popupUrl="/html/AXA_PRO/chi/termOfUse_chi.html?keepThis=true"+"&nextUrl="+nextUrl+"&openType="+openType+"&TB_iframe=true&height=185&width=570";
	 }else{
		var popupUrl="/html/AXA_PRO/eng/termOfUse.html?keepThis=true"+"&nextUrl="+nextUrl+"&openType="+openType+"&TB_iframe=true&height=185&width=570";
	 }
	
	var newWin = window.open(popupUrl,'window','menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0, location=0, width=700,height=700');
	newWin.moveTo(250,250);
 }


function autoResize(id){
        var newheight;
        var newwidth;
    	if(document.getElementById){
            newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
            newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth;
        }
    	document.getElementById(id).height= (newheight) + "px";
        document.getElementById(id).width= (newwidth) + "px";
    }

// For Term Of Use
 function goNextPage()
 {
	var url = window.location.href;
	var pairs=url.split("?")[1];
	var nextUrl;
	var openType;

	if(typeof(pairs)!="undefined"){
		nextUrl = getValue("nextUrl", pairs);
	}

	SetCookie("AXA.MPF.ImportNotesCookie", "YES");
	window.open(nextUrl, "_self");

 }

 function goBusinessNextPage(type){
  var url = window.location.href;
  var pairs=url.split("?")[1];
  var nextUrl;
   nextUrl = getValue("nextUrl", pairs);
   var strCokkie="AXA.AboutAXA.OurBusiness.ImportNotesCookie."+type;
   SetCookie(strCokkie, "YES");
   window.open(nextUrl,'newWindow','location=no, menubar=no, toolbar=no, resizable=yes');
  var previous;
  previous= getValue("lang", pairs);

  if(previous=='eng'){
   document.location.href='/html/AXA_PRO/eng/about/BCC/bancassurance/bancassurance_landing.html';
  }else{
   document.location.href='/html/AXA_PRO/Chi/about/BCC/bancassurance/bancassurance_landing_chi.html';
  }
 }
//CR-041
 function goCSTrustNextPage()
 {
	var url = window.location.href;
	var lang;
	var strFormChiCookie="AXA.CS.trust_form_disclaimer.chi";
	var strFormEngCookie="AXA.CS.trust_form_disclaimer.eng";
	var strBrochureChiCookie="AXA.CS.trust_brochure_disclaimer.chi";
	var strBrochureEngCookie="AXA.CS.trust_brochure_disclaimer.eng";
	
	var pairs=url.split("?")[1];
	var nextUrl;
	if(typeof(pairs)!="undefined"){
		nextUrl = getValue("nextUrl", pairs);
	}

	if(url.toLowerCase().indexOf("_chi.")>0){
		lang="chi";
		if(url.toLowerCase().indexOf("/chi/cs/unit_trust_brochure_chi.html")>0){			
			SetCookie(strBrochureChiCookie, "YES");
		}		
		if(url.toLowerCase().indexOf("/chi/cs/coo/awa_download_forms_chi.html")>0){			
			SetCookie(strFormChiCookie, "YES");
		}
	
	}else{
		lang="eng";		
		if(url.toLowerCase().indexOf("/eng/cs/unit_trust_brochure.html")>0){			
			SetCookie(strBrochureEngCookie, "YES");
		}		
		if(url.toLowerCase().indexOf("/eng/cs/coo/awa_download_forms.html")>0){			
			SetCookie(strFormEngCookie, "YES");
		}
	}

	window.open(nextUrl, "_self");

 }
function goCSTrustBackPage()
 {
	var strUrl = window.location.href;

	if(strUrl.toLowerCase().indexOf("_chi.")>0){
		lang="chi";
		var nextUrl="/html/AXA_PRO/chi/cs/downloads_chi.html";
		window.open(nextUrl, '_self'); 
	}else{
		lang="eng";
		var nextUrl="/html/AXA_PRO/eng/cs/downloads.html";
		window.open(nextUrl, '_self'); 
	}		
 }//end CR-041


 function popupAXAOurWindow(linkURL,nextUrl,lang,type) {
	var strUrl = window.location.href;
	var strCokkie="AXA.AboutAXA.OurBusiness.ImportNotesCookie."+type;
	var hadAgreeVal=getCookie(strCokkie);

	if(hadAgreeVal!=null && hadAgreeVal=="YES"){
		window.open (nextUrl,'newWindow','location=no, menubar=no, toolbar=no, resizable=yes');
	}else{
		var popupUrl=linkURL+"?keepThis=true&nextUrl="+nextUrl+"&lang="+lang;
		window.open(popupUrl, '_self'); 
   }
 }
	

 function getValue(key, str)
 {
	 var val = "";
	 valueList = str.split("&");
	 for(var i = 0; i < valueList.length; i++)
	 {
		 var value = valueList[i].split("=");
		 if(key == value[0])
		 {
			 val = value[1];
		 }
	 }

	 return val;
 }

 function SetCookie(name,value)
 {
	 window.parent.document.cookie = name + "="+ escape (value) + ";"+"path=/";
 }

 function getCookie(name)
 {
	 var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	  if(arr != null)
		  return unescape(arr[2]);
	  return null;

 }


function getConfirmcookie(cookieStr){
	//cookieStr='Insurance.InvestmentLinkedInsurance.ImpNotes'
	var url = window.location.href;
	var pairs=url.split("?")[1];
	var nextUrl = getValue("nextUrl", pairs);
	SetCookie(cookieStr, "YES");
	document.location.href=nextUrl;



 }	

 function checkInvestmentPage(importantNotesUrl){
    var strUrl = window.location.href;
	var strCokkie="Insurance.InvestmentLinkedInsurance.ImpNotes";
	var hadAgreeVal=getCookie(strCokkie);
	var lang;
	if(strUrl.toLowerCase().indexOf("_chi.")>0){
		lang="chi";
	}else{
		lang="eng";
	}
	if(strUrl.indexOf("/insurance/Investment_linked_insurance/")>=0){
		if(hadAgreeVal!=null && hadAgreeVal=="YES"){
			//window.open (strUrl);
		}else{
		var nextUrl=strUrl+"?keepThis=true&nextUrl="+strUrl+"&lang="+lang;
		window.open(popupUrl, '_self'); 
		}
	}
 }

