$(document).ready(function(){
	
	//$('#title').animate({left: 250}, {duration: 5000, easing: "easeinout"}).animate({left: 220}, {duration: 5000, easing: "easeinout"})
	//$('#logo').fadeIn(5000);
	//$('#page').corner({});
	
	bindAjax();
	
	//$('#menubar a').corner();
	//$('#menubar a').css('opacity','.4');
	
	$(".nav")
	.superfish({
		animation : { opacity:"show",height:"show"}
	})
	.find(">li[ul]")
		.mouseover(function(){
			$("ul", this).bgIframe({opacity:false});
		})
		.find("a")
			.focus(function(){
				$("ul", $(".nav>li[ul]")).bgIframe({opacity:false});
			});
	
});

function bindAjax()
{
	$('#loading').hide();
	if( !$.browser.msie )
	{
		$('#logo').fadeIn(2000);
		$('#content').fadeIn('fast');
	}
	else
	{
		$('#logo').show();
		$('#content').show();
	}
	
	$('#menubar a').unbind();
	$('#menubar a').hover(
		function(){
			//$(this).fadeTo("fast",1);
		},
		function(){
			//$(this).fadeTo("fast",.4);
		}
	);
	
	$('.ajax').click(function(){
		// Narrow the header
		if( $('#header').height() > 120 )
		{
			$('#logo').animate({top:"-102px",left:"-25px"},{duration:1000, easing: "easeinout"});
			$('#title').animate({top:"-145px",left:"340px"},{duration:1000, easing: "easeinout"});
			$('#header').animate({height:"120px"},{duration:1000, easing: "easeinout"});
			$('#pastors').animate({width:"227px",height:"125px",top:"0px",left:"753px"},{duration:1000, easing: "easeinout"});
		}
		var el = this;
		$(this).unbind();
		if( $.browser.msie )
		{
			$('#content').hide();
			$('#loading').show();
			$('#content').load($(el).attr('href'), bindAjax);
		}
		else
		{
			$('#content').fadeOut('fast',function(){
				$('#loading').show();
				$('#content').load($(el).attr('href'), bindAjax);
			});
		}
		return false;
	});
}
