var slideIndex = 0;

$(function()
{
	// bind 'cufon' event to allow cufon to be applied to ajax enabled calls
	$(window).bind('cufon',function(){
		if (typeof Cufon != 'undefined') { // in case called without cufon
			Cufon.replace('h1', {
				fontFamily: 'Helvetica Black',
				lineHeight: '.9em'
			});
			Cufon.replace('.rockwell,.widgetTitle', {
				fontFamily: 'Rockwell Extra Bold'
			});
			Cufon.replace('.helvetica,#topnav>li>a,#slideshow h4,.weatherCont span,#sidenav h4,.news-header h2,.calendar-widget .widgetTitle,.imgBoxCookinCont .widgetTitle', {
				fontFamily: 'Helvetica Black'
			});
		}
	});
	// use the following to reload cufon
	$(window).trigger('cufon');

	$("#topnav>li").hover(function() {
		if (!$.browser.msie) $(this).addClass("sfhover").find(".sfcontent").fadeIn("fast");
	}, function() {
		if (!$.browser.msie) $(this).removeClass("sfhover").find(".sfcontent").fadeOut("fast");
	});
	$("#topnav>li:last .sfcontent").css({left:"auto",right:-25});
    if (document.all) {
        $("#topnav li").hoverClass ("sfhover");
    }
	if (typeof Shadowbox != 'undefined') { // in case called without shadowbox
		Shadowbox.init({
			players: ['img', 'swf', 'html', 'iframe', 'flv']
		});
	}
	if($("#slideshow>div").length > 1)
		setInterval(nextSlide, 5000);
	$(".search input[name=search]").focus(function(){if($(this).val() == "Search the site") this.select()});
});
function nextSlide()
{
	slideIndex = slideIndex < $("#slideshow > div").length - 1 ? slideIndex + 1 : 0;
	$("#slideshow > div").fadeOut("slow").eq(slideIndex).fadeIn("slow");
}
$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};   

$(document).ready(function(){
	$('a.calendar-overview').live('click',function(){
		Shadowbox.open({
			content: $(this).attr('href')
			,player: 'iframe'
			,width: '700'
			,height: '600'
			,options: {
				onClose: function(el) {
					window.location.reload();
				}
			}
		});
		return false;
	});
});

