function changeMetaData(metaTitle,mataValue){

	// First, get the array of meta-tag elements
	metatags = document.getElementsByTagName("meta");
	 
	// Iterate through the array, listing them all
	// Update only the Title meta tag
	for (cnt = 0; cnt < metatags.length; cnt++)
	{
		var name = metatags[cnt].getAttribute("name");
		var content = metatags[cnt].getAttribute("content");
		
		// Update the Title meta tag
		if (metatags[cnt].getAttribute("name") == metaTitle)
			metatags[cnt].setAttribute("content", mataValue);
	}
	
}

pageAnchor = '';

function scrollToAnchor(myAnchor){
	var checkA = document.getElementById(myAnchor);
	if (checkA) {
		new Element.scrollTo(myAnchor);
	}
}

function setPageToolOn(type){
	var pageToolPhone = document.getElementById(type); 
	pageToolPhone.className = pageToolPhone.className == 'pageTool' ? 'pageTool pageToolActive' : 'pageTool';
}

function setIdOn(myA){	
	resetSelected();
	myA = myA.replace("/", "_");
	var myElement =  document.getElementById("menu-"+myA);
	if (myElement) {
		myElement.className = "selectedItem";
	}
}

function resetSelected(){
	var pageTool = document.getElementById('pagetoolEmail');
	if (pageTool) pageTool.className = 'pageTool';
	var cells = document.getElementsByTagName("a"); 
	for (var i = 0; i < cells.length; i++) { 
			if ((cells[i].getAttribute("class")=="topMenu_selectedItem") || (cells[i].getAttribute("class")=="selectedItem")) {
				cells[i].className="topMenu_selectedItem_empty";
    		}
			if ((cells[i].getAttribute("className")=="topMenu_selectedItem") || (cells[i].getAttribute("className")=="selectedItem")) {
				cells[i].className="topMenu_selectedItem_empty";
    		}
	} 
	
	var parentNode =  document.getElementById("topMenu-id")
	
	for (var i = 0; i < parentNode.childNodes.length; i++) {
		if (parentNode.childNodes[i].className="selectedItem") {
			parentNode.childNodes[i].className="topMenu_selectedItem_empty";
		}
	}
}

function setMoTOn(myName){
	var cells = document.getElementById(myName);
	if (cells) {
		var parentElement = cells.parentNode;
		parentElement.className="topMenu_selectedItem";
	}
}

function setMoTOnNew(myUrl){
	myUrl = myUrl.replace("/", "_");
	var mot = document.getElementById("mot-"+myUrl);
	if (mot) {
		mot.className="topMenu_selectedItem";
	}
}

function loadContent(myUrl){

	var checkOldURLHash = location.hash.indexOf('/');
	var checkNewURL = myUrl.indexOf('/');

	//alert("HomePage : " + checkNewURL);
	
	if (checkNewURL == -1 && ( loginMode == 'true' || (myUrl.indexOf('?debugstate') > -1)))
	{
		$("topMenu-id").hide();
		$("leftMenu").style.top = "64px"
	}
	else
	{
		$("topMenu-id").show();
		$("leftMenu").style.top = "158px"
	}

	getContent(myUrl,'dynamic_content','ajax');
	if (myUrl.indexOf("?")>-1) {
		getContent(myUrl+'&breadcrum=on','dynamic_breadcrumContainer','ajax');
	}else{
		getContent(myUrl+'?breadcrum=on','dynamic_breadcrumContainer','ajax');
	}
}

function loadIlink(newLocation){
	ResertAndDisplay(newLocation);
}

function saveElementsPage(myLocation,myTitle,myId) {

    

	var complexObject = new Object();
    complexObject.value = new Array();
    complexObject.value[0] = myLocation;
    complexObject.value[1] = myTitle;
	if (myId) complexObject.value[2] = myId; else complexObject.value[2] = myLocation;
	
	if (myLocation.indexOf("?")>-1) {
		var myPos=(myLocation.indexOf("?"));
		var myNewLocation=myLocation.substring(0,myPos);
		dhtmlHistory.add(myNewLocation,complexObject);
	}else{
		dhtmlHistory.add(myLocation,complexObject);
	}
}

function updateElementsPage(myLocation,myTitle,myId) {

	//changeElementsPageWT(myTitle);
	//the function over is call by extension template
	loadContent(myLocation);
	if (myId) setIdOn(myId);
	setMoTOnNew(myLocation);

	scrollTo(0,0);
	if (myTitle) {

		var countryName=DCSext.Countryname;
		document.title="ABN AMRO Private Banking - " + countryName + " - " +myTitle;
		changeMetaData('WT.cg_n',myTitle);
		dcsMultiTrack('DCS.dcsuri',urlServer+myLocation,'WT.ti',"ABN AMRO Private Banking - "+myTitle,'WT.cg_n',myTitle,'DCSext.Country',DCSext_Country,'DCSext.Language',DCSext_Language,'DCSext.ContentType',DCSext_ContentType,'WT.sp',Country_WT_sp);
	}
 
}

