/// JavaScript Document



//IMPORTANTE: ---------------------------------------------------------------
//Essa funcão faz o site todo centralizar em todas as resoluções, por favor nao remover
$(document).ready(function() {
    function ajustarjanela() {
        larguraSite = $(document).width();
        if (larguraSite > 1024) {
            $('div#divConteinerGeral').css('width', 100 + '%');
            $('#divRodape #containerDireitos').css('width', 100 + '%');
            $('#divRodape #containerApoio').css('width', 100 + '%');
            $('#divRodape').css('width', 100 + '%');
        }

        larguraSiteP = $(document).width();
        if (larguraSiteP < 1024) {
            $('.boxOverlay').css('width', 130 + '%');
        }
    }
    window.onresize = function() { ajustarjanela(); }
    ajustarjanela();

//REMOVE BARRA ROLAGEM HORIZONTAL EM 1024
$(document).ready(function() {
larguraSiteGeral = $(document).width();
        if (larguraSiteGeral = 1024) {
            $('body').css('overflow-x', 'hidden');
        }
});
    
	
    //GALERIA DE FOTOS

    var jogo;

    var galeria = $.query.get("galeria");

    var thumb = (galeria != '') ? $("img#thumb" + galeria) : $("div.foo ul li:first").find('img');


    // GALERIA DE VÍDEO

    if ($("div.foo").length) {
        $("div.foo").carousel({ direction: "vertical" });

        jogo = thumb.attr("title");

        $("div#description").html(jogo.split('|')[0] + '<br />' + jogo.split('|')[1]);
        galeriasVideo = $('.PlayerLarge .galeria');
    }






    //SCROLLPANE
    $('#divScrollTexto').jScrollPane();






});

$('.PlayerLarge .PrevPlayerLarge, .PlayerLarge .NextPlayerLarge').click(function() {
    //galeriasVideo
});

function mudarGaleria(count) {
    galeriasVideo.hide();
    $('#galeria' + count).show();
}


