
	/*<![CDATA[* /
	function IEHoverPseudo() {

		var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
		
		for (var i=0; i<navItems.length; i++) {
			if(navItems[i].className == "menuparent") {
				navItems[i].onmouseover=function() { this.className += " over"; }
				navItems[i].onmouseout=function() { this.className = "menuparent"; }
			}
		}

	}
	window.onload = IEHoverPseudo;
	/*]]>*/

	function changestyle(objRow,className) {
		document.getElementById(objRow).className=className;
	}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var hasDom=true

function disguise() {
    var ary=disguise.arguments;
    for(a=0;a<ary.length;a++) {
        var name=ary[a];
        if (hasDom) {
            var lyrStyle=document.getElementById("lyr_"+name).style;
            lyrStyle.display="none";
        }
    }
}

function reveal() {
	var ary=reveal.arguments;
    for(a=0;a<ary.length;a++) {
		var name=ary[a];
        if (hasDom) {
					var lyrStyle=document.getElementById("lyr_"+name).style;
					lyrStyle.display="block";
        }

    }
}



var preloadFlag = true;

/* 
The JavaScript Source!! http://javascript.internet.com/forms/character-counter.html
Created by: Steve | http://jsmadeeasy.com/ 
*/
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}


var set_name

function show(name) {
	if ( set_name ) {
		disguise(set_name)
	}
	reveal(name)
	set_name=name
}

function hide(name) {
	disguise(name)
	set_name=null
}
	
	
/* Ultimater's edited version of:
   http://jibbering.com/2002/4/httprequest.html
   to serve IE7 with XMLHttpRequest instead of ActiveX */

var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 	try {
 		 xmlhttp = new XMLHttpRequest();
 	} catch (e) {
 		 xmlhttp=false;
 	}
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

/* Ultimater's edited version of:
   http://javascript.internet.com/ajax/ajax-navigation.html */

var please_wait = "Loading.. Please wait";

function open_url(url, targetId) {
  if(!xmlhttp)return false;
    var e=document.getElementById(targetId);if(!e)return false;
    if(please_wait)e.innerHTML = please_wait;

    var d = new Date();
    var tm=d.getDate() + d.getHours() + d.getMinutes() + d.getMilliseconds();
    // Check to see if there is a ? in the url, then add a timestamp
    if ( url.search(/\?/)<0 ) { url += '?tm='+tm         }
    else { url += '&tm='+tm }
	    
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() { response(url, e); }
    try{
      xmlhttp.send(null);
    }catch(l){
    while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
    e.appendChild(document.createTextNode("request failed"));
  }
}

function response(url, e) {
  if(xmlhttp.readyState != 4)return;
    var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
    //insert the output returned into the temp glossary div for printing purposes
    populate_glossary_temp_div(tmp);
    var d=document.createElement("div");
    d.innerHTML=tmp;
    setTimeout(function(){
      while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
      e.appendChild(d);
    },10)
}

function populate_glossary_temp_div (text){
	document.getElementById('glossary_temp_div').innerHTML = text;
}


/**Code to allow switching of css files to enable printer friendly ajax divs**/
setActiveStyleSheet('');
function setActiveStyleSheet(title) {
   var i, a, main; 
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
   	
   	if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
function getActiveStyleSheet() {
var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  if(a.getAttribute("rel").indexOf("style") != -1
  && a.getAttribute("title")
  && !a.disabled) return a.getAttribute("title");
  }
  return null;
}




//set the global session handling variables
var activity_flag = true
var session_expired = false
var interval_wait = '3300000' //this is in miliseconds and should be just before the server session expiry (currently set to 55minutes (server is 60))
//initiate the timer
checkActivityFlag();

function setActivityFlag() {
	//check that the session hasn't expired, if not, set flag, if so, display error message
	if(session_expired == false)
		activity_flag = true;
	else
		alert("WARNING: Your session has expired. You will need to log back in to continue. NOTE: Any unsaved work will be lost");
}

function checkActivityFlag() {
	
	if(activity_flag == true){
		//if activity flag is true, keep session alive by making a request to the server
		xmlhttp.open("GET","refresh_session.php", true);
      	xmlhttp.send(null);
		//change the activity counter to false
		activity_flag = false;
	} else {
		//there has been no activity, set session expired to true
		session_expired = true;
	}
	
	//re-run this function in so much time
	timer = setTimeout("checkActivityFlag()", interval_wait);
}