// image rollover swap and preload functions
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;
}

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];}}
}

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];}
}


// navigation tree functions
function tree (a_items, a_template) {
	this.a_tpl      = a_template;
	this.a_config   = a_items;
	this.o_root     = this;
	this.a_index    = [];
	this.o_selected = null;
	this.n_depth    = -1;
	
	var o_icone = new Image(),
		o_iconl = new Image();
	o_icone.src = a_template['icon_e'];
	o_iconl.src = a_template['icon_l'];
	a_template['im_e'] = o_icone;
	a_template['im_l'] = o_iconl;
	for (var i = 0; i < 64; i++)
		if (a_template['icon_' + i]) {
			var o_icon = new Image();
			a_template['im_' + i] = o_icon;
			o_icon.src = a_template['icon_' + i];
		}
	this.toggle = function (n_id) {	var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
	this.select = function (n_id) { return this.a_index[n_id].select(); };
	this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
	this.mover  = function (n_id) { this.a_index[n_id].upstatus() };

	this.a_children = [];
	for (var i = 0; i < a_items.length; i++)
		new tree_item(this, i);

	this.n_id = trees.length;
	//document.write(trees.length);
	trees[this.n_id] = this;
	
	for (var i = 0; i < this.a_children.length; i++) {
		document.write(this.a_children[i].init());
		this.a_children[i].open();
	}
}
function tree_item (o_parent, n_order) {

	this.n_depth  = o_parent.n_depth + 1;
	this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
	if (!this.a_config) return;

	this.o_root    = o_parent.o_root;
	this.o_parent  = o_parent;
	this.n_order   = n_order;
	this.b_opened  = !this.n_depth;

	this.n_id = this.o_root.a_index.length;
	this.o_root.a_index[this.n_id] = this;
	o_parent.a_children[n_order] = this;

	this.a_children = [];
	for (var i = 0; i < this.a_config.length - 2; i++)
		new tree_item(this, i);

	this.get_icon = item_get_icon;
	this.open     = item_open;
	this.select   = item_select;
	this.init     = item_init;
	this.upstatus = item_upstatus;
	this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}

function item_open (b_close) {
	var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id);
	if (!o_idiv) return;
	
	if (!o_idiv.innerHTML) {
		var a_children = [];
		for (var i = 0; i < this.a_children.length; i++)
			a_children[i]= this.a_children[i].init();
		o_idiv.innerHTML = a_children.join('');
	}
	o_idiv.style.display = (b_close ? 'none' : 'block');
	
	this.b_opened = !b_close;
	var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id],
		o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_jicon) o_jicon.src = this.get_icon(true);
	//else
	//o_iicon.src = '/images/icons/base.gif';
	if (o_iicon) o_iicon.src = this.get_icon();
	this.upstatus();
}

function item_select (b_deselect) {
	if (!b_deselect) {
		var o_olditem = this.o_root.o_selected;
		this.o_root.o_selected = this;
		if (o_olditem) o_olditem.select(true);
	}
	var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_iicon) o_iicon.src = this.get_icon();
	get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'normal';
	this.upstatus();
	return Boolean(this.a_config[1]);
}

function item_upstatus (b_clear) {
	//window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10);
	//alert(this.a_config[1]);
}

function item_init () {
	var a_offset = [],
		o_current_item = this.o_parent;
	for (var i = this.n_depth; i > 1; i--) {
		a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
		o_current_item = o_current_item.o_parent;
	}
	//modified by charles 2/14/2003
	if (this.a_config[1]=="logout.asp")
		this.o_root.a_tpl['target']="_top";
	else
		this.o_root.a_tpl['target']="_self";
	//end point
	str_icon = this.get_icon(true);
	str_output = '<table cellpadding="0" cellspacing="0" border="0"><tr bgcolor="transparent"><td nowrap>'
		+ (this.n_depth ? a_offset.join('')
		+ (this.a_children.length ? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" target="_self">'
		+ '<img src="' + str_icon + '" border="0" align="absbottom" name="j_img' + this.o_root.n_id + '_' + this.n_id + '"></a>' : '<img src="' + str_icon + '" border="0" align="absbottom">') : '') 
		+ '<a href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] 
		+ '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id 
		+ ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' 
		+ this.n_id + ')" class="t' + this.o_root.n_id + 'i" id="i_txt' 
		+ this.o_root.n_id + '_' + this.n_id 
		+ '" target="_self" >'
		+ '<img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.o_root.n_id + '_' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a>'
		+ '</td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : '');
	//alert(str_output);
	return str_output;
}