var openCad = 0;

    var maxLstItens = 4; //QUANTIDADE MÁXIMA DE LIST-ITENS A SEREM MOSTRADOS POR VEZ.
    var ListItemRel;

    function fixRow(list) {
        var grupos = list;
        //
        for (var i = 0; i < grupos.length; i++) {
            var total = $(".grupo" + grupos[i]).length;
            //
            $(".grupo" + grupos[i]).find(".grupo").attr("rowspan", total);
        }
    }

    function limitChars(textid, limit) {
        var text = $('#' + textid).val();
        var textlength = text.length;

        if (textlength > limit) {
            $('#' + textid).val(text.substr(0, limit));
            return false;
        } else {
            return true;
        }
    }

    $(document).ready(function() {
  
    if ($("#txt-escreva").length != 0) {
        $("#txt-escreva").keyup(function() {
            limitChars('txt-escreva', 155);
        });
  
    }
    /* floater ronaldo */
    $("a.um").bind("mouseover", function() {
        $('#balaoUm').fadeIn(300);
        $('#balaoDois').fadeOut(150);
        $('#balaoTres').fadeOut(150);
    });

    $("a.um").bind("mouseleave", function() { $('#balaoUm').fadeOut(150); });


    $("a.dois").bind("mouseover", function() {
        $('#balaoDois').fadeIn(300);
        $('#balaoUm').fadeOut(150);
        $('#balaoTres').fadeOut(150);
    });

    $("a.dois").bind("mouseleave", function() { $('#balaoDois').fadeOut(150); });


    $("a.tres").bind("mouseover", function() {
        $('#balaoTres').fadeIn(300);
        $('#balaoUm').fadeOut(150);
        $('#balaoDois').fadeOut(150);
    });

    $("a.tres").bind("mouseleave", function() { $('#balaoTres').fadeOut(150); });

    if (screen.width <= 800) {
        $("#divConteinerGeral").width($(document).width());
        $("#containerDireitos").width($(document).width());
        $("#divRodape").width($(document).width());
    }
    $('#promo-camisa-lightbox').hide();
    /*if($('#divMascaraDestaque').flash){
    $('#divMascaraDestaque').flash({
    src: 'Util/swf/DestaqueEventos.swf',
    width: 525,
    height: 360,
    version: 9,
    expressInstall: true,
    wMode: 'transparent',
    id: 'swfEventos',
    allowScriptAccess: 'sameDomain',
    swliveconnect: "true"
    });
    }*/


    /*if($('#divMascaraDestaquePromocao').flash){
    $('#divMascaraDestaquePromocao').flash({
    src: 'Util/swf/DestaquePromocoes.swf',
    width: 525,
    height: 360,
    version: 9,
    expressInstall: true,
    wMode: 'transparent',
    id: 'swfPromocoes',
    allowScriptAccess: 'sameDomain',
    swliveconnect: "true"
    });
    }*/

    //Funcões Básicas

    /* Target hack - para Strict */
    $('a.blank').click(function() {
        $(this).attr("target", "_blank");
    });

    $('a.self').click(function() {
        $(this).attr("target", "_self");
    });

    $('a.parent').click(function() {
        $(this).attr("target", "_parent");
    });

    /* Limpa o Input ao clicar */
    $('input:text').focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("");
            if ($(this).hasClass("password")) {
                $(this).attr("type", "password");
            }
            $(this).bind("blur", function() {
                if ($(this).val() == '') {
                    if ($(this).hasClass("password")) {
                        $(this).attr("type", "text");
                    }
                    $(this).val($(this).attr("title"));
                }
            });
        }
    });

    // Ancoras
    $("#divAncoras a").click(function() {
        var e = $(this).attr("href");
        $(window).scrollTop($(e).offset().top + 30);
        return false;
    });

    //Scroll Personalizado
    $(".divScrollTexto").jScrollPane({
        scrollbarWidth: 17,
        scrollbarMargin: 10,
        showArrows: true,
        animateTo: true,
        wheelSpeed: 20
    });

    $("#containerScroll").jScrollPane({
        scrollbarWidth: 8,
        scrollbarMargin: 10,
        showArrows: true,
        animateTo: true,
        wheelSpeed: 20
    });

    $("#termos-scroll").jScrollPane({
        scrollbarWidth: 8,
        scrollbarMargin: 10,
        showArrows: true,
        animateTo: true,
        wheelSpeed: 20
    });

    $("#conteudoScroll").jScrollPane({
        scrollbarWidth: 20,
        scrollbarMargin: 10,
        showArrows: true,
        animateTo: true,
        wheelSpeed: 20
    });

    $("#boxRegulamento").jScrollPane({
        scrollbarWidth: 20,
        scrollbarMargin: 10,
        showArrows: true,
        animateTo: true,
        wheelSpeed: 20
    });

    /*$('.listaEventos a').click(function(e){
    var flash = getFlashMovieObject('swfEventos');
    var p = $(this).parent().parent();
    var titulo = $('h4 a', p).text();
    var data = $('p:eq(0) a', p).text();
    var local = $('p:eq(1) a', p).text();
    var desc = $('p.descricao', p).text();
    var imagem = $('span.imagem', p).text();
    var urlink = $('span.link', p).text();
    var descricao = data +" - "+ local +" - "+ desc;

		flash.novoDestaque("http://guarananovoportal.tv1.com.br"+imagem, titulo, descricao, urlink);
    e.preventDefault();
    });

	$('.listaPromocoes a').click(function(e){
    var flash = getFlashMovieObject('swfPromocoes');
    var p = $(this).parent().parent();
    var titulo = $('h4 a', p).text();
    var data = $('p:eq(0) a', p).text();
    var local = $('p:eq(1) a', p).text();
    var desc = $('p.descricao', p).text();
    var imagem = $('span.imagem', p).text();
    var urlink = $('span.link', p).text();
    var descricao = data +" - "+ local +" - "+ desc;
    flash.novoDestaque("http://guarananovoportal.tv1.com.br"+imagem, titulo, descricao, urlink);
    e.preventDefault();
    });*/

    /* AUMENTAR COLUNA GUARANAUTAS */
    var alturaEsquerda = $(".divLadoEsquerdo").height();
    var alturaDireita = $('.divLadoDireito').height();
    if (alturaEsquerda > alturaDireita) {
        $(".divLadoDireito .overlay").css("height", alturaEsquerda);
    }
    else if (alturaDireita > alturaEsquerda) {
        $(".divLadoEsquerdo .overlay").css("height", alturaDireita);
    }

    /* FORMULA SECRETA - EXPANDIR BOX */
    $('a.expande').click(function() {
        bloco = $(this).parent().parent().find('div.quadro_aviso');
        novaAltura = $(this).parent().parent().find('div.quadro_aviso').height();
        marginElemento = $(this).parent().css('top').replace('px', '');

        teste = parseInt(marginElemento)
        novaMarginElemento = (parseInt(novaAltura) + parseInt(marginElemento) + 25);
        imagem = $(this).find('img')
        imagemSrc = $(this).find('img').attr('src');

        if (bloco.css("display") == "none") {
            $(bloco).slideToggle("slow");
            //$(bloco).show();
            $(this).parent().css('top', novaMarginElemento + 'px');
            novaImagem = imagemSrc.replace('mais', 'menos');
            imagem.attr('src', novaImagem);
        }
        else {
            $(bloco).slideToggle("slow");
            //$(bloco).hide();
            $(this).parent().css('top', '192px');
            novaImagem = imagemSrc.replace('menos', 'mais');
            imagem.attr('src', novaImagem);
        }
    });


    $(".boxInfograficos").click(function() {
        openInfo2($('div a', this).attr('href'));
    });

    $(".boxInfograficos").click(function() {
        openInfo2($('div a', this).attr('href'));
    });

    $("a.tipbalao").hover(
		function() {
		    $(this).parent().siblings().css("z-index", "1");
		    $(this).parent().css("z-index", "9999");
		}
	);

    //GA MUNDO
    $('a.openModal').click(function() {
        var idDiv = $(this).attr('rel');
        openLightBoxCentered(idDiv);

        if (idDiv == "#divSegundoCadastro") {
            initializeCadastro();
        }
    });

    $('a.openRegulamento').click(function() {
        closeLightBox();
        openLightBoxCentered("#divRegulamento");
    });

    $('img.fechaRegulamento').click(function() {
        closeLightBox();
        setTimeout(function(){openLightBoxCentered("#divSegundoCadastro");},1000);
    });

    $('a.openDuvidasCadastro').click(function() {
        closeLightBox();
        openLightBoxCentered("#divDuvidas");
        openCad = 1;
    });

    $('#lkFechaDuvidas').click(function() {
        closeLightBox();
        if (openCad == 1) {
            openLightBoxCentered("#divSegundoCadastro");
            openCad = 0;
        }
    });

    // END - SIMPLE MODAL JQUERY

    $('.close').click(function() {
        closeLightBox();
    });

    $('.window').hide();

    $(document).keydown(function(e) {
        // ESCAPE key pressed
        if (e.keyCode == 27) {
            closeLightBox();
            openCad = 0;
        }
    });

    // FIM GA MUNDO

    /* GA RECEITA - LISTA BANDEIRAS ===== DESENVOLVIDO POR FILIPE HENRIQUE */
    /***********************************************************************/

    $('a.lstItem').click(function() {
        ListItemRel = parseInt($(this).attr('rel'));
        //MakelistItens(ListItemRel, maxLstItens);
		moverItemPara();
    });
	

    $('span.prev').click(function() {
        ListItemRel = parseInt($("input#lstItemAtivo").val()) - 1;
        MakelistItens(ListItemRel, maxLstItens);
    });

    $('span.next').click(function() {
        ListItemRel = parseInt($("input#lstItemAtivo").val()) + 1;
        MakelistItens(ListItemRel, maxLstItens);
    });
	

    /* / GA RECEITA - LISTA BANDEIRAS ========================================= */

});

	function moverItemPara(){
        MakelistItens(ListItemRel, maxLstItens);
	}

    function MakelistItens(ListItemRel, maxLstItens) {
        var relItens = ListItemRel * maxLstItens - 3; //MÚLTIPLICAMOS A NÚMERO DA RELAÇÃO PELA QUANTIDADE MÁXIMA DE ITENS A SEREM EXIBIDOS.
        var showLIs;
        var changeItens = false;
        var i;
        var itemAtual;
        var qtdaLi = parseInt($('ul#ListAllReceitas').children().length);
        var qtdaPaginacao = parseInt($('li#paginacao').children('a').length)

        if (ListItemRel > 0 && ListItemRel <= qtdaPaginacao) {
        
            $("input#lstItemAtivo").val(ListItemRel); //ARMAZENA O VALOR DO REL DO LIST-ITEM CLICADO PARA USO DAS SETAS DE NEXT E PREV.

            for (i = qtdaLi - 1; i >= 0; i--) {

                itemAtual = $('ul#ListAllReceitas li:eq(' + i + ')').attr('class').replace(/^\s*/, "").replace(/\s*$/, "");

                if (itemAtual == "showItem") { //VERIFICA QUAL O ÚLTIMO LI QUE ESTÁ COM DISPLAY BLOCK, CLASSE "showItem".
                    if (relItens >= i) { //SE O ÍTEM CLICADO FOR MAIOR MOSTRA OS PRÓXIMOS ITENS.
                        showLIs = relItens;
                        typeChange = "next";
                        changeItens = true;
                        i = -1;
                    }
                    else { //SE FOR MENOR VAI MOSTRA OS ÍTENS ANTERIORES.
                        showLIs = relItens;
                        typeChange = "prev";
                        changeItens = true;
                        i = -1;
                    }
                }
            }

            if (changeItens) {

                for (i = qtdaLi; i >= 0; i--) { //ADICIONA A CLASSE COM DISPLAY NONE PARA TODAS AS LI.
                    $('ul#ListAllReceitas li:eq(' + i + ')').removeClass("showItem");
                    $('ul#ListAllReceitas li:eq(' + i + ')').addClass('hideItem');
                }

                if (typeChange == "next") {
                    for (i = showLIs; i < showLIs + maxLstItens; i++) {
                        $('ul#ListAllReceitas li:eq(' + i + ')').removeClass('hideItem').addClass('showItem'); //CLASSE COM DISPLAY BLOCK SOMENTE PARA AS LI DEFINIDAS.
                    }
                    return true;
                }
                else {
                    for (i = showLIs; i < showLIs + maxLstItens; i++) {
                        $('ul#ListAllReceitas li:eq(' + i + ')').removeClass('hideItem').addClass('showItem'); //CLASSE COM DISPLAY BLOCK SOMENTE PARA AS LI DEFINIDAS.
                    }
                }
            }
        }
    }

