<!-- Preload Image 
image1 = new Image();
image1.src = "../imagens/menu_hospedagem_b.gif";

image2 = new Image();
image2.src = "../imagens/menu_assine_b.gif";

image3 = new Image();
image3.src = "../imagens/menu_dominio_b.gif";

image4 = new Image();
image4.src = "../imagens/menu_suporte_b.gif";

image5 = new Image();
image5.src = "../imagens/menu_contato_b.gif";


// Funcao abrir janela central do assinante
function abrir_janela_central (width, height, myname, url)
{
  var left, top;

  if (screen.width < width)
    left = 0;
  else
    left = (screen.width  - width) / 2;

  if (screen.height < height)
    top = 0;
  else
    top = (screen.height - height) / 4;

  if ( navigator.appName == "Netscape" )
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",screenX=" + left + ",screenY=" + top + ",scrollbars=yes,status=yes,toolbar=0,menubar=yes,location=0,directories=0,resizable=yes");}
  else
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",left=" + left + ",top=" + top + ",scrollbars=yes,status=yes,toolbar=0,menubar=yes,location=0,directories=0,resizable=yes");}

  if (w)
   w.focus ();
   
}

// Funcao abrir janela em pdf
function abrir_janela_pdf (width, height, myname, url)
{
  var left, top;

  if (screen.width < width)
    left = 0;
  else
    left = (screen.width  - width) / 2;

  if (screen.height < height)
    top = 0;
  else
    top = (screen.height - height) / 4;

  if ( navigator.appName == "Netscape" )
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",screenX=" + left + ",screenY=" + top + ",scrollbars=no,status=yes,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}
  else
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",left=" + left + ",top=" + top + ",scrollbars=no,status=yes,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}

  if (w)
   w.focus ();
   
}



// funcao abrir janela
function abrir_janela (width, height, myname, url)
{
  var left, top;

  if (screen.width < width)
    left = 0;
  else
    left = (screen.width  - width) / 2;

  if (screen.height < height)
    top = 0;
  else
    top = (screen.height - height) / 4;

  if ( navigator.appName == "Netscape" )
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",screenX=" + left + ",screenY=" + top + ",scrollbars=yes,status=no,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}
  else
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",left=" + left + ",top=" + top + ",scrollbars=yes,status=no,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}

  if (w)
   w.focus ();
   
}


// funcao abrir janela simples
function abrir_janela_simples (width, height, myname, url)
{
  var left, top;

  if (screen.width < width)
    left = 0;
  else
    left = (screen.width  - width) / 2;

  if (screen.height < height)
    top = 0;
  else
    top = (screen.height - height) / 4;

  if ( navigator.appName == "Netscape" )
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",screenX=" + left + ",screenY=" + top + ",scrollbars=no,status=no,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}
  else
  {  var w = window.open (url, myname, "height="+height+",width="+width+ 
    ",left=" + left + ",top=" + top + ",scrollbars=no,status=no,toolbar=0,menubar=no,location=0,directories=0,resizable=yes");}

  if (w)
   w.focus ();
   
}



// funcao mostrar tr
function show (ID){
  	var el = document.getElementById(ID);
  	if (el.style.display == "none")
  	{
  		el.style.display = "block";
  	}
  	else 
  	{
  		el.style.display = "block";
  	}
  }
  
  
  
// funcao ocultar tr
  function hide (ID){
  	var el = document.getElementById(ID);
  	if (el.style.display == "block")
  	{
  		el.style.display = "none";
  	}
  	else 
  	{
  		el.style.display = "none";
  	}
  }



// funcao pop
function pop(url){
	if(navigator.userAgent.indexOf("Mac")!=-1)
		if(parent.window.opener) parent.window.opener.top.location.href=url; 
		else window.open(url,'nj','')
	else
	 	if (!parent.window.opener.closed) parent.window.opener.top.location.href=url;
		else void(window.open(url,'popwinpop','menubar=1,status=1,directories=1,toolbar=1'));	
	top.close(); 
}


//funcoes feitas por Marcelo Barbosa
function cepjava()
{
    var number = document.getElementById('txtCEP').value;
    if (number.length == 8)
    {
        ajax.cep(number, cep_callback);
    }
}

