﻿var img = new Image();
img.src = 'imagens/novo/bordas/carregando.gif';

function EsqueciSenha(){
    window.open('esqueci-senha.html','esqueci','scrollbars=no,width=300,height=300');
}

function SSL(){
    window.open('https://seal.thawte.com/thawtesplash?form_file=fdf/thawtesplash.fdf&dn=WWW.NETMOVIES.COM.BR&lang=br', 'SSL', 'resizable=1,scrollbars=yes,width=515,height=570');
}

function RND(A, B){
    return Math.ceil((A+(B-A))*Math.random());
}

function attachEvt(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
}

function detachEvent(o, e, f, s){
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
}
        
function RetornaInfoArquivo(nomeArquivo)
{    
    var indicePonto = -1;
    var indiceBarra = -1;
    var arquivo = new Array();
    for(var i=0; i<nomeArquivo.length; i++){
        x = nomeArquivo.substring(i,1);
        
        if(nomeArquivo.substr(i,1) == '.')
        {
            indicePonto = i;
        }
        
        if(nomeArquivo.substr(i,1) == '/')
        {
            indiceBarra = i;
        }
    }
    if(indicePonto > 0)
    {
        arquivo['nome'] = nomeArquivo.substring(indiceBarra + 1, indicePonto);
    }
    if(indiceBarra > 0)
    {
        arquivo['extensao'] = nomeArquivo.substring(indicePonto);
        arquivo['caminho'] = nomeArquivo.substring(0, indiceBarra + 1);
    }    
    return arquivo;
}

function autoTab(input, len, e) {
    var keyCode = (e.which) ? e.which : e.keyCode;
    var filter = (e.which) ? [0,8,9] : [0,8,9,16,17,18,38,38,39,40,46];

    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
    }
    
    function containsElement(arr, ele) 	{
        var found = false, index = 0;
        while(!found && index < arr.length)
            if(arr[index] == ele)
                found = true;
            else
                index++;
        return found;
    }
    function getIndex(input)	{
        var index = -1, i = 0, found = false;
        while (i < input.form.length && index == -1)
            if (input.form[i] == input)
                index = i;
            else 
                i++;
        return index;
    }
    return true;
}

function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}

function Formata(e, src, mask) {
    var code = (e.which)? e.which : e.keyCode;

    if(code > 47 && code < 58) { // números de 0 a 9
        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);
        } 
        return true;
    } else {
        if (code != 8 && code != 9) { // tecla espaço ou tab
            return false;
        } else {
            return true;
        }
    }
}

function TrataEnter(e){
    var e  = (e) ? e : window.event;
    var el = (e.target) ? e.target : e.srcElement;    
    if(e.keyCode == 13){
    	e.cancelBubble = true;
    	e.returnValue = false;
    	if (e.stopPropagation)
    	    e.stopPropagation();
    	if (e.preventDefault)
    	    e.preventDefault();
        __doPostBack(el.name, 'TextChanged');
    }
}

function CancelaEnter(e){
    var e  = (e) ? e : window.event;
    var el = (e.target) ? e.target : e.srcElement;    
    if(e.keyCode == 13){
    	e.cancelBubble = true;
    	e.returnValue = false;
    	if (e.stopPropagation)
    	    e.stopPropagation();
    	if (e.preventDefault)
    	    e.preventDefault();
    	return true;        
    }
    return false
}

function CancelaFilaEventos(e){
    var e  = (e) ? e : window.event;
    var el = (e.target) ? e.target : e.srcElement;    
	e.cancelBubble = true;
	e.returnValue = false;
	if (e.stopPropagation)
	    e.stopPropagation();
	if (e.preventDefault)
	    e.preventDefault();
}

function FormataTexto(texto, args){
    var retorno = texto;
    for(var i=0;i<args.length;i++){
        retorno = retorno.replace('{' + i + '}', args[i]);
    }
    return retorno;
}

function RetornaProximo(elemento){  
    var retorno = elemento.nextSibling;
    while(retorno != null && retorno.nodeType != 1){
        retorno = retorno.nextSibling;
    }
    return retorno;
}

function RetornaPrimeiroFilho(elemento){
    var retorno = elemento.firstChild;
    while(retorno != null && retorno.nodeType != 1){
        retorno = retorno.nextSibling;
    }
    return retorno;
}

function RetornaUltimoFilho(elemento){  
    var retorno = elemento.lastChild;
    while(retorno != null && retorno.nodeType != 1){
        retorno = retorno.previousSibling;
    }
    return retorno;
}

function IndefinidoNulo(objeto){
	return (objeto == undefined || objeto == null);
}

function AtribuiOpacidade(objeto, opacidade){
	if(IndefinidoNulo(objeto.style.filter) == false){
		opacidade *= 100;
		objeto.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacidade+')';
	}else if(IndefinidoNulo(objeto.style.opacity) == false){
		objeto.style.opacity = opacidade;
	    objeto.style.MozOpacity = opacidade;
	}else {
		opacidade *= 100;
	    try {
	      objeto.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacidade;
	    } catch (e) {
			try{
				objeto.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+opacidade+')';
			}catch(e){}
	    }
	}
}

function AbreJanela(html, largura, altura){
    window.open(html,"nova_janela", "width="+largura+",height="+altura+",top=0,left=0");
    void(0);
}

function BotaoDefault(event){
    if(!event) event = window.event;
    var target = event.srcElement?event.srcElement:event.target;
    if(!window._defaultFired && event.keyCode == 13 && target.tagName.toLowerCase() != "textarea"){
        var el = document.getElementsByTagName('INPUT');
        var found = false;
        for(var i=0; i < el.length; i++){
            var obj = el[i];
            if(obj == target)
                found = true;
            var isSubmit = obj.type == 'submit' || obj.type == 'image';
            if(found && isSubmit){
                try {
                    obj.focus();
                } catch(e){}
                __doPostBack(obj.name, 'click');
                window._defaultFired = true;
                setTimeout(function() { window._defaultFired = false; }, 1000);
                return false;
            }
        }
    }
    return true;
}
