// JavaScript Document
$(function () {
	resizeImage()
	$(window).resize(function () {
		resizeImage();
	});
});

$(function () {
	$('#slides').slides({
		preload: true,
		preloadImage: '/Content/images/loading.gif',
		play: 7000,
		pause: 2500,
		hoverPause: true,
		animationStart: function (current) {
			$('.caption').animate({
				bottom: -35
			}, 100);
			if (window.console && console.log) {
				// example return of current slide number
				console.log('animationStart on slide: ', current);
			};
		},
		animationComplete: function (current) {
			$('.caption').animate({
				bottom: 0
			}, 200);
			if (window.console && console.log) {
				// example return of current slide number
				console.log('animationComplete on slide: ', current);
			};
		},
		slidesLoaded: function () {
			$('.caption').animate({
				bottom: 0
			}, 200);
		}
	});
});

$(document).ready(function () {
    var height;
    if ($(window).height() > ($('div#container').height())) {
        height = $(window).height() - $('div#container').height() + 8;
        $('div#footer').height(height);
    }
});

resizeImage = function () {
    var width;
    if ($(window).width() > $("div#container").width()) {
        width = $(window).width();
    } else {
        width = $("div#container").width();
    }

    var height;
    if ($(window).height() > ($('div#container').height())) {
        height = $(window).height() - $('div#container').height() + 8;
        $('div#footer').height(height);
    }

    var windowWidth = $(window).width();
    var windowHeight = $(window).height();
    var imgWidth = 1900;
    var imgHeight = 1358;

    var windowRatio = windowWidth / windowHeight;
    var imageRatio = imgWidth / imgHeight;

    var newWidth = windowWidth;
    var newHeight = (newWidth / imgWidth) * imgHeight;

    if (imageRatio > windowRatio) { /// img is platter dan window. img moet breder dan 100% worden, height moet 100% worden.
        newHeight = windowHeight;
        newWidth = (newHeight / imgHeight) * imgWidth;


    }

    var diff = newHeight - windowHeight;
    var topPos = 0;

    if (diff > 0) {
        topPos = -1 * (diff / 2);
    }

    $('div#bgimage img').css({ 'width': newWidth + 'px', 'height': newHeight + 'px', 'top': topPos + 'px' });
}

function mainmenu() {
    $(" #drospdown ul ").css({ display: "none" }); // Opera Fix
    $(" #drospdown li").hover(function () {
        $(this).find('ul:first').css({ visibility: "visible", display: "none" }).slideDown(400);
    }, function () {
        $(this).find('ul:first').slideUp(400);
    });
}
$(document).ready(function () {
    mainmenu();
});
