/* LIGHTBOX */
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.headingEval = 'this.thumb.alt';
hs.headingOverlay.position = 'below';
hs.addSlideshow({
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});
/* FIM LIGHBOX */
$(document).ready(function() {
	$("#galeria-home").parent().parent().children("#footer").addClass("home");
	/* EBIS */
	$("#link").mouseover(function() {
		$("#ebis img").stop();
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
			$("#ebis img + img").animate({top:35, opacity: 1}, 250);																  
		});																	  
	});
	$("#link").mouseout(function() {
		$("#ebis img").stop();
		$("#ebis img + img").animate({top:45, opacity: 0}, 250);						   
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
		});																	  
	});
	/* ANIM */
	function countChild(elem){
		return $(elem).size();
	}
	function writeCode( num ){
		var str;
		var j = 1;
		str="";
		for(i=1; i<= num; i++){
			str = str + '<a class="" href="#">'+j+'</a>';
			j++;
		}
		return str;
	}
	function createLinks(){
		var code;
		code = writeCode(countChild(".images > div"));
		$(".slidetabs").html(code);
	}
	$(function() {
		createLinks();
		$(".slidetabs").tabs(".images > div", {
			effect: 'fade',
			fadeOutSpeed: "slow",
			rotate: true

		}).slideshow({ autoplay: true, interval: 7000});
	});
	/* CANTOS ARREDONDADOS */
	$("#novidades-home li, #galeria-home > div ul li").corner("5px");
	$(".pagination > a, .pagination span").corner("3px");
	/* GALERIA */
	$("#images .scrollable").scrollable();
	$("#images .items img").click(function() {
		if ($(this).hasClass("active")) { return; }
		var url = $(this).attr("src").replace("_t", "");
        url = url.replace("&largura=112&altura=75", "&largura=500&altura=335");

		var alt = $(this).attr("alt");
        var wrap = $("#image_wrap").fadeTo("medium", 0.5);
		var img = new Image();
		img.onload = function() {
				wrap.fadeTo("fast", 1);
				wrap.find("img").attr("src", url);
                wrap.find("img").attr("alt", alt);
		};
		img.src = url;
        $("#images #image_wrap p").html(alt);
		$(".items img").removeClass("active");
		$(this).addClass("active");
	}).filter(":first").click();
});
