var contaClique = function(cod_videos) {
	$.post("_inc/contar.inc.php",{cod_videos:cod_videos},function(){
		var foo = '';
	});		
	return false;
}; // fim contaClique

$(function(){

	$('.lnk-hs').click(function(){
		var cod_videos = $(this).attr('rel');
		contaClique(cod_videos);
	});
	
	// Enviar a um amigo
	$('#send_friend').hide();
	$('#bt_friend').click(function(){
		$('#send_friend').show();
		//return hs.htmlExpand(this, { contentId: 'enviar_amigo' } );
	});
	$('#close_fri').click(function(){
		$('#send_friend').hide();
	});	
	// Tabs
	/*$("#gn-foto").addClass("active");*/
	
	//$(".gals").hide();
	
	$(".borda a").click(function(){
		$(".borda a").removeClass("bt3_ativo");
		$(this).addClass("bt3_ativo");
		var href = $(this).attr("href");		
		var target = href.slice(5);
		$("#gal-foto, #gal-video").hide();
		$("#gal-"+target).show();
		return false;
		
	});
	$("#gal-video").hide();
	
	
	$("#nav2 a").click(function(){
		$("#nav2 a").removeClass("bt3_ativo");
		$(this).addClass("bt3_ativo");
		var href = $(this).attr("href");		
		var target = href.slice(5);
		$("#gal-txt, #gal-table").hide();
		$("#gal-"+target).show();
		return false;
		
	});
	$("#gal-table").hide();	
	
});


// valida e-mail
var validaEmail = function(s) {
	var regexpEmail = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
	return regexpEmail.test(s);
}; // fim validaEmail

$(document).ready(function(){
	$('#enviar_url').click(function(){
		erro = "";
		
		var nome 		= $('#seunome').val();
		var email		= $('#seuemail').val();
		var nome_amigo	= $('#nomeamigo').val();
		var email_amigo	= $('#emailamigo').val();
		
		var tipo_amigo	= $('#tipo_amigo').val();
		var cod_amigo	= $('#cod_amigo').val();
		
		if(!nome) {
			erro += "- Informe seu nome.\n";
		}
		if (!email) {
			erro += "- Informe seu e-mail.\n";
		} else if (!validaEmail(email)) {
			erro += "- Seu e-mail é inválido.\n";
		}
		if(!nome_amigo) {
			erro += "- Informe o nome do amigo.\n";
		}
		if (!email_amigo) {
			erro += "- Informe o e-mail do amigo.\n";
		} else if (!validaEmail(email_amigo)) {
			erro += "- O e-mail do amigo é inválido.\n";
		}	
		if (erro){
			alert(erro);
		} else {
			$.post("_inc/recomendar.inc.php",{nome:nome,email:email,nome_amigo:nome_amigo,email_amigo:email_amigo,tipo:tipo_amigo,codigo:cod_amigo},function(){
				$("#form_amigo").html("<p>Recomenda&ccedil;&atilde;o enviada com sucesso!</p>");
				setTimeout("$('.highslide-wrapper').parent().fadeOut();", 4000);
			});	
		}
		return false;
	});
	
	$('#area_video').flash({
	    src: '_swf/video.swf',
	    width: 320,
	    height: 285
	});
	
	
});
