//apagar e acender a luz

$(document).ready( function(){
            $("#shadow").css("height", $(document).height()).hide();
			var fn = function(){
				$("#shadow").toggle();
                if ($("#shadow").is(":hidden"))
                	$("#btApagar").removeClass("btnacende");
                 else
                	$("#btApagar").addClass("btnacende");	
            }
            $("#btApagar").click(fn);
            $("#shadow").click(fn);
        });

//abrir palanque


$(document).ready(function() {
$("#comente_palanque, #comentepalanqueinterna").hide();
$('.btnEnvieOpniao').click(function() {
$(this).next().slideToggle('fast');
});
});

$(document).ready(function() {
	$('.young-form').hide();
	$('.btnyoung').click(function() {
	$(this).next().slideToggle('fast');
	});
	});


$(document).ready(function() {
	$('.box667 > .comentepalanqueindex').hide(); 
	$('.box667 > .btnEnvieOpniao1').click(function() {
		$('.box667 > .comentepalanqueindex:visible').hide("fast"); 
		$(this).next('.comentepalanqueindex:hidden').show("fast");
	});
});

$(document).ready(function() {
	if($.browser.msie && ($.browser.version < 7)){ $("body").addClass("ie"); }
	 $("#tvFlash").flash({ src: '../swf/tvflash.swf', width: 980, height:
		 316, wmode: 'transparent', flashvars: {
		                xmlPath: ['../swf/xml/tvflash.xml'].join(' ')
		        }}, { version: 8 });
 	$("#box303x221").flash({ src: '../swf/banner_proxxima_22.swf', width: 258, height: 198, wmode: 'transparent' }, { version: 8 });
//	$("#banner300x250").flash({ src: '../swf/300x250.swf', width: 300, height: 250, wmode: 'opaque' }, { version: 8 });
//	$("#boxSuperBanner").flash({ src: '../swf/728x90.swf', width: 728, height: 90, wmode: 'opaque' }, { version: 8 });
 	$(".flashRa580x416").flash({ src: '/portal/proxxima//swf/ra.swf', width: 580, height: 416, wmode: 'opaque' }, { version: 8 });
	$("#twitter").getTwitter({
		userName: "proxxima",
		numTweets: 2,
		loaderText: "Loading tweets...",
		slideIn: true,
		showHeading: false,
		showProfileLink: true
	});

	$("textarea.maxlength").maxlength({
	    'feedback' : '.charsLeft span'
	});

	$("input[type=file]").filestyle({
	    image: "../img/choose-file.gif",
	    imageheight :  20,
	    imagewidth : 73,
	    width : 330
	});

	$("ul.mainMenu").superfish({pathClass: 'current'}); 

	$(".result span").each(function() {
		$width = $(this).html();
		$(this).css("width",$width + "%").append('<strong>'+ $width +'%</strong>');
	});

	$("ul#fotosMaking li a").click(function(){
		$img = $(this).attr("href");
		$txt = $(this).find("img").attr("alt");
		$(".makingFull img").attr('src', $img).hide().fadeIn();
		$(".makingFull p").html($txt);
		return false;
	});

	//////////////////////////////////////////////////
	$(".box303x211 a.btnVote").click(function(){
		$.ajax({
			type: 'GET',
			data: 'idProxximaEnqueteItem='+$('input[name=palanque]:checked').val()+'&idProxximaEnquete='+$('input[name=idProxximaEnquete]').val(),
			dataType: "json",
			url: '/portal/proxxima/proxxima!votarPalanqueDigital.xxi',
			success: function(json) {
				if (json.msg == "ok") {
					var prct = json.porcentagens.split(';');
					for(i = 0 ; i < prct.length ; i++){
						$('#porcentagem_'+json.origemId+'_'+i+' strong').html(prct[i] + '%');
					}
					$('#enquete_total_'+json.origemId).html(json.total);
					$(".box303x211 .question").hide();
					$(".box303x211 .result").show();
				}else{
					alert(json.msg);
				}
			}
		});		
		return false;
	});

	$(".btnRecomende20x20").click(function(){
		$.ajax({
			type: 'GET',
			data: 'url='+location.href,
			dataType: "json",
			url: '/portal/proxxima/proxxima!processRecomende.xxi',
			success: function(json) {
				if (json.msg == "ok") {
					alert('Recomendação realizada com sucesso.');
				}else{
					alert(json.msg);
				}
			}
		});
		return false;
	});
	
	$(".box303x211 a.btnResultados").click(function(){
		$(".box303x211 .question").hide();
		$(".box303x211 .result").show();
		return false;
	});
	
	$(".box303x211 a.btnVoltar").click(function() {
		$(".box303x211 .question").show();
		$(".box303x211 .result").hide();
		return false;
	});
	
	$("a.btnLogin").click(function(){
		$("li.form").show();
		return false;
	});
	
	$(".boxRedesSociais ul li a").hover(function(){
		$txt = $(this).html();
		$(this).parent().append('<span class="tooltip">'+ $txt +'</span>').end().parent().find("span").hide().fadeIn();
	}, function(){
		$(".boxRedesSociais ul li").find("span.tooltip").hide().remove();
	});

	$(".contentDetalheNews ul.listPortfolio li .analise label").hover(function(){
		$txt = $(this).attr("rel");
		$(this).parent().append('<span class="tooltipAnalise">'+ $txt +'</span>').end().parent().find("span").hide().fadeIn();
	}, function(){
		$(".contentDetalheNews ul.listPortfolio li .analise").find("span.tooltipAnalise").remove();
	});

	$(".content913 ul.listPortfolio li .analise label").hover(function(){
		$txt = $(this).attr("rel");
		$(this).parent().append('<span class="tooltipAnaliseTop">'+ $txt +'</span>').end().parent().find("span").hide().fadeIn();
	}, function(){
		$(".content913 ul.listPortfolio li .analise").find("span.tooltipAnaliseTop").remove();
	});

	$(".box190 ul li a img").hover(function(){
		$txt = $(this).attr("alt");
		$(this).parent().append('<span class="tooltipRevista">'+ $txt +'</span>').end().parent().find("span").hide().fadeIn();
	}, function(){
		$(".box190 ul li a").find("span.tooltipRevista").remove();
	});

 	$(".archives ul li h5").click(function(){
		$(".archives ul li h5").removeClass("hover");
		$(".archives ul li table").hide();
		if($(this).next().is(":visible")){
			$(this).removeClass("hover").next().hide();
		}else{
			$(this).addClass("hover").next().show();
		}
		return false;
	});
	$(".archives ul li h5.hover").trigger("click");

 	$("ul.convidadosBlog li a").click(function(){
		$("ul.convidadosBlog li a").removeClass("hover");
		$("ul.convidadosBlog li div").hide();
		if($(this).next().is(":visible")){
			$(this).removeClass("hover").next().slideUp();
		}else{
			$(this).addClass("hover").next().slideDown();
		}
		return false;
	});
	$("ul.convidadosBlog li a.hover").trigger("click");

	$("ul.convidadosBlog li a.link").click(function(){
		$link = $(this).attr("href");
		window.location = $link
		return false;
	});
	$("ul.convidadosBlog li a.linkblank").click(function(){
		$link = $(this).attr("href");
		window.open($link);
		return false;
	});

	$("ul.indique li a").click(function(){
		$valor = $(this).attr("href").split("#")[1];
		if($valor != ''){
			$(".boxComentario, .boxEnvie").hide();
			$("ul.indique li a").removeClass("hover");
			if($(this).hasClass("hover")){
				$(this).removeClass("hover");
				$(this).parent().parent().parent().find("." + $valor).slideUp();
			}else{
				$(this).addClass("hover");
				$(this).parent().parent().parent().find("." + $valor).slideDown();
			}
		}
		return false;
	});
	$("ul.boxmaismenu li a").click(function(){
		$valor = $(this).attr("href").split("#")[1];
		if($valor != ''){
			$(".maisRecentes, .maisVistos, .maisComentados, .maisRecomendados").hide();
			$("ul.boxmaismenu li a").removeClass("hover");
			if($(this).hasClass("hover")){
				$(this).removeClass("hover");
				$(this).parent().parent().parent().find("." + $valor).hide();
			}else{
				$(this).addClass("hover");
				$(this).parent().parent().parent().find("." + $valor).show();
			}
		}
		return false;
	});
	
	$("ul.boxmaisaudio li a").click(function(){
		$valor = $(this).attr("href").split("#")[1];
		if($valor != ''){
			$(".Box-Podcast, .Box-Audios").hide();
			$("ul.boxmaisaudio li a").removeClass("hover");
			if($(this).hasClass("hover")){
				$(this).removeClass("hover");
				$(this).parent().parent().parent().find("." + $valor).hide();
			}else{
				$(this).addClass("hover");
				$(this).parent().parent().parent().find("." + $valor).show();
			}
		}
		return false;
	});

	$("a.btnComente125x23").click(function(){
		$("ul.indique li a[href='#boxComentario']").trigger("click");
		return false;
	});

	$("a.btnEnvie75x23").click(function(){
		$("ul.indique li a[href='#boxEnvie']").trigger("click");
		return false;
	});

	$("input[name='trabalho'] + label, input[name='trabalho']").click(function(){
		$(this).prev().attr("checked", true);
		$val = $(this).parent().find("input:checked").val();
		$(".contentRadio .site, .contentRadio .banner, .contentRadio .video").hide();
		$(".contentRadio ." + $val).show();
	});

	
	$(".formFaleConosco").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorComments"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $(".formFaleConosco").serialize(),
					dataType: "json",
					url: '/portal/proxxima/proxxima!faleConoscoEnvie.xxi',
					success: function(json) {
						if (json.msg == "ok") {							
							$("#nome").val('');
							$("#assunto").selectedIndex=0;
							$("#seuemail").val('');
							$("#mensagem").val('');
							$(".msgError").hide();
							$(".sucessComments").fadeIn();
						}else{							
							$(".msgError").html(json.msg);
							$(".msgError").fadeIn;
						}
					}
				});
			}
		});
	});
	

	$(".formDadosEmpresa").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorComments"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $(".formDadosEmpresa").serialize(),
					dataType: "json",
					url: '/portal/proxxima/proxxima!dadosEmpresaEnvie.xxi',
					success: function(json) {
						if (json.msg == "ok") {							
							document.location = '../pagamento/';
						}else{							
							$(".msgError").html(json.msg);
							$(".msgError").fadeIn;
						}
					}
				});
			}
		});
	});
	
	$(".formPagamento").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorComments"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $(".formPagamento").serialize(),
					dataType: "json",
					url: '/portal/proxxima/proxxima!finalizaInscricao.xxi',
					success: function(json) {
						if (json.msg == "ok") {																
							
							var cartaoBoleto = document.getElementById("cartaoBoleto");
							var cartaoMastercard = document.getElementById("cartaoMastercard");
							var cartaoVisa = document.getElementById("cartaoVisa");
							var cartaoAmex = document.getElementById("cartaoAmex");
							var cartaoDiners = document.getElementById("cartaoDiners");
							var link = '';
							var aba = document.getElementById("aba");
							var abradi = document.getElementById("abradi");
							var mma = document.getElementById("mma");
							
							if (cartaoBoleto != null && cartaoBoleto.checked == true) {
								json.num_order = json.num_order.split('|')[0];
							} else {
								json.num_order = json.num_order.split('|')[1];
							}
							
							if (cartaoBoleto != null && cartaoBoleto.checked == true) {
								link = 'https://comprasegura.meioemensagem.com.br/proxxima2010/ficha/pagamento_boleto.php?n=' + json.num_order;
							} else if (cartaoMastercard != null && cartaoMastercard.checked == true) {
								link = 'https://comprasegura.meioemensagem.com.br/proxxima2010/ficha/pagamento_cartao_mc.php?id=' + json.num_order;
							} else if (cartaoVisa != null && cartaoVisa.checked == true) {
								link = 'https://comprasegura.meioemensagem.com.br/proxxima2010/ficha/pagamento_cartao_visa.php?id=' + json.num_order;
							} else if (cartaoAmex != null && cartaoAmex.checked == true) {
								link = 'https://comprasegura.meioemensagem.com.br/proxxima2010/ficha/pagamento_cartao_amex.php?id=' + json.num_order;
							} else if (cartaoDiners != null && cartaoDiners.checked == true) {
								link = 'https://comprasegura.meioemensagem.com.br/proxxima2010/ficha/pagamento_cartao_mc.php?bd=d&id=' + json.num_order;
							}
							
							if (link != '') {
								$("#btnConfirmaCadastro").hide();
								window.open(link, 'pagamento', 'scrollbars=yes');
															
								if(mma != null && mma.checked){
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso.'  
											+'<a href=\"' + link + '\" style=\"color: white;\" target=\"_blank\">Clique aqui</a> para finalizar a inscrição.</p>'
											+'<p>Validaremos sua associa&ccedil;&atilde;o junto &agrave; institui&ccedil;&atilde;o MMA</p>');
								}
								else if(abradi != null && abradi.checked){
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso.'  
											+'<a href=\"' + link + '\" style=\"color: white;\" target=\"_blank\">Clique aqui</a> para finalizar a inscrição.</p>'
											+'<p>Validaremos sua associa&ccedil;&atilde;o junto &agrave; institui&ccedil;&atilde;o ABRADI</p>');
								}
								else if(aba != null && aba.checked){
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso.'  
											+'<a href=\"' + link + '\" style=\"color: white;\" target=\"_blank\">Clique aqui</a> para finalizar a inscrição.</p>'
											+'<p>Validaremos sua associa&ccedil;&atilde;o junto &agrave; institui&ccedil;&atilde;o ABA</p>');
								}
								else{
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso.'  
											+'<a href=\"' + link + '\" style=\"color: white;\" target=\"_blank\">Clique aqui</a> para finalizar a inscrição.</p>');
								}								
							} else {
								$("#btnConfirmaCadastro").hide();
								if (isCortesia) {
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso !</p><p>Você receber&aacute; um e-mail confirmando sua inscri&ccedil;&atilde;o.</p>');
								}else{
									$(".sucessComments").html('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1061637485/?label=FxknCKvOnQEQ7Zqd-gM&amp;guid=ON&amp;script=0"/>'
											+'<p>Dados enviados com sucesso !</p>');
								}
							}

							// Limpo os campos
							$(":checkbox").attr('checked', '');							
							$(":text").val('');							
							$(":radio").attr('checked', '');													
							$(".msgError").hide();
							$(".sucessComments").show();
							
							
						}else{
							$("#msgError").html(json.msg);
							$("#msgError").show();
						}
					}
				});
			}
		});
	});
	

	$("#formInscrevaYoung").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorComments"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $("#formInscrevaYoung").serialize(),
					dataType: "json",
					url: '/eventos/young!cadastroProxxima.mm',
					success: function(json) {
						if (json.msg == "ok") {	
							$("#enviaYoung").html('<p>Dados enviados com sucesso !</p>');
							$(":text").val('');	
						}else{
							$("#msgError").html(json.msg);
							$("#msgError").show();
						}
					}
				});
			}
		});
	});

	
	$(".formComentario").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorComments"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $(".formComentario").serialize(),
					dataType: "json",
					url: '/portal/proxxima/proxxima!processComentario.xxi',
					success: function(json) {
						if (json.msg == "ok") {
							$("#comentario_total_"+json.origemId).html(json.comentarioTotal);
							$("#nome").val('');
							$("#email").val('');
							$("#site").val('');
							$("#comentario").val('');
							$(".msgError").hide();
							$(".sucessComments").fadeIn();
							$(".sucessComments_palanque").fadeIn();
							$("#sucessComments_palanque_interna_"+json.origemId).fadeIn();
						}else{							
							$(".msgError").html(json.msg);
							$(".msgError").fadeIn;
						}
					}
				});
			}
		});
	});
	

	$(".formEnvie").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorEnvie"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $(".formEnvie").serialize(),
					dataType: "json",
					url: '/portal/proxxima/proxxima!processEnvie.xxi',
					success: function(json) {
						if (json.msg == "ok") {
							$(".contentEnvie").fadeOut();
							$(".sucessEnvie").fadeIn();
						}else{
							$(".msgError").html(json.msg);
							$(".msgError").fadeIn;
						}
					}
				});
			}
		});

	});
	
    $("#proxxima").validate({ errorContainer: $(".msgErrorEspaco"), errorLabelContainer: $(".msgError"),
        submitHandler: function() {
            $.ajax({
                type: 'POST',
				data: $("#proxxima").serialize(),
                dataType: "json",
                url: '/portal/proxxima/proxxima!logar.xxi',
                success: function(json) {
                    if (json.msg == "ok") {
						$("ul.nav li.form").hide();
						$("ul.nav li#login_nome span").html('Olá, ' + json.nome);
						$("ul.nav li#login_nome").show();
						$("ul.nav li#login_btn_logout").show();
						$("ul.nav li a.btnCadastreSe").hide();
						$("ul.nav li a.btnFaleConosco").hide();
						$("ul.nav li#login_btn_login").hide();		
						location.reload();
					}else{
						$(".msgErrorLogin").val(json.msg);
						$(".msgErrorLogin").show();
						$(".msgError").show();
					}
                }
            });
        }
    });
    
	$("#login_btn_logout a").click(function(){
        $.ajax({
            type: 'GET',
            url: '/portal/proxxima/proxxima!logout.xxi',
            success: function() {
				$("input[name=meuEmail]").val('');
				$("input[name=senha]").val('');
				$("ul.nav li.form").show();
				$("ul.nav li#login_nome").hide();
				$("ul.nav li#login_btn_logout").hide();
				$("ul.nav li a.btnCadastreSe").show();
				$("ul.nav li a.btnFaleConosco").show();
				$("ul.nav li#login_btn_login").show();
				$(".msgErrorLogin").hide();
            }
        });
	});

    $("#formEspaco").validate({ errorContainer: $(".msgErrorEspaco"), errorLabelContainer: $(".msgError"),
        submitHandler: function() {
            $.ajax({
                type: 'GET',
				data: $("#formEspaco").serialize(),
                dataType: "json",
                url: '/portal/proxxima/proxxima!enviarEspacoAberto.xxi',
                success: function(json) {
                    if (json.msg == "ok") {
						$(".contentEspaco").hide();
						$(".sucessEspaco").show();
					}else{
						$(".msgErrorLogin").val(json.msg);
						$(".msgError").show();
					}
                }
            });
        }
    });

	$("#cadastro").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorEmail"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $("#cadastro").serialize(),
					dataType: "json",
					 url: '/portal/proxxima/proxxima!cadastroCanais.xxi',
					success: function(json) {
						if (json.msg == "ok") {
							$(".contentCadastro").hide();
							$(".sucessCadastro").show();
						}else{
							$(".msgError").show;
						}

					}
				});
			}
		});
    });

	$("#alterarCadastro").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorAlterado"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $("#alterarCadastro").serialize(),
					dataType: "json",
					url: '/inc/processCadastroAlterar.html',
					success: function(json) {
						if (json.msg == "ok") {
							$(".contentAlterado").hide();
							$(".sucessAlterarCadastro").show();
						}else{
							$(".msgError").show;
						}
					}
				});
			}
		});
    });


	$("#cancelarCadastro").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorCancelado"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
				$.ajax({
					type: 'GET',
					data: $("#cancelarCadastro").serialize(),
					dataType: "json",
				    url: '/portal/proxxima/proxxima!enviarCancelaAssinatura.xxi',
					success: function(json) {
						if (json.msg == "ok") {
							$(".contentCancelar").hide();
							$(".sucessCancelar").show();
						}else{
							$(".msgError").show;
						}
					}
				});
			}
		});
    });

	$("#formEnviePor").each(function(){
		$(this).validate({ errorContainer: $(".msgErrorEnvieSeu"), errorLabelContainer: $(".msgError"),
			submitHandler: function() {
	        $("#formEnviePor").ajaxSubmit({
	    		success: function(responseText, statusText)  {
	        		var jsonMsg = eval('(' + responseText + ')');
	    			if (jsonMsg.msg == 'ok') {
						$(".contentEnvieSeu").hide();
						$(".sucessEnvieSeu").show();
					}else{
						$(".msgError").html(jsonMsg.msg);
						$(".msgError").show();
					}
	    		}
	        }); 
	        return false; 
			}
	    });
    });		

    $(".btnAddFuncao").live("click", function() {
        $clone = $(".itensClone .itemAdd:last").clone();
        $number = $(".itensClone .itemAdd:last input.funcao").attr("name").split("[")[1].split("]")[0];
        $number++;
        if($size == 1){
			$(".itensClone .itemAdd").show();
			$size++;
		}else{
			$(".itensClone").append($clone);
			$(".itensClone .itemAdd:last input.funcao").attr("name", "funcao[" + $number + "]");
			$(".itensClone .itemAdd:last input.nomes").attr("name", "nomes[" + $number + "]");
		}
        return false;
    });


    $(".btnAddFoto").live("click", function() {
        $clone = $(".itensCloneFoto .itemAddFoto:last").clone();
        $number = $(".itensCloneFoto .itemAddFoto:last textarea.descFoto").attr("name").split("[")[1].split("]")[0];
        $number++;
        if($size == 1){
			$(".itensCloneFoto .itemAdd").show();
			$size++;
		}else{
			$(".itensCloneFoto").append($clone);
			$(".itensCloneFoto .itemAddFoto:last input.foto").attr("name", "foto[" + $number + "]");
			$(".itensCloneFoto .itemAddFoto:last textarea.descFoto").attr("name", "descFoto[" + $number + "]");
		}
        return false;
    });


	$size = $(".itensClone .itemAdd").size();
    $(".addAmigos").live("click", function() {
        $clone = $(".itensClone .itemAdd:last").clone();
        $number = $(".itensClone .itemAdd:last input.nome").attr("name").split("[")[1].split("]")[0];
        $number++;
        if($size == 1){
			$(".itensClone .itemAdd").show();
			$size++;
		}else{
			$(".itensClone").append($clone);
			$(".itensClone .itemAdd:last input.nome").attr("name", "nomeAmigo[" + $number + "]").attr("id", "nomeAmigo[" + $number + "]").addClass("required");
			$(".itensClone .itemAdd:last input.email").attr("name", "emailAmigo[" + $number + "]").attr("id", "emailAmigo[" + $number + "]").addClass("required");
		}
        return false;
    });

    $(".itemAdd .btnExcluirAmigo").live("click", function() {
        $size = $(".itensClone .itemAdd").size();
		if($size == 1){
			$(this).parent().find("input").removeClass("required").end().hide();
		}else{
			$(this).parent().remove();
		}
        return false;
    });

	$("ul.listGlossario li a").click(function(){
		$letter = $(this).html().toLowerCase();
		$("ul.listGlossario a").removeClass("hover");
		$(this).addClass("hover");
		$("#boxGlossario .content ul").hide();
		if($letter == '#'){$letter = 'outros'}
		$("#boxGlossario .content ul.list-"+ $letter +"").fadeIn();
		return false;
	});
	$("ul.listGlossario li a:first").trigger("click");

	$("ul.listPortfolio li").hover(function(){
		$(this).addClass("hoverPink");
		$(this).find(".txt").fadeIn();
	}, function(){
		$(this).removeClass("hoverPink");
		$(this).find(".txt").fadeOut();
	});


	$(".box235 .post, .box235 .item, .sidebar309 .box303x244, .contentPortfolio .left, .contentPortfolio .right, .box303x182").hover(function(){
		$(this).addClass("active");
	}, function(){
		$(this).removeClass("active");
	});

	$(".content431 .newsPink").hover(function(){
		$(this).addClass("activePink");
	}, function(){
		$(this).removeClass("activePink");
	});

	$(".content431 .newsBlue").hover(function(){
		$(this).addClass("activeBlue");
	}, function(){
		$(this).removeClass("activeBlue");
	});

	$(".content431 .newsOrange").hover(function(){
		$(this).addClass("activeOrange");
	}, function(){
		$(this).removeClass("activeOrange");
	});

	$(".content431 ul.itemPink li, .content431 li.itemPink, .box667 ul.itemPink li, .box667 li.itemPink, .box667 .right175 .pink, .sidebar309 .box303x221, #boxGlossario ul li").hover(function(){
		$(this).addClass("hoverPink");
	}, function(){
		$(this).removeClass("hoverPink");
	});

	$(".content431 ul.itemBlue li, .content431 li.itemBlue, .box667 ul.itemBlue li, .box667 li.itemBlue, .box667 .blue").hover(function(){
		$(this).addClass("hoverBlue");
	}, function(){
		$(this).removeClass("hoverBlue");
	});

	$(".content431 ul.itemOrange li, .content431 li.itemOrange, .box667 ul.itemOrange li, .box667 li.itemOrange, .box667 .right175 .orange").hover(function(){
		$(this).addClass("hoverOrange");
	}, function(){
		$(this).removeClass("hoverOrange");
	});

	$(".box667 ul.itemGreen li, .box667 li.itemGreen").hover(function(){
		$(this).addClass("hoverGreen");
	}, function(){
		$(this).removeClass("hoverGreen");
	});

	$(".box667 .destNewsPink .item").hover(function(){
		$(this).addClass("itemHoverPink");
	}, function(){
		$(this).removeClass("itemHoverPink");
	});

	$(".box667 .destNewsBlue .item").hover(function(){
		$(this).addClass("itemHoverBlue");
	}, function(){
		$(this).removeClass("itemHoverBlue");
	});


	$(".box667 .destNewsOrange .item").hover(function(){
		$(this).addClass("itemHoverOrange");
	}, function(){
		$(this).removeClass("itemHoverOrange");
	});

    $("input + label").click(function() {
		if ($(this).prev().attr("type") == 'checkbox') {
			if ($(this).prev().is(":checked")) {
				$(this).prev().attr("checked", false);
			} else {
				$(this).prev().attr("checked", true);
			}
		} else {
			$(this).prev().attr("checked", true);
		}
    });
	
	$("input[type=file]").filestyle({ 
		image: "../img/choose-file.gif",
		imageheight :  20,
		imagewidth : 73,
		width : 330
	});

	$(".item a[href*=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target	|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
	
	/* tagCloud */
	$links = '';
	$(".tagcloud a").each(function(){
		$tamanho = $(this).css('font-size');
		$(this).attr({ style: 'font-size:' + $tamanho }).removeAttr('class');
		//$links += $(this).html();
	});
	$val = '<tags>' + $(".tagcloud").html() + '</tags>';
	// $val = $val.toLowerCase();
	$(".tagcloud").each(function(){
		$w = $(this).width();
		$h = $(this).height();
		$(this).flash({ src: '../swf/tagcloud.swf', width: $w, height: $h, wmode: 'transparent',  flashvars: { tagcloud: $val, distr: "true", mode: "both", tcolor: "0x636363", tcolor2: "0x636363", hicolor: "0x636363", tspeed: "200" } });
	});
	/* tagCloud */

	/*SINCD EVENTOS*/
	$("#googleMaps").each(function(){
		if (GBrowserIsCompatible()){
			var map;
				map = new GMap2(document.getElementById("googleMaps"));
				map.addControl(new GSmallMapControl());
				map.addControl(new GMenuMapTypeControl());
				map.setCenter(new GLatLng(0,0), 0);

			var $i = 0;
			var latlng1 = new Array();
			var latlngbounds = new GLatLngBounds();
			var points = $(".info .geo").size();
			$(".info .geo").each(function(){
				$lat = $(this).find(".latitude").text();
				$lon = $(this).find(".longitude").text();
				latlng1[$i] = new GLatLng($lat, $lon);
				var marker = new GMarker((latlng1[$i]));
				map.addOverlay(marker);
				latlngbounds.extend(latlng1[$i]);
				$i++;
			});
			map.setCenter(latlngbounds.getCenter(), map.getBoundsZoomLevel(latlngbounds));
		}
	});

	$(".programacao li a.btnExpandir").click(function(){
		$(".programacao li").removeClass("expandido");
		$(".programacao .palestrantes").slideUp();
		if($(this).prev().is(":visible")){
			$(this).prev().slideUp();
		}else{
			$(this).parents("li").addClass("expandido");
			$(this).prev().slideDown();
		}
		return false;
	});	

    $("ul.navTabEdicoes li a").click(function() {
        $tab = $(this).attr("href").split("#")[1];
        $("ul.navTabEdicoes li a").removeClass("hover");
        $(this).addClass("hover");
        $(".tab").hide();
        $("#" + $tab).fadeIn();
        return false;
    });
    $("ul.navTabEdicoes li a.btnGaleriaFotos").trigger("click");
	/*SINCD  EVENTOS*/
	
	
	$("input.dd").mask("99");
	$("input.mm").mask("99");
	$("input.aaaa").mask("9999");
    $("#exibir, #ordenar").selectbox();
	$("ul#noticias, ul.newsletter, ul.tabCincoMais, ul#multimidia-proxxima").idTabs(); 
	$(".checkbox").cssCheckbox();
    $(".radio").cssRadio();
	$(".pub").append("<span class='publicidade'></span>");
	$(".fix, span.smartPhone, span.eventoProxxima").ifixpng();
	$("input.hint").hint();
	$(".rating input").rating('enable');
	$("ul.galeriaFotos a").fancybox();
	$(".fontsize").each(function(){
		fontResizer('11px','11px','14px');
	});
	
	$("input[name=busca]").autocomplete("/portal/proxxima/proxxima!buscarTermos.xxi", {
		width: 260,
		formatItem: function(data, i, total) {
			return data[1];
		}
	});
	$('input[name=busca]').result(function(event, data, formatted) {
		document.location = '/portal/noticia/'+data[0];
	});
});

