$(function(){
	initSifrContent();
	initMenu();
	initRating();
	initEmail();
	initGalery();
	initSize();
	
	Utils.fieldFocus($("#busca").get(0),"O que você está procurando?");
	Utils.fieldFocus($("#emailLogin").get(0));
	
	$(".mnImprimir").click(function(){
		Utils.pop("/imprimir.jsp","Imprimir",573,545);
		return false;
	});
	
	$("#frmBusca").submit(function(){
		if($.trim($("#busca").val())==""){
			alert("Digite algum critério de busca");
			return false;
		}
		$("#busca").val($.trim($("#busca").val()));
	});
	
	initEsqueciSenha();
	initEnquete();
	
	$(window).resize(function(){
		if($(this).width() < 998) $("#container,#intervencaoSocial").width("998px");
		else $("#container,#intervencaoSocial").width("100%");
	});
	
	$("a[href^=http://foodservices.sadia.com.br]").click(function(){
		pageTracker._trackPageview("/rodape_foodservice/");
		dataMetrics({pageName:"Food Service - "+window.location.pathname,channel:"Institucional"});
	});
	$("a[href^=http://ri.sadia.com.br]").click(function(){
		pageTracker._trackPageview("/menu_sup_investidores/");
		dataMetrics({pageName:"Investidores - "+window.location.pathname,channel:"Institucional"});
	});
	$("a[href^=http://www.institutosadia.org.br]").click(function(){
		pageTracker._trackPageview("/sobre-a-sadia/sai_institutosadia/");
		dataMetrics({pageName:"Instituto Sadia - "+window.location.pathname,channel:"Institucional"});
	});
	$(".btYouTube").click(function(){
		pageTracker._trackPageview("/rodape_youtube/");
		dataMetrics({pageName:"Junte-se a Sadia - You Tube",channel:"Outros sites Sadia",events:"event23"});
	});
	$(".btTerraTv").click(function(){
		pageTracker._trackPageview("/rodape_terratv/");
		dataMetrics({pageName:"Junte-se a Sadia - TerraTV",channel:"Outros sites Sadia",events:"event23"});
	});
	
	$(".padrao").parents(".produto").find("a").click(function(){
		pageTracker._trackPageview("/s-para-voce/papel-parede/download/["+ $(this).attr("href") +"]/");
	});
	$(".baixar_agora").parents(".produto").find("a").click(function(){
		pageTracker._trackPageview("/s-para-voce/protetores-de-tela/download/["+ $(this).attr("href") +"]/");
	});
	$(".emoticons").parent(".produtoG").find("a").click(function(){
		pageTracker._trackPageview("/s-para-voce/emoticons/download/["+ $(this).attr("href").split("/")[$(this).attr("href").split("/").length-1] +"]/");
	});
	
	openBlank();
	getHeightReceita();
});

function initEsqueciSenha(){
	$(".jsEsqueciSenha").unbind("click").click(function(){
		modalSenha = new Modal();
		modalSenha.init({ajax:{type:"get",url:$(this).attr("href"), call: "responseEsqueciSenha"}});
		
		pageTracker._trackPageview("/menu_compartilhe_esqueci_senha/");
		return false;
	});
}

function initEsqueciSenhaModal(){
	$(".jsEsqueciSenhaModal").unbind("click").click(function(){
		closeModal();
		modalSenha = new Modal();
		modalSenha.init({ajax:{type:"get",url:$(this).attr("href"), call: "responseEsqueciSenha"}});
		
		pageTracker._trackPageview("/menu_compartilhe_esqueci_senha/");
		return false;
	});
}

function responseEsqueciSenha(){
	$("#frmEsqueciSenha").validate({
		errorLabelContainer: $("ul.error"),
		wrapper: 'li',
		submitHandler: function(form){
			pageTracker._trackPageview("/menu_compartilhe_esqueci_senha_enviar/");
			Utils.executeAjax({type:"post", url:$(form).attr("action"), data:$(form).serialize()},modalSenha);	
		},
		rules: {
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			email: {
				required: 'Preencha o campo email',
				email: 'Endereço do campo email inválido'
			}
		}
	});
}

