function VerificaDisponibilidade() {
	var dominio;
	
	if(getE('dominio_prefixo').value == '' || getE('dominio_sufixo').value == '') {
		alert('Você deve preencher o campo respectivo ao domínio para poder fazer a verificação!')
		return;
	}
	
	dominio = getE('dominio_prefixo').value + '.' + getE('dominio_sufixo').value;
	
	setVerificaDisponibilidade('Verificando disponibilidade do domínio. Aguarde ...', '#000000');
	
	ajaxGet("http://www.plugzone.com.br/ContratarHospedagem/ajax=true&dominio="+dominio, function () {
		if(ajaxLastResult == 'ERRO') {
			setVerificaDisponibilidade('Domínio inválido!', '#FF0000');
			getE('dominio_tipo_registrar').disabled = true;
			getE('dominio_tipo_registrado').disabled = true;
		}
		if(ajaxLastResult == 'DISPONIVEL') {
			setVerificaDisponibilidade('Domínio disponível para registro.', '#008800');
			getE('dominio_tipo_registrar').disabled = null;
			getE('dominio_tipo_registrado').disabled = null;
		}
		if(ajaxLastResult == 'INDISPONIVEL') {
			setVerificaDisponibilidade('Este domínio já foi registrado e não está disponível!', '#FF0000');
			getE('dominio_tipo_registrar').disabled = true;
			getE('dominio_tipo_registrado').disabled = null;
		}
	} );
}
function setVerificaDisponibilidade(txt, color) {
	getE('AjaxButton').value = txt;
	getE('AjaxButton').style.color = color;
}
function resetVerificaDisponibilidade() {
	getE('AjaxButton').value = 'Verificar disponibilidade';
	getE('AjaxButton').style.color = '#000000';
	
	getE('dominio_tipo_registrar').disabled = true;
	getE('dominio_tipo_registrar').checked = null;
	getE('dominio_tipo_registrado').checked = null;
}
// STEPS
function Step1() {
	getE('Step1').style.display = '';
	getE('Step2').style.display = 'none';
	getE('Step3').style.display = 'none';
}
function Step2() {
	if(getE('dominio_prefixo').value == ''){
		alert('Você deve escolher um domínio para adquirir a hospedagem!');
		return;
	}
	if( !isChecked(getE('dominio_tipo_registrar')) && !isChecked(getE('dominio_tipo_registrado')) ) {
		alert('Você deve escolher se quer que a PluGzOne gerencie o domínio ou não.');
		return;
	}
	
	getE('Step1').style.display = 'none';
	getE('Step2').style.display = '';
	getE('Step3').style.display = 'none';
	
	getE('mioloInter_top').style.height = '';
	getE('mioloInter_bottom').style.height = '';
	getE('FundoEsquerda').style.height = '';
	getE('FundoDireita').style.height = '';
	getE('FundoEsquerdaChild').style.height = '';
	getE('FundoDireitaChild').style.height = '';
	
	fixCssHeight();
	
	resetPagamento();
}
function resetPagamento() {
	if(getE('plano').value == 'br_redirecionamento' || getE('plano').value == 'us_basico') {
		getE('pagamento_frequencia_mensal').disabled = true;
		getE('pagamento_frequencia_trimestral').disabled = true;
		getE('pagamento_frequencia_semestral').disabled = true;
		getE('pagamento_frequencia_mensal').checked = null;
		getE('pagamento_frequencia_trimestral').checked = null;
		getE('pagamento_frequencia_semestral').checked = null;	
		getE('pagamento_frequencia_anual').checked = true;
		getE('pagamento_tipo_deposito').disabled = true;
		getE('pagamento_tipo_deposito').checked = null;		
		getE('pagamento_tipo_boleto').checked = true;
	} else {
		getE('pagamento_frequencia_mensal').disabled = null;
		getE('pagamento_frequencia_trimestral').disabled = null;
		getE('pagamento_frequencia_semestral').disabled = null;
		getE('pagamento_tipo_deposito').disabled = null;
	}
}
function Step3() {
	// valida
	if(getE('plano').value == ''){
		alert('Você deve escolher um Plano de Hospedagem antes de prosseguir.');
		return;
	}
	if( !isChecked(getE('pagamento_tipo_boleto')) ) {
		if( !isChecked(getE('pagamento_tipo_deposito')) ) {
			alert('Você deve escolher o Método de Pagamento antes de prosseguir.');
			return;
		}
	}
	if( !isChecked(getE('pagamento_frequencia_mensal')) ) {
		if( !isChecked(getE('pagamento_frequencia_trimestral')) ) {
			if( !isChecked(getE('pagamento_frequencia_semestral')) ) {
				if( !isChecked(getE('pagamento_frequencia_anual')) ) {
					alert('Você deve escolher a Frequência de Pagamento antes de prosseguir.');
					return;
				}
			}
		}
	}/*
	// prepara formulário
	if(getE('dominio_sufixo').value.indexOf('br') != -1 && isChecked(getE('dominio_tipo_registrar')) && getE('dominio_sufixo').value != 'nom.br') {
		getE('dados_tipo_pf').disabled = true;
		getE('dados_tipo_pf').checked = null;
		getE('dados_tipo_pj').checked = true;
	} else {
		getE('dados_tipo_pf').disabled = null;
	}/**/
	
	resetForm();
		
	getE('Step1').style.display = 'none';
	getE('Step2').style.display = 'none';
	getE('Step3').style.display = '';
	
	getE('mioloInter_top').style.height = '';
	getE('mioloInter_bottom').style.height = '';
	getE('FundoEsquerda').style.height = '';
	getE('FundoDireita').style.height = '';
	getE('FundoEsquerdaChild').style.height = '';
	getE('FundoDireitaChild').style.height = '';
	
	fixCssHeight();
}
var form_isPJ = false;
function resetForm() {
	if( isChecked(getE('dados_tipo_pf')) ) {
		getE('DadosPF').style.display = '';
		getE('DadosPJ').style.display = 'none';
		form_isPJ = false;
	} else {
		if( isChecked(getE('dados_tipo_pj')) ) {
			getE('DadosPF').style.display = '';
			getE('DadosPJ').style.display = '';
			form_isPJ = true;
		} else {
			getE('DadosPF').style.display = 'none';
			getE('DadosPJ').style.display = 'none';
		}
	}
	
	getE('mioloInter_top').style.height = '';
	getE('mioloInter_bottom').style.height = '';
	getE('FundoEsquerda').style.height = '';
	getE('FundoDireita').style.height = '';
	getE('FundoEsquerdaChild').style.height = '';
	getE('FundoDireitaChild').style.height = '';
	
	fixCssHeight();
}

