function showurlin(url, dest, options) {
	switch(dest) {
	case 'popup':
		window.open(url, 'popup', options);
		break;
	case 'original':
    	if (window.opener && window.opener.location)
			window.opener.location.href = url;
		break;
	default:
	}
}

function imgSwap(obj, newsrc) {
	obj.oldsrc = obj.src;
	obj.src = newsrc;
	return true;
}

function imgRestore(obj) {
	if(obj.oldsrc) obj.src = obj.oldsrc;
	return true;
}

//** IE Mac compatibility code (prototypes ROCK!) **
if(typeof Array.prototype.push=='undefined')
  Array.prototype.push=function(){
    var i=0;
    b=this.length,a=arguments;
    for(i;i<a.length;i++)this[b+i]=a[i];
    return this.length
  };
// Utility Functions
window.loadTasks = new Array();
window.unloadTasks = new Array();
window.onload = driverInit;
window.onunload = driverFinish;

function registerLoadTask(fn) {
	window.loadTasks.push(fn);
}

function registerUnloadTask(fn) {
	window.unloadTasks.push(fn);
}

function driverInit() {
	for(var i in window.loadTasks) {
		if(typeof window.loadTasks[i] == 'string')
			eval(window.loadTasks[i]);
	}
}

function driverFinish() {
	for(var i in window.unloadTasks) {
		eval(window.unloadTasks[i]);
	}
}

// Pop-ups
registerLoadTask('addLinkHandlers("A")');
registerLoadTask('addLinkHandlers("AREA")');

function addLinkHandlers(tagname) {
	var links = document.getElementsByTagName(tagname);
	for(i=0; i < links.length; i++) {
		var link = links[i];
		if(rel=link.getAttribute('rel')) {
			link.onclick = function(){return handleLinkRel(this);};
		}
	}
}

function handleLinkRel(link) {

	var relbits = link.getAttribute('rel').split('|');
	var href;
	if(typeof link.getAttribute == 'undefined')
		href = link.href;
	else
		//* This one is correct in both IE6 and Firefox
		href = link.getAttribute('href', 2);

	switch(relbits[0]) {
		case 'popup':
  			switch(relbits.length) {
  				case 1:
  					// No parameters
  					window.open(href);
  					break;
  				case 2:
  					// One parameter. Use it for window properties
  					window.open(href, null, relbits[1]);
  					break;
  				case 3:
  				default:
  					// Two (or more) parameters. Use 'em both
  					window.open(href, relbits[1], relbits[2]);
  					break;
  			}
			return false;
  			break;
  		default:
  			//Unknown link rel -- do nothing
			return true;
	}
}

var menuShowDelay = 200;
var menuHideDelay = 500;
window.visibleMenus = new Array();

function menuMouseOver(node) {
	var menu = findMenu(node);
	if(!menu) return;
	if(menu.showPending) {window.clearTimeout(menu.showPending); menu.showPending = false;}
	if(menu.hidePending) {window.clearTimeout(menu.hidePending); menu.hidePending = false;}
	if(menu.style.visibility == 'visible') return;
	menu.showPending = setMenuShowTimeout(menu, menuShowDelay);
}

function menuMouseOut(node) {
	var menu = findMenu(node);
	if(!menu) return;
	if(menu.showPending) {window.clearTimeout(menu.showPending); menu.hidePending = false;}
	if(menu.hidePending) {window.clearTimeout(menu.hidePending); menu.showPending = false;}
	if(menu.style.visibility == 'hidden') return;
	menu.hidePending = setMenuHideTimeout(menu, menuHideDelay);
}

function findMenu(node) {
	if(typeof node.getElementsByTagName != 'undefined') {
		var children = node.getElementsByTagName('DIV');
		if(children)
			return children[0];
		else
			return null;
	}
	else {
		var children = node.childNodes;
		for(var i=0; i < children.length; i++)
			if (children[i].nodeName == 'DIV')
				return children[i];
		return null;
	}
}


function showElement(object_id){
  var object = document.getElementById(object_id);
  return (object.style.visibility='visible');
}

function hideElement(object_id){
  var object = document.getElementById(object_id);
  return (object.style.visibility='hidden');
}

function setMenuShowTimeout(object, delay) {
    return setTimeout('showMenu("'+object.id+'")', delay);
}

function setMenuHideTimeout(object, delay) {
    return setTimeout('hideMenu("'+object.id+'")', delay);
}

