
/////////////// MACROMEDIA FUNCTIONS ///////////////

function MM_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=MM_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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/////////////// CUSTOM FUNCTIONS ///////////////

function highlightSlot(p_index, p_over) {
	MM_findObj("slot_" + p_index + "_upperleft").src = (p_over) ? "images/upperleft.gif" : "images/shim.gif";
	MM_findObj("slot_" + p_index + "_upperright").src = (p_over) ? "images/upperright.gif" : "images/shim.gif";
	MM_findObj("slot_" + p_index + "_lowerleft").src = (p_over) ? "images/lowerleft.gif" : "images/shim.gif";
	MM_findObj("slot_" + p_index + "_lowerright").src = (p_over) ? "images/lowerright.gif" : "images/shim.gif";
	MM_findObj("itemtitle_" + p_index).className = (p_over) ? "itemtitleover" : "itemtitle";
	MM_findObj("itemtext_" + p_index).className = (p_over) ? "itemtextover" : "itemtext";
	var o = MM_findObj("itemimage_" + p_index);
	if (o) o.className = (p_over) ? "slotover" : null;
}

function discoverBtn(p_index, p_over) {
	if (p_index != 1) {
		o_n1 = MM_findObj("discoverbtns_1");
		o_n1.src = "images/home_disc_01_out.gif";
	}
	o_img = MM_findObj("discoverbtns_" + p_index);
	//o_img.src = (p_over) ? "images/btn_discover_over.gif" : "images/btn_discover_out.gif";
	o_img.src = (p_over) ? "images/home_disc_0" + p_index + "_lit.gif" : "images/home_disc_0" + p_index + "_out.gif";
	if (p_over) {
		if (typeof(discoverTimer) != "undefined") window.clearTimeout(discoverTimer);
		MM_findObj("discovertext").innerHTML = o_img.alt;
	} else {
		MM_findObj("discovertext").innerHTML = "&nbsp;";
		discoverTimer = window.setTimeout("resetDiscoverBtn();", 1000);
	}
}
function resetDiscoverBtn() {
	MM_findObj("discoverbtns_1").src = "images/home_disc_01_lit.gif";
	MM_findObj("discovertext").innerHTML = MM_findObj("discoverbtns_1").alt;
}

function gotoUrl(p_url, p_win) {
	if (p_url.toLowerCase().indexOf("javascript:".toLowerCase())>-1) {
		tgt_func = p_url.replace(/javascript:/gi,"");
		eval(tgt_func);
		return;
	}
	
	p_url += ((p_url.indexOf("?")>0) ? "&" : "?") + "null=" + (new Date()).getTime();
	if (typeof(p_win) != "undefined") {
		window.open(p_url, p_win);
	} else {
		document.location.href=p_url;
	}
}

function gotoUrlDelay(p_url, p_win) {
	// paired with cancelUrlDelay() - this function should be used for the onclick="" action of a tag, when
	// at least one link inside it should go to a different page than the whole area links to
	if (typeof(document.gotoUrlDelayDont) == "undefined") document.gotoUrlDelayDont = false;
	if (!document.gotoUrlDelayDont) {
		p_url += ((p_url.indexOf("?")>0) ? "&" : "?") + "null=" + (new Date()).getTime();
		if (typeof(p_win) != "undefined") {
			document.gotoUrlDelayUrl = p_url;
			document.gotoUrlDelayAction = window.setTimeout("window.open(document.gotoUrlDelayUrl, '" + p_win + "');", 200);
		} else {
			document.gotoUrlDelayUrl = p_url;
			document.gotoUrlDelayAction = window.setTimeout("document.location.href=document.gotoUrlDelayUrl;", 200);
		}
	}
	document.gotoUrlDelayDont = false;
}
function cancelUrlDelay() {
	// usually from a link inside a clickable area, that will go to a different location that the clickable area
	// this function should get fired first, if it's on the onclick="" of the <a> tag of the unique link
	document.gotoUrlDelayDont = true;
	window.clearTimeout(document.gotoUrlDelayAction);
}

/* Creates a Unique number per call on one client browser.
	DOES NOT CREATE A SERVER-SCOPED UNIQUE KEY! */
function createUUID() {
	return (new Date()).getTime().toString();
}

function popRC(loc) {
	pop = window.open(loc, 'rcchild', 'scrollbars,status,resizable,width=425,height=600');
	pop.focus();
}

function popNew(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,resizable,width=' + width + ',height=' + height);
	pop.focus();
}
function popupVideo(oid) {
	if (isNaN(oid)) return;
	popNew("display_photo.cfm?oid="+oid,"detail",400,400);
}
function popRestricted(loc,name,width,height) {
	pop = window.open(loc,name,'status,width=' + width + ',height=' + height);
	pop.focus();
}

function popRestrictedScroll(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,width=' + width + ',height=' + height);
	pop.focus();
}

function popNewNoChrome(loc,name,width,height) {
	pop = window.open(loc,name,'width=' + width + ',height=' + height);
	pop.focus();
}

function popReal(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,toolbar,menubar,directories,location,resizable,width=' + width + ',height=' + height);
	pop.focus();
}
function popTimeline() {
	pop = window.open("timeline.cfm","Timeline","resizable=0,scrollbars=0,width=700,height=501");
	pop.focus();
}
/* used to submit forms easily within divs, or from within other forms */
function submitForm(frm) { //v3.0
	var obj = MM_findObj(frm);
	obj.submit();
}
function submitformcheck(form) {
	var obj=MM_findObj(form);
	var frmname='_CF_check' + form + '(obj)';
	if (eval(frmname)) {
		obj.submit();
	}
}
function submitFormCheck(form) {
	submitformcheck(form);
}

function alignTop(p_new, p_orig) {
	var o_new = MM_findObj(p_new);
	var o_orig = MM_findObj(p_orig);
	var n_top = parseInt(o_orig.style.top) - parseInt(o_new.clientHeight);
	var n_left = parseInt(o_orig.style.left);
	o_new.style.top = n_top + "px";
	o_new.style.left = n_left + "px";
}
function showLayer(p) { MM_findObj(p).style.visibility = "visible"; }
function hideLayer(p) { MM_findObj(p).style.visibility = "hidden"; }

function alignLayer(p_src, p_orig, p_offset_x, p_offset_y) {
	if (arguments.length < 3) p_x = 0;
	if (arguments.length < 4) p_y = 0;
	var o_src = MM_findObj(p_src);
	var o_orig = MM_findObj(p_orig);
	if (typeof(o_orig) == "undefined" || typeof(o_src) == "undefined") return;
	var n_top = parseInt(o_orig.style.top) + p_offset_y;
	var n_left = parseInt(o_orig.style.left) + p_offset_x;
	o_src.style.top = n_top + "px";
	o_src.style.left = n_left + "px";
}