function initSifrContent(){
	if (typeof sIFR != 'undefined') {
		fontePath = {src: '/swf/sifr_frankGothic.swf'};
		sIFR.activate();
        sIFR.replace(fontePath, {selector: '#main h1.error',css: '.sIFR-root {color: #B85C02; font-style:italic}',wmode: 'transparent'});
		sIFR.replace(fontePath, {selector: '#content h2.vidaSaudavel',css: '.sIFR-root {color: #3f6594; font-style:italic}',wmode: 'transparent'});
		sIFR.replace(fontePath, {selector: '#content h2,#contentG h2',css: '.sIFR-root {color: #B85C02; font-style:italic}',wmode: 'transparent'});
		sIFR.replace(fontePath, {selector: 'h3.titReplaceSifr',css: '.sIFR-root {color: #a99e80}',wmode: 'transparent'});
	}
}

function initMenu(){
	$(".pergunta li > a").click(function(){
		var thisAux = this;
		$(this).parent().find("> div, > ul").slideToggle(200,function(){
			if($(this).css("display")=="block"){
				dataMetrics({pageName:"Fale Conosco - Visualizou Duvida "+$(thisAux).attr("title")});
			}
		});
		
		return false;
	});
	$(".jsMenuColapse > li > a[href=#]").click(function(){
		if(!$(this).parent().hasClass("open")){
			$(this).parents("ul.jsMenuColapse").find("li.open ul,li.open > div").slideToggle(300,function(){
				$(this).parent().toggleClass("open");
			});
		}
		$(this).parent().find(" > ul, > div").slideToggle(300,function(){
			$(this).parent().toggleClass("open");
		});
		return false;
	});

	var currentItem = $(".jsMenuColapse ul a:[href="+ window.location.pathname +"]");
	
	if(currentItem.size() == 0 && window.location.pathname.indexOf("_")>-1) {
		currentItem = $(".jsMenuColapse ul a:[href^="+ window.location.pathname.split("_")[0] +"]");
	}
	currentItem.addClass("ativo").parents("li:last").addClass("open").children().show();
	
}

function initSize(){
	$(".controlSize .decrease").click(function(){
		var font = $("#content").css("fontSize");
		if(parseInt(font) !=9 )
			$("#content").css("fontSize", (parseInt(font)-1) +"px");

		return false;
	});
	
	$(".controlSize .increase").click(function(){
		var font = $("#content").css("fontSize");
		if(parseInt(font) !=17 )
			$("#content").css("fontSize", (parseInt(font)+1) +"px");
		
		return false;
	});
	
}


function GetActionTag(URL) {
	$('#action_tag').attr('src',"http://view.atdmt.com/action/" + URL);	
}

Rating = function(){
	this.elem;
	this.init = function(elem){
		this.elem = elem;
		var thisAux = this;
		
		$(elem).each(function(){
			$(this).data("rate", $(this).find("a").index($(this).find("a.ativo:last")))
			thisAux.moveTo($(this).data("rate"),this);
		});		
		
		$(elem).find("a").mouseover(function(){
			if(!$(this).parents(elem).hasClass("desabilitado"))
				thisAux.moveTo($(this).parents(elem).find("a").index(this),$(this).parents(elem));
		}).mouseout(function(){
			thisAux.moveTo($(this).parents(elem).data("rate"),$(this).parents(elem));			
		}).click(function(){
			thisAux.votar(this);
			return false;
		});
	}
	this.votar = function(a){
		var index = $(a).parents("ul").find("a").index(a)+1;
		if (!$(a).parents(this.elem).hasClass("desabilitado")) {
			$(a).parents(this.elem).addClass("desabilitado");
			$(a).mouseout();
			Utils.executeAjax({type: "get",url: $(a).attr("href")});
			
			var nameReceita = $(a).attr("href").split("/")[2].split("_")[1].replace(/\+/g," ");
			dataMetrics({prop6:index,pageName:"Receita - "+nameReceita+" - Nota "+index,channel:"Receitas",events:"event22"});
			pageTracker._trackPageview("/receitas/["+ nameReceita +"]/votar/["+ index +"]");
		}
	}
	this.moveTo = function(rate, parent){
		$(parent).find("a").removeClass("ativo");
		$(parent).find("a").each(function(index,value){
			if(rate==index-1) return false;
			$(this).addClass("ativo");
		});
	}
}