function cep_callback(res)
{
    if (res.value!='null')
    {
        var endereco = res.value.split('|');

        document.getElementById('txtEndereco').value = endereco[0];
        document.getElementById('txtBairro').value = endereco[1];
        document.getElementById('txtCidade').value = endereco[2];
        document.getElementById('ddEstado').value = endereco[3];

//        document.getElementById('txtEndereco').disabled = true;
//        document.getElementById('txtBairro').disabled = true;
//        document.getElementById('txtCidade').disabled = true;
//        document.getElementById('ddEstado').disabled = true;
        
        hide('txtEnderecoVazio');
        hide('txtBairroVazio');
        hide('txtCidadeVazio');
        hide('txtCEPInvalido');
        
        document.getElementById('txtNumero').focus();
    }
    else
    {
        document.getElementById('txtEndereco').value = '';
        document.getElementById('txtBairro').value = '';
        document.getElementById('txtCidade').value = '';
        document.getElementById('ddEstado').value = 0;

//        document.getElementById('txtEndereco').disabled = false;
//        document.getElementById('txtBairro').disabled = false;
//        document.getElementById('txtCidade').disabled = false;
//        document.getElementById('ddEstado').disabled = false;

        document.getElementById('txtEndereco').focus();
        hide('txtNumeroVazio');
    }
}

function loginajax()
{
    var login = document.getElementById('txtLogin').value;
    if (login.length > 3)
    {
        ajax.IsLoginCadastrado(login, login_callback);
    }
    else
    {
        show('txtLoginInvalido');
    }
}

function login_callback(res)
{
    if (res.value == true)
    {
        show('txtLoginCadastrado');
        hide('txtLoginInvalido');
    }
    else
    {
       hide('txtLoginCadastrado');
       hide('txtLoginInvalido');
    }
}

function MascaraCEP()
{
    if (document.getElementById('txtCEP').value.length == 8)
    {
        document.getElementById('txtCEP').value = document.getElementById('txtCEP').value.mask('#####-###');
    }
    else
    {
//        document.getElementById('txtEndereco').disabled = true;
//        document.getElementById('txtBairro').disabled = true;
//        document.getElementById('txtCidade').disabled = true;
//        document.getElementById('ddEstado').disabled = true;
        
        document.getElementById('txtEndereco').value = '';
        document.getElementById('txtBairro').value = '';
        document.getElementById('txtCidade').value = '';
        document.getElementById('ddEstado').value = '';
        
//        hide('txtEnderecoVazio');
//        hide('txtBairroVazio');
//        hide('txtCidadeVazio');
    }
}

function SelecionaOpcao(opcao)
{
    var aux = opcao;
    
    if (aux == 1)
    {
        document.getElementById('rbHospedar').checked = true;
    }
    if (aux == 2)
    {
        document.getElementById('rbHospedarTransferir').checked = true;
        show('transferencia');hide('hospedagem');hide('registro');hide('reserva');show('plano_hospedagem');hide('plano_reserva');
    }
    if (aux == 3)
    {
        document.getElementById('rbHospedarRegistrar').checked = true;
        hide('transferencia');hide('hospedagem');show('registro');hide('reserva');show('plano_hospedagem');hide('plano_reserva');
    }
    if (aux == 4)
    {
        document.getElementById('rbReservar').checked = true;
        hide('hospedagem');hide('transferencia');hide('registro');show('reserva');hide('plano_hospedagem');show('plano_reserva');
    }
}

function SelecionaPlano(opcao)
{
    document.getElementById('ddProduto').value = opcao;
}

function ExibePessoaJuridica()
{
    show('pessoa_juridica');
}

function ResetErros()
{
    hide('txtDominioInvalido');
    hide('txtNomeCompletoVazio');
    hide('txtNomeCompletoInvalido');
    hide('txtCPFInvalido');
    hide('txtRazaoSocialVazio');
    hide('txtRazaoSocialInvalido');
    hide('txtNomeFantasiaInvalido');
    hide('txtCNPJInvalido');
    hide('txtCEPInvalido');
    hide('txtEnderecoVazio');
    hide('txtNumeroVazio');
    hide('txtBairroVazio');
    hide('txtCidadeVazio');
    hide('txtTelefoneDDDInvalido');
    hide('txtTelefoneNumeroInvalido');
    hide('txtCelularDDDInvalido');
    hide('txtCelularNumeroInvalido');
    hide('txtEmailInvalido');
    hide('txtLoginCadastrado');
    hide('txtLoginInvalido');

}

