$(document).ready(function(){

	/*Fechar Modal*/

	$(".fechar-modal").live("click",function(){
		parent.$(".nyroModalCont").css("display","none");
		parent.$(".nyroModalBg").css("display","none");
	})

	/*Fechar Modal*/

	$("#telefone").mask("(99)9999-9999")
        $("#celular").mask("(99)9999-9999")

	$(".modal").nyroModal();

	$('#mycarousel_fotos').jcarousel({
		scroll: 1
	});

	$('#mycarousel').jcarousel({
		scroll: 1,
		auto: 2,
		wrap: 'both',
		itemFirstInCallback: {
		  onAfterAnimation: adddescription
		}
	});

	function adddescription(carousel, item, idx, state) {

		$("#descricao-carousel li:not(:eq(" + (idx - 1) + ")) a").animate({ color: '#d8d8d8' }, 1000).removeClass();
		$("#descricao-carousel li:not(:eq(" + (idx - 1) + ")) p").animate({ color: '#d8d8d8' }, 1000).removeClass("addaspas");
		$("#descricao-carousel li:not(:eq(" + (idx - 1) + ")) p a").animate({ color: '#d8d8d8' }, 1000).removeClass("addaspas2");

		$("#descricao-carousel li:eq(" + (idx - 1) + ") a").animate({ color: '#909090' }, 1000).addClass("selected");
		$("#descricao-carousel li:eq(" + (idx - 1) + ") p").animate({ color: '#909090' }, 1000).addClass("addaspas");
		$("#descricao-carousel li:eq(" + (idx - 1) + ") p a").animate({ color: '#909090' }, 1000).addClass("addaspas2");


		$("#descricao-carousel li").click(function() {
			carousel.scroll($("#descricao-carousel li").index(this) + 1);
		})

		$(item).hover(
			function() {
				carousel.stopAuto()
			},
			function() {
				carousel.startAuto()
			}
		)
	}

	$(".busca").bind({
		focus: function() {
			if ($(this).val() == "Digite aqui para buscar") {
				$(this).css("color","#434343")
				$(this).val("");
			}
		},
		blur: function() {
			if ($(this).val() == "") {
				$(this).css("color","#cdcdcd")
				$(this).val("Digite aqui para buscar");
			}
		}
	})

	/*Menu*/

	$("#menu ul li a, #menu ul li ul").hover(function(){
		$(this).parent().find("ul").stop(true, true).show();
		$(this).parent().find(" > a").addClass('menu-selected');
	},function(){
		$(this).parent().find("ul").stop(true, true).hide();
		$(this).parent().find(" > a").removeClass('menu-selected');
	})

	$("#navegacao ul li a, #navegacao ul li ul").hover(function(){
		$(this).parent().find("ul").stop(true, true).show();
		$(this).parent().find(" > a").addClass('menu-selected2');
	},function(){
		$(this).parent().find("ul").stop(true, true).hide();
		$(this).parent().find(" > a").removeClass('menu-selected2');
	})

	/*Menu*/

	/* Galeria */

	$("#mycarousel_fotos li a").click(function(){
		var url_thumb = $(this).find('img').attr("src");
		var exploded = url_thumb.split('.');
		$('.galeria_foto_grande img').attr("src",exploded[0] + "_g." + exploded[1]);
                $('.galeria_foto_grande span').html($(this).find('img').attr("alt"));
	})

	$(".galeria_videos #mycarousel_fotos li a").click(function(){
		var url_thumb = $(this).attr("title");
		$('.galeria_foto_grande iframe').attr("src","http://www.youtube.com/embed/"+url_thumb);
	})

	/* Galeria */
})
