//-----------------------------------
// Misc
//-----------------------------------

// Popup a window
function popitup(url, width, height, scrollbars, resizable)
{
    width = (width == null) ? 600 : width;
    height = (height == null) ? 400 : height;
    scrollbars = (scrollbars == null) ? 'yes' : scrollbars;
    resizable = (resizable == null) ? 'yes' : resizable;
    popup = window.open(url,'popup','width='+width+',height='+height+',scrollbars='+scrollbars+',resizable='+resizable+',toolbar=no,directories=no,menubar=no,status=no,left=100,top=100');
    if (window.focus)
        { popup.focus() }
    return false;
}

//-----------------------------------
// Nav Menu
//-----------------------------------

var menu = new Array("bp_menu", "stories_menu", "partners_menu", "projects_menu", "part_menu");

var timeon;

function menuOver(name) {
	clearTimeout(timeon);
	hideAllMenus(name);
	showHideLayer(name, 'show');
}

function menuOut() {
	timeon = setTimeout("oriStatus()", 200);
}

function showHideLayer(name, status) {
	ele = document.getElementById(name);
	if (ele.style) {
    	ele = ele.style;
    	status = (status =='show') ? 'visible' : (status=='hide') ? 'hidden' : status;
   	}
	ele.visibility = status;
}

function oriStatus() {
	hideAllMenus();
	if (cmenu) showHideLayer(cmenu, 'show');
}

function hideAllMenus(except) {
	for (i = 0; i < menu.length; i++) {
		if (menu[i] != except) {
			showHideLayer(menu[i], 'hide');
		}
	}
}

function showPopUp(on, name, popup) {
	clearTimeout(timeon);
	hideAllMenus(name);
	o = document.getElementById(on);
	n = document.getElementById(name);
	pp = document.getElementById(popup);
	pp.style.left = parseInt(o.style.left) + n.offsetLeft;
	pp.style.top = parseInt(o.style.top) + n.offsetTop - parseInt(pp.style.height);
	al = parseInt(pp.style.width) + parseInt(pp.style.left) - parseInt(o.style.left) - parseInt(o.offsetWidth);
	if ( parseInt(al) > 0 ) {
		pp.style.left = parseInt(pp.style.left) - parseInt(al);
	}
	pp.style.visibility = 'visible';
}

function restore(name, filename) {
	obj = document.getElementById(name);
	if (obj != null)
		obj.src = filename;
}

function swap(name, filename) {
	obj = document.getElementById(name);
	if (obj != null)
		obj.src = filename;
}

function 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=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];}}
}