function pageLen() {
	var myHash = hashpage();
	var myPage = myHash.split("/");
	if (myPage.length>2)
		return myPage[0]+'_'+myPage[1];
	else
		return false;
}

function changeElementsPageWT(myTitle,myId) {


	if ((myId) && (myId!="")) loadIlink(myId);
	if (myTitle) {
	
		document.title="ABN AMRO Private Banking - "+myTitle;
		changeMetaData('WT.cg_n',myTitle);
	}
	DCSext_ContentType = 'Content';
	changeMetaData('DCSext.ContentType',DCSext_ContentType);
	changeMetaData('WT.si_n','');
	changeMetaData('WT.si_p','');
}
	
function loadPageElementsILink(myLocation,myTitle,myId) {

	surveymonkey();
	saveElementsPage(myLocation,myTitle,myId);
	if ((myId) && (myId!="")) loadIlink(myId); else loadIlink(myLocation);
	updateElementsPage(myLocation,myTitle,myId);
}

function setupPrintTool()
{
var countryNameForFlash;
var currWorldContactURL1 = document.URL;
currWorldContactURL1 = currWorldContactURL1.toLowerCase();

if(currWorldContactURL1.indexOf("global") != -1)
{
countryNameForFlash= "global";
}
if(currWorldContactURL1.indexOf("belgium") != -1)
{
countryNameForFlash= "belgium";
}
if(currWorldContactURL1.indexOf("uae") != -1)
{
countryNameForFlash= "uae";
}
if(currWorldContactURL1.indexOf("neuflizeobc") != -1)
{
countryNameForFlash= "neuflizeobc";
}
if(currWorldContactURL1.indexOf("delbethmaff") != -1)
{
countryNameForFlash= "delbethmaff";
}
if(currWorldContactURL1.indexOf("hongkong") != -1)
{
countryNameForFlash= "hongkong";
}
if(currWorldContactURL1.indexOf("jersey") != -1)
{
countryNameForFlash= "jersey";
}
if(currWorldContactURL1.indexOf("luxembourg") != -1)
{
countryNameForFlash= "luxembourg";
}
if(currWorldContactURL1.indexOf("singapore") != -1)
{
countryNameForFlash= "singapore";
}
if(currWorldContactURL1.indexOf("switzerland") != -1)
{
countryNameForFlash= "switzerland";
}
var tempVarForFlash = countryNameForFlash + "?print=";

document.getElementById('pagetoolPrint').onclick = function(){var mypage=hashpage(); 
var offlocid=document.getElementById('officelocator');  
window.open(tempVarForFlash+mypage); 
return false;}
}

function loadPageElements(myLocation,myTitle) {
	surveymonkey();
	saveElementsPage(myLocation,myTitle,myLocation);
	updateElementsPage(myLocation,myTitle,myLocation);
	setupPrintTool();
}

function loadPageElementsAdminNews(myLocation) {
	if (myLocation.indexOf("?")>-1) {
		var myPos=(myLocation.indexOf("?"));
		var myNewLocation=myLocation.substring(0,myPos);
		myNewLocation=myNewLocation+myLocation.substring(myPos+1);
		dhtmlHistory.add(myNewLocation,myLocation);
	}else{
		dhtmlHistory.add(myLocation);
	}
	loadContent(myLocation); 
	loadIlink(myLocation); 
	scrollTo(0,0);
}

function toggles(myId){

	thisId=document.getElementById(myId);
	if (thisId.style.display == "none"){
	    thisId.style.display = "";
	}else{
	    thisId.style.display = "none";
	}
						
	var body = document.getElementById(myId);
	var count = document.all(myId).length;
	for(i=0; i<count; i++){
		body = document.all(myId);
		body.style.display = "";
	}
}

function hashpage(){

	var myPage=window.location.hash;
	myPage=myPage.substring(1);
	return myPage;
}

function shortPageName(){
	var PageName = hashpage();
	if (PageName.indexOf("/")>-1) {
		var myPos=(PageName.indexOf("/"));
		PageName=PageName.substring(myPos+1);
	}else{
		PageName = "";
	}
	return PageName;
}


//for Contact form US Persons 

