// JavaScript Document

$(document).ready(function(){
	// fade in
	$(".topbar").delay(100).animate({'left':'0','opacity':'1'},1000);
	$(".middlebar").delay(300).animate({'left':'0','opacity':'1'},1000);
	$(".bottombar").delay(500).animate({'left':'0','opacity':'1'},1000);
	$(".hotel").delay(1500).animate({'left':'0','opacity':'1'},1000);
	$(".carlton").delay(2300).animate({'left':'0','opacity':'1'},1000);
	
	// to time fade out, add carlton numbers and make sure all others add up to that number (eg. topbar fadein + topbar feadeout = carlton combined numbers)
	
	// fadeout 
	$(".topbar").delay(3600).animate({'opacity':'0'},500);
	$(".middlebar").delay(3400).animate({'opacity':'0'},500);
	$(".bottombar").delay(3200).animate({'opacity':'0'},500);
	$(".hotel").delay(2200).animate({'opacity':'0'},500);
	$(".carlton").delay(1400).animate({'opacity':'0'},500);
	$(".shade").delay(5000).animate({'opacity':'0'},1500, // to add in redirect add comma at end of this line (1) 
	//); // code out this line (2)
	function() // uncode this line (3)
	{ // uncode this line (4)
	window.location.href = "http://www.hotellincoln.com.au/home-news-and-events";}); // lastly, uncode this line (5)
});



$(window).load(function() {    

        var theWindow        = $(window),
            $bg              = $("#bg"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('bgwidth');
                }

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});