function ExibeDescricao()
{
    if (document.getElementById('rbHospedar').checked == true)
    {
        show('hospedagem');hide('transferencia');hide('registro');hide('reserva');show('plano_hospedagem');hide('plano_reserva');
    }
    if (document.getElementById('rbHospedarTransferir').checked == true)
    {
        show('transferencia');hide('hospedagem');hide('registro');hide('reserva');show('plano_hospedagem');hide('plano_reserva');
    }
    if (document.getElementById('rbHospedarRegistrar').checked == true)
    {
        hide('transferencia');hide('hospedagem');show('registro');hide('reserva');show('plano_hospedagem');hide('plano_reserva');
    }
    if (document.getElementById('rbReservar').checked == true)
    {
        hide('hospedagem');hide('transferencia');hide('registro');show('reserva');hide('plano_hospedagem');show('plano_reserva');
    }
}

function ExibeErros(p_erros)
{
    if (p_erros.value!='null')
    {
        var erros = p_erros.split(',');
        var l = erros.length;
        
        for(var i = -1; ++i < l;)
        {
            show(erros[i]);
        }
    }
}

function WhoisPopUp()
{
    var dominio = document.getElementById('txtDominio').value;
    if (dominio != '')
    {
        abrir_janela(400,350,'HospedixWHOIS','http://www.hospedix.com.br/dominio/pop_whois.aspx?d='+dominio);
    }
}

function VerificaVazio(el)
{
    if (document.getElementById(el).value == '')
    {
        show(el + 'Vazio');
    }
    else
    {
        if (el != 'txtEmail')
        {
            document.getElementById(el).value = document.getElementById(el).value.SuperTrim().toUpperCase();
        }
        else
        {
            document.getElementById(el).value = document.getElementById(el).value.SuperTrim().toLowerCase();
        }
        hide(el + 'Vazio');
    }
}

function VerificaConcordo()
{
    alert('entrou');
    if (document.getElementById('chkConcordo').checked)
    {
        hide('chkConcordoInvalido');
    }
}

function ToUpperTrim(el)
{
    var aux = document.getElementById(el).value.SuperTrim().toUpperCase();
    
    document.getElementById(el).value = aux;
}

function FormataCPFCNPJ(el, tipo)
{
    var valor = document.getElementById(el).value;

    if (tipo == 'CPF')
    {
        if (valor.isCPF())
        {
            if (valor.length == 11)
            {
                document.getElementById(el).setAttribute('maxlength', 14);
                document.getElementById(el).value = valor.mask('###.###.###-##');
            }
            hide(el + 'Invalido');
        }
        else
        {
            //CPF invalido
            show(el + 'Invalido');
        }
    }
    else
    {
        if (valor.isCNPJ())
        {
            if (valor.length == 14)
            {
                document.getElementById(el).value = valor.mask('##.###.###/####-##');
            }
            hide(el + 'Invalido');
        }
        else
        {
            //CNPJ invalido
            show(el + 'Invalido');
        }
    }
}

function UpperText(el)
{
    document.getElementById(el).value = document.getElementById(el).value.SuperTrim().toUpperCase();
}

function TelefoneDDD(el)
{
    var aux = document.getElementById(el).value;
    if (aux.length != 2)
    {
        show(el + 'Invalido');
    }
    else
    {   
        hide(el + 'Invalido');
    }
}

function TelefoneNumero(el)
{
    var aux = document.getElementById(el).value;
    if (aux.length < 7)
    {
        show(el + 'Invalido');
    }
    else
    {
        if (aux.length == 7)
        {
            document.getElementById(el).value = document.getElementById(el).value.mask('###-####');
        }
        else
        {
            document.getElementById(el).value = document.getElementById(el).value.mask('####-####');
        }
        hide(el + 'Invalido');
    }
}

function MascaraTelefone(el)
{
    var aux = document.getElementById(el).value;

    if (aux.length == 7)
    {
        document.getElementById(el).value = document.getElementById(el).value.mask('###-####');
    }
    else
    {
        if (aux.length == 8)
        {
            document.getElementById(el).value = document.getElementById(el).value.mask('####-####');
        }
    }
}

