/* Setup settings */
var FCOLOR_MENU_MOVER  = '#FFFF33';
var FCOLOR_MENU_MOUT   = '#FFFFFF';

var FCOLOR_ITEM_MOVER  = '#FF0000';
var FCOLOR_ITEM_MOUT   = '#0000FF';

var BCOLOR_ITEM_MOVER  = '#FFFFCC';
var BCOLOR_ITEM_MOUT   = '#FFFFFF';

var MARK_MENU_OPEN     = String.fromCharCode(8211);
var MARK_MENU_CLOSED   = '+';
	
/* DO NOT edit below this line */
var IE = (navigator.appName.indexOf('Microsoft')!=-1)? true:false;
var RE = /(^\W*)(\w.+$)/;

function init() {
var divCollection = document.getElementsByTagName('DIV');
 var obj = null;
for (i=0; i<divCollection.length; i++) {
  obj = divCollection[i];
if (obj.className == 'mHeader') {
   obj.id = 'm'+i;
   obj.isExpanded = (obj.id == getCookie(obj.id))? true:false;
   setMenuMark(obj);
   setMenuEvents(obj); 
   setMenuItems(divCollection, obj, i);
  }
  else if (obj.className == 'mButton') {
   obj.id = 'b' + i;
   obj.hideFocus = true;
   setMenuEvents(obj);
  }
  else {
   /* NOP */
  }
 }
}

function setMenuMark(m) {
   /* NOP */
}

function expandCollapseMenu(m) {
 var j = 0;
 if (m.isExpanded) {
  setCookie(m.id, '');
  for (j=0; j<m.Submenu.length; j++) {
   hide(m.Submenu[j]);
  }
 }
 else {
  setCookie(m.id, m.id);
  for (j=m.Submenu.length-1; j>=0; j--) {
   show(m.Submenu[j]);
  }
 }
 m.isExpanded = !m.isExpanded;
 setMenuMark(m);
}

function setMenuEvents(m) {
 if (IE) {
  m.onmouseover = function() {this.runtimeStyle.color = FCOLOR_MENU_MOVER;}
  m.onmouseout  = function() {this.runtimeStyle.color = FCOLOR_MENU_MOUT;}
 }
 else {
  m.onmouseover = function() {this.style.color = FCOLOR_MENU_MOVER;}
  m.onmouseout  = function() {this.style.color = FCOLOR_MENU_MOUT;}
 }
 if (m.className == 'mHeader') {
  m.onclick = function() {expandCollapseMenu(this);}
  // m.ondblclick ?
 }
}

function setMenuItems(divs, menu, i) {
 var arr = new Array();
 var obj = null;
 i++;
 while ((divs[i])&&(divs[i].className == 'mItem')) {
  obj = divs[i];
  arr.push(obj);
  obj.hideFocus = true;
  obj.id = 'i'+i;
  setItemEvents(obj);
  if (menu.isExpanded) {
   show(obj);
  }
  else {
   hide(obj);
  }
  i++;
 }
  menu.Submenu = arr;
}

function setItemEvents(i) {
 if (IE) {
  i.onmouseover = function() {
                   this.runtimeStyle.color = FCOLOR_ITEM_MOVER;
                   this.runtimeStyle.backgroundColor = BCOLOR_ITEM_MOVER;
                  }
  i.onmouseout  = function() {
                   this.runtimeStyle.color = FCOLOR_ITEM_MOUT;
                   this.runtimeStyle.backgroundColor = BCOLOR_ITEM_MOUT;
                  }
 }
 else {
  i.onmouseover = function() {
                   this.style.color = FCOLOR_ITEM_MOVER;
                   this.style.backgroundColor = BCOLOR_ITEM_MOVER;
                  }
  i.onmouseout  = function() {
                   this.style.color = FCOLOR_ITEM_MOUT;
                   this.style.backgroundColor = BCOLOR_ITEM_MOUT;
                  }
 }
}

function hide(it) {
 if (IE) {
  if (navigator.appMinorVersion !='') {
   it.runtimeStyle.display = 'none';
  }
  else {
    it.style.display = 'none';	 	  
  }
 }
 else {
  it.style.display = 'none';
 }
}

function show(it) {
 if (IE) {
  if (navigator.appMinorVersion !='') {
   it.runtimeStyle.display = 'block';
  }
  else {
   it.style.display = 'block';	  
  }
 }
 else {
  it.style.display = 'block';
 }
}

function setCookie(cName, cValue, cExpires) {
 var str = cName+'='+escape(cValue);
     str+= ((cExpires == null) ? '' : ('; expires='+ cExpires));
 document.cookie = str;
 /* Sample expiration setup code:
    expDate.setTime(today.getTime() + 1000*60*60*24*365); */
}

function getCookie(cName) {
 var cValue = '';
 cName += '=';
 var offset, end;
 if ((document.cookie)&&(document.cookie.length > 0)) {
  offset = document.cookie.indexOf(cName);
  if (offset != -1) {
   offset += cName.length;
   end = document.cookie.indexOf(';', offset);
   if (end == -1) {end = document.cookie.length;}
   cValue = unescape(document.cookie.substring(offset, end));
  }
 }
 return cValue;
}

function getURL(u) {
 setCookie('LastLink',u);
 document.location.href = u;
}

window.onload=init;