﻿//função para o menu dropdown para usuário logado
function horizontal() {
    if(document.getElementById("menu_dropdown") != null)
    {
        var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");

        for (var i=0; i< navItems.length; i++) {
            if(navItems[i].className == "submenu")
            {
                if(navItems[i].getElementsByTagName('ul')[0] != null)
                {
                    navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "#000000";}
	                navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "";}
                }
            }
        }
    }
}


function isValue(e, obj, valida){
    
    var whichCode = (e.which == undefined) ? e.keyCode : e.which;
    
	if ((whichCode < 48 || whichCode > 57) && whichCode != 8 && whichCode != 0) {
		if(valida){
			if(whichCode != 44 || obj.value.indexOf(",") != -1){
				e.preventDefault? e.preventDefault() : e.returnValue = false; 
			}
			return;
		}
		e.preventDefault? e.preventDefault() : e.returnValue = false; 
	}
}

//TRATAMENTO DE MASCARA
function formatar(src, mask)
{
	var i = src.value.length;
	var saida = mask.substring(0,1);
	var texto = mask.substring(i)
	
	if (texto.substring(0,1) != saida) 
	{
		src.value += texto.substring(0,1);
	}
}

function currencyFormat(c, v, e) 
        {                    
            var myValue = (v.toString().length > 0 ? parseInt(v) : 0);
            //var whichCode = (window.Event) ? e.which : e.keyCode;
            var whichCode = (e.which == undefined) ? e.keyCode : e.which;
            var strCheck = '0123456789';
            var key = '';
            var newkey = 0;
            
            if ((whichCode > 95) && (whichCode < 106))
	        {
		        whichCode -= 48;
	        }
	        
            if (whichCode == 13) return true;  // Enter            
            
            key = String.fromCharCode(whichCode);  // Get key value from key code
                       
            if ((strCheck.indexOf(key) == -1) && (whichCode != 8 && whichCode != 46))
            {
                return false;  // Not a valid key
            }          
            
            if (myValue > 0)
            {
               if (whichCode == 8 || whichCode == 46)
               {
                    myValue = parseInt((myValue/10).toString());
               }
               else
               {
                    newkey = parseInt(key);
                    myValue = myValue * 10 + newkey;
               }
            }
            else
            {
                myValue = parseInt(key);
            }
        
            if (myValue < 1001)
            {
                c.value = myValue.toString() + ',00';                                            
            }
                        
            return false;    
        }

// JScript File
        
        gblId = 0;
        tt = new Array();                
        
        function first()
        {
            document.getElementById('ganhepremiostexto').innerHTML = tt[0];
        }
        
        function tracaMsg()
        {
            try
            {
                var i = gblId;
                
                if(gblId > tt.length -1)
                    i = 0;

                document.getElementById('ganhepremiostexto').innerHTML = tt[i];
                
                gblId = i + 1;
            }
            catch(e)
            {
                
            }
        }
        
        setInterval('tracaMsg()', 5000);
        
// Pop-up Jogos

var mine = null;

function abreJogo(url) {

    var Width = screen.availWidth;
    var Height = screen.availHeight;
    //window.open('JogoAbrir.aspx?Jogo='+url,'','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');
    //window.open('JogoAbrir.aspx?Jogo='+url,'JogoApp','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');

    //mine = window.open('JogoAbrir.aspx?Jogo=' + url, 'JogoApp', 'width=' + Width + ',height=' + Height + ',resizable=0,fullscreen=1,scrollbars=0');
    //mine.focus();
    
//    if(!mine)
//    {
//        mine = window.open('JogoAbrir.aspx?v=1&Jogo='+url,'JogoApp_' + url ,'width='+Width+',height='+Height+',resizable=1,fullscreen=0,scrollbars=0, top=0, left=0');
//    }
//    else
//    {
//        mine.location = 'JogoAbrir.aspx?v=1&Jogo=' + url;
//        mine.focus();
    //    }

    window.open('JogoAbrir.aspx?v=1&Jogo=' + url, 'JogoApp_' + url, 'width=' + Width + ',height=' + Height + ',resizable=1,fullscreen=0,scrollbars=0, top=0, left=0');
}

