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

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

/*
 * Place your custom code inside this function
 */
function custom()
{
	$("#jsddm li:last").addClass('last');
}

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 handleImageHrefs()
{
	$('.imageItem').find('img').each(function(i) {
		if($(this).attr('href'))
		{
			$(this).wrap('<a href="' + $(this).attr('href') + '" />')
		}

	});

}

function core()
{
	custom();

	handleImageHrefs();

	// setWrapperHeights();

	hanleRandomDivs();

	handleVideos();
}


