function mainmenu(){
		$("#menubar ul").css({display: "none"}); // Opera Fix
		$("#menubar li").hover(function(){
				$(this).find('ul:first').css({visibility: "visible", display: "none", zIndex: "9000"}).show(400);
				},function(){
				$(this).find('ul:first').css({visibility: "hidden"});
				});
		};

function onBefore() {
	if ($.browser.msie && $.browser.version < 9 ) {
    	$('.title').hide();
	} else {
		$('.title').fadeTo(500, 0);
	}
};

function onAfter() {
	if ($.browser.msie && $.browser.version < 9 ) {
    	$('.title').show();
	} else {
		$('.title').fadeTo(1000, 1);
	}
};
function captionHovers() {

    // In theory, you could use IE8 but the alpha trans is
    // messed up.  Someting to fix in the future.  If you
    // use a non alpha trans caption bg, you could use this
    // on IE8, and maybe even IE7.
	if ($.browser.msie && $.browser.version < 9 ) return;

    // Adjust the title to accomodate a new span
    $('.slide a .title').css({top: '-140px'});

    // Insert the new crossfade span and remove
    // the regular hover color class.  Replace it
    // with a special class that won't trigger
    // hover switch
    $('.slide a .title.orange')
        .removeClass('orange')
        .addClass('nohvorange')
        .before('<span class="hover hvorange"></span>');
    $('.slide a .title.purple')
        .removeClass('purple')
        .addClass('nohvpurple')
        .before('<span class="hover hvpurple"></span>');
    $('.slide a .title.blue')
        .removeClass('blue')
        .addClass('nohvblue')
        .before('<span class="hover hvblue"></span>');
    $('.slide a .title.red')
        .removeClass('red')
        .addClass('nohvred')
        .before('<span class="hover hvred"></span>');
    $('.slide a .title.green')
        .removeClass('green')
        .addClass('nohvgreen')
        .before('<span class="hover hvgreen"></span>');

    // Hide the hovers
    $('.hover').css({opacity: 0});
    // Bind hover state to slides, fade in and out span.hover
    // for that slide only
    $('.slide').hover(function () {
        $('span.hover', this).stop().fadeTo(250, 1);
        }, function () {
        $('span.hover', this).stop().fadeTo(250, 0);
    });

};

function controlHovers() {
	if ($.browser.msie && $.browser.version < 9 ) {
        $('#slideshow-box').hover(function () {
            $('#prev').show();
            $('#next').show();
            }, function() {
            $('#prev').hide();
            $('#next').hide();
        }); 

    } else {
        $('#slideshow-box').hover(function () {
            $('#prev').fadeIn();
            $('#next').fadeIn();
            }, function() {
            $('#prev').fadeOut();
            $('#next').fadeOut();
        }); 
    }
}

$(document).ready(function(){
    controlHovers();
	captionHovers();
	
	$('#slides').cycle({
		speed: 1000,
		timeout: 6000,
		before: onBefore,
		after: onAfter,
		pause: true,
        next: '#next',
        prev: '#prev'
	});
	
	$('.calendar').click(function (e) {
		jQuery.modal('<iframe src="'+this.href+'" width="790" height="560"></iframe><p style="text-align:center; padding-bottom:20px; color:black;"><a target="_blank" href="'+this.href+'">View larger</a> - <a href="javascript:$.modal.close();">Close</a></p>', {   
			containerCss: {
			    height: 600,
			    width: 800
			}
		});
		return false;
	});
	mainmenu();
	/* Layering fix for IE */
	if($.browser.msie && $.browser.version < 8 )
	{
		$('#menubar li ul ul').css({left:'208px'});
		var zIndexNumber = 1000;
		$('div').each(function() {
			$(this).css('zIndex',zIndexNumber);
			zIndexNumber -=10;
		});
	};
	/* Alignment fix for firefox */
	if(jQuery.browser.mozilla == true)
	{
		$('#menubar a').css( { 'padding-top': '10px'} );
	};
	
	$("#header a").removeAttr("title");
});