function fixFooterIE() {
	fixBackground();
}

function fixFooter() {
	 var windowheight = $(window).height();
	 var cmsheight = $('#aveqcms').height();
	 var displayheight = cmsheight+105
	 
	 if(windowheight>displayheight) {
		// Pinned footer
	 	//alert("Ja overflow want: window:"+windowheight+" > displayHeight:"+displayheight+"\nFooter topPos: "+cmsheight);
	 	$('body').css({overflow: "hidden"});
	 	$('html').css({overflow: "hidden"});
	 	$('#footer').css({top: cmsheight, height: '100%'});
	 	$('#aveqcms').css({padding: '0'});
	 } else {
	 	// Sticky fixed footer
	 	//alert("Nee overflow want: window:"+windowheight+" < displayHeight:"+displayheight);
	 	$('body').css({overflow: "auto"});
	 	$('html').css({overflow: "auto"});
	 	
	 				var footerHeight = '151';
				
	 	$('#footer').css({bottom: 0, top: 'auto', height: footerHeight+'px'});
	 	$('#aveqcms').css({padding: ' 0px 0px '+footerHeight+'px 0px'});
	 	
		// ie6 fixed footer fix
	 }
	 
	 fixBackground();
}

function fixBackground() {
	//var newheight = $(window).scrollTop() +  $(window).height();
	//alert($(window).scrollTop());

}



$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});

	$('#loopheader').cycle({ 
		fx:    'fade', 
		speed:  1000,
		timeout: 4000,
		random:  1 
	 });

	
 	if (jQuery.browser.msie) { 
	if(parseInt(jQuery.browser.version) <= 6) { 
		var oldbrowser = 1;
	} }
	if(oldbrowser==1) {
		fixFooterIE();
		window.onresize = fixFooterIE;
	} else {
		fixFooter();
		window.onresize = fixFooter;
	}
	
	$(".accordion").accordion({
		header: '.acctitle',
		active: false, 
		alwaysOpen: false,
		collapsible: true,
		autoHeight: false
		/*,change: function() { fixFooterIE(); alert('hoi');  }*/
	});
	
	
	
});



(function($) {
    $(document).ready(function() {
        $.fn.StaticFooter = function() {
            var c = $(this);
            function repo() {
                c.css({position: "absolute", top:($(window).scrollTop()+$(window).height()-c.height()+5)+"px"});
            }
            repo();
            $(window).resize(repo).scroll(repo);
        }

        if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
            $("#footer").StaticFooter();
        }
    });
})(jQuery);