//GA MUNDO
function openLightBoxCentered(idDiv)
{
    var maskHeight = $('#divConteinerGeral').height() + $('#containerApoio').height() + $('#containerTags').height() + $('#containerDireitos').height();
    var maskWidth = $('#divConteinerGeral').width();
    
    $('#mask').css({
        'width':maskWidth,
        'height':maskHeight,
        'background' : '#000',
        'opacity' : 0.6,
        'cursor' : 'pointer'
    });

    $('#mask').fadeIn();

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();
      
    $(idDiv).css('top', '100'+'px');
    $(idDiv).css('left', winW/2-$(idDiv).width()/2);

    $(idDiv).fadeIn(); 
}

function closeLightBox()
{
    $('.window').fadeOut();	
    $('#mask').fadeOut();
}

function openLightBoxArquivo(idL, imagem)
{
    $("#tituloArquivo").text(locations[idL].titulo);
    $("#nomeArquivo").text(locations[idL].nome);
    $("#imgFoto").attr("style", "display:none");
    $("#embedVideo").attr("style", "display:none");
    if (locations[idL].comentarios.length > 0) { 
        $("#comentariosArquivo").html(textToHtml(locations[idL].comentarios)).attr("style", "display:block"); 
    }
    
    if (imagem) {
        $("#imgFoto").attr("src", locations[idL].foto).attr("alt", locations[idL].titulo).attr("style", "display:block");
        
    } else {
		$("#embedVideo").html(textToHtml(locations[idL].video)).attr("style", "display:block");
    }
    
    openLightBoxCentered("#lightBoxLista");    
}

