// funcao mostra-esconde //

function MostraEsconde(idMostra, idEsconde){
	if (idMostra) {
		try{
			document.getElementById("tab_"+idMostra).className = idMostra + "Over";
		}catch(e){};
		var a = idMostra.split(/\W/);
		for (var i in a) {
			var e = document.all && document.all[a[i]] || document.getElementById && document.getElementById(a[i]);
			if (e)
				e.style.display = '';
		}
	}
	if (idEsconde) {
		var a = idEsconde.split(/\W/);
		for (var i in a) {
			var e = document.all && document.all[a[i]] || document.getElementById && document.getElementById(a[i]);
			if (e){
				e.style.display = 'none';
				try{
					document.getElementById("tab_" + a[i]).className = a[i];
				}catch(i){};
			}
		}
	}
}
//-->

function compartilhe(id){
	retorno = true;
	$('#lbStrNome'+id).css('color','#000');
	$('#lbStrEmail'+id).css('color','#000');
	$('#lbStrNomeAmigo'+id).css('color','#000');
	$('#lbStrEmailAmigo'+id).css('color','#000');
	$('#msgCompartilhe'+id).html("");  
	if($('#strNome'+id).val()==''){
		$('#strNome'+id).focus();
		$('#lbStrNome'+id).css('color','#f00');
		$('#msgCompartilhe'+id).html("O preenchimento de todos os campos &eacute; obrigat&oacute;rio");  
		retorno = false;
	}
	if($('#strEmail'+id).val()==''){
		$('#lbStrEmail'+id).css('color','#f00');
		if(retorno){
			$('#strEmail'+id).focus();
			$('#msgCompartilhe'+id).html("O preenchimento de todos os campos &eacute; obrigat&oacute;rio");  
			retorno = false;
		}
	}	
	if($('#strNomeAmigo'+id).val()==''){
		$('#lbStrNomeAmigo'+id).css('color','#f00');
		if(retorno){
			$('#strNomeAmigo'+id).focus();
			$('#msgCompartilhe'+id).html("O preenchimento de todos os campos &eacute; obrigat&oacute;rio");  
			retorno = false;
		}
	}	
	if($('#strEmailAmigo'+id).val()==''){
		$('#lbStrEmailAmigo'+id).css('color','#f00');
		if(retorno){
			$('#strEmailAmigo'+id).focus();
			$('#msgCompartilhe'+id).html("O preenchimento de todos os campos &eacute; obrigat&oacute;rio");  
			retorno = false;
		}
	}				
	if(retorno){
		var params = $("#form-compartilhe"+id).serialize();
		$.ajax({
			type: 'POST',
			url: 'ajaxEnviaAmigo.php',
			data: params,
			success: function(txt){
				$('#strNome'+id).val('');
				$('#strEmail'+id).val('');
				$('#strNomeAmigo'+id).val('');
				$('#strEmailAmigo'+id).val('');
				$('#msgCompartilhe'+id).css('color','#00600D');
				$('#msgCompartilhe'+id).html("E-mail enviado com sucesso!");  
			},
			error: function(txt){
				$('#msgCompartilhe'+id).html("Houve um erro ao cadastrar, tente novamente.");				
			}
		});				
	}
	return false;
}

$(document).ready(function() {
	$(".prod-menu").hover(
		function () {
			$('.submenu-prods').fadeIn();
			$('.submenu-prods').stop(1,1).animate({'margin-top': '-36px'}, 500);
		},
		function () {
			$('.submenu-prods').css({'margin-top': '-100px'});
			$('.submenu-prods').hide();
	});
			
	$(".receitas-menu").hover(
		function () {
			$('.submenu-receitas').fadeIn();
			$('.submenu-receitas').stop(1,1).animate({'margin-top': '-36px'}, 350);
		},
		function () {
			$('.submenu-receitas').css({'margin-top': '-100px'});
			$('.submenu-receitas').hide();
	});

});

