google.load("jquery", "1.3.2");
google.load("swfobject", "2.1");

google.setOnLoadCallback(function() 
{
	core();
});

/*
 * Place your custom code inside this function
 */
function custom()
{	
	$(".accordion .header").click(function() {		    			
		if($(this).hasClass('active') == false)
		{
			var item = $(this);
			$(this).parents(".accordion").find(".content").slideUp();
			
			$(".accordion .active").removeClass('active');
    		$(item).addClass('active');		    						    		
	    	$(item).next().slideDown('fast');
			
			
		}
	});
	
	$(".accordion").each(function() {
		$(this).find(".header:first").click();
	});
}

function hanleRandomDivs()
{
	$(".random").each(function() 
	{
		var nthChild = Math.floor(Math.random() * $(this).children().size() + 1);

		$(this).find(":nth-child(" + nthChild + ")").show();
	});
}

function handleVideos()
{
	$(".videoItem").each(function(i) 
	{
		var vars = { 'file': $(this).find('img').attr('rel'), 'stretching': 'exactfit'};
		var params = { menu: 'false', allowfullscreen: 'true' };
		var attributes = { id: $(this).find('img').attr('id'), name: $(this).find('img').attr('id') };
		
		swfobject.embedSWF('http://www.websitebeheermodule.nl/Lib/WYSIWYG/swf/player.swf', $(this).find('img').attr('id'), $(this).find('img').width(), $(this).find('img').height(), "9.0.0", "", vars, params, attributes);	
	});
}

function setWrapperHeights()
{
	$(".wrapper").each(function() 
	{
		var maxHeight = 0;
		$(this).find('.workspaceItem').each(function() 
		{
			var top = parseInt($(this).css('top').replace('px',''));			
			var height = $(this).height();
			
			if(top+height > maxHeight)
			{
				maxHeight = top+height;
			}
		});
		
		$(this).parent().height(maxHeight);		
		$(this).show();
	});
}

function core()
{
	custom();

	// setWrapperHeights();
	
	hanleRandomDivs();
	
	handleVideos();
}