function initRating(){
	rating = new Rating();
	rating.init(".lstVotacao");
}

function initEmail(){
	$("#btEmail").click(function(){
		modal = new Modal();
		modal.init({height:220,width:500, ajax:{type:"get",url:"/email.jsp", call: "responseEmail"}});
		pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/enviar_email/?id="+(_userSadia.id!=""?_userSadia.id:0));
		
		return false;
	});
}

function responseEmail(){
	$("#frmEmail").validate({
		errorLabelContainer: $("ul.error"),
		wrapper: 'li',
		submitHandler: function(form){
			Utils.executeAjax({type:"post", url:$(form).attr("action"), data:$(form).serialize()},modal);
			
			dataMetrics({pageName:getPageName()+" - Enviar por email",events:getEvents()});
			pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/email_sucesso/?id="+(_userSadia.id!=""?_userSadia.id:0));
		},
		rules: {
			nome_remetente: 'required',
			email_remetente: {
				required: true,
				email: true
			},
			nome_amigo:'required',
			email_amigo: {
				required: true,
				email: true
			}
		},
		messages: {
			nome_remetente: 'Preencha o campo nome',
			email_remetente: {
				required: 'Preencha o campo email',
				email: 'Endereço do campo email inválido'
			},
			nome_amigo: 'Preencha o campo nome do amigo',
			email_amigo: {
				required: 'Preencha o campo email do amigo',
				email: 'Endereço do email do amigo inválido'
			}
		}
	});
	
	if($("#page_link") != null)
		$("#sendLink").val($("#page_link").val());
	
	if($("#current_name") != null)
		$("#itemName").val($("#current_name").val());
	
	if($("#current_image") != null)
		$("#imageLink").val($("#current_image").val());
}

Galery2 = function(galCont){
	this.index;
	this.galCont = galCont;
	this.galRec;
	this.paginacao = $(galCont).find(".lstPaginacao a,.jsPagGaleria a");
	this.width = $(galCont).find("img:visible").get(0).offsetWidth;
	this.height = $(galCont).find("img:visible").get(0).offsetHeight;
	this.player;
	this.total = $(this.paginacao).size();
	
	this.init = function(){
		_thisGalery = this;
		this.buildPlayerGalery();
		this.index = 1;
	
		$(this.paginacao).click(function(){
			_thisGalery.index = $(this).parent().parent().find("a").index(this);
			_thisGalery.galRec = $($(".jsGaleriaAux:eq("+ _thisGalery.index +")"));
			
			_thisGalery.player.reset();
			$(_thisGalery.galCon).find(".jsGaleriaAux").children().not($(_thisGalery.galCon).find(".jsGaleriaAux h2")).hide();
			$(_thisGalery.galRec).children().show();
			
			$(this).parents("ul").find("li").removeClass("ativo");
			$(this).parents("li").addClass("ativo");
			
			var left = -$(_thisGalery.galRec).position().left;
			$(".jsGaleriaContainerGrAux").css({left: left});
			
			dataMetrics({prop16:"Home_destaque"+(_thisGalery.index+1)});
			pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/media/["+ (_thisGalery.index+1) +"]");

			return false;
		});
	}
	this.buildPlayerGalery = function(){
		var thisAux = this;
		this.player = new PlayerVideo({width:this.width,height:this.height});
		$(this.galCont).find(".linkVideo").click(function(){
			thisAux.player.buildPlayer($(this).parents(".galeriaPlayerVideo"));
			thisAux.player.init(this,thisAux.index);
			return false;
		}).data("inicial",true);
	}
	this.next = function(){
		$(this.paginacao).eq(this.index).click();
		this.index = (this.total == this.index+1)?0:this.index+1;
	}
}