/* HINT */
/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/
(function ($) {

$.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }
    
  return this.each(function () {
    // get jQuery version of 'this'
    var $input = $(this),
    
    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title
      
      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

})(jQuery);
/* HINT */
/* FONT SIZER VERSION 1.0
 Developed by fluidByte (http://www.fluidbyte.net) */

function fontResizer(smallFont,medFont,largeFont)
{
function clearSelected() { $(".smallFont").removeClass("curFont"); $(".medFont").removeClass("curFont"); $(".largeFont").removeClass("curFont"); }
function saveState(curSize) {	var date = new Date(); date.setTime(date.getTime()+(7*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); document.cookie = "fontSizer"+"="+curSize+expires+"; path=/"; }

$(".smallFont").click(function(){ $('.fontsize').css('font-size', smallFont); clearSelected(); $(".smallFont").addClass("curFont"); saveState(smallFont); });

$(".medFont").click(function(){ $('.fontsize').css('font-size', medFont); clearSelected(); $(".medFont").addClass("curFont"); saveState(medFont); });

$(".largeFont").click(function(){ $('.fontsize').css('font-size', largeFont); clearSelected(); $(".largeFont").addClass("curFont"); saveState(largeFont); });

function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.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 ""; }

var savedSize = getCookie('fontSizer');

if (savedSize!="") { $('.fontsize').css('font-size', savedSize); switch (savedSize) { case smallFont: $(".smallFont").addClass("curFont"); break; case medFont: $(".medFont").addClass("curFont"); break; case largeFont: $(".largeFont").addClass("curFont"); break; default: $(".medFont").addClass("curFont"); } }
else { $('.fontsize').css('font-size', medFont); $(".medFont").addClass("curFont"); }
}
