// remap jQuery to $

(function($){  
})(window.jQuery);

$(document).ready(function(){
	if($.cookie("Okay_css")) {
		$("link#color").attr("href",$.cookie("Okay_css"));
	}
	$(".color a").click(function() {
		$("link#color").attr("href",$(this).attr('rel'));
		$.cookie("Okay_css",$(this).attr('rel'), {expires: 365, path: '/'});
		return false;
	});
	$('.media').media( { width: 400, height: 300, autoplay: true } );
	$("#winkelimages").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
	});
	$('.slideshow').slideshow();

});

$(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");
		$("#bg").fadeIn();
		$("#page-wrap").fadeIn();
		$(".fader").hover(function(){
			$(this).find("img").fadeOut();
			}, function() {
		    $(this).find("img").fadeIn();
		});
		$('#map').jMapping({
			force_zoom_level: 15,
			default_zoom_level: 15
			});

}); 

;(function($) {
			
	$.fn.slideshow = function(options) {
		options = $.extend({
			timeout: 5000,
			speed: 600
		}, options);
		return this.each(function() {
			var $elem = $(this);
			$elem.children().eq(0).appendTo($elem).show();
			setInterval(function() {
				$elem.children().eq(0)
				.hide().appendTo($elem)
				.fadeIn(options.speed)
			}, options.timeout);
		});
	};
})(jQuery);