function item_get_icon (b_junction) {
	return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))];
}

var trees = [];
get_element = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };

/* 
	the format of the tree definition file is simple,
	you can find specification in the Tigra Menu documentation at:
	
	http://www.softcomplex.com/products/tigra_menu/docs/items.html	
*/
function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // WM_readCookie

// tree icons
/*
	Feel free to use your custom icons for the tree. Make sure they are all of the same size.
	User icons collections are welcome, we'll publish them giving all regards.
*/

var tree_tpl = {
	'target'  : '_self',	// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top

	'icon_e'  : 'images/icons/empty.gif', // empty image
	'icon_l'  : 'images/icons/line.gif',  // vertical line
	
	'icon_48' : 'images/icons/base.gif',   // root icon normal
	'icon_52' : 'images/icons/base.gif',   // root icon selected
	'icon_56' : 'images/icons/base.gif',   // root icon opened
	'icon_60' : 'images/icons/base.gif',   // root icon selected
	
	'icon_16' : 'images/icons/folder.gif', // node icon normal
	'icon_20' : 'images/icons/folderopen.gif', // node icon selected
	'icon_24' : 'images/icons/folder.gif', // node icon opened
	'icon_28' : 'images/icons/folderopen.gif', // node icon selected opened

	'icon_0'  : 'images/icons/page.gif', // leaf icon normal
	'icon_4'  : 'images/icons/page.gif', // leaf icon selected
	'icon_8'  : 'images/icons/page.gif', // leaf icon opened
	'icon_12' : 'images/icons/page.gif', // leaf icon selected
	
	'icon_2'  : 'images/icons/joinbottom.gif', // junction for leaf
	'icon_3'  : 'images/icons/join.gif',       // junction for last leaf
	'icon_18' : 'images/icons/plusbottom.gif', // junction for closed node
	'icon_19' : 'images/icons/plus.gif',       // junction for last closed node
	'icon_26' : 'images/icons/minusbottom.gif',// junction for opened node
	'icon_27' : 'images/icons/minus.gif'       // junction for last opended node
};



	// Copyright 1999 - 2002 by Ray Stott, Pop-up Windows Script ver 2.0
	// OK to use if this copyright is included
	// Script is available at http://www.crays.com/jsc          
	
	var popWin = null    // use this when referring to pop-up window
	var winCount = 0
	var winName = "popWin"

	function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
	  var d_winLeft = 20  // default, pixels from screen left to window left
	  var d_winTop = 20   // default, pixels from screen top to window top
	  winName = "popWin" + winCount++ //unique name for each pop-up window
	  closePopWin()           // close any previously opened pop-up window
	  if (openPopWin.arguments.length >= 4)  // any additional features? 
	    winFeatures = "," + winFeatures
	  else 
	    winFeatures = "" 
	  if (openPopWin.arguments.length == 6)  // location specified
	    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
	  else
	    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop) +" resizable=no"
		//document.write(winFeatures);
	  popWin = window.open(winURL, winName, "width=" + winWidth 
	           + ",height=" + winHeight + winFeatures)
	  }

	function closePopWin(){    // close pop-up window if it is open 
	  if (navigator.appName != "Microsoft Internet Explorer" 
	      || parseInt(navigator.appVersion) >=4) //do not close if early IE
	    if(popWin != null) if(!popWin.closed) popWin.close() 
	  }

	function getLocation(winWidth, winHeight, winLeft, winTop){
	  return ""
	  }

	  
	function getLocation(winWidth, winHeight, winLeft, winTop){
	  var winLocation = ""
	  if (winLeft < 0)
	    winLeft = screen.width - winWidth + winLeft
	  if (winTop < 0)
	    winTop = screen.height - winHeight + winTop
	  if (winTop == "cen")
	    winTop = (screen.height - winHeight)/2 - 20
	  if (winLeft == "cen")
	    winLeft = (screen.width - winWidth)/2
	  if (winLeft>0 & winTop>0)
	    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft	
	                + ",screenY=" + winTop + ",top=" + winTop
	  else
	    winLocation = ""
	  return winLocation
	  }









function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);   
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='images/icons/plus.gif' width='19' height='16' hspace='0' vspace='0' border='0'>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='images/icons/minus.gif' width='19' height='16' hspace='0' vspace='0' border='0'>";
   }
   
}

function Expand() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='images/icons/minus.gif' width='19' height='16' hspace='0' vspace='0' border='0'>";
   }
}

function Collapse() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='images/icons/plus.gif' width='19' height='16' hspace='0' vspace='0' border='0'>";
   }
}