//FIM GA MUNDO

$(window).load(function() {
	//$(".listaEventos:eq(0) a:eq(0)").click();	
	//$(".listaPromocoes:eq(0) a:eq(0)").click();	
});

function abreLigthbox(){
	alturaLightboxConteudo = $('#divConteinerGeral').height();
	alturaLightboxRodape = $('#divRodape').height();
	alturaLightbox = alturaLightboxConteudo + alturaLightboxRodape + 82;
	$(".boxOverlay").css('height',alturaLightbox);
	
	$(".boxOverlay, .lightbox").fadeIn('fast');
	$(".boxOverlay").animate({opacity: 0.8}, 100);
	$(".divFrame").append('<iframe frameborder="0" scrolling="no" src="fale-conosco.aspx" class="idFrame" id="frameContato"></iframe>');
	$(".divBoxVideo").css('visibility','hidden');
	
	return false;
}

function abreLigthboxRealidade(){
	alturaLightboxConteudo = $('#divConteinerGeral').height();
	alturaLightboxRodape = $('#divRodape').height();
	alturaLightbox = alturaLightboxConteudo + alturaLightboxRodape + 82;
	$(".boxOverlay").css('height',alturaLightbox);
	
	$(".boxOverlay, .lightboxRealidade").fadeIn('fast');
	$(".boxOverlay").animate({opacity: 0.8}, 100);
	$(".divBoxVideo").css('visibility','hidden');
	
	return false;
}

