$(document).ready(function() {
    setTimeout('activateElements()', 500);
    $('#menu li')
    .css( {backgroundPosition: "0 -1px"} )
    .mouseover(function(){
        $(this).stop().animate({backgroundPosition:"(0 -350px)"}, {duration:500});
    })
    .mouseout(function(){
        $(this).stop().animate({backgroundPosition:"(0 -1px)"}, {duration:500});
    });
    $('.down-list li:last-child').addClass("last");
    $('.down-list').width(135);
    $('.drop-down').hover( function() {
        $('.down-list', this).fadeIn(300);
    }, function() {
        $('.down-list', this).fadeOut(300);
    });
    $('#first_drop').hover(function() {
        $('#menu').addClass('first_drop_active');   
    },
    function() {
        $('#menu').removeClass('first_drop_active');
    });
    $('#last_drop').hover(function() {
        $('#menu').addClass('last_drop_active');   
    },
    function() {
        $('#menu').removeClass('last_drop_active');
    });
    $.history.init(function(url) {
   	pageClick(url == "" ? "" : url);
    });
});

function activateElements()
{
    var time1 = 1000;
    var time2 = 600;
    //$('#logo_container').slideDown(time1, function() {
        $('#menu').slideDown(time1);
        $('#logo').fadeIn(2000, function() {
            $('#logo_container').slideUp(time1);
            $('#tagline').fadeIn(time1);
        });
        $('#weddings').fadeIn(time2, function() {
            $('#family_events').fadeIn(time2, function() {
                $('#quinces_swt16').fadeIn(time2, function() {
                    $('#schools').fadeIn(time2, function() {
                        $('#corp').fadeIn(time2);
                    });
                });
            });
        });
    //});
}

function pageClick(link)
{
    var time = 1000;
    if (link)
    {
    	$('#loading').slideDown(function() {
    	$.get(link+'?ajax=1', function(data) {
	    $('#content').fadeOut(time, function() {
	    	$('#content').html(data);
		$('#content').fadeIn(time, function() {
		    $('#loading').slideUp();
		});
	    });
	});
	});
	$.history.load(link);
    }
    return false; 
}
function toggleJukebox()
{
    var toggle = $('#toggle-jukebox').html();
    if (toggle == 'show jukebox')
    {
        $('#jukebox').animate({'height':'240px'}, 'slow');
        $('#toggle-jukebox').html('hide jukebox');
    }
    else
    {
        $('#jukebox').animate({'height':'0px'}, 'slow');
        $('#toggle-jukebox').html('show jukebox');
    }
}