function SomenteNumeros(el)
{
    var aux = document.getElementById(el).value;
    document.getElementById(el).value = aux.OnlyNumeric();
}

function RetiraEspacos(el)
{
    var aux = document.getElementById(el).value.SuperTrim();
    document.getElementById(el).value = aux;
}

function IsEmail(el)
{
    var aux = document.getElementById(el).value.IsEmail();
    
    if (aux == true)
    {
        hide('txtEmailInvalido');
    }
    else
    {
        show('txtEmailInvalido');
    }
}

function RetiraWWW(el)
{
    var aux = document.getElementById(el).value;
    
    if (aux.substring(0,4).toLowerCase() == 'www.')
    {
        document.getElementById(el).value = aux.substring(4, aux.length).toLowerCase();
    }
}

function IsDominio(el)
{
    var aux = document.getElementById(el).value.IsDominio();
    
    if (aux == true)
    {
        hide('txtDominioInvalido');
    }
    else
    {
        show('txtDominioInvalido');
    }
}

String.prototype.IsDominio = function(v)
{
    var RegEx = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/

    if (this.match(RegEx))
    {
        return true;
    }
    else
    {
        return false;
    }
}

String.prototype.IsEmail = function(v)
{
    var RegEx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/

    if (this.match(RegEx))
    {
        return true;
    }
    else
    {
        return false;
    }
}

String.prototype.OnlyNumeric = function(v)
{
    return this.replace(/[^\d]/g,'');
}

String.prototype.OnlyAlpha = function(v)
{
    //return this.replace(/[\d]/g,'');
    return this.replace(/[^a-zA-Z ]/g,'');
}

String.prototype.SuperTrim = function(v)
{
    var aux = this.split(' ');
    var retorno = '';
    for (var i = -1; ++i <= aux.length -1;)
    {
        var letra = aux[i].split('');
        if (letra[0] != undefined)
        {
            retorno = retorno + aux[i] + ' ';
        }
    }
    return retorno.trim(' ');
}


//FIM funcoes feitas por Marcelo Barbosa

/*********************************************
* Autor: Yuri Vecchi - 11 August 2005
* Site: Sem nenhum no momento...
* E-mail: yuriyoda 'arroba' gmail 'ponto' com
*********************************************/

String.prototype.rTrim = function (c){
    return this.replace(new RegExp("["+ (c == undefined ? " " : c) + "]+$", ""), "");
};

String.prototype.lTrim = function (c){
    return this.replace(new RegExp("^["+ (c == undefined ? " " : c) + "]+", ""), "");
};

String.prototype.trim = function (c){
    return this.lTrim(c).rTrim(c);
};

/*
**************************************
* String.mask Function v1.0          *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
String.prototype.mask = function(m) {
    var m, l = (m = m.split("")).length, s = this.split(""), j = 0, h = "";
    for(var i = -1; ++i < l;)
        if(m[i] != "#"){
            if(m[i] == "\\" && (h += m[++i])) continue;
            h += m[i];
            i + 1 == l && (s[j - 1] += h, h = "");
        }
        else{
            if(!s[j] && !(h = "")) break;
            (s[j] = h + s[j++]) && (h = "");
        }
    return s.join("") + h;
};

/*
**************************************
* String.isCPF Function v1.0         *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
String.prototype.isCPF = function(){
    var c = this;
    if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
    if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
    for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    return true;
};

/*
**************************************
* String.isCNPJ Function v1.0         *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
String.prototype.isCNPJ = function(){
    var b = [6,5,4,3,2,9,8,7,6,5,4,3,2], c = this;
    if((c = c.replace(/[^\d]/g,"").split("")).length != 14) return false;
    for(var i = 0, n = 0; i < 12; n += c[i] * b[++i]);
    if(c[12] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    for(var i = 0, n = 0; i <= 12; n += c[i] * b[i++]);
    if(c[13] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    return true;
};

/*
**************************************
* Restrict Class v1.0                *
* Autor: Carlos R. L. Rodrigues      *
* E-mail: rodrigolr@uol.com.br       *
**************************************
*/

//========================================================
// REQUIRES http://www.jsfromhell.com/geral/event-listener
//========================================================