function fechaLighBox(){
	$(".boxOverlay, .lightbox").fadeOut('slow');
	$(".divBoxVideo").css('visibility','visible');
	$("#frameContato").attr("src", "fale-conosco.aspx");
	return false;
}

function fechaLighBoxRealidade(){
	$(".boxOverlay, .lightboxRealidade").fadeOut('slow');
	$(".divBoxVideo").css('visibility','visible');
	return false;
}

/* light do ronaaaaldo */

function abreLightboxRonaldo(){
	$(".boxOverlay, .lightboxRonaldo").fadeIn('fast');
	$(".boxOverlay").animate({opacity: 0.8}, 100);
	return false;
}

function fechaLighBoxRonaldo(){
	$(".boxOverlay, .lightboxRonaldo").fadeOut('slow');
	return false;
}


function getFlashMovieObject(movieName) {
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; 
	}
	else {
		return document.getElementById(movieName);
	}
}

function toggle(i) {
	if($(i).is(":hidden")) $(i).show();
	else $(i).hide();
}

function flashNovoDestaque(arquivo, titulo, texto, link){
	var flash = getFlashMovieObject('swfPromocoes');
	while(!flash.novoDestaque || flash.novoDestaque == 'undefined'){
		setTimeout(function(){flashNovoDestaque(arquivo, titulo, texto, link)},"1000");
		return;
	}

	flash.novoDestaque(arquivo, titulo, texto, link);

}

