$(document).ready(function(){
	$("div.shadow").each(function(i){
		fator = ($(this).css("border") == undefined || $(this).css("border") == "") ? 0 : 2;
		width = parseInt($(this).css("width"));
		height = parseInt($(this).css("height"));
		$(this)
			.after('<div class="shadowbox" style="width:' + (width + 14 + fator) + 'px"><div class="clear"><div style="float:left; ' + $(this).attr("style") + '" class="' + $(this).attr("class") + '" >' + $(this).html() + '</div><div class="rigthtop"></div><div class="rigth" style="height:' + ((height - 20) - fator) + 'px"></div><div class="rigthbotton"></div></div><div class="bottonleft"></div><div class="botton" style="width:' + ((width - 20) - fator) + 'px"></div><div class="bottonrigth"></div></div>').next()
			.prev().remove();
	});
	$("img.shadow").each(function(i){
		src = $(this).attr("src");
		width = parseInt($(this).attr("width"));
		height = parseInt($(this).attr("height"));
		$(this)
			.after('<div class="shadowbox" style="width:' + (width + 14) + 'px"><div class="clear"><img src="' + src + '" width="' + width + '" height="' + height + '" border="0" /><div class="rigthtop"></div><div class="rigth" style="height:' + (height - 20) + 'px"></div><div class="rigthbotton"></div></div><div class="bottonleft"></div><div class="botton" style="width:' + (width - 20) + 'px"></div><div class="bottonrigth"></div></div>').next()
			.prev().remove();
	});

	$('a').each(function(i){
		if ($(this).attr("rel") != "")
			$(this).click( function(i){ $(this).blur(); s($(this).attr("rel")) } );
		else
			$(this).click( function(i){ $(this).blur(); } );
	});
	if (sm != '') s(sm);
});

s = function(sm) {
	for (i = 1; i < 5; i++)
		$('#sm0'+i).slideUp('slow');
	$('#sm'+sm).slideDown('slow');
}
