$(document).ready(function(){

	$("#bandeira-pt").click(function(){
		window.location = "cb/cookies-ml.php?tp=pt";
	});
	
	$("#bandeira-es").click(function(){
		window.location = "cb/cookies-ml.php?tp=es";
	});
	
	$("#bandeira-en").click(function(){
		window.location = "cb/cookies-ml.php?tp=en";
	});
	
	
	
	if($("a[rel^='prettyPhoto']").length > 0)

		$("a[rel^='prettyPhoto']").prettyPhoto({theme:'light_rounded'});

		

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

	

	$('#tabs li a').featureList({

		output		: '#output li',

		start_item	: 0

	});



	swapValue = [];

	$("form > .input").each(function(i){

		swapValue[i] = $(this).val();

		$(this).focus(function(){

			if ($(this).val() == swapValue[i]) {

				$(this).val("");

			}

		}).blur(function(){

			if ($.trim($(this).val()) == "") {

				$(this).val(swapValue[i]);

			}

		});

	});



	if((typeof iniciaOutros) == 'function'){

		iniciaOutros();

	}

	

	$('#banner').flash({

			swf: 'include/swf/banner_3.swf',

			width:675,

			height:365,

			params:{

			play:true,

			allowscriptaccess:'always',

			wmode:'transparent'

			}

		});



	

	//NewsLetters

	$("#btnnews").click(function(){

		var nome = $.trim($("#txtnomen").val());

		var mail = $.trim($("#txtemailn").val());

		

		if((nome=="") || (mail==""))

		{

			

		}

		else

		{

			$("#btnnews").val("Enviando...");

			$("#btnnews").attr('disabled', true);						

			

			$.post('cb/newsletters.php',{ nome:nome,mail:mail }, function(data){

				$("#txtnomen").attr("value","");

				$("#txtemailn").attr("value","");				

				$("#btnnews").val("Cadastrar");

				$("#btnnews").attr('disabled', false);	

				

				if(data==1)

				{

					$("#mensagensPage").html("Dados enviados com sucesso");

					$("#mensagensPage").toggle("slow");

					window.setTimeout("removerDivMsg()", 6000);

				}

				else if(data==2)

				{

					$("#mensagensPage").html("Problemas ao cadastrar e-mail");

					$("#mensagensPage").toggle("slow");

					window.setTimeout("removerDivMsg()", 6000);

				}

				else if(data==3)

				{

					$("#mensagensPage").html("E-mail ja esta cadastrado");

					$("#mensagensPage").toggle("slow");

					window.setTimeout("removerDivMsg()", 6000);

				}

				else if(data==4)

				{

					$("#mensagensPage").html("Todos os campos devem ser preenchidos");

					$("#mensagensPage").toggle("slow");

					window.setTimeout("removerDivMsg()", 6000);

				}

			});

		}

	});

	

	//Enquete 

	$("#btnEnquete").click(function(){		

		var idE   = $("#idEnquete").val();

		var voto  = "";

		$('#fenquete input:radio').each(function() {

    		if($(this).is(':checked')){

        		voto = $(this).val();

    		}

		});

		

		if(voto == "")

		{

			alert("Selecione uma opcao.");

		}

		else

		{

			$("#btnEnquete").val("Enviando...");

			$.post("cb/enquete.php",{codigo:idE,resposta:voto},function(data){				

				$("#fenquete").html(data);

			});

		}

	});

	

	$("#fenquete a").click(function(){

		

		var idE = $("#idEnquete").val();

		$.post("cb/enquete.php",{visualizar:"1",codigo:idE},function(data){				

				$("#fenquete").html(data);

			});

	});





	$('#gallery a').lightBox();

});



function removerDivMsg()

{

	$("#mensagensPage").html("");

	$("#mensagensPage").toggle("slow");

} 


