/* Author: 

*/

$(document).ready(function() {
	$(window).resize(function() {
		howBigIsWindow();
	});
	
	var h = $("#container").outerHeight();
	if($('body').hasClass('home')) {
		h += $("#footer").outerHeight();
	}
	function howBigIsWindow() {
				
		
		if($(window).height() > h) {
			$("#footer").css('position', 'absolute');
		}
		else {
			$("#footer").css('position', 'relative');
		}
		
	}
	
	howBigIsWindow();
	
	
	$(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");

	});
	
	
	$("#mailing_list a").click(function(event) {
		event.preventDefault();
		
		$(this).parents('form').submit();
	});
	
	
	if(!$(".submenu .secondmenu li").length) {
		$(".submenu .secondmenu").remove();
	}
	
});
