window.onerror = null;

//initialise all variables

var olddiv = new Array();    //this will become a reference to the objects that are being shown or were last shown

function getRefToDivNest( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	return document[divID];
}

function showdiv(thisdiv,mylevel) {
	//this function shows the div and sets the level that the div exists at to 'mylevel'
	hideDivsToLevel(mylevel); //first, hide the last one
	olddiv[mylevel] = getRefToDivNest(thisdiv);
	//Make the object visible
	if( olddiv[mylevel].style ) {
		//DOM compliant
		olddiv[mylevel].style.visibility = 'visible';
	} else {
		if( olddiv[mylevel].visibility ) {
			//Netscape and old versions of Mozilla compliant
			olddiv[mylevel].visibility = 'show';
		} else {
			//Nothing found, no known way of changing the style
			olddiv[mylevel] = false;
			notifyFail();
			return;
		}
	}
}

function hideDivsToLevel(mylevel) {
	//hide all the divs that are showing this level and higher
	if( olddiv[mylevel] ) {
		//try the next level up first
		hideDivsToLevel(mylevel+1);
		//hide the last hidden object that was shown in the current level
		if( olddiv[mylevel].style ) {
			//DOM compliant
			olddiv[mylevel].style.visibility = 'hidden';
		} else {
			//Netscape and old versions of Mozilla compliant
			olddiv[mylevel].visibility = 'hide';
		}
		//No need for else notifyFail()
		//If it was going to fail, it would have failed while it was being shown
	}
	olddiv[mylevel] = false;
}

function hideDivSpecial(specialDiv) { //hide a div, bypassing levels
	specialDiv = getRefToDivNest(specialDiv);
	if( specialDiv.style ) {
		//DOM compliant
		specialDiv.style.visibility = 'hidden';
	} else {
		if( specialDiv.visibility ) {
			//Netscape and old versions of Mozilla compliant
			specialDiv.visibility = 'hide';
		} else {
			//Nothing found, no known way of changing the style
			notifyFail();
			return;
		}
	}
}

function notifyFail() {
	//oops, I guess nothing works in this browser
	if( window.myalternative ) {
		if( window.confirm( "You are having problems displaying some components of this page.\n"+
			"\nWould you like to try the other page design?" ) ) { location.href = myalternative; }
	} else {
		window.alert( "You are having problems displaying some components of this page.\n\n"+
			"Sorry, but there is not yet an alternative page." );
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

	//page displayed if browser incompatible
	var myalternative = "sitemap.html";
	
	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;
	}
	/* Functions that swaps images. */
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.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];}
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	/* Functions that handle preload. */
	function MM_preloadImages() { //v3.0
	 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];}}
	}


	//window:
	function bigWin(obj){
     var winOpt = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=640,height=455,left=0,top=0,status";
     window.open(obj.href,obj.target,winOpt);
     }