PlayerVideo = function(opt){
	this.index;
	this.elem;
	this.divVideo;
	this.a;
	this.playerId;
	this.width = opt.width;
	this.height = opt.height;
	
	this.buildPlayer = function(elem){
		this.elem = elem;
		duracao = $(elem).find("span");
		videoAtual = $(elem).find("a").get(0);
		this.playerId = ($(videoAtual).attr("href").indexOf("v=")==-1) ? $(videoAtual).attr("href").split("/")[4] : $(videoAtual).attr("href").split("v=")[1];
		this.divVideo = $('<div style="position:absolute" />').attr({id: "flashVideo"});
		this.divVideoWrap = $('<div style="position:absolute;top:0" />').attr({id: "flashVideoWrap"}).append(this.divVideo);
	}
	this.init = function(a,index){
		var thisAux = this;
		this.a = a;
		this.index = index;
		
		if($(a).data("inicial")){
			var load = Utils.loader({src:"/img/ajax-loader-player.gif"});
			$(load).insertAfter(this.elem);
			$(this.divVideoWrap).insertAfter(this.elem);
			$(videoAtual).data("inicial",false);
			$(videoAtual).addClass("pause");
			var params = {quality:"high",wmode:"transparent",allowscriptaccess:"always"};
		    var attributes = {id:"flashVideo"};
		    swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid="+this.playerId, "flashVideo", this.width, this.height, "8", "swf/expressInstall.swf", null, params, attributes);
		}else{
			if($(a).hasClass("pause")) this.pause();
			else this.play();
		}
		
		this.initControls();
	}
	this.initControls = function(){
		_thisPlayer = this;
		$(this.elem).parent().find("*").click(function(e){Utils.stopPropagEvent(e)});
		$(".galeriaComentario, .galeriaLegenda, .lstPaginacao, .galeriaPlayerVideo").unbind("mouseout").unbind("mouseover").mouseover(function(e){
			_thisPlayer.appearControls();
			Utils.stopPropagEvent(e);
		});
		
		$(".galeriaLegenda:visible, .galeriaPlayerVideo:visible").each(function(){
			$(this).data("top",this.offsetTop);
			$(this).data("height",this.offsetHeight);
		});
		$(this.elem).parent().unbind("mouseout").unbind("mouseover").mouseover(function(e){
			_thisPlayer.appearControls();
		}).mouseout(function(e){
			_thisPlayer.disappearControls();
		}).mousemove(function(e){
			if(typeof disappearControlsTimeout != 'undefined') clearTimeout(disappearControlsTimeout);
			_thisPlayer.appearControls();
			disappearControlsTimeout =  setTimeout("_thisPlayer.disappearControls()",3000);
		});
	}
	this.disappearControls = function(){
		$(".galeriaComentario").stop().animate({top:-29},250);
		$(".lstPaginacao").stop().animate({opacity:0});
		$(".galeriaLegenda:visible, .galeriaPlayerVideo:visible").each(function(){
			var top = $(this).data("top");
			var height = $(this).data("height");
			$(this).stop().css({overflow:"hidden"}).animate({top:top+height,height:0},250);
		});
	}
	this.appearControls = function(){
		$(".galeriaComentario").stop().animate({top:0},250);
		$(".lstPaginacao").stop().animate({opacity:1});
		$(".galeriaLegenda:visible, .galeriaPlayerVideo:visible").each(function(){
			var top = $(this).data("top");
			var height = $(this).data("height");
			$(this).stop().css({overflow:"hidden"}).animate({top:top,height:height},250);
		});
	}
	this.play = function(){
		ytplayer.playVideo();
		$(this.a).addClass("pause");
	}
	this.pause = function(){
		ytplayer.pauseVideo();
		$(this.a).removeClass("pause");
		
		pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/pausa_video/["+ (this.index+1) +"]");
	}
	this.reset = function(){
		if (typeof duracao != 'undefined' && ytplayer != null) {
			var seg = Math.round(ytplayer.getCurrentTime());
			var segTotal = Math.round(ytplayer.getDuration());
			var porc = ((seg * 100) / segTotal).toFixed(2) + "%";
			var tit = $("h2 span span").text();
			
			pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/fim_video/["+ (galery.index+1) +"]");
			dataMetrics({pageName:"Receita - "+ tit +" - Video - Stop",prop27:"Portal - Video "+ tit,prop28:seg,prop29:porc});
		}
		
		$(videoAtual).data("inicial",true).removeClass("pause");
		if(typeof duracao != 'undefined') $(duracao).html("00:00");
		ytplayer = null;
		$("#flashVideoWrap").remove();
		
		if (typeof disappearControlsTimeout != 'undefined' && disappearControlsTimeout!='') {
			clearTimeout(disappearControlsTimeout);
			disappearControlsTimeout = '';
			this.appearControls();
		}
		$(this.elem).parent().unbind("mouseover").unbind("mouseout").unbind("mousemove");
		$(".galeriaComentario, .galeriaLegenda, .lstPaginacao, .galeriaPlayerVideo").unbind("mouseover").unbind("mouseout");
	}
}

