// Popup window for details
var newwindow;
function openImgWindow(img)
{
	var url = 'media/' + img + '.jpg';
	newwindow=window.open(url, 'details', 'width=820,height=554,toolbar=no,scrollbars=no,status=no,resizable=yes');
	if(window.focus){ newwindow.focus(); }
	//return false;
}

// Suckerfish Dropdown Menus
sfHover = function() {
	var sfEls = document.getElementById("menu").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"), "");
		}
	}
}

// Blurbs Fader
function fadeOut(f)
{
	var fader = new Fx.Style(blurb_div, 'opacity', {onComplete:function(){updateForm(f)}, duration:blurb_fadeSpeed});
	fader.start.pass([1,0], fader).delay(blurb_fadeSpeed);
}

function updateForm(f) 
{
	//###ADD blurbID retrieval from <span> here!
	new Ajax ('/_blurbs.php?action=random&id=-1',{
		postBody: '',
		update: $(blurb_div),
		onComplete: completeUpdate
	}).request();
}

function completeUpdate() 
{
	var fader = new Fx.Style(blurb_div, 'opacity', {duration: blurb_fadeSpeed});
	//fader.hide()
	fader.start.pass([0,1], fader).delay(blurb_fadeSpeed);
	setTimeout(fadeOut,blurb_repeatDelay);
}


//if (window.attachEvent) window.attachEvent("onload", sfHover);
//if (window.attachEvent) window.attachEvent("onload", setTimeout(fadeOut, 3000));


//DISABLED UNTIL WE CAN FIX BLURBS TO WORK WITH MOOTOOLS v1.2.0
//setTimeout(fadeOut, blurb_initialDelay)


/*
window.addEvent('domready', function() {
	var blurb = $('blurb');

	// Make the "next" button work.
	$('blurbNext').addEvent('click', function(e) {
		// You often will need to stop propagation of the event
		e.stop();
		
		// Fade out.
		blurb.fade(0);
		
		// Fetch a new blurb.
		
		// Populate the DIV with the new content.
		
		// Set the blurbID to the ID of the new content.
	});
	

});
*/
