var $imgColor = ['cd_acoustic_pb.gif', 'cd_shaman2008_pb.gif', 'cd_shamanimmortal_pb.gif', 'cd_tempestt_pb.gif'], $imgSrc="", imageH="";

$(function(){
	createImg();
	if (!$.browser.msie)
	{
		$("#multimidia ol img").mouseover(function(){
			$(this).attr("src", $(this).attr("src").replace("_pb", "") );
			imageH = ($(this).hasClass("cd")) ? 107 : 148;
			$(this).animate({
				width: "157px",
				height: imageH+50+"px"
			}, {queue:false, duration:110});
		
			var $src = $(this).attr("src");
			$imgSrc = $src.replace( $src.substr($src.lastIndexOf("/")), "" )+"/"+$imgColor[$(this).attr("id")-1];
		
			$(this).mouseout(function(){
				$(this).attr("src", $imgSrc );
				$(this).animate({width:"107px", height:imageH+"px"}, {queue:false, duration:110});
			});
		}); 
	}
	
	$("#multimidia ol img").click(function(){
		$this = $(this);
		$("#overlay").remove();
		$this.unbind('mouseout');
		var $body = $(($.browser.msie && $.browser.version == '6.0')?document.body:document);
		var overlayCont = '<div id="overlayCont"><div class="close">Fechar</div></div>';
		var overlay = '<div id="overlay"></div>';
		var cssOver = {'width' : $body.width(),'height' : $body.height()};
		var cssOverCont = {'top' : ($(window).height()/2)+$(window).scrollTop()};

		$("body").append(overlay);
		$("body").append(overlayCont);
		
		$("#overlay").css(cssOver).fadeIn('slow', function(){
			var $conteudo = $this.parent("li").html();
			$("#overlayCont").css(cssOverCont).append($conteudo).fadeIn('slow');
		}).click(function(){
			fechar();
		});
		$(".close").click(function(){fechar();});
		function fechar(){
			$("#overlay").fadeOut('slow', function(){
				$this.animate({width:"107px", height:($this.height()-50)+"px"}, {queue:false, duration:110});
				$this.attr("src", $imgSrc);
				$("#overlay").remove();
				$("#overlayCont").fadeIn("slow", function(){$(this).remove();});
			});
		}
	});	
});

function createImg()
{
	var imgpb = ['cd_acoustic.gif', 'cd_shaman2008.gif', 'cd_shamanimmortal.gif', 'cd_tempestt.gif'], im=0;
	for ( ; im < imgpb.length; im++ ) {
		$('body').append('<img src="/wp-content/themes/leomancini/images/'+imgpb[im]+'" id="id-'+im+'" />');
		$("#id-"+im).hide();
	}
}