function abreJogoAutomatico(url) {

    var Width = screen.availWidth;
    var Height = screen.availHeight;
    //window.open('JogoAbrir.aspx?Jogo='+url,'','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');
    //window.open('JogoAbrir.aspx?Jogo='+url,'JogoApp','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');

    //mine = window.open('JogoAbrir.aspx?Jogo=' + url, 'JogoApp', 'width=' + Width + ',height=' + Height + ',resizable=0,fullscreen=1,scrollbars=0');
    //mine.focus();

    if(!mine)
    {
        mine = window.open('JogoAbrir.aspx?v=1&Jogo='+url,'JogoApp_' + url ,'width='+Width+',height='+Height+',resizable=1,fullscreen=0,scrollbars=0, top=0, left=0');
    }
    else
    {
        mine.location = 'JogoAbrir.aspx?v=1&Jogo=' + url;
        mine.focus();
    }
}

function abreJogoPoker()
{
    var Width = screen.availWidth;
    var Height = screen.availHeight;
    
    if(!mine)
    {
        mine = window.open('JogoPokerAbrir.aspx', 'JogoApp','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');
    }
    else
    {
        mine.location = 'JogoPokerAbrir.aspx';
        mine.focus();
    }
    
    //var mine = window.open('JogoPokerAbrir.aspx', 'JogoApp','fullscreen=yes, scrollbars=no'); 
}
var clicado = 0;


function abreJogo2(url)
{
    clicado = 1;
    jogo = 1;
    //window.location = 'JogoAbrir.aspx?Jogo='+url;
    
    var Width = screen.availWidth;
    var Height = screen.availHeight;
    //window.open('JogoAbrir.aspx?Jogo='+url,'','width='+Width+',height='+Height+',resizable=0,fullscreen=1,scrollbars=0');
    window.open('JogoAbrir.aspx?Jogo='+url,'','width='+Width+',height='+Height+',resizable=0,scrollbars=0');
    
}

function jogaDeslogado()
{
    alert('Você precisa estar logado para entrar em algum jogo!');
    document.getElementById("ctl00_txtUsuario").focus();
}
        
function saindo()
{
    if(clicado == 0)
    {
        window.opener.location.href='http://www.google.com.br';
    }    
}

function reload()
{
    clicado = 1;
    window.location = window.location;
}

function fechar()
{
    window.self.close();
}

function bloquear()
{
    window.location.href='http://www.google.com.br';
}

function abreChat() {
    window.open("Chat/Default.aspx","Chat","width=450,height=360");
}

//alinha height

function alinhaheight()
{
    var centro = document.getElementById('contentCentro');
    var menu = document.getElementById('menuLeft');
    
    var hMenu = menu.offsetHeight;
    var hCentro = centro.offsetHeight;
    
    if(hCentro < hMenu)
        centro.style.height = (hMenu - 85) + "px";
}

//janela senha

function lostPassword()
{
    var xposition = (screen.Width / 2) - 150;
    var yposition = (screen.Height / 2) - 50;
    window.open('LembrarSenha.aspx','Senha','width=300,height=100,resizable=0,top='+xposition+',left='+yposition);
}

// Somente Números
function onlytxt(field)
	{
		var wrote = "0123456789_-ABCDEFGHIJKLMNOPQRSTUVXYWZabcdefghijklmnopqrstuvxywz ";
		var field_temp;
		for (var i=0; i<document.all[field.id].value.length; i++)
		{
			field_temp = document.all[field.id].value.substring(i,i+1);
			
			if ((wrote.indexOf(field_temp)==-1) == true)
			{
				document.all[field.id].value = document.all[field.id].value.substring(0,i);
				break;
			}
		}
	}
	function onlynum(field)
	{
		var wrote = "0123456789,.-";
		var field_temp;
		for (var i=0; i<document.all[field.id].value.length; i++)
		{
			field_temp = document.all[field.id].value.substring(i,i+1);
			
			if ((wrote.indexOf(field_temp)==-1) == true)
			{
				document.all[field.id].value = document.all[field.id].value.substring(0,i);
				break;
			}
		}
	}
	
	function noEnter()
	{
	    if (window.event.keyCode == 13)
        {
            event.returnValue=false; 
            event.cancel = true;
        }
	}
// valida cpf

function validaCPF(cpf)
	{
		if(cpf.length < 11)
			return false;
	
		var cpfCount = "";
	
		for(i=0;i<10;i++)
		{
			cpfCount = "";
	
			for(j=0;j<11;j++)
				cpfCount += i;
	
			if(cpfCount == cpf)
			{
				return false;
				break;
			}
		}
	
		var a = [];
		var b = new Number;
		var c = 11;
	
		for(i=0; i<11; i++)
		{
			a[i] = cpf.charAt(i);
			if(i < 9) b += (a[i] * --c);
		}
	
		if((x = b % 11) < 2) 
			a[9] = 0;
		else
			a[9] = 11-x;
	
		b = 0;
		c = 11;
		
		for(y=0; y<10; y++) b += (a[y] * c--); 
	
		if((x = b % 11) < 2)
			a[10] = 0;
		else
			a[10] = 11-x;
	
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]))
		return false
	
	return true
}

