//updated by C Hirschorn on 06/01/06
//SETUP VARIABLES

var TheURL = "http://collections.europarchive.org/tna/20060829101539/http://www.processrequest.com/nationalarchives/register/signup.asp"; //SET THIS TO THE URL OF THE POPUP WINDOW

var expDays = 31; //SET THIS TO EXPIRE COOKIE IN WHATEVER # OF DAYS

var Mode = 2; //SET THIS TO 1 TO MAKE IT POPUP EVERYTIME FOR TESTING - BACK TO 2 FOR ONE TIME

//POPUP ONLY

var Chance = 1; //SET THIS TO THE TOP OF THE CHANCE EQUATION. FOR A 1 IN 100 CHANCE SET IT TO 100

var closetime = 0; // 0 = do not close, anything else = number of seconds

//FUNCTIONS



function PopundeR() { //This function opens the popup and hides it underneath current browser window
var popunder = window.open(TheURL,"view","toolbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=650,height=450");
popunder.blur();
window.focus();
}


function GetCookie(name) {

	var StartpoinT = document.cookie.indexOf(name+"=");
	var NameLenghT = StartpoinT+name.length+1;
	if ((!StartpoinT) && (name != document.cookie.substring(0,name.length))) return null;
	if (StartpoinT == -1) return null;
	var EnD = document.cookie.indexOf(";",NameLenghT);
	if (EnD == -1) EnD = document.cookie.length;
	return unescape(document.cookie.substring(NameLenghT,EnD));
}

function SetCookie (name, value) { //THIS FORMATS AND SETS THE COOKIE IN THE BROWSER

	//THE FOLLWING VARIABLES SET UP THE DIFFERENT PARTS OF A STANDARD COOKIE
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : ""); //THIS PUTS ALL THE PARTS TOGETHER INTO THE BROWSER
}

function Roulette() {

	return Math.floor( 1 + Math.random() * Chance);
}


//INITIALIZATION

//WebTV AND AOL PASS
var NoGo = 1;
var userAgent=navigator.appName + " " + navigator.appVersion;
var agentInfo=userAgent.substring(0, 5);
var strBrowserVersion = navigator.appVersion ;
if (strBrowserVersion.indexOf("AOL") > 0) {NoGo = 2;}
if (agentInfo == "WebTV") {NoGo = 2;}
if (NoGo == 1) { //

	var exp = new Date();
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	if (Roulette() == 1){

		if (GetCookie('count') == 2) {

			SetCookie('count',Mode,exp,'/');

		} else {

			PopundeR();
			SetCookie('count',Mode,exp,'/');
		}
	}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

