//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Homepage (slideshow) 
//////////////////////////////////////////////////////////////////////////////////////////////////////////

begin_slideshow = function()
{
	$('#stage #image').cycle({
		fx:'fade',
		timeout:6000,
		pager: '#stage #controls',
		after: update_title,
		before: fade_out_title
	})
}

//update title after slide fades
update_title = function()
{
	var a = $(this).contents().filter("img").attr("alt");
	var h = $(this).attr("href");
	$('#stage #title h2').html("<a href='"+h+"'>"+a+"</a>");
	$('#stage #title h2').fadeIn('fast');

}

//fade title out
fade_out_title = function()
{
	$('#stage #title h2').fadeOut('fast');
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main Nav (dropdown menus)
//////////////////////////////////////////////////////////////////////////////////////////////////////////

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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Misc Functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){

//Add targets to non-render links, so we can remain xhtml strict :)
//$("a[href^=http://]").not("a[href^=www.montgomeryparksfoundation.org]").attr("target", "_blank");
				
});