var Errata = new Array();
function CheckOut() {	
	
		// form check		
		var Error = "Antes de continuar você deve:";
		var Last = new Array();
		/*var*/ First = "nenhum";
		var Num = 1;
		var Cont = 0;
		var ErrCor = '#FFFFFF';
		
		for (var i = 0; i < Errata.length; i++)
			{
				document.getElementById(Errata[i]).style.background = ErrCor;
			}		
		
		if(form_isPJ) {
			if(document.contratar_checkout.cnpj.value == "" || verificaCNPJ(document.contratar_checkout.cnpj) == false)
				{
					Error += "\n"+Num+++") Preencher o campo CNPJ com um CNPJ válido";
					Last[Cont++] = 'cnpj';
					if(First == "nenhum")
						{
							First = document.contratar_checkout.cnpj;
						}
				}
			if(document.contratar_checkout.razao.value == "")
				{
					Error += "\n"+Num+++") Preencher o campo Nome Completo";
					Last[Cont++] = 'razao';
					if(First == "nenhum")
						{
							First = document.contratar_checkout.razao;
						}
				}
			if(document.contratar_checkout.responsavel.value == "")
				{
					Error += "\n"+Num+++") Preencher o campo Responsável";
					Last[Cont++] = 'responsavel';
					if(First == "nenhum")
						{
							First = document.contratar_checkout.responsavel;
						}
				}
		}
		
		if(document.contratar_checkout.cpf.value == "" || verificaCPF(document.contratar_checkout.cpf) == false)
			{
				Error += "\n"+Num+++") Preencher o campo CPF com um CPF válido";
				Last[Cont++] = 'cpf';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.cpf;
					}
			}
		if(document.contratar_checkout.nome.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Nome Completo";
				Last[Cont++] = 'nome';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.nome;
					}
			}
		if(document.contratar_checkout.nascimento.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Data de Nascimento";
				Last[Cont++] = 'nascimento';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.nascimento;
					}
			}
		if(document.contratar_checkout.email.value.indexOf("@") == -1 || document.contratar_checkout.email.value.indexOf(".") == -1 || document.contratar_checkout.email.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo E-mail com um e-mail válido";
				Last[Cont++] = 'email';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.email;
					}
			}
		if(isNaN(document.contratar_checkout.cep.value) || document.contratar_checkout.cep.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo CEP somente com números";
				Last[Cont++] = 'cep';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.cep;
					}
			}
		if(document.contratar_checkout.endereco.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Endereço Completo";
				Last[Cont++] = 'endereco';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.endereco;
					}
			}
		if(document.contratar_checkout.bairro.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Bairro";
				Last[Cont++] = 'bairro';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.bairro;
					}
			}
		if(document.contratar_checkout.cidade.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Cidade";
				Last[Cont++] = 'cidade';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.cidade;
					}
			}
		if(document.contratar_checkout.estado.value == "")
			{
				Error += "\n"+Num+++") Selecionar algum item na caixa de seleção Estado";
				Last[Cont++] = 'estado';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.estado;
					}
			}
		if(isNaN(document.contratar_checkout.ddd.value) || document.contratar_checkout.ddd.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo DDD somente com números";
				Last[Cont++] = 'ddd';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.ddd;
					}
			}
		if(isNaN(document.contratar_checkout.telefone.value) || document.contratar_checkout.telefone.value == "")
			{
				Error += "\n"+Num+++") Preencher o campo Telefone somente com números";
				Last[Cont++] = 'telefone';
				if(First == "nenhum")
					{
						First = document.contratar_checkout.telefone;
					}
			}
		
		if(Error != "Antes de continuar você deve:")
			{ 
 				alert(Error);
				try { First.focus(); }
				catch(e) { ; }
				for (var i = 0; i < Last.length; i++)
					{
						Errata[i] = Last[i];
						document.getElementById(Last[i]).style.backgroundColor = '#FFFDBB';
						document.getElementById(Last[i]).style.background = '#FFFDBB';
					}
				return false;
			}
		else
			{
				return true;
			}
	}
