google.load("jquery", "1.3.2");
google.setOnLoadCallback(function() {
	core();
});

function hanleRandomDivs()
{
	$(".random").each(function() {
		var nthChild = Math.floor(Math.random() * $(this).children().size() + 1);

		$(this).find(":nth-child(" + nthChild + ")").show();
	});
}

function core()
{
	custom();

	hanleRandomDivs();
	handleImageHrefs();
}

function custom()
{
	$("#jsddm li:last").addClass('last');
}

function handleImageHrefs()
{
	$('.imageItem').find('img').each(function(i) {
		if($(this).attr('href'))
		{
			if($(this).attr('target') != '')
			{
				$(this).wrap('<a href="' + $(this).attr('href') + '" target="' + $(this).attr('target') + '" />')
			}
			else
			{
				$(this).wrap('<a href="' + $(this).attr('href') + '" />')
			}
		}

	});
}
