$(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");
});

$(function(){
    //NAVIGATION DROPDOWN
    /*
    $('#nav li').hover(
        function () { $('ul', this).fadeIn(500);  },
        function () { $('ul', this).fadeOut(200); }
    );
    */

    //SOCIAL MEDIA HOVER
    if (navigator.appName != "Microsoft Internet Explorer") {
        $('.socialIcon').fadeTo(0, 1);
        $('.socialIcon').hover( function() {
            $(this).stop(true, true).fadeTo(300, 0.6);
        }, function() {
            $(this).stop(true, true).fadeTo(300, 1);
        });
    }

    //CUFON
    Cufon.replace('h1')('h2')('h3');
    Cufon.replace('.nav a', { hover : true });

    //CYCLE ARTIKEL HOME
    $('#header_cycle').cycle({
        fx: 'fade',
        timeout: 4500
    });

    //CYCLE NEWS ARCHIVE
    $('#newsArchive').cycle({
        fx: "scrollVert",
        timeout: 0,
        startingSlide:   0,
        pager:  '.pager',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"> &bull; </a>';
        },

        before: function(slide,next){
                $("#newsArchive").animate({
                'height' :  $(next).height()
                }, 1000);
        }
    }, 500);

  $('.oddeven:even').css("background-color", "#EEE");

    //CYCLE GUESTBOOK
    $('.cycle').cycle({
        fx: "scrollVert",
        timeout: 0,
        startingSlide:   0,
        pager:  '.pager',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"> &bull; </a>';
        },

        before: function(slide,next){
                $(".cycle").animate({
                'height' :  $(next).height()
                }, 1000);
        }
    }, 500);
	
	//CYCLE PROJECTS
    $('.prjct').cycle({
        fx: "scrollVert",
        timeout: 0,
        startingSlide:   0,
        pager:  '.pager2',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"> &bull; </a>';
        },

        before: function(slide,next){
                $(".prjct").animate({
                'height' :  $(next).height() + 25
                }, 1000);
        }
    }, 500);

    //FANCYBOX
        $(".fancybox").fancybox();

    //FANCYBOX FLOORPLANNER
        $("a.fancyboxIframe").fancybox({
            'width'        : '85%',
            'height'      : '85%',
            'autoScale'       : false,
            'transitionIn'    : 'none',
            'transitionOut'    : 'none',
            'type'        : 'iframe'
        });

    //FANCYBOX PROJECTEN
    //$("a.gallery").fancybox();

    //DROPDOWN
    $('#nav ul li').hover( function() {
        $(this).children('ul').stop(true, true).fadeIn(200);
    }, function() {
        $(this).children('ul').stop(true, true).fadeOut(200);
    });

    //LAVALAMP MENU
    $('#nav ul#lavaLampBasicImage').lavaLamp({
        fx: "easeInOutBack",
        autoResize:true,
        speed: 700
    });

});