function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("flashVideo");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
  ytplayer.addEventListener("onError", "onPlayerError");
  ytplayer.loadVideoById(playerId,0);
}

function onytplayerStateChange(newState) {
	switch(newState) {
		case 0:
			galery.player.reset();
		break;
		case 1:
			playerInterval = setInterval(timePlayer, 250);
			
			var tit = $("h2 span span").text();
			pageTracker._trackPageview("/"+ window.location.pathname.split("/")[1] +"/["+ document.title +"]/play_video/["+ (galery.index+1) +"]");
			dataMetrics({pageName:"Receita - "+ tit +" - Video - Play",prop27:"Portal - Video "+ tit,events:"event19"});
		break;
		case 3:
			$("._loader").remove();
		break;
	}
}
function timePlayer(){
	if (ytplayer) {
		var seg = ytplayer.getCurrentTime();
		var seg2 = (new String(Math.round(seg % 60)).length == 1) ? "0" + Math.round(seg % 60) : Math.round(seg % 60);
		var min = parseInt(seg / 60) + ":" + seg2;
		
		var totalSeg = ytplayer.getDuration();
		$(duracao).html(min);
	}else{
		clearInterval(playerInterval);
	}
}
function onPlayerError(errorCode) {
	var msgError = "";
	if(errorCode == 150){
		msgError = "Vídeo não pode ser incorporado.";
	}
  	alert("Um erro ocorreu: "+ msgError);
}

function initGalery(){
	
	videoAtual = null;
	playerInterval = null;
	
	if ($(".jsGaleriaContainerGr").size() != 0) {
		galery = new Galery2($(".jsGaleriaContainerGr"));
		if($("#navB").size()!=0) galery.paginacao = $("#navB div a");
		galery.init();
	}
}

