<!-- Copyright 2006 Bontrager Connection, LLC
// Published on October 31, 2006 for Possibilities 
//   ezine. See http://BontragerCGI.com/ article titled 
//   "Setting and Reading Cookies with JavaScript."
//
////
//
// These functions set and read cookies. See article 
//   mentioned above for information and instructions.
//
////  ////  ////  ////

function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
} // function SetCookie()

function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
} // function ReadCookie()

function showExitPoll (url, w, h) {
	window.open(url, "poll","width="+w+",height="+h+",scrollbars=yes,resizable=yes");
}


function rollDice (url, w, h) {
	if(ReadCookie("BrainTrain3ExitPoll")==""){
		//var CHANCE_GOING_IN = 5;
		//var chance = Math.floor(Math.random()*CHANCE_GOING_IN);
		//if (chance==0) 
		showExitPoll(url, w, h);
		
	}
}

/*
function amnstub(){
	rollDice(SITE_PATH + "exitpoll.aspx","560","400");	
}
*/

/*
window.onbeforeunload = confirmExit;
var aClick=false;
function confirmExit(e)
{
    if(document.all){
        e = event;
    }
    if(!e){
        e=window.event;
    }
    
    if (e){
        
        if(aClick==false && (e.target==document || e.clientX<0 || e.clientY<0)) {         
            //alert("aaa");
            amnstub();
        } 
    }
} 
*/
  
/*
if(window.attachEvent){
	window.attachEvent("onunload", amnstub);
} else if(document.addEventListener || window.addEventListener){
	if(document.addEventListener){
		document.addEventListener("unload", amnstub, false);	
	};
	if(window.addEventListener){
		window.addEventListener("unload", amnstub, false);	
	};
} else {
	window.onunload = function(){
		amnstub();
	}
};
*/