/*
 * standard.js : standard functions for the Wholesale portals
 */

currURL = document.location.href;
if (currURL.indexOf('/wholesale/') > 0 || currURL.indexOf('.wholesale.') > 0) {
 newURL = currURL.replace(/\/wholesale\//, '/corporates/')
 newURL = newURL.replace(/\.wholesale\./, '.corporates.')
 document.location.replace(newURL)
}

// getgtsserver(): returns the URL of the GTS server to use (PR or ET),
// determined by the current location. If we're in UAT, then we'll suggest
// wwwacc. Default is to stay with production (www.gts.abnamro.com).
// [KK 2005-06-10] 
function getgtsserver() {
    var loc = window.location;
    var re  = new RegExp ('whole-mig', 'i');
    if (re.test (loc)) return ('https://wwwacc.gts.abnamro.com');
    return ('https://www.gts.abnamro.com');
}
function getaccessserver() {
    var loc = window.location;
    var re  = new RegExp ('whole-mig', 'i');
    if (re.test (loc)) return ('https://access.workingcapital.uat.gb.abnamro.com');
    return ('https://access.workingcapital.abnamro.com');
}
function getwocaserver() {
    var loc = window.location;
    var re  = new RegExp ('whole-mig', 'i');
    if (re.test (loc)) return ('http://wocaopen.uat.gb.abnamro.com');
    return ('http://www.workingcapital.abnamro.com');
}

// goservice(number): open a service in a new window, chosen by the user
// in the right hand side drop down box
function goservice(num) {
	if (num.indexOf('http') == 0) {
		window.open(num);
	}
	else {
		num = parseFloat(num);
		switch(num)
		{
		 case 1:
			window.open('https://www.dealstation.abnamro.com/');
			break;
		 case 2:
			window.open('http://www.maxtrad.com');
			break;
		 case 3:
		 	window.open('http://www.abnamroresearch.com/');
			break;
		 case 4:
		 	window.open('/cdi/');
			break;
		 case 5:
		 	window.open('/corporates/docs/product/OnlineConfirmations/index.html','OnlineConfirmations','toolbar=0,location=0,menubar=1,resizable=1,scrollbars=1,directories=0,status=1,width=796,height=600');
			break;
		 case 6:
		 	alert('Please select a Sign On method for this service.');
			break;
		 case 7:
		 	window.open(getgtsserver() + '/sms/login/password/redirect_login.html?' + 'USERTARGET=/wos/closed/');
			break;
		 case 8:
			window.open(getgtsserver() + '/sms/login/dp300/redirect_login.html?' + 'USERTARGET=/wos/closed/');
			break;
		 case 11:
			window.open('http://www.abnamro.com/online/');
			break;
		 case 12:
			window.open(getaccessserver());
			break;


		 case 15:
		 	alert('Please select a Sign On method for this service.');
			break;
		 case 20:
			window.open(getgtsserver() + '/sms/login/password/redirect_login.html?' + 'USERTARGET=/wos/closed/');
			break;
		 case 21:
			window.open(getgtsserver() + '/sms/login/dp300/redirect_login.html?' + 'USERTARGET=/wos/closed/');
			break;
		 case 22:
			window.open('https://www.abnamro.nl/nl/wocalogon/identification.html');
			break;
		 case 25:
			window.open('https://access.abnamro.com/wps/myportal/');
			break;
		 case 26:
			window.open('http://www.access.abnamro.com/wps/portal/!ut/p/kcxml/04_Sj9SPykssy0xPLMnMz0vM0Y_QjzKLN4j3NQLJgFjGpvqRqCKOcIEgfW99X4_83FT9AP2C3NCIckdHRQB4PYyY/delta/base64xml/L0lDU0lKQ1RPN29na21BISEvb0VvUUFBSVFnakZJQUFRaENFSVFqR0VBLzRKRmlDbzBlaDFpY29uUVZHaGQtc0lRIS83XzBfRFZQLzI!?PC_7_0_DVP_file=%2fopenworld%2fjsp%2fen%2fAccessOnline%2fdemonstration.jsp#7_0_DVP');
			break;
		 case 30:
			window.open('https://www.maxtrad.com/');
			break;
		 case 31:
			window.open('http://www.maxtrad.com/demo/index.html');
			break;
		 case 35:
			window.open('https://www.dealstation.abnamro.com/');
			break;
		 case 36:
			window.open('https://www.dealstation-demo.abnamro.com/clientExtDemo.html');
			break;
		 case 40:
			window.open('/cdi/');
			break;
		 case 41:
			window.open('/corporates/docs/product/OnlineConfirmations/index.html');
			break;
		 case 45:
			window.open('https://www.abnamroresearch.com/');
			break;
		 default:
		 	alert('Please select a service.');
			break;
		 }
	}
}

function showmeta() {
 showLayer('metapopup');
}

function hidemeta() {
 hideLayer('metapopup');
}



function hideLayer(whichLayer) {
 if (document.getElementById) {
  document.getElementById(whichLayer).style.visibility = "hidden";
 }
 else if (document.all) {
  document.all[whichlayer].style.visibility = "hidden";
 }
 else if (document.layers) {
  document.layers[whichLayer].visibility = "hidden";
 }
}

function showLayer(whichLayer) {
 if (document.getElementById) {
  document.getElementById(whichLayer).style.visibility = "visible";
 }
 else if (document.all) {
  document.all[whichlayer].style.visibility = "visible";
 }
 else if (document.layers) {
  document.layers[whichLayer].visibility = "visible";
 }
}

function changeImage(id, source) {
 if (document.getElementById) {
  document.getElementById(id).src = source
 }
 else if (document.all) {
  document.all[source].src = source
 }
}

window.onload = levelOneWhiteLine;
window.onresize = resizeContentTable;

function resizeContentTable() {
 if (document.getElementById) {
  if (document.getElementById('contenttable')) {
   blSpace = (levOneNav) ? 252 : 199;
   if (window.innerHeight) {
    document.getElementById('contenttable').style.height = window.innerHeight - blSpace
   }
   else if (window.document.body.offsetHeight) {
    document.getElementById('contenttable').style.height = window.document.body.offsetHeight - blSpace
   }
   if (document.getElementById('navigation')) {
    nav = document.getElementById('navigation');
    if (parseInt(document.getElementById('contenttable').offsetHeight) < parseInt(nav.offsetHeight) + 110) {
     document.getElementById('contenttable').style.height = parseInt(nav.offsetHeight) + 110
    }
   }
  }
 }
 if (document.getElementById('product0')) reposFooter(document.getElementById('product0'))
 if (document.getElementById('sector0')) reposFooter(document.getElementById('sector0'))
}

function blurImages() {
 for (i=0; i<document.images.length; i++) {
//  document.images[i].attachEvent('onclick','this.blur()')
 }
}

function levelOneWhiteLine() {
 if (document.getElementById && selectedImage) {
  if (document.getElementById(selectedImage)) {
   levelonenav = document.getElementById(selectedImage)
   layerleft = levelonenav.offsetLeft - 11
   layertop = levelonenav.offsetTop
   var eParElement = levelonenav.offsetParent;
   while (eParElement != null) {
    layerleft += eParElement.offsetLeft;
    layertop += eParElement.offsetTop;
    eParElement = eParElement.offsetParent;
   }
   myDiv = document.createElement('div')
   myDiv.style.position = 'absolute';
   myDiv.style.width = levelonenav.offsetWidth + 22;
   if (parseInt(layerleft) + parseInt(myDiv.style.width) > 754) myDiv.style.width = levelonenav.offsetWidth + 11
   myDiv.style.left = layerleft;
   if (selectedImage=='levelonenav0') { myDiv.style.left = layerleft + 0; myDiv.style.width = levelonenav.offsetWidth + 22 }
   myDiv.style.height = 1;
   myDiv.style.top = layertop + levelonenav.offsetHeight;
   myDiv.style.backgroundColor = '#FFF'
   myDiv.innerHTML = '<img src="/corporates/resources/images/blank.gif" height="1" width="'+myDiv.style.width+'"/>'
   document.body.appendChild(myDiv)
  }
 }
 initNews()
 scrollnews()
 resizeContentTable()
 alignRelInfo()
 blurImages()
 mouseOverArrows()
// spaceABNAmro()
}

function alignRelInfo() {
 if (document.getElementById) {
//  if (document.location.href.indexOf('/country/') < 0) {
   if (document.getElementById('MainColumn') && document.getElementById('RelInfo') && !document.getElementById('SignOn')) {
    toppos = document.getElementById('MainColumn').offsetTop
    eParElement = document.getElementById('MainColumn').offsetParent;
    while (eParElement != null) {
     toppos += eParElement.offsetTop;
     eParElement = eParElement.offsetParent;
    }
    document.getElementById('RelInfo').style.position = 'absolute'
    document.getElementById('RelInfo').style.top = toppos
   }
//  }
 }
}


function printFriendlyPage() {
 docTitle = '<title>'+document.title+'</title>'
 mainCont = document.getElementById('PrintArea').innerHTML;
 relInfo = document.getElementById('RelInfo').innerHTML;
 cssLink = '<link href="/country/resources/css/print.css" type="text/css" rel="stylesheet" />';
 logoAAB = '<img src="/country/resources/images/static/logo.gif"/>';
 printScript = '<scr'+'ipt>printed = false; function printIt() { window.print(); printed = true; if (document.getElementById) setTimeout("window.close()",5000); } function closeIt() { if (printed) window.close() }</scr'+'ipt>';
 if (document.location.href.indexOf('/news/') != 0) {
  w_html = '<html><head>'+docTitle+''+cssLink+''+printScript+'</head><body onload="printIt()" onfocus="closeIt()">'+logoAAB+'<br><br>'+mainCont+'<br><br>'+relInfo+'</body></html>'
 }
 if (document.location.href.indexOf('/country/contacts/') != 0) {
  mainCont = mainCont.replace(/<SPACER ([a-zA-Z0-9 "=\/\\]*)>/i, '<br/><br/>'+relInfo)
  w_html = '<html><head>'+docTitle+''+cssLink+''+printScript+'</head><body onload="printIt()" onfocus="closeIt()">'+logoAAB+'<br><br>'+mainCont+'</body></html>'
 }
 w = window.open('about:blank','printWindow','width=600,height=600,menubar=yes,scrollbars=yes,resizable=yes,status=no,directories=no,location=no');
 w.document.open();
 w.document.write(w_html)
 w.document.close();
}

function mouseOverArrows() {
 if (document.getElementById){
  for (i=0; i<document.getElementsByTagName('a').length; i++) {
   for (j=0; j<document.getElementsByTagName('a')[i].childNodes.length; j++) {
    if (document.getElementsByTagName('a')[i].childNodes[j].nodeName.toLowerCase() == 'img') {
	 if (document.getElementsByTagName('a')[i].childNodes[j].src.indexOf('but_arrow_r.gif') > 0) {
	  if (document.addEventListener) {
	   document.getElementsByTagName('a')[i].addEventListener('mouseover', mouseOverArrow, false)
	   document.getElementsByTagName('a')[i].addEventListener('mouseout', mouseOutArrow, false)
	  }
	  else if (document.attachEvent) {
	   document.getElementsByTagName('a')[i].attachEvent('onmouseover', mouseOverArrow)
	   document.getElementsByTagName('a')[i].attachEvent('onmouseout', mouseOutArrow)
	  }
	 }
	}
   }
   if (document.getElementsByTagName('a')[i].href.indexOf(document.domain) != 7 && document.getElementsByTagName('a')[i].href.indexOf('http://') == 0) {
    document.getElementsByTagName('a')[i].target = '_blank';
   }
   else if (document.getElementsByTagName('a')[i].href.indexOf(document.domain) == 7 && document.getElementsByTagName('a')[i].href.indexOf('.pdf') > 15) {
    document.getElementsByTagName('a')[i].target = '_blank';
   }
  }  
 }
}

function mouseOverArrow(e) {
 if (!e) var e = window.event;
 if (e.target) { currLink = e.target }
 else { currLink = e.srcElement }
 if (currLink.childNodes.length == 1) currLink = currLink.parentElement
 for (j=0; j<currLink.childNodes.length; j++) {
  if (currLink.childNodes[j].nodeName.toLowerCase() == 'img') {
   if (currLink.childNodes[j].src.indexOf('but_arrow_r.gif') > 0) {
    currLink.childNodes[j].src = currLink.childNodes[j].src.replace(/but_arrow_r/i, 'but_arrow_n')
   }
  }
 }
}

function mouseOutArrow(e) {
 if (!e) var e = window.event;
 if (e.target) { currLink = e.target }
 else { currLink = e.srcElement }
 if (currLink.childNodes.length == 1) currLink = currLink.parentElement
 for (j=0; j<currLink.childNodes.length; j++) {
  if (currLink.childNodes[j].nodeName.toLowerCase() == 'img') {
   if (currLink.childNodes[j].src.indexOf('but_arrow_n.gif') > 0) {
    currLink.childNodes[j].src = currLink.childNodes[j].src.replace(/but_arrow_n/i, 'but_arrow_r')
   }
  }
 }
}

function reposFooter(lay) {
 h = parseInt(lay.offsetHeight) + 133;
 if (document.getElementById) {
  if (document.getElementById('contenttable')) {
   if (parseInt(document.getElementById('contenttable').style.height) > h) {
    if (window.innerHeight) {
     document.getElementById('contenttable').style.height = window.innerHeight - 222
    }
    else if (window.document.body.offsetHeight) {
     document.getElementById('contenttable').style.height = window.document.body.offsetHeight - 222
    }
   }
   if (parseInt(document.getElementById('contenttable').style.height) <= h) {
    document.getElementById('contenttable').style.height = h;
   }
  }
 }
}

//function spaceABNAmro() {
// if (document.getElementById) {
//  if (document.getElementById('contenttable')) {
//   document.getElementById('contenttable').innerHTML = document.getElementById('contenttable').innerHTML.replace(/ABN AMRO/g,'ABN&nbsp;AMRO');
//  }
// }
//}

var t;
function showmeta2() {
 clearTimeout(t)
 showLayer('metapopup2');
 document.getElementById('keyword').focus()
}

function hidemeta2() {
 t = setTimeout('hideLayer(\'metapopup2\')', 1000);
}

function initNews() {
 if (document.getElementById) {
  if (document.getElementById('newsWindow')) {
    n1 = document.getElementById('newsLayer1');
    n2 = document.getElementById('newsLayer2');
    nW = document.getElementById('newsWindow');
    n1.style.display = '';
    n2.style.display = '';
    n1H = parseInt(n1.offsetHeight);
    n2H = parseInt(n2.offsetHeight);
    nWH = (n1H > n2H) ? n1H : n2H;
    n1.style.height = nWH;
    n2.style.height = nWH;
    nW.style.height = nWH;
    n1.style.top = parseInt(nW.style.top) + nWH;
    n2.style.top = parseInt(nW.style.top);
    n2Flag = false;
  }
 }
}

function scrollnews() {
 if (document.getElementById) {
  if (document.getElementById('newsWindow')) {
    
    n1T = parseInt(n1.style.top);
    n2T = parseInt(n2.style.top);
    nWT = parseInt(nW.style.top);

    if (n1T - nWH <= nWT) {
     n1.style.visibility = 'visible';
     n1.style.display = '';
    }
    
    if (n1T == nWT) n2Flag = true;

    if (n2T - nWH <= nWT && n2Flag) {
     n2.style.visibility = 'visible';
     n2.style.display = '';
    }

    n1.style.top = n1T - 1;
    n1CT = (n1T < nWT) ? (nWT - n1T) : 0;
    n1CB = (n1T > nWT + nWH) ? 0 : (nWT+nWH - n1T);
    n1.style.clip = 'rect('+n1CT+'px, 140px, '+n1CB+'px, 0px)'

    n2.style.top = n2T - 1;
    n2CT = (n2T < nWT) ? (nWT - n2T) : 0;
    n2CB = (n2T > nWT + nWH) ? 0 : (nWT+nWH - n2T);
    n2.style.clip = 'rect('+n2CT+'px, 140px, '+n2CB+'px, 0px)'

    if (n1T + (nWH - 1) == nWT) {
     n1.style.top = nWT + nWH;
    }

    if (n2T + (nWH - 1) == nWT) {
     n2.style.top = nWT + nWH;
    }

    tO = (n1T == nWT || (n2T == nWT && n2Flag)) ? 2500 : 30;
    t = setTimeout('scrollnews()', tO)
  }
 }
}


if (document.layers) {
    document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = captureMousePosition;

var topPos = 0;
var topNewPos = 0;
var yBase = 0;
var yDiff = 0;
var yPos = 0;
function captureMousePosition(e) {
    if (document.layers){
		topPos = e.pageY-20
		yBase = window.innerHeight
	}
	else if (document.all){
		topPos = window.event.y+document.body.scrollTop-20
		yBase = window.document.body.offsetHeight
	}
	else if (document.getElementById){
		topPos = e.pageY-20
		yBase = window.innerHeight
	}
	yPos = topPos + 20
	yDiff = yBase - topPos -20
	yBase = yBase -100;
	topNewPos = yPos - 100;
	topPos = (topPos > yBase) ? topNewPos : topPos
	topPos = (yDiff <= 300) ? yPos - 100 : topPos
	topPos = (topPos <= 100) ? 110 : topPos
}

var objectShown = false;

function download(object,url,size) {
	type = object.toUpperCase();

	if (type.match(/GIF/g)) { Title = "gif" }
	else if (type.match(/JPG/g)) { Title = "jpg"  }
	else if (type.match(/JPEG/g)) { Title = "jpeg" }
	else if (type.match(/MP3/g)) { Title = "mp3" }
	else if (type.match(/MPEG/g)) { Title = "mpeg" }
	else if (type.match(/PPS/g)) { Title = "pps" }
	else if (type.match(/PPT/g)) { Title = "ppt" }
	else if (type.match(/PDF/g)) { Title = "pdf" }
	else if (type.match(/ZIP/g)) { Title = "zip" }
	else { Title = "Document" }

	if (!isNaN(size)) size = size + "&nbsp;KB";

	if (document.location.href.toLowerCase().indexOf('/exco/') >= 0) url = "/country/resources/images/exco/"+url;
	if (url.indexOf('images/') == 0 || url.indexOf('attachments/') == 0) url = "/country/resources/"+url;

	html = '<table border="0" cellspacing="0" cellpadding="1" bgcolor="#000000" width="350"><tr><td  valign="top" height="100%">';
	html+= '<table border="0" cellspacing="0" cellpadding="12" bgcolor="#FFFFFF" width="100%">';
	if (type.match(/GIF/g) || type.match(/JPG/g) || type.match(/JPEG/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open image</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a large image.';
		html+=	'<br>';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open file (' + size + ')</b></a>';
	}else if (type.match(/PPS/g) || type.match(/PPT/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open PowerPoint presentation</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a PowerPoint file.';
		html+=	'<br>You need at least Microsoft PowerPoint Viewer 97 in order to read this file.';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open file (' + size + '&nbsp;KB)</b></a>';
		html+= '<br><br>If you don\'t have the software, you can download a <a href="http://www.microsoft.com/downloads/details.aspx?familyid=428d5727-43ab-4f24-90b7-a94784af71a4" target="_blank">Microsoft PowerPoint Viewer</a> for free.';
	}else if (type.match(/MPEG/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open video file</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a video file.';
		html+=	'<br>You need a media player in order to see this file.';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open file (' + size + ')</b></a>';
		html+= '<br><br>If you don\'t have the software, you can download <a href="http://www.windowsmedia.com/download" target="_blank">Windows Media Player</a> for free.';
		html+= '<br><br><a href=" http://www.windowsmedia.com/download" target="_blank"><img src="/country/resources/images/getmediaplayer.gif" alt="Download Windows Media Player" border="0"></a>';
	}else if (type.match(/MP3/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open audio file</td></tr>';
		html+=	'<tr><td class="normal">You are about to open an audio file.';
		html+=	'<br>You need a media player in order to hear this file.';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open file (' + size + ')</b></a>';
		html+= '<br><br>If you don\'t have the software, you can download <a href="http://www.windowsmedia.com/download" target="_blank">Windows Media Player</a> for free.';
		html+= '<br><br><a href=" http://www.windowsmedia.com/download" target="_blank"><img src="/country/resources/images/getmediaplayer.gif" alt="Download Windows Media Player" border="0"></a>';
	}else if (type.match(/PDF/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open&nbsp;' +Title.toUpperCase()+ '&nbsp;document</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a&nbsp;' +Title.toUpperCase()+ '&nbsp;document.';
		html+=	'<br>To read and print it you need at least version 4 of the free software program Adobe Acrobat Reader.';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open document (' + size + ')</b></a>';
		html+= '<br><br>If you don\'t have the software, you can download <a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">Adobe Acrobat Reader</a> for free.<br><br><a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank"><img src="/country/resources/images/getacro.gif" width="88" height="31" alt="" border="0"></a>';
	}else if (type.match(/ZIP/g)){
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open&nbsp;' +Title.toUpperCase()+ '&nbsp;document</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a&nbsp;' +Title.toUpperCase()+ '&nbsp;file.';
		html+=	'<br>To open and/or extract it you need the free software program WinZip.';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open document (' + size + ')</b></a>';
		html+= '<br><br>If you don\'t have the software, you can download <a href="http://www.winzip.com/downwzeval.htm" target="_blank">WinZip</a> for free.<br><br><a href="http://www.winzip.com/downwzeval.htm" target="_blank"><img src="/country/resources/images/getwinzip.gif" alt="" border="0"></a>';
	}else {
		html+=	'<tr><td bgcolor="#009286" align="left" valign="middle" class="titlelevel1">Open&nbsp;' +Title+ '</td></tr>';
		html+=	'<tr><td class="normal">You are about to open a&nbsp;' +Title+ '.';
		html+=	'<br>To read and print it you need software program that supports document type';
		html+= '<br><br><a href="' + url + '" target=_blank><b>Open file (' + size + ')</b></a>';
		html+= '<br><br>If you don\'t have related software, please contact your system administrator.';
	}
	html+= '</td></tr>'
	html+= '<tr><td align="right" valign="bottom"><a href="javascript:hide(\''+object+'\')">Close window</a></td></tr>'
	html+= '</table></td></tr>';
	html+= '</table>';
	if (document.layers && document.layers[object]) {
		document.layers[object].document.open();
		document.layers[object].document.write(html);
		document.layers[object].document.close();
	}
	else if (document.getElementById) {
                if (!document.getElementById(object)) {
			dlDiv = document.createElement('div');
			dlDiv.id = object;
			dlDiv.className = 'download';
			document.body.appendChild(dlDiv);
		}
		document.getElementById(object).innerHTML = html;
	}
	else if (document.all) {
		document.all[object].innerHTML = html;
	}
	show(object);
}

function show(object) {
	if (objectShown)
		hide(objectShown)
	if (document.layers && document.layers[object]){
		document.layers[object].visibility = 'visible';
		document.layers[object].top = topPos;
	}else if (document.getElementById){
		document.getElementById(object).style.visibility = 'visible';
		document.getElementById(object).style.top = topPos;
	}else if (document.all){
		document.all[object].style.visibility = 'visible';
		document.all[object].style.top = topPos;
	}
	objectShown = object;
}
function hide(object) {
	if (document.layers && document.layers[object])
		document.layers[object].visibility = 'hide';
	else if (document.getElementById)
		document.getElementById(object).style.visibility = 'hidden';
	else if (document.all)
		document.all[object].style.visibility = 'hidden';
}



/**                                                   *
 * function rotateImages()                            *
 * this function is used to rotate the title and PoD  *
 * images based on a client-specified interval        *
**/

function rotateImages(startDate, duration, timeframe, homeImages) {
 if (document.getElementById) {
  seconds = 1000;
  minutes = seconds * 60;
  hours = minutes * 60;
  days = hours * 24;
  weeks = days * 7;

  titleFolder = '/corporates/resources/images/titles/'
 
  today = new Date();
 
  if (timeframe != 'weeks' && timeframe != 'days' && timeframe != 'hours' && timeframe != 'minutes' && timeframe != 'seconds') timeframe = 'days';
  timeframe=eval(timeframe);
 
  if (!parseInt(startDate) || startDate.length != 8) return;
  startDate = new Date(startDate.substring(0,4), (startDate.substring(4,6)-1), startDate.substring(6,8));
  if (startDate < today) {
   timeDiff = parseInt((today.getTime() - startDate.getTime()) / timeframe);
  }
  else {
   return;
  }
  duration = parseInt(duration);
  if (!duration) duration = 7;
 
  cycleNo = parseInt(parseInt(timeDiff) / parseInt(duration));
  imagesNo = cycleNo % homeImages.length;

  titleImg = document.getElementById('titleImage');
  titleImg.setAttribute('src', titleFolder + homeImages[imagesNo][0]);
  titleImg.setAttribute('alt', homeImages[imagesNo][1]);
 }
}



/**
 * This section below added for ABN AMRO Survey (Clicktools).
 * Added to stylesheet.js to ensure cookies are used on all 
 * pages, without the need to regenerate all pages on the site. 
 * For future (re-)development, a generic js should be created 
 * to hold temporary functions like these.
**/


var showSurvey = false;
var expDate;
var pageVisits;
var visitorNumber;
var randomNumber = Math.floor(Math.random()*4) + 1;
var popupURL = "http://nl.sitestat.com/abnamro/wholesale/s?Survey&ns_type=clickin"; //"/country/resources/survey/index.html";
var popupWin;


/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a 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));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/** Create an expiration date for the cookie that determines if
    the popup has been shown. Currently set to now + 10 years. **/
expDate = new Date;expDate.setDate(expDate.getDate()+3650);

/** How many pages has the user visited in this session(!)
    Set it in a session-cookie **/
//pageVisits = getCookie("visits") ? parseInt(getCookie("visits")) + 1 : 1;
//setCookie("visits", pageVisits, "", "/");

/** Since we want to show this popup to only 25% of the users, we 
    create a random number between 1 and 4 (for this session only!)
    If the visitor gets a number 4, we show them the popup after
    the second page. Also stored in a session-cookies **/
//visitorNumber = getCookie("visitorNumber") ? getCookie("visitorNumber") : randomNumber;
//setCookie("visitorNumber", visitorNumber, "", "/");

/** If the visitor has a number "4", has visted more than 1 page,
    and has never seen the popup before, prepare to popup the
    survey as soon as they exit this page **/
//if ((pageVisits > 1 && visitorNumber == 4) && (!getCookie("surveyShown") || getCookie("surveyShown") != 'true')) { 
// window.onunload = popUpSurvey;
// window.onclose = popUpSurvey;
//}

/** Function to pop up the survey window, check whether it really was 
    opened (not blocked by popup-blocker) and set a cookie (for the 
    period set above) that the popup has been shown. This way, they 
    should not see it more than once.
    If it was blocked, the cookie has not been set. The popup will try 
    to load again on the next page (so they have the option of 
    (temporary) allowing popups, and it will still be shown) **/
function popUpSurvey() {
 popupWin = window.open(popupURL,'survey','scrollbars=yes,resizable=no, status=yes,width=760,height=540');
 if (popupWin == null || typeof(popupWin) == "undefined") {
  return false;
 } else {
  setCookie("surveyShown", "true", expDate, "/");
 }
}


/** New popup for Countries popup **/
/** Country popups disabled - 11-Oct-2006
function countryPopUp(popUpDoc) {
 popUpShown = getCookie(popUpDoc+'-new') ? true : false;
 if (!popUpShown) {
  popUpWin = window.open('/corporates/docs/country/popups/'+popUpDoc,'countries','scrollbars=no,resizable=no,status=no,width=750,height=357');
  expDate = new Date;expDate.setDate(expDate.getDate()+1);
  setCookie(popUpDoc+'-new', "true", expDate, "/");
 }
}

currURL = document.location.href;
if (currURL.indexOf('?country=') < 0) {
 if (currURL.indexOf('/corporates/docs/country/sweden/index.jsp') > 0) countryPopUp('popup_swedish.htm');
 if (currURL.indexOf('/corporates/docs/country/norway/index.jsp') > 0) countryPopUp('popup_norwegian.htm');
 if (currURL.indexOf('/corporates/docs/country/finland/index.jsp') > 0) countryPopUp('popup_finish.htm');
 if (currURL.indexOf('/corporates/docs/country/denmark/index.jsp') > 0) countryPopUp('popup_danish.htm');
 if (currURL.indexOf('/corporates/docs/country/norway.jsp') > 0) countryPopUp('popup_english_no.htm');
 if (currURL.indexOf('/corporates/docs/country/sweden.jsp') > 0 || currURL.indexOf('/corporates/docs/country/finland.jsp') > 0 || currURL.indexOf('/corporates/docs/country/denmark.jsp') > 0) countryPopUp('popup_english_se_fi_dk.htm');
}
**/