Restrict = function(form){
    this.form = form, this.field = {}, this.mask = {};
};
Restrict.field = Restrict.inst = Restrict.c = null;
Restrict.prototype.start = function(){
    var $, __ = document.forms[this.form], s, x, j, c, sp, o = this;
    var p = {".":/./, w:/\w/, W:/\W/, d:/\d/, D:/\D/, s:/\s/, a:/[\xc0-\xff]/, A:/[^\xc0-\xff]/};
    for(var _ in $ = this.field)
        if(/text|textarea|password/i.test(__[_].type)){
            x = $[_].split(""), c = j = 0, sp, s = [[],[]];
            for(var i in x){
                if(x[i] == "\\" || sp){
                    if(sp = sp ? 0 : 1) continue;
                    s[j][c++] = p[x[i]] || x[i];
                }
                else if(x[i] == "^") c = (j = 1) - 1;
                else s[j][c++] = x[i];
            }
            __[_].pt = s;
            addEvent(__[_], "keydown", function(e){
                var r = Restrict.field = e.target;
                if(!o.mask[r.name]) return;
                r.l = r.value.length;
                Restrict.inst = o; Restrict.c = e.key;
                setTimeout(o.onchanged, r.e = 1);
            });
            addEvent(__[_], "keyup", function(e){
                (Restrict.field = e.target).e = 0;
            });
            addEvent(__[_], "keypress", function(e){
                o.restrict(e) || e.preventDefault();
            });
            addEvent(__[_], "keypress", function(e){
                var r = Restrict.field = e.target;
                if(!o.mask[r.name]) return;
                if(!r.e){
                    r.l = r.value.length;
                    Restrict.inst = o; Restrict.c = e.key || 0;
                    setTimeout(o.onchanged, 1);
                }
            });
        }
};
Restrict.prototype.restrict = function(e){
    var o, c = e.key, n = (o = e.target).name, r;
    var has = function(c, r){
        for(var i in r)
            if(r[i] instanceof RegExp){
                if(r[i].test(c)) return true;
            }
            else if(r[i] == c) return true;
        return false;
    }
    var inRange = function(c){
        return has(c, o.pt[0]) && !has(c, o.pt[1]);
    }
    return (c < 30 || inRange(String.fromCharCode(c))) ?
        Boolean(this.onKeyAccept && this.onKeyAccept(o, c) || 1) :
        Boolean(this.onKeyRefuse && this.onKeyRefuse(o, c) && 0);
};
Restrict.prototype.onchanged = function(){
    var ob = Restrict, si, moz = false, o = ob.field, t, lt = (t = o.value).length, m = ob.inst.mask[o.name];
    if(o.l == o.value.length) return;
    if(si = o.selectionStart) moz = true;
    else if(o.createTextRange){
        var obj = document.selection.createRange(), r = o.createTextRange();
        if(!r.setEndPoint) return false;
        r.setEndPoint("EndToStart", obj); si = r.text.length;
    }
    else return false;
    for(var i in m = m.split(""))
        if(m[i] != "#")
            t = t.replace(m[i] == "\\" ? m[++i] : m[i], "");
    var j = 0, h = "", l = m.length, ini = si == 1, t = t.split("");
    for(i = 0; i < l; i++)
        if(m[i] != "#"){
            if(m[i] == "\\" && (h += m[++i])) continue;
            h += m[i];
            i + 1 == l && (t[j - 1] += h, h = "");
        }
        else{
            if(!t[j] && !(h = "")) break;
            (t[j] = h + t[j++]) && (h = "");
        }
    o.value = o.maxLength > -1 && o.maxLength < (t = t.join("")).length ? t.slice(0, o.maxLength) : t;
    if(ob.c && ob.c != 46 && ob.c != 8){
        if(si != lt){
            while(m[si] != "#" && m[si]) si++;
            ini && m[0] != "#" && si++;
        }
        else si = o.value.length;
    }
    if(!moz){
        obj.move("character", si);
        obj.select();
    }
    else o.setSelectionRange(si, si);
};

/*
**************************************
* Event Listener Function v1.3       *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/

addEvent = function(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a;
    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(f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? a.call(o, e) : (o._ = a, o._(e), o._ = null)));
        e = null;
    }
};

removeEvent = function(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;
};