//************************************************************
// handle netscape-css resize problems
function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

//************************************************************
// Global variables
var isNav, isIE, isNavSix;
var coll = "";
var styleObj = "";
if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true;
		if (parseInt(navigator.appVersion) >= 5) {
		isNavSix = true;
		}
	} else {
		isIE = true;
		coll = "all.";
		styleObj = ".style";
	}
}

// Convert object name string or object reference into a valid object reference
function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		theObj = eval("document." + coll + obj + styleObj);
	} else {
		theObj = obj;
	}
	if (isNavSix) {
	theObj = document.getElementById(obj).style
	}
	return theObj;
}

//************************************************************
//rollover functions
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_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;
}

//************************************************************
// cookies.js
// Derived from the Bill Dortch code at http://www.hidaho.com/cookies/cookie.txt

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { 
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
	
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;
}

function SetCookie (name, value, expDays) {
	var theValue = escape(value);
	if (expDays > 0) {
		var exp = new Date(); 
		exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 
		
		var theString = name + "=" + theValue + "; expires=" + exp.toGMTString();
	} else {
		var theString = name + "=" + theValue;
	}
	document.cookie = theString;
}

//************************************************************
// Setting the visibility of an object to visible
function show(obj) {
	var theObj = getObject(obj);
	theObj.visibility = "visible";
}

// Setting the visibility of an object to hidden
function hide(obj) {
	var theObj = getObject(obj);
	theObj.visibility = "hidden";
}

// Move an object
function move(obj,x,y) {
	var theObj = getObject(obj);
	if (isIE) {
	theObj.pixelLeft = x;
	theObj.pixelTop = y;
	} else if (isNav) {
	theObj.moveTo(x,y);//x,y in pixels
	}
}

// go back
function goBack() {
	window.history.back(-1);
}

// open window
function openWin(arg_url, arg_name, arg_width, arg_height, arg_scroll, arg_resize) {
  var win = window.open(arg_url,arg_name,'scrollbars=' + arg_scroll + ',resizable=' + arg_resize + ',width=' + arg_width +  ',height=' + arg_height);
}

// close window
function closeWin() {
  window.close();
}

// print window
function printWin() {
	window.print();
}