//_# FUNÇÃO NEVER REPEAT #_
function neverRepeat(){
	data = new Date();
	nr = data.getDay() + data.getMonth() + data.getFullYear() + data.getHours() + data.getMinutes() + data.getSeconds() + data.getMilliseconds();
	return nr;
}
//_#

$(document).ready(function(){
	$(".ck img").each(function(){
		w = $(this).width();
		h = $(this).height();
		src = $(this).attr('src') + '/' + w + '-' + h;
		style = $(this).attr('style');
		alt = $(this).attr('alt');
		titulo = $(this).attr('title');
		nr = neverRepeat();
		after = '<div style="'+style+'" class="legendaCont" id="lc'+nr+'">';
		if (titulo != ''){
			after += '<div class="creditos" style="height: '+h+'px;" id="c'+nr+'">&nbsp;&nbsp;'+titulo+'&nbsp;&nbsp;</div>';
		}
		after += '<img src="'+src+'" alt="'+alt+'" title="'+alt+'" stlye="float:left" />';
		if (alt != ''){
			after += '<br /><div class="legendas" style="width: '+(w-5)+'px;" id="l'+nr+'">'+alt+'</div>';
		}
		after += '</div>';
		$(this).after(after);
		$(this).remove();
		$("#c"+nr).mbFlipText(false);
		$("#c"+nr).css('width','0px');
		$("#c"+nr).css('padding','0px 0px 0px 1px');
		if (titulo != ''){
			$("#lc"+nr).css('width',(w+1));
		}
		if (alt != '' && titulo == ''){
			$("#l"+nr).css('width',(w-6));
		}
	});
	
	$('.legendaCont').click(function(){
		img = $(this).find("img");
		srcMAX = $(img).attr('src');
		srcMAX = srcMAX.substr(0,srcMAX.lastIndexOf("/"));
		//srcMAX += '/1280-1024';
		alt = $(img).attr('alt');
		$.prettyPhoto.open(srcMAX,'',alt);
	});
});