function initEnquete(){
	if($("#jsLinkEnquete").size() > 0){
		comentEnquete = new Comentario();
		comentEnquete.init("#jsLinkEnquete");
		comentEnquete.setReset = function(){
			if($(this.id).data("voto") || getCookie("sadiaCookieEnquete") == "yes"){
				$($('<p>Obrigado por participar!</p><p>Faltou dizer algo? Utilize nosso <a href="/fale-conosco/" title="fale conosco">fale conosco</a> e envie sua mensagem.</p>')).insertBefore("#frmEnquete1");
				$("#frmEnquete1,#frmEnquete2").remove();
			}
			$("#frmEnquete1").show();
			$("#frmEnquete2,#frmEnquete2 div").hide();
			$("#boxEnquete span").html("Passo 1 de 2");
			
			pageTracker._trackPageview("/rodape_pesq_gostousite/");
		}
		$("body").click(function(){
			comentEnquete.close();
		});
	}
	
	$("#frmEnquete1").submit(function(){
		if($(this).find("input:checked").size()==0){
			alert("Escolha uma das opções");
			return false;
		}
		
		$("#boxEnquete span").html("Passo 2 de 2");
		$(this).hide();
		$("#frmEnquete2").show();
		$("#frmEnquete2 div:eq("+ (parseInt($(this).find("input:checked").val())-1) +")").show();
		comentEnquete.execPosition();
		
		if ($(this).find("input:checked").val() == 1) {
			pageTracker._trackPageview("/rodape_pesq_gostousite_sim/");
			dataMetrics({pageName:"O que achou do novo site - Adorei ",channel:"Institucional"});
		}
		else {
			pageTracker._trackPageview("/rodape_pesq_gostousite_nao/");
			dataMetrics({pageName:"O que achou do novo site - Gostava do outro",channel:"Institucional"});
		}
		return false;
	});
	
	$("#frmEnquete2").submit(function(){
		if($("#frmEnquete2 input:checked").size()==0){
			alert("Escolha uma das opções");
			return false;
		}
		Utils.executeAjax({type:$(this).attr("method"), url:$(this).attr("action"), data:$(this).serialize(),call:"enqueteResponse"});
		divLoadEnq = $("<div />").css({height:"60px",position:"relative"}).addClass("loadComentario");
		var load = Utils.loader({src:"/img/ajax-loader-laranja.gif"});
		
		$(this).parent().append(divLoadEnq);
		$(divLoadEnq).append(load);
		
		$(this).hide();
		comentEnquete.execPosition();
		
		return false;
	});
}
function enqueteResponse(response){
	$(divLoadEnq).html(response);
	$(comentEnquete.id).data("voto",true);
	comentEnquete.execPosition();
	setTimeout('comentEnquete.close()', 2000);
	
	pageTracker._trackPageview("/rodape_pesq_gostousite_obrigado/");
}
function getCookie(cookieName) {
	if (document.cookie.length>0) {
		var c_start=document.cookie.indexOf(cookieName + "=");
		if (c_start!=-1) {
			c_start=c_start + cookieName.length+1;
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
		    return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

/*
 *	@author			Rafael Lazarini <joao.lazarini@agenciaclick.com.br>
 *	@description	Pega a maior altura e adiciona ela como principal..
 */
function getHeightReceita(){
	var maxHeight = 0;
	var thisHeight = 0;
	$(".lstIngredientes li").each(function(i){
		thisHeight = $(this).height();
		if(thisHeight > maxHeight) maxHeight = thisHeight;
	});
	$(".lstIngredientes li").css("height" , (maxHeight+10));
}

/*
 *	@author			Clauber Stipkovic <clauber.halic@agenciaclick.com.br>
 *	@description	Abre o link em uma nova janela.
 */
function openBlank(){
	$("a.openBlank").click(function(){
		window.open($(this).attr("href"));
		return false;
	});
}

function CopyLink(text) {
	var browser = navigator.appName;
	$('#'+text).focus();
	$('#'+text).select();
	copy = document.getElementById(text);
	if(browser == "Microsoft Internet Explorer") {
		Copied = copy.createTextRange();
		Copied.execCommand("Copy");
	} else {
		texto = copy.value;
		while(texto.indexOf('+')!=-1) texto = texto.replace('+','_');
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) {
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="/swf/_clipboard.swf" FlashVars="clipboard='+ texto +'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
}

$(function(){
	
	$("p.bts a[rel='prev']").click(function(){
		var left = $(this).parent().parent().find('div.jsGaleriaPostMaskAux').css('left');
		var position = parseInt(left,10)/186;
		var index = position * (-1);
		
		if(index>0) { index = index-1; }
		
		var id = $(this).parent().parent().find('div.itemGaleriaCardapio:eq('+index+')').children("input[name='recipeId']").val();
		
		$(this).parent().parent().find("input[name='SelectedRecipes']").val(id);
	});
	
	$("p.bts a[rel='next']").click(function(){
		var left = $(this).parent().parent().find('div.jsGaleriaPostMaskAux').css('left');
		var position = parseInt(left,10)/186;
		var index = position * (-1);
		var total= ($(this).parent().parent().find('div.itemGaleriaCardapio').length-1);
		
		if(index == total) {
			index = index;
		} else {
			index = index+1;
		}
		
		var id = $(this).parent().parent().find('div.itemGaleriaCardapio:eq('+index+')').children("input[name='recipeId']").val();
		
		$(this).parent().parent().find("input[name='SelectedRecipes']").val(id);
	});
	
})