/*
    POKE Posterwall
    jQuery plugin that always streaches the body background image to the full screen size.
    Auth: Mattias Gunneras POKE, 2009-11-17
    
    This is heavily influenced by, and kindly borrowed from Supersized @ http://buildinternet.com/project/supersized/
    which is a much more fully featured version that provides slideshow and navigation functionality.
*/

(function($){
	
	// Resize image now, on document load,
	// and when the browser window is resized.
	$.fn.posterwall = function(options) {
	    var options = $.extend({}, $.fn.posterwall.defaults, options);
	    this.each(function() {
	        
	        // update straight away.
	        $(this).update(options);
	        var that = this;
	        
	        var trigger_update = function() {
	            $(that).update(options);
	        };
	        
            //update on dom ready
            $(document).ready(trigger_update);
            // update on window resize
            $(window).bind("resize", trigger_update);
            // update when user triggers 'update'
            $(this).bind('update', trigger_update);
            // update when image is fully loaded.
            $(this).load(trigger_update);
	    });
	};
	
	$.fn.update = function(options) {
	    var options = $.extend({}, $.fn.posterwall.defaults, options);
	  	return this.each(function() {  	    	
			//Define image ratio
            // var startheight = startwidth = 100;
            // var ratio = startheight/startwidth;
            var ratio = options.ratio[1]/options.ratio[0];
			
			//Gather browser and current image size
			var imagewidth = $(this).width();
			var imageheight = $(this).height();
			var browserwidth = $(window).width();
			var browserheight = $(window).height();
            
			//Resize image to proper ratio
			if ((browserheight/browserwidth) > ratio){
			    var width = browserheight / ratio;
			    var height = browserheight;
			} else {
			    var width = browserwidth;
			    var height = browserwidth * ratio;
			}
			
			// set the new width and height values
			// if the width and hight is big enough
			width = width > options.min_size[0] ? width : options.min_size[0];
	        height = height > options.min_size[1] ? height : options.min_size[1];
	        $(this).width(width);
	        $(this).height(height);
		        
	    	// center the image
			if (options.vertical_center == 1){
                var left = (browserwidth - $(this).width())/2;
                var top = (browserheight - $(this).height())/2;
                $(this).css('left', left);
                $(this).css('top', top);
			}
    		
			return false;
		});
	};
	
	$.fn.posterwall.defaults = { 
		vertical_center: 1,
		ratio: [16,9],
		min_size: [980, 600]
	};	
	
})(jQuery);

/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

$(document).ready(function(){


$("#dropline li.current").children("ul").css("left", "0px").show();

$("#dropline li.current").children(":first-child").css("color", "#c0002a")


$("#dropline li").hover(function(){
								 
				$("#tekst_sub_menu").css('background-image', 'url(/afbeeldingen/wit_trans.png)');	
				
	if(this.className.indexOf("current") == -1)  {
		getCurrent = $(this).parent().children("li.current:eq(0)");
		if(this.className.indexOf("top") != -1)  {
			$(this).children("a:eq(0)").css({color : '#c0002a'});
			
			
		}
		else {
			$(this).children("a:eq(0)").css({color : '#c0002a', 'font-style' : 'italic'});
				
				}
		if (getCurrent = 1 ) {
			$(this).parent().children("li.current:eq(0)").children("ul").hide();
			
		}
			$(this).children("ul:eq(0)").css("left", "0px").show();
	 							
					
	}
},function(){
	if(this.className.indexOf("current") == -1)  {
		getCurrent = $(this).parent().children("li.current:eq(0)");
		if(this.className.indexOf("top") != -1) {
			$(this).children("a:eq(0)").css({color : '#fff', 'font-style' : 'normal'});	
			$("#tekst_sub_menu").css('background-image', 'url(/afbeeldingen/spacer.png)');
		}
		else {
			$(this).children("a:eq(0)").css({color : '#fff', 'font-style' : 'normal'});	
			
		}
		if (getCurrent = 1 ) {
			$(this).parent().children("li.current:eq(0)").children("ul").show();
		
		}
			$(this).children("ul:eq(0)").css("left", "-99999px").hide();
	}
		
});


});



function toondiv() {
	$("#posterwall_raster").toggle()
	};
	

