$(document).ready(function() {
	redrawLayout();
});

$(window).resize(function() {
	redrawLayout();
});

var a = null;
function redrawLayout() {
	// Vars
	windowWidth = jQuery(window).width();
	windowHeight = jQuery(window).height();
	
	// Linker en rechter deel uitrekenen
	widthLeft = Math.round(windowWidth / 100 * 45);
	widthRight = Math.round(windowWidth / 100 * 55);
	if(widthLeft < 474) widthLeft = 474;
	
	// Gewone body
	$("#body-wrapper").css('height',windowHeight+'px');
	$("#body-wrapper").css('width',widthLeft+'px');
	
	$("#body").css('top',((windowHeight-$("#body").outerHeight())/2)+'px');
	$("#body").css('left',((widthLeft-$("#body").outerWidth())/2)-25+'px');
	
	// Flash-Wrapper
	$("#flash-wrapper").css('width',windowWidth+'px');
	$("#flash-wrapper").css('height',windowHeight+'px');
	
	if($("#producten").length > 0) {
		productenLeft = ((widthRight-$("#producten").outerWidth())/2)+widthLeft;
		if(productenLeft < widthLeft) productenLeft = widthLeft;
		
		$("#producten").css('top',((windowHeight-$("#producten").outerHeight())/2)+'px');
		$("#producten").css('left',productenLeft+'px');
		
		$(".pijl").each(function() {			
			var wKop = $(this).find('div.kop').width();
			var wMidden = 0;
			var wEind = $(this).find('div.eind').width();
			
			if(jQuery.browser.msie == true) wMidden = $(this).find('div.midden div').width();
			else {
				$(this).find('div.midden canvas').each(function() {
					wMidden += $(this).width();
				});
				
				wMidden -= 10;
			}
			
			$(this).find('div.midden').css('width',wMidden + 'px');
			if(jQuery.browser.msie == true) {
				$(this).find('div.midden div').css('margin','0');
			}
			
			if($(this).hasClass('rechts')) {
				// Rechter pijl doen
				$(this).find('div.kop').css('right','0px');
				$(this).find('div.midden').css('right',wKop + 'px');
				$(this).find('div.eind').css('right',(wKop + wMidden) + 'px');
			}
			else {
				// Linker pijl doen
				$(this).find('div.kop').css('left','0px');
				$(this).find('div.midden').css('left',wKop + 'px');
				$(this).find('div.eind').css('left',(wKop + wMidden) + 'px');
			}
		});
	}
}