function filter_country(myCurrentLanguage){

    var a="\u00E4";
	var u="\u00FC";
	var e="\u00E9";
	var e_cap="\u00EA";
	var a_fr="\u00E0";
	var countryAlert=" ";
	var x=document.getElementById("customer_country");
 	var countryOfResidence=x.options[x.selectedIndex].text;
	 
	 //checking the language version
	 if(myCurrentLanguage=="en") //for english version
	 	var countryAlert= "Thank you for your interest in our bank. Unfortunately,"+'</br>'+" due to legal restriction, we are unable to provide any"+'</br>'+" service to US residents at the moment."+'</br></br>'+"We hope to have the opportunity to serve you in the "+'</br> '+"future."; 
	 
	 else if(myCurrentLanguage=="fr")  //for french version
	  	var countryAlert= "Madame, Monsieur,"+'</br>'+"Nous vous remercions de l&#8217;int"+e+"r"+e_cap+"t que vous portez "+a_fr+" notre banque."+'</br> '+"Malheureusement, pour des raisons r"+e+"glementaires, nous"+'</br> '+" ne sommes pas en mesure pour le moment servir les"+'</br>'+" r"+e+"sidents am"+e+"ricains."+'</br></br>'+"Nous esp"+e+"rons avoir l&#8217;opportunit"+e+" de vous proposer nos"+'</br> '+"services dans un proche avenir."+'</br></br> '+"Dans cette attente, nous vous prions d&#8217;agr"+e+"er,Madame,"+'</br>  '+"Monsieur, nos salutations distingu"+e+"es.";
	 
	 else if (myCurrentLanguage=="de")  //for german version
		 var countryAlert = "Frau, Herr,"+'</br>'+"Vielen Dank f"+u+"r Ihr Interesse. Leider d"+u+"rfen wir US-B"+u+"rgern auf Grund rechtlicher Beschr"+a+"nkungen derzeit keine Dienstleistungen anbieten."+'</br> '+"Wir hoffen, in Zukunft einmal Gelegenheit zu haben, Ihnen behilflich zu sein.";
	 
	 else if (myCurrentLanguage=="it")  //for italian version
	 	 var countryAlert= "Grazie per il suo interesse per la nostra Banca. Ci dispiace che a causa di restrizioni legali, attualmente non siamo in grado di fornire alcun servizio ai residenti negli Stati Uniti."+ '</br> '+"Ci auguriamo di avere quest'opportunit&#224; in futuro.";
	 
	 else if (myCurrentLanguage=="nl")  //for dutch version
	 	 var countryAlert = "Bedankt voor uw interesse in onze bank. Helaas kunnen we inwoners van de Verenigde Staten om juridische redenen geen diensten aanbieden. "+'</br> '+" We hopen dat we in de nabije toekomst de mogelijkheid hebben om u van dienst te zijn.";
	 
	 else    
	 	 var countryAlert= "Thank you for your interest in our bank. Unfortunately,"+'</br> '+" due to legal restriction, we are unable to provide any"+'</br>'+" service to US residents at the moment."+'</br></br>'+"We hope to have the opportunity to serve you in the future."; 
	 
	if (countryOfResidence=="United States") // Displaying special message for US Residents
	 {
	 	
	 	document.getElementById("country_filter").innerHTML=countryAlert;
		document.getElementById("countryMsg").style.display="block";
		document.getElementById("country_filter").style.display="block";
		document.getElementById("lastRow").style.display="none";

	 }

	 else
	 {
	 	document.getElementById("country_filter").innerHTML=" ";
		document.getElementById("countryMsg").style.display="none";
		document.getElementById("lastRow").style.display="block";
		document.getElementById("country_filter").style.display="none";
		document.getElementById("lastRow").style.display="block";
	 }	 
  }
  
var varForNoFlash= "No";

function changeVarForNoFlash(opt)
{
//alert(document.URL);
var currWorldContactURL = document.URL;
var currCountryFlash;
var launchFlashURL;
currWorldContactURL = currWorldContactURL.toLowerCase();

if(currWorldContactURL.indexOf("global") != -1)
{
currCountryFlash = "global";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/ghp-worldwide-contacts";
}
if(currWorldContactURL.indexOf("belgium") != -1)
{
currCountryFlash = "belgium";
launchFlashURL = "http://www.abnamroprivatebanking.com/nl/print/be-where-find-us"
}
if(currWorldContactURL.indexOf("uae") != -1)
{
currCountryFlash = "uae";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/uae-where-find-us";
}
if(currWorldContactURL.indexOf("neuflizeobc") != -1)
{
currCountryFlash = "neuflizeobc";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/obc-worldwide-contacts";
}
if(currWorldContactURL.indexOf("delbethmaff") != -1)
{
currCountryFlash = "delbethmaff";
launchFlashURL = "http://www.abnamroprivatebanking.com/de/print/debm-worldwide-contacts";
}
if(currWorldContactURL.indexOf("hongkong") != -1)
{
currCountryFlash = "hongkong";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/hk-where-find-us";
}
if(currWorldContactURL.indexOf("jersey") != -1)
{
currCountryFlash = "jersey";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/bi-where-find-us";
}
if(currWorldContactURL.indexOf("luxembourg") != -1)
{
currCountryFlash = "luxembourg";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/lu-where-find-us";
}
if(currWorldContactURL.indexOf("singapore") != -1)
{
currCountryFlash = "singapore";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/sg-where-find-us";
}
if(currWorldContactURL.indexOf("switzerland") != -1)
{
currCountryFlash = "switzerland";
launchFlashURL = "http://www.abnamroprivatebanking.com/print/en/ch-worldwide-contacts";
}

varForNoFlash = opt;
if(varForNoFlash=="No")
{
document.getElementById('pagetoolPrint').onclick = function(){window.open(launchFlashURL); return false;}
}
if(varForNoFlash=="Yes")
{
document.getElementById('pagetoolPrint').onclick = function(){window.open('http://www.abnamroprivatebanking.com/print/en/ghp-worldwide-contacts' + "?noflash=yes&noflashprint=yes"); return false;}
}
}
 
