function showurlin(url, dest, options) {
	switch(dest) {
	case 'popup':
		window.open(url, 'popup', options).focus();
		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
  };

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 == 'function') {
		var children = node.getElementsByTagName('UL');
		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
 */

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;
			menu.style.visibility = 'hidden';
		}
		else {
			newvis.push(vis[i]);
		}
	}
	window.visibleMenus = newvis;
}

function hideMenu(id) {
	var menu = document.getElementById(id);
	if(!menu) return;
	var vis = window.visibleMenus;
	var newvis = new Array();
	menu.style.visibility = 'hidden';
	for(var i = 0; i < vis.length; i++) {
		if(vis[i] != menu) {
			newvis.push(vis[i]);
		}
	}
	window.visibleMenus = newvis;
}

function showMenu(id) {
	var menu = document.getElementById(id);
	if(!menu) return;
	hideMenusNow();
	menu.style.visibility = 'visible';
	window.visibleMenus.push(menu);
}

function fixmacie(classname){        
	var divs=document.getElementsByTagName("DIV");   
  for(var d=0; d < divs.length;d++){     
		if(divs[d].className.indexOf(classname)==0){    
		divs[d].innerHTML+= "<div class='mac-clearfix'> </div>"; 
		/* The above html tags get added to the end of 
		the cleared container if the browser is IE/mac. */  
		} 
	} 
}

function clearfix_init(){
	/* Check if the browser is IE5 Mac */
   if( navigator.appVersion.indexOf('Mac')!=-1 && document.all){     
		/* Pass the class name on the container to fixmacie 
		(must be the FIRST classname if multiple classnames 
		are used on the div!) */    
		fixmacie("clearfix");  
	} 
}

/* start the ball rolling when the page loads */
window.onload=clearfix_init;

