///////
// PRELOAD

function preload_image(image_name, image_src) {
    if (document.images) {
        eval(image_name + ' = new Image()');
        eval(image_name + '.src = "' + image_src + '"');
    }
}
function initPreload() {
	preload_image('NAME','PATH');
}



///////
// IE DROP DOWN MENU FIX
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

//////
// EXPANDING BLOCK ELEMENTS
//////
// expand arrows
var arrow_down = new Image();
arrow_down.src = "images/right.gif";
var arrow_up = new Image();
arrow_up.src = "images/down.gif";
// expand functions
function showExpand(title,objToShow,expandGroup) {
	var nScrollHeight = document.getElementById(objToShow).scrollHeight;
	var nActualHeight = document.getElementById(objToShow).offsetHeight;
	var arrow = "arrow_" + title.split("_")[1];
	if (nActualHeight < nScrollHeight) {
		sizeObjV(objToShow,nScrollHeight,"null");
		document.getElementById(title).className = "expand-selected";
		document.getElementById(arrow).src = arrow_up.src;
	}
	else {
		sizeObjV(objToShow,1,"null");
		document.getElementById(title).className = "expand-normal";
		document.getElementById(arrow).src = arrow_down.src;
	}
}
function hoverExpand(title,hover) {
	if (document.getElementById(title).className != "expand-selected"){
		var arrow = "arrow_" + title.split("_")[1];
		if (hover) { 
			document.getElementById(title).className = "expand-hover";
			//document.getElementById(arrow).src = arrow_hover.src;
		}
		else { 
			document.getElementById(title).className = "expand-normal";
			//document.getElementById(arrow).src = arrow_down.src;
		}
	}
}
function sizeObjV(objToShow,showSize,completeFunction) {
	//completeFunction should take format: null OR {complete:function() {setStatus('done fading element.',1500);}} 
	new Rico.Effect.Size(document.getElementById(objToShow),null,showSize,20,10,completeFunction);	
}
function sizeObjH(objToShow,showSize,completeFunction) {
	//completeFunction should take format: null OR {complete:function() {setStatus('done fading element.',1500);}} 
	new Rico.Effect.Size(document.getElementById(objToShow),showSize,null,20,10,completeFunction);	
}
function fadeObjV(objToFade,opacity,completeFunction) {
	new Rico.Effect.FadeTo(document.getElementById(objToFade),opacity,500,10,completeFunction);
}


function popUp(URL) {
popper = window.open(URL, "popper",'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=580');
popper.focus();
}



//////
// ADD LOAD LISTENER
function addLoadListener(fn) {
	if (typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined') 
	{
		document.addEventListener('load', fn, false);
	} 
	else if (typeof window.attachEvent != 'undefined') 
	{
		window.attachEvent('onload', fn);
	}
	else 
	{
		var oldfn = window.onload;
		if (typeof window.onload != 'function') 
		{
			window.onload = fn;
		} 
		else 
		{
			window.onload = function() {
					oldfn();
					fn();
			};
		}
	}
}

//////
addLoadListener(initPreload);
//addLoadListener(sfHover());