/*
 * New Stuff
 */
// Changes by TOAST 2005-07-01 for MPA.  The first level of nav's isn't visible/invis, but display: '' or none.

function hideMenusNow() {
	var vis = window.visibleMenus;
	var newvis = new Array();
	var i = 0;
	for(i=0; i < vis.length; i++) {
		var menu = vis[i];
		if(menu.hidePending ) {
			window.clearTimeout(menu.hidePending);
			menu.hidePending = false;
			if(menu.className=='subNavFirstLevelActive') {
				menu.style.display = 'none';
			}
			else if(menu.className=='subNavFirstLevel') {
				menu.style.display = 'none';
			}
			else {
				menu.style.visibility = 'hidden';
			}
		}
		else {
			newvis.push(vis[i]);
		}
	}
	window.visibleMenus = newvis;
	if (newvis.length == 0) showSelectControls(document.body)
}

function hideAllMenusNow() {
	var vis = window.visibleMenus;
	var newvis = new Array();
	var i = 0;
	for(i=0; i < vis.length; i++) {
		var menu = vis[i];
		if(true) {
			window.clearTimeout(menu.hidePending);
			menu.hidePending = false;
			if(menu.className=='subNavFirstLevelActive') {
				menu.style.display = 'none';
			}
			else if(menu.className=='subNavFirstLevel') {
				menu.style.display = 'none';
			}
			else {
				menu.style.visibility = 'hidden';
			}
		}
		else {
			newvis.push(vis[i]);
		}
	}
	window.visibleMenus = newvis;
	if (newvis.length == 0) showSelectControls(document.body)
}


function hideMenu(id) {
	var menu = document.getElementById(id);
	if(!menu) return;



	var vis = window.visibleMenus;
	var newvis = new Array();
	if(menu.className=='subNavFirstLevelActive') {
		menu.style.display = 'none';
	} 
	else if(menu.className=='subNavFirstLevel') {
		menu.style.display = 'none';
	}
	else {
		menu.style.visibility = 'hidden';
	}

	for(var i = 0; i < vis.length; i++) {
		if(vis[i] != menu) {
			newvis.push(vis[i]);
		}
	}
	window.visibleMenus = newvis;
	if (newvis.length == 0) showSelectControls(document.body)
}

function showMenu(id) {

	var menu = document.getElementById(id);
	if(!menu) return;


	if(menu.className=='subNavFirstLevelActive') {
		if(menu.style.display != 'block') {
			hideAllMenusNow();
			menu.style.display = 'block';
			if(window.visibleMenus.length == 0) hideSelectControls(document.body);
			window.visibleMenus.push(menu);
		}
	}
	else if(menu.className=='subNavFirstLevel') {
		if(menu.style.display != 'block') {
			hideAllMenusNow();
			menu.style.display = 'block';
			if(window.visibleMenus.length == 0) hideSelectControls(document.body);
			window.visibleMenus.push(menu);
		}
	}
	else {
		menu.style.visibility = 'visible';
		if(window.visibleMenus.length == 0) hideSelectControls(document.body);
		window.visibleMenus.push(menu);
	}
}

function hideSelectControls(root) {
	var selectControls = root.getElementsByTagName('SELECT');
	for(var i = 0 ; i < selectControls.length; i++) {
		selectControls[i].style.visibility = 'hidden';
		selectControls[i]._hiddenByRefract = true;
	}
}

function showSelectControls(root) {
	var selectControls = root.getElementsByTagName('SELECT');
	for(var i = 0 ; i < selectControls.length; i++) {
		if(selectControls[i]._hiddenByRefract) selectControls[i].style.visibility = 'visible';
	}
}

// Browser Slide-Show script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs)
{
  var imageSeparator = imageFiles.indexOf(";");
  var nextImage = imageFiles.substring(0,imageSeparator);

  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = 'w.gif';
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }

  if (document.all)
  {
    document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
    document.getElementById(pictureName).filters.blendTrans.Apply();
  }
  document.getElementById(pictureName).src = nextImage;
  if (document.all)
  {
    document.getElementById(pictureName).filters.blendTrans.Play();
  }


  var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
    + ';' + nextImage;
  setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",
    displaySecs*1000);
  // Cache the next image to improve performance.
  imageSeparator = futureImages.indexOf(";");
  nextImage = futureImages.substring(0,imageSeparator);
  if (slideCache[nextImage] == null) {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].src = nextImage;
  }
}