function flashNovaMusica(arquivo, musica, artista, disco, autoplay){

	var flash = getFlashMovieObject('PlayerMusica');
	while(!flash.novaMusica || flash.novaMusica == 'undefined'){
		setTimeout(function(){flashNovaMusica(arquivo, musica, artista, disco, autoplay)},"1000");
		return;
	}

	flash.novaMusica(arquivo, musica, artista, disco, autoplay);

}

/* CADASTRO LIGHTBOX */
function abreLigthboxCadastro(){
	alturaLightboxConteudo = $('#divConteinerGeral').height();
	alturaLightboxRodape = $('#divRodape').height();
	alturaLightbox = alturaLightboxConteudo + alturaLightboxRodape + 82;
	$(".boxOverlay").css('height',alturaLightbox);
	
	$(".boxOverlay, .lightboxCadastro").fadeIn('fast');
	$(".boxOverlay").animate({opacity: 0.8}, 100);
	//$(".divFrameCadastro").append('<iframe frameborder="0" allowtransparency="true" scrolling="no" src="/cadastro-portal.aspx" height="222" class="idFrameCadastro" id="frameCadastro"></iframe>');
	$(".divBoxVideo").css('visibility','hidden');
	
	return false;
}

function fechaLighBoxCadastro(){
	$(".boxOverlay, .lightboxCadastro").fadeOut('slow');
	$(".divBoxVideo").css('visibility','visible');
	$("#frameCadastro").attr("src", "cadastro-portal.aspx");
	return false;
}

function AbrirPopup(url)
{
    window.open(url, 'game', 'status=0, toolbar=1, location=1, menubar=1, width=822, height=531, scrollbars=1, resizable=0');
}

function openInfo(e)
{
	window.open(e.href, "Fase1", "toolbar=no, location=no,status=no, menubar=no,width=984,height=475");
	//alert(e.href);
	return false;
}

function openInfo2(eHref)
{
	window.open(eHref, "Fase1", "toolbar=no, location=no,status=no, menubar=no,width=984,height=475");
	return false;
}
//abrir();

function linkBoxInfograficos() {
	boxInfo = document.getElementsByTagName('div');
}

//INÍCIO: COPA - CADASTRO
jQuery(function($){
	$("#ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ConteudoGeral_ConteudoGeralApoio_CadastroCopaDe2010_1_txtDataNascimento").mask("99/99/9999");
});

function calcularIdade(dataNasc){
	var dataNasc = dataNasc.split("/");
	var nascDia = dataNasc[0];
	var nascMes = dataNasc[1];
	var nascAno = dataNasc[2];
	
	var dataAtual = new Date();
	var dia = dataAtual.getDate();
	var mes = dataAtual.getMonth()+1;
	var ano = dataAtual.getFullYear();
	
	var idade = ano - nascAno;

	if(dia >= nascDia && mes >= nascMes) {
		return idade;
	}
	else {
		return idade - 1;
	}
}

function verificarIdade(inputDataNasc) {
	var idade = calcularIdade(inputDataNasc.value);
	if(idade < 18) {
		$("#ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ConteudoGeral_ConteudoGeralApoio_CadastroCopaDe2010_1_camposparamenores").removeClass("hidden");
	}
	else {
		if(!$("#ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ConteudoGeral_ConteudoGeralApoio_CadastroCopaDe2010_1_camposparamenores").hasClass("hidden")) {
			$("#ctl00_ctl00_ctl00_ctl00_ContentPlaceHolderDefault_ConteudoGeral_ConteudoGeralApoio_CadastroCopaDe2010_1_camposparamenores").addClass("hidden");
		}
	}
	return false;
}

