var atmSurveyURL = "/ols/0,,90738,00.html ";
var cookieDomain = ".nab.com.au";
var atmPercentage = 30;

function custSurveyChkATM() {
	var randomNum = Math.floor(Math.random() * 101)
	if (randomNum <= atmPercentage) {
		var cookieString = document.cookie;
		if (cookieString.indexOf("teleCSS") == -1) {
			document.getElementById("atmSurveyPop").style.display="block";		
		}
	}
	return false;
}

function createCookieTeleHP(name, value, expires, path, domain) {
	var exp = new Date();
	var currDate = exp.getTime();
	var expiryDate = currDate + (182 * 24 * 60 * 60 * 1000);
	exp.setTime(expiryDate);
	document.cookie = name + "=" + ( value ) + "; expires=" + exp.toGMTString() + "; path=" + path + "; domain=" + domain;
}

function showDHTMLATMHP() {
	var winXPos = 160;
	var winYPos = 90;

	if (parseInt(navigator.appVersion) > 3){
		if ((navigator.appName=="Microsoft Internet Explorer")&&document.body) {
			winXPos = (document.body.offsetWidth / 2) - 200;
			winYPos = (document.body.offsetHeight / 2) - 175;
		} else if (navigator.appName=="Netscape") {
			winXPos = (window.innerWidth / 2) - 200;
			winYPos = (window.innerHeight / 2) - 175;
		}
	}

	if (winYPos < 0) {
		winYPos = 300;
	}
	
	var inline="<div id='atmSurveyPop' class='atmSurveyPop' tabindex='-1' style='z-index:500;border:#999 2px solid;font-size:1.1em;background-color:#fff;width:400px;height:350px;padding:5px;position:absolute;display:none;top:" + winYPos + "px;left:" + winXPos + "px'>";
	sometext ="<table><tr><td align='left' valign='top' height='55'><img src='/images/nabLogo.gif' border='0' alt='nab logo' /></td><td align='right' valign='top' height='55'><a tabindex='1' href='javascript:createCookieTeleHP(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");hideDHTMLATMHP();'><img src='/vgnmedia/images/National/nab_icon_close.gif' border='0' alt='close survey offer' /></a></td></tr>";
	sometext +="<tr><td colspan='2' align='left'><h1>Improving our ATMs</h1><p>Thankyou for visiting our website today. We are interested in knowing your thoughts about our NAB ATMs and would like to ask you a few questions using an online survey.</p><p>The purpose of the survey is to help us refine our ATM service so that it better meets your needs.</p><p>The survey is easy to complete and should take approximately 5 minutes. It is completely anonymous and your answers will not be disclosed to any third party.</p></td></tr>";
	sometext +="<tr><td height='5' colspan='2'>&nbsp;</td></tr>";
	sometext +="<tr><td colspan='2' align='right'><p><a href='javascript:createCookieTeleHP(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");hideDHTMLATMHP();'><img tabindex='2' src='/vgnmedia/downld/noThankYou.gif' border='0' alt='cancel survey' /></a>&nbsp;<a tabindex='3' href=\"javascript:globalWindowOpen(\'"+atmSurveyURL+"\', \'teleCSS\', 800, 600, 1,0,0,1,1,0,0,0,0);\" onClick='javascript:createCookieTeleHP(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");hideDHTMLATMHP();'><img src='/vgnmedia/downld/startSurvey.gif' border='0' alt='start survey' /></a></p></td></tr></table></div>";
	message = inline+sometext;

	document.write(message);
}

function hideDHTMLATMHP() {
	document.getElementById("atmSurveyPop").style.display="none";
}

