// Version: 1.0.1 - Date Modified: 19/11/2007 - Telephone Banking and ATM CSS

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

function custSurveyChkTele() {
	if (detectValidBrowser() == "correct") {
		var randomNum = Math.floor(Math.random() * 101)
		if (randomNum <= telePercentage) {
			var cookieString = document.cookie;
			if (cookieString.indexOf("teleCSS") == -1) {
				showDHTMLTele();
				document.getElementById('teleSurveyPop').focus();
			}
		}
	}
}

function custSurveyChkATM() {
	var randomNum = Math.floor(Math.random() * 101)
	if (randomNum <= atmPercentage) {
		var cookieString = document.cookie;
		if (cookieString.indexOf("teleCSS") == -1) {
			dcsMultiTrack('DCS.dcsuri','ATM CSS Displayed','DCS.dcssip','nab.com.au','WT.ti','ATM CSS Displayed');
			$(".atmSurveyPop").show();
		}
	}
}

function createCookieTele(name, value, expires, path, domain) {
	var expireDate = new Date;
	expireDate.setMonth(expireDate.getMonth()+expires);
	document.cookie = name + "=" + ( value ) + "; expires=" + expireDate.toGMTString() + "; path=" + path + "; domain=" + domain;
}

function showDHTMLTele() {
	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) - 185;
		} else if (navigator.appName=="Netscape") {
			winXPos = (window.innerWidth / 2) - 210;
			winYPos = (window.innerHeight / 2) - 175;
		}
	}

	var inline="<div id='teleSurveyPop' tabindex='-1' style='z-index:500;border:#999 2px solid;font-size:1.1em;background-color:#fff;width:425px;height:350px;padding:5px;position:absolute;top:" + winYPos + ";left:" + winXPos + "'>";
	sometext ="<script type=\"text/javascript\">dcsMultiTrack('DCS.dcsuri','TB CSS Displayed','DCS.dcssip','nab.com.au','WT.ti','TB CSS Displayed');</script><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:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"TB CSS No Thankyou\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"TB CSS No Thankyou\");invi(1,\"teleSurveyPop\")'><img src='/vgnmedia/images/National/nab_icon_close.gif' border='0' alt='close survey offer' /></a></td></tr>";
	sometext +="<tr><td colspan='2'><h1>Improving NAB Telephone Banking</h1><p>Thankyou for visiting our website today. We are interested in knowing your thoughts about NAB Telephone Banking 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 telephone banking 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:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"TB CSS No Thankyou\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"TB CSS No Thankyou\");invi(1,\"teleSurveyPop\")'><img tabindex='2' src='/vgnmedia/downld/noThankYou.gif' border='0' alt='cancel survey' /></a>&nbsp;<a tabindex='3' href=\"javascript:globalWindowOpen(\'"+teleSurveyURL+"\', \'teleCSS\', 800, 600, 1,0,0,1,1,0,0,0,0);\" onClick='javascript:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"TB CSS Start Survey\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"TB CSS Start Survey\");invi(1,\"teleSurveyPop\");'><img src='/vgnmedia/downld/startSurvey.gif' border='0' alt='start survey' /></a></p></td></tr></table></div>";
	message = inline+sometext;

	document.write(message);
}

function showDHTMLATM() {
	if (detectValidBrowser() == "correct") {
		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;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:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"ATM CSS No Thankyou\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"ATM CSS No Thankyou\");hideDHTMLATM();'><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:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"ATM CSS No Thankyou\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"ATM CSS No Thankyou\");hideDHTMLATM();'><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:createCookieTele(\"teleCSS\",\"viewed\",6, \"/\",\""+cookieDomain+"\");dcsMultiTrack(\"DCS.dcsuri\",\"ATM CSS Start Survey\",\"DCS.dcssip\",\"nab.com.au\",\"WT.ti\",\"ATM CSS Start Survey\");hideDHTMLATM();'><img src='/vgnmedia/downld/startSurvey.gif' border='0' alt='start survey' /></a></p></td></tr></table></div>";
		message = inline+sometext;

		document.write(message);
		$(".atmSurveyPop").hide();
	}
}

function hideDHTMLATM() {
	$(".atmSurveyPop").hide();
}

function invi(flag,name) {
	if (!DHTML) return;
	var x = new getObj(name);
	x.style.visibility = (flag) ? 'hidden' : 'visible';
	x.style.display = (flag) ? 'none' : 'block'
}

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

function detectValidBrowser() {
   var thing = new its();
   var browser = "incorrect";
	
	if(thing.opera) {
		browser = "correct";
	}
	
	// If PC and either win95, win98, winnt or win2k.
	// Valid browsers NN 7.0 to less than 7.20 and IE 5.01 to 6.0.
	else if (thing.win95 || thing.win98 || thing.win2k || (thing.winnt && !(thing.win2k) && !(thing.winxp) && !(thing.vista))) {
		if ((thing.nn && thing.minor >= 7.0 && thing.minor <= 7.20) || (thing.ie && thing.minor == 6)) {
			browser = "correct";
		}
	}
	// If PC and winme.
	// Valid browsers NN 7.0 to 7.20 and IE 5.5 to 6.0.
	else if (thing.winme) {
		if ((thing.nn && thing.minor >= 7.0 && thing.minor <= 7.20) || (thing.ie && thing.minor == 6)) {
			browser = "correct";
		}
	}
	// If PC and winxp.
	// Valid browsers NN 7.0 to 7.20 and IE6 to 7.
	else if (thing.winxp) {
		if ((thing.nn && thing.minor >= 7.0 && thing.minor <= 7.20) || (thing.ie && thing.minor >= 6 && thing.minor <= 7)) {
			browser = "correct";
		}
	}
	// if vista
	else if (thing.vista) {
		if (thing.ie && thing.minor == 7) {
			browser = "correct";
		}
	}
	//If any OS and Firefox 1.0 to 2.0
	if (thing.firefox) {
		ffVer = thing.minor;
		ffVer = ffVer + "";
		if (ffVer != 0) {
			ffVerArray = ffVer.split(".");
			if (ffVerArray.length == 3) {
				ffVer = ffVerArray[0] + "." + ffVerArray[1] + ffVerArray[2];
			}
			if (ffVer >= 1.00 && ffVer <= 2.0) {
				browser = "correct";
			}
		}
	}

   return browser;
}