//Função para validação de caracteres
function only(t, o, e) {
    if (window.event) {
        key = window.event.keyCode;
    } else if (e) {
        key = e.which;
    } else {
        return true;
    }
    S = o ? o : "";
    if (t == "num" || t == "number" || t == "numeric") {
        S += "0123456789";
    }
    if (t == "data") {
        S += "0123456789/";
    }
    if (t == "tel") {
        S += "0123456789()- ";
    }
    if (t == "valor") {
        S += "0123456789.,";
    }
    if (t == "alnum" || t == "alphanumeric") {
        S += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\xE1\xE0\xE3\xE2\xE4\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF3\xF2\xF5\xF4\xF6\xFA\xF9\xFB\xFC\xE7\xC1\xC0\xC3\xC2\xC4\xC9\xC8\xCA\xCB\xCD\xCC\xCE\xCF\xD3\xD2\xD5\xD4\xD6\xDA\xD9\xDB\xDC\xC7 0123456789";
    }
    if (t == "let" || t == "letters") {
        S += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\xE1\xE0\xE3\xE2\xE4\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF3\xF2\xF5\xF4\xF6\xFA\xF9\xFB\xFC\xE7\xC1\xC0\xC3\xC2\xC4\xC9\xC8\xCA\xCB\xCD\xCC\xCE\xCF\xD3\xD2\xD5\xD4\xD6\xDA\xD9\xDB\xDC\xC7 ";
    }
    if (t == "rest" || t == "restrict") {
        S += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    }
    if (t == "email") {
        S += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@-_.";
    }
    
    if (key == null || ((t != "nothing") && (key == 0 || key == 8 || key == 9 || key == 13 || key == 27))) {
        return true;
    } else if (S.indexOf(String.fromCharCode(key)) != -1) {
        return true;
    } else {
        return false;
    }
}

function isEmail(email) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(email);
}

function textToHtml(text)
{
    return text.replace(/&lt;{1}/gi,"<").replace(/&amp;lt;{1}/gi,"<").replace(/&gt;{1}/gi,">").replace(/&amp;gt;{1}/gi,">");
}
function htmlToText(text)
{
    return text.replace(/<{1}/gi,"&lt;").replace(/>{1}/gi,"&gt;");
}
function jump(limit, idField, idNextField)
{
    if (document.getElementById(idField) && document.getElementById(idField).value.length == limit)
    {
        if (document.getElementById(idNextField))
        {
            document.getElementById(idNextField).focus();
        }
    }
}

//FIM: COPA - CADASTRO

function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}

function ContaCaracteres(contador, obj, e) {
    if ((149 - obj.value.length) == -1) {
        obj.value = obj.value.substr(0, 149);
    }
    else {
        if (window.event) // IE
        {
            if (e.keyCode == 8 || e.keyCode == 36) {
                if (obj.value.length != -1)
                    document.getElementById(contador).value = 149 - (obj.value.length);
            }
            else {
                document.getElementById(contador).value = 149 - (obj.value.length);
            }
        }
        else {
            if (e.which == 8 || e.which == 36) {
                if (obj.value.length != -1)
                    document.getElementById(contador).value = 149 - (obj.value.length);
            }
            else {
                document.getElementById(contador).value = 149 - (obj.value.length);
            }
        }
    }
}

 $(document).ready(function() {
				    $("#twitter").getTwitter({
					    userName: "guarana",
					    numTweets: 2,
					    loaderText: "",
					    slideIn: true,
					    showHeading: true,
					    headingText: "Latest Tweets",
					    showProfileLink: true
				    });
			    });

//Reconhece KeyCode da tecla Enter
//function EnterKeyCode() {
//    if ((window.event ? event.keyCode : event.which) == 13) {
//        document.form1.submit;
//    }
//}


//function EnterKeyCode(myfield, e) {
//    var keycode;
//    if (window.event) keycode = window.event.keyCode;
//    else if (e) keycode = e.which;
//    else return true;

//    if (keycode == 13) {
//        myfield.form.submit();
//        return false;
//    }
//    else
//        return true;
//}

