//check to see if the 'RETURN' key has been pressed
document.onkeypress = keyhandler;
   
//==================================================================================================	
function keyhandler(e) {
	if (document.layers){
        Key = e.which;
    }
    else {
		Key = window.event.keyCode;
		if (Key==13) {
			//doSubmit();
			return false;
		}
    }
}
//==================================================================================================	
//Shows or hides the div boxes on each page
function flipBox(who) {
	var tmp; 
	if (document.images["b_" + who].src.indexOf("_on") == -1) { 
		tmp = document.images["b_" + who].src.replace("_off", "_on");
		document.getElementById('box_' + who).style.display = "none";
		document.images["b_" + who].src = tmp;
	} else { 
		tmp = document.images["b_" + who].src.replace("_on", "_off");
		document.getElementById('box_' + who).style.display = "block";
		document.images["b_" + who].src = tmp;
	} 
}
//==================================================================================================
//Opens a new window with the specified url, width (x) & height (y) dimensions. used for .pdfs, .docs, etc
function openWin(url) {
	var dimx, dimy
	dimX = 800;
	dimy = screen.availHeight;
	
	if (cl != null) { 
		if (cl.name != 'annexe') {
			cl.close();
			cl=null
			} 
		else {
		var cl=null
		}
	}

	if (url!='') {
		var nom = '';
		featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,alwaysRaised=yes,system=no,resizable=yes,width="+ dimx + ",height=" + dimy;
		cl = window.open(url,nom,featur);
		cl.focus()
	}
}
//==================================================================================================
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	if (args[0]=='answers') {
		content=myArray[args[1]];
		answers.innerHTML=content;
	}
    obj.visibility=v;
	}
}

function restoreImage() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function changeImage() {
  var i,j=0,x,a=changeImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//===========================================================================================================================================

// 'internal' function used by the other cookie functions
function getCookieVal (offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function getCookie (name) 
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

// sets a cookie. 
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" : "");
}

// delete the 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";
	}
}