// Formulário de Cadastro
function VerificaCampos()
{
var Nome = document.getElementById("ctl00_ContentPlaceHolder1_txtNome"),
    Apelido = document.getElementById("ctl00_ContentPlaceHolder1_txtApelido"),
    Senha = document.getElementById("ctl00_ContentPlaceHolder1_txtSenha"),
    SenhaConf = document.getElementById("ctl00_ContentPlaceHolder1_txtSenhaConf"),
    Email = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail"),
    EmailConf = document.getElementById("ctl00_ContentPlaceHolder1_txtEmailConf"),
    Dia = document.getElementById("ctl00_ContentPlaceHolder1_cmbDia"),
    Mes = document.getElementById("ctl00_ContentPlaceHolder1_cmbMes"),
    Ano = document.getElementById("ctl00_ContentPlaceHolder1_cmbAno"),    
    Newsletter = document.getElementById("ctl00_ContentPlaceHolder1_chkNewsletter"),
    h18Anos = document.getElementById("ctl00_ContentPlaceHolder1_chk18Anos"),
    Regras = document.getElementById("ctl00_ContentPlaceHolder1_chkRegras");
    
    if(Nome.value == '')
    {
        alert("Campo NOME não preenchido");
        Nome.focus(); return false;
    }
    if(Apelido.value == '')
    {
        alert("Campo APELIDO não preenchido");
        Apelido.focus(); return false;
    }
    if(Senha.value == '')
    {
        alert("Campo SENHA não preenchido");
        Senha.focus(); return false;
    }
    if(SenhaConf.value != Senha.value)
    {
        alert("Senha Incorreta");
        SenhaConf.focus(); return false;
    }
    if(Email.value == '')
    {
        alert("Campo E-MAIL não preenchido");
        Email.focus(); return false;
    }
    
    
    if(Email.value != '')
	{
		var e_mail = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
		if (!e_mail.exec(Email.value)) {
			alert("E-mail inválido.")
			Email.focus()
			return false
		}
	}
	
    if(EmailConf.value != Email.value)
    {
        alert("E-mail incorreto");
        EmailConf.focus(); return false;
    }
    
    if(Dia.value == '')
    {
        alert("Campo DIA não selecionado");
        Dia.focus(); return false;
    }
    if(Mes.value == '')
    {
        alert("Campo MÊS não selecionado");
        Mes.focus(); return false;
    }
    if(Ano.value == '')
    {
        alert("Campo ANO não Selecionado");
        Ano.focus(); return false;
    }    
    if(h18Anos.checked == false)
    {
        alert("Você deve ser maior de 18 anos");
        h18Anos.focus(); return false;
    }
    if(Regras.checked == false)
    {
        alert("Você deve aceitar as regras do site");
        Regras.focus(); return false;
    }
    return true;
}

// Formulário de resgate

function VerificaCamposResgate()
{
    var Banco = document.getElementById("ctl00_ContentPlaceHolder1_txtBanco"),
        Agencia = document.getElementById("ctl00_ContentPlaceHolder1_txtAgencia"),
        Conta = document.getElementById("ctl00_ContentPlaceHolder1_txtConta"),
        Cpf = document.getElementById("ctl00_ContentPlaceHolder1_txtCpf"),
        Valor = document.getElementById("ctl00_ContentPlaceHolder1_txtValor");

    if(Banco.value == "")
    {
        alert("Campo BANCO não preenchido");
        Banco.focus();
        return false;
    }
 if(Agencia.value == "")
    {
        alert("Campo AGÊNCIA não preenchido");
        Agencia.focus();
        return false;
    }
    if(Conta.value == "")
    {
        alert("Campo CONTA não preenchido");
        Conta.focus();
        return false;
    }
    
    
    
    if(Cpf.value.length < 11)
    {
        alert("Campo CPF não preenchido corretamente");
        Cpf.focus();
        return false;
    }
    
    if(validaCPF(Cpf.value) == false)
    {
        alert("CPF inválido");
        Cpf.focus();
        return false;
    }
    
    if(Valor.value < 1)
    {
        alert("Campo Valor deve ser maior que zero");
        Valor.focus();
        return false;
    }
    return true;
}

