

$(document).ready(
	function()
	{
		if (resizeContent())
		{
			doFlash();
			$(".tooltip").tooltip({showURL: false});
		}
		
		$(".right-block a img, #leftright-wrap a img").each(
			function()
			{
				$(this).parent().addClass("imglink");
			}
		);
		
		$("input[name=hoeOpWebsiteAnders]").hide();
		
		$("select[name=hoeOpWebsite]").change(
			function()
			{
				if ($(this).val() == 'anders')
				{
					$("input[name=hoeOpWebsiteAnders]").show();
				}
				else
				{
					$("input[name=hoeOpWebsiteAnders]").hide();
				}
			}
		);
		
		setTimeout(function(){resizeContent()}, 3000);
	}
);

//$(window).bind("resize", function(){resizeContent()});

function resizeContent()
{
	doResize();
	if ($(".right-block img").length > 0)
	{
		var aantal = $(".right-block img").length;
		var count = 0;
		
		$(".right-block img").each(
				function()
				{
					$(this).load(
						function()
						{
							count++;
							
							if (count == aantal)
							{
								doResize();
							}
							
							return true;
						}
					);
				}
		);
	}
	else
	{
		doResize();
	}
	
	return true;
}

function doResize()
{
	var pos = $("#layout-footer").position();
		
	if ($.browser.version.charAt(0) == 7 && $.browser.msie)
	{
		$("#layout-footer").css("top", "65px");
		$("#layout-content").height((pos.top-(146))+"px");
		
		var height = $(document).height() + 65;
		
		$("#flash-bg").height(height+"px");
	}
	else
	{
		$("#flash-bg").height($(document).height()+"px");
		$("#flash-bg").height("100%");
	}
	
	var pos = $("#layout-footer").position();
	
	if (($("#layout-content").height() < pos.top) && ($(window).height() >= ($(document).height()-10)))
	{
		$("#layout-content").height((pos.top-(236))+"px");
	}
	else if ($.browser.version.charAt(0) == 8 && $.browser.msie)
	{
		$("#layout-content").height((pos.top-(50))+"px");
	}	
}

function getHeight()
{
	return $(document).height();
}

function doFlash()
{
	var flashvarsnav = {xmlURL:"showtemplate/navigatie.xml?ID="+folderID};
	var flashvarsmediabox = {xmlURL:"showtemplate/mediabox.xml?ID="+folderID};
	var flashvarsmediaboxHome = {xmlURL:"showtemplate/mediabox_home.xml?ID="+folderID};
	var flashvarsmediaboxMapUitv = {xmlURL:"showtemplate/mediabox_mapuitv.xml?ID="+folderID};
	var flashvarsmediaboxMapSpel = {xmlURL:"showtemplate/mediabox_mapspel.xml?ID="+folderID};
	var flashvars = {
						theme:theme,
						height:$("#flash-bg").height()
					};
	var params = {};
	params.wmode = "transparent";
	params.salign = "tl";
	params.allowScriptAccess = "always";
	var attributes = {};
	attributes.align = "middle";
		
	swfobject.embedSWF("swf/Spelerij_BG.swf", "flash-bg", "100%", $("#flash-bg").height()+"px", "9.0.0", "Spelerij_BG.swf", flashvars, params, attributes);
	swfobject.embedSWF("swf/Spelerij_NAV.swf", "header-flash", "860", "165", "9.0.0", "Spelerij_NAV.swf", flashvarsnav, params, attributes);
	
	/*if ($("body").hasClass("home"))
	{
		swfobject.embedSWF("swf/Spelerij_MEDIA.swf", "content-flash", "560", "380", "9.0.0", "Spelerij_MEDIA.swf", flashvarsmediaboxHome, params, attributes);

	}
	else */
	if ($("#content-flash").hasClass("image"))
	{
	}
	else if ($("#content-flash-map").hasClass("map-uitvinderij"))
	{
		swfobject.embedSWF("swf/Uitvinderij_MAP.swf", "content-flash-map", "762", "900", "9.0.0", "Uitvinderij_MAP.swf", flashvarsmediaboxMapUitv, params, attributes);
	}
	else if ($("#content-flash-map").hasClass("map-spelerij"))
	{
		swfobject.embedSWF("swf/Spelerij_MAP.swf", "content-flash-map", "762", "900", "9.0.0", "Spelerij_MAP.swf", flashvarsmediaboxMapSpel, params, attributes);
	}
	else
	{
		swfobject.embedSWF("swf/Spelerij_MEDIA.swf", "content-flash", "560", "380", "9.0.0", "Spelerij_MEDIA.swf", flashvarsmediabox, params, attributes);
	}
}


function doFlashPosition(pos)
{
	var iWidth = $(window).width();
	var iHeight = $(document).height();
	
	iWidth = Math.round(iWidth / 2)-404;
	
	$("#flash-"+pos).css("width", iWidth).css("height", iHeight);
	
	var a = new Array();
	a[0] = iWidth;
	a[1] = iHeight;
	
	return a;
}
