// JavaScript Document


/***************************/
/*   BACKGROUND RESIZING   */
/***************************/



/*$(window).load(function() {    
        var theWindow = $(window),
            $bg = $("img.fader"),
            aspectRatio = $bg.width() / $bg.height();
			
        function resizeBg() {
                var newWidth = theWindow.width()
				
				$bg.attr('width',newWidth);
				$bg.attr('height',(newWidth/aspectRatio));
				var offset = theWindow.width();
				offset = ( offset - (newWidth/aspectRatio)/2);	
				$('#bg-wrapper').css({'top': 0});
        }
        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});*/

$(window).load(function() {    
        var theWindow = $(window),
            $bg = $("img.fader"),
            aspectRatio = $bg.width() / $bg.height();
			
        function resizeBg() {
                var newHeight = theWindow.height()
				$bg.attr('height',newHeight);
				$bg.attr('width',(newHeight*aspectRatio));
				var offset = theWindow.width();
				offset = ( offset - (newHeight*aspectRatio))/2;	
				$('#bg-wrapper').css({'left': offset});
				$('#bg-wrapper img.fader').css({'display': 'block'});
        }
        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});

/*****************/
/*   SOCIAL NAV  */
/*****************/

$(document).ready(function() {
	$('#social_nav a').hover(function() {
						$(this).children('img').animate({opacity: 1}, 250);		
					}, 
					function() {
						$(this).children('img').animate({opacity: 0}, 250);		
					});
});

/***************/
/*   MARQUEE   */
/***************/

$(document).ready(function() {
	$('a#open-marquee').click(function ($e) {
		$e.preventDefault();
		$('a#open-marquee').hide();
		$('#marquee-control').animate({top: '-=44px'}, 500);
		$('a#close-marquee').show("slide", {direction: "down"}, 500, function() {$('div.pointer').show("slide", {direction: "down"}, 500);});
		
	});	
});

$(document).ready(function() {
	$('a#close-marquee').click(function ($e) {
		$e.preventDefault();
		$('div.pointer').hide("slide", {direction: "down"}, 500, function(){$('a#close-marquee').hide();});	
		
		
		$('#marquee-control').animate({top: '+=44px'}, 500, function() {$('a#open-marquee').show()});
		
	});	
});


$(document).ready(function() {
    $('#footer-marquee').marquee('pointer').mouseover(function () {
        $(this).trigger('stop');
    }).mouseout(function () {
        $(this).trigger('start');
    }).mousemove(function (event) {
        if ($(this).data('drag') == true) {
            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
        }
    }).mousedown(function (event) {
        $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
    }).mouseup(function () {
        $(this).data('drag', false);
    });
	
	$('a#open-marquee').trigger('click');
});