// Verifica campos editar

function VerificaCamposEditar()
{
var Nome = document.getElementById("ctl00_ContentPlaceHolder1_txtNome"),
    Apelido = document.getElementById("ctl00_ContentPlaceHolder1_txtApelido"),
    Senha = document.getElementById("ctl00_ContentPlaceHolder1_txtSenha"),
    Email = document.getElementById("ctl00_ContentPlaceHolder1_txtEmail"),
    Dia = document.getElementById("ctl00_ContentPlaceHolder1_cmbDia"),
    Mes = document.getElementById("ctl00_ContentPlaceHolder1_cmbMes"),
    Ano = document.getElementById("ctl00_ContentPlaceHolder1_cmbAno"),
    Sexo = document.getElementById("ctl00_ContentPlaceHolder1_rdoSexo"),
    Endereco = document.getElementById("ctl00_ContentPlaceHolder1_txtEndereco"),
    Compl = document.getElementById("ctl00_ContentPlaceHolder1_txtCompl"),
    Bairro = document.getElementById("ctl00_ContentPlaceHolder1_txtBairro"),
    CEP = document.getElementById("ctl00_ContentPlaceHolder1_txtCep"),
    DDD = document.getElementById("ctl00_ContentPlaceHolder1_txtDDD"),
    Telefone = document.getElementById("ctl00_ContentPlaceHolder1_txtTelefone"),
    Cidade = document.getElementById("ctl00_ContentPlaceHolder1_txtCidade"),
    Estado = document.getElementById("ctl00_ContentPlaceHolder1_cmbEstado");
    
    if(Nome.value == '')
    {
        alert("Campo NOME não preenchido");
        Nome.focus(); return false;
    }
    if(Apelido.value == '')
    {
        alert("Campo APELIDO não preenchido");
        Apelido.focus(); return false;
    }
    
    if(Email.value == '')
    {
        alert("Campo E-MAIL não preenchido");
        Email.focus(); return false;
    }
    
    if(Email.value != '')
	{
		var e_mail = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	
		if (!e_mail.exec(Email.value)) {
			alert("E-mail inválido.")
			Email.focus()
			return false
		}
	}

    if(Dia.value == '')
    {
        alert("Campo DIA não selecionado");
        Dia.focus(); return false;
    }
    if(Mes.value == '')
    {
        alert("Campo MÊS não selecionado");
        Mes.focus(); return false;
    }
    if(Ano.value == '')
    {
        alert("Campo ANO não Selecionado");
        Ano.focus(); return false;
    }
    if(Endereco.value == '')
    {
        alert("Campo ENDERECO não preenchido");
        Endereco.focus(); return false;
    }
    if(Compl.value == '')
    {
        alert("Campo COMPLEMENTO não preenchido");
        Compl.focus(); return false;
    }
    if(Bairro.value == '')
    {
        alert("Campo BAIRRO não preenchido");
        Bairro.focus(); return false;
    }
    if(CEP.value == '')
    {
        alert("Campo CEP não preenchido");
        CEP.focus(); return false;
    }
    if(DDD.value == '')
    {
        alert("Campo DDD não preenchido");
        DDD.focus(); return false;
    }
    if(Telefone.value == '')
    {
        alert("Campo Telefone não preenchido");
        Telefone.focus(); return false;
    }
    if(Cidade.value == '')
    {
        alert("Campo CIDADE não preenchido");
        Cidade.focus(); return false;
    }
    if(Estado.value == '')
    {
        alert("Campo ESTADO não selecionado");
        Estado.focus(); return false;
    }
    
    return true;
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }

function correctPNG() {
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i]
        var imgName = img.src.toUpperCase()
        if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
     + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
     + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i - 1
        }
    }
}
//window.attachEvent("onload", correctPNG);



//função que trata do ENTER nos browsers FF e Chrome
function clickButton(e, buttonid) {
    //debugger;
    var bt = document.getElementById(buttonid);
    if (typeof (bt) == 'object') {
        if (navigator.appName.indexOf("Netscape") > -1) {
            if (e.keyCode == 13) {
                if (bt && typeof (bt.click) == 'undefined') {
                    bt.click = addClickFunction1(bt);
                }
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > -1) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}

function addClickFunction1(bt) {
    //debugger;
    var result = true;
    if (bt.onclick) result = bt.onclick();
    if (typeof (result) == 'undefined' || result) {
        eval(bt.href);
    }
}
