document.write('<script src="arquivos/jquery.js" type="text/javascript"></script>');
document.write('<script src="arquivos/cep.js" type="text/javascript"></script>');
document.write('<script src="arquivos/mascara_verificadores.js" type="text/javascript"></script>');
document.write('<script src="arquivos/xml_request.js" type="text/javascript"></script>');


function sub(secao){
	if($(secao).css("display")=="none"){
		$('#local ul').hide({height: 'toggle', opacity: 'toggle'},"slow");
		$(secao).animate({height: 'toggle', opacity: 'toggle'},"slow");
	}
	else{
		$(secao).animate({height: 'toggle', opacity: 'toggle'},"slow");
	}
}
function subJa(secao){
	$(secao).show();
}

function muda(oq){
	$(oq).toggle('fast');
}

function planos(mostra){
	if($(mostra).css("display")=="none"){
		$('#conteudo .detalhes_planos').hide();
		$(mostra).animate({height: 'toggle', opacity: 'toggle'},"slow");
	}
	else{
		$(mostra).animate({height: 'toggle', opacity: 'toggle'},"slow");
	}
}

function pgto(forma){

	// ajusta os botões de contratar

	if(forma == 'Anual'){

		document.getElementById('con1').href="contratar_host.php?plano=1&pgto=1";
		document.getElementById('con2').href="contratar_host.php?plano=2&pgto=4";
		document.getElementById('con3').href="contratar_host.php?plano=3&pgto=7";
		document.getElementById('con4').href="contratar_host.php?plano=4&pgto=10";
		document.getElementById('con5').href="contratar_host.php?plano=5&pgto=13";

	}else if(forma == 'Semestral'){

		document.getElementById('con1').href="contratar_host.php?plano=1&pgto=2";
		document.getElementById('con2').href="contratar_host.php?plano=2&pgto=5";
		document.getElementById('con3').href="contratar_host.php?plano=3&pgto=8";
		document.getElementById('con4').href="contratar_host.php?plano=4&pgto=11";
		document.getElementById('con5').href="contratar_host.php?plano=5&pgto=14";

	}else if(forma == 'Mensal'){

		document.getElementById('con1').href="contratar_host.php?plano=1&pgto=3";
		document.getElementById('con2').href="contratar_host.php?plano=2&pgto=6";
		document.getElementById('con3').href="contratar_host.php?plano=3&pgto=9";
		document.getElementById('con4').href="contratar_host.php?plano=4&pgto=12";
		document.getElementById('con5').href="contratar_host.php?plano=5&pgto=15";

	}

	valor = "#v" + forma;
	forma = "#" + forma;

	// ajusta os valores

	if($(valor).css("display")=="none"){
		$('#conteudo .valores').hide();
		$(valor).show();
		$('#conteudo #formas td').css("font-weight", "normal");
		$('#conteudo #formas td').css("background", "#F7F7F7");
		$(forma).css("background", "#fff1bf");
		$(forma).css("font-weight", "bolder");
	}
	else{
		$(valor).show();
		$('#conteudo #formas td').css("font-weight", "normal");
		$('#conteudo #formas td').css("background", "#F7F7F7");
		$(forma).css("background", "#fff1bf");
		$(forma).css("font-weight", "bolder");
	}
}

function definir_pgto(){

	d = document.form;

	if (d.plano.value == "Plano I"){
		d.pgto.length=3;
		d.pgto[0].text = "Anual - R$ 178,90";
		d.pgto[0].value = "1";
		d.pgto[1].text = "Semestral - R$ 77,40";
		d.pgto[1].value = "2";
		d.pgto[2].text = "Mensal - R$ 14,90";
		d.pgto[2].value = "3";
	}else if (d.plano.value == "Plano II"){
		d.pgto.length=3;
		d.pgto[0].text = "Anual - R$ 298,80";
		d.pgto[0].value = "4";
		d.pgto[1].text = "Semestral - R$ 167,40";
		d.pgto[1].value = "5";
		d.pgto[2].text = "Mensal - R$ 29,90";
		d.pgto[2].value = "6";
	}else if (d.plano.value == "Plano III"){
		d.pgto.length=3;
		d.pgto[0].text = "Anual - R$ 538,80";
		d.pgto[0].value = "7";
		d.pgto[1].text = "Semestral - R$ 287,40";
		d.pgto[1].value = "8";
		d.pgto[2].text = "Mensal - R$ 49,90";
		d.pgto[2].value = "9";
	}else if (d.plano.value == "Plano IV"){
		d.pgto.length=3;
		d.pgto[0].text = "Anual - R$ 778,80";
		d.pgto[0].value = "10";
		d.pgto[1].text = "Semestral - R$ 407,40";
		d.pgto[1].value = "11";
		d.pgto[2].text = "Mensal - R$ 69,90";
		d.pgto[2].value = "12";
	}else if (d.plano.value == "Plano V"){
		d.pgto.length=3;
		d.pgto[0].text = "Anual - R$ 1138,80";
		d.pgto[0].value = "13";
		d.pgto[1].text = "Semestral - R$ 587,40";
		d.pgto[1].value = "14";
		d.pgto[2].text = "Mensal - R$ 99,90";
		d.pgto[2].value = "15";
	}
}

function definir_pessoa() {

	tmp = document.forms['contratar'].pessoa.options[document.forms['contratar'].pessoa.selectedIndex].value;

	if (tmp == "Fisica") {

		$('.pFisica').show();
		$('.pJuridica').hide();

	}else if (tmp == "Juridica") {

		$('.pFisica').hide();
		$('.pJuridica').show();
	}
}

function mensal(){

	$('#taxa').hide();

	d = document.form;

	if ((d.pgto.value == "3") || (d.pgto.value == "6") || (d.pgto.value == "9") || (d.pgto.value == "12") || (d.pgto.value == "15")) {
		$('#taxa').show();
	}
}

function validaContrato(frm){

	d = document.form;

	if(d.pessoa.value == "Fisica"){

		nomedocampo = Array("dominio","nome","nascimento","cpf","rg","email","cep1","endereco1","numero","bairro1","cidade1","estado","fone");

		descricao = Array("Domínio","Nome","Nascimento","CPF","RG","E-mail","CEP","Endereço","Número","Bairro","Cidade","Estado","Telefone");

	}else if(d.pessoa.value == "Juridica"){


		nomedocampo = Array("dominio","rsocial","responsavel","cnpj","iEstadual","email","cep1","endereco1","numero","bairro1","cidade1","estado","fone");

		descricao = Array("Domínio","Razão Social","Responsável","CNPJ","Insc. Estadual","E-mail","CEP","Endereço","Número","Bairro","Cidade","Estado","Telefone");


	}else{
		return false;	
	}

	msgAlert = "Por favor complete os seguintes Campos:\n\n";
	msg = msgAlert.length;
	
	for (i = 0; i < nomedocampo.length; i++){
		objetos = frm.elements[nomedocampo[i]];
		if (objetos){
			switch(objetos.type){
			case "select-one":
				if (objetos.selectedIndex == -1 || 
					objetos.options[objetos.selectedIndex].text == ""){
					msgAlert += " - " + descricao[i] + "\n";
				}
				break;
			case "select-multiple":
				if (objetos.selectedIndex == -1){
					msgAlert += " - " + descricao[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (objetos.value == "" || objetos.value == null){
					msgAlert += " - " + descricao[i] + "\n";
				}
				break;
			default:
			}
			if (objetos.type == undefined){
				blnchecked = false;
				for (j = 0; j < objetos.length; j++){
					if (objetos[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					msgAlert += " - " + descricao[i] + "\n";
				}
			}
		}
	}
		if (msgAlert.length == msg){

			if (d.aceito.checked == false ){
				alert('Você deve confirmar que as informação são verdadeiras clicando na caixa Declaro que as informações acima...');
				return false;
			}else{
				document.form.submit();
			}

	}else{
		alert(msgAlert);
		return false;
	}
}

// INTERNET WIRELESS

function definir_wplano(){

	d = document.form;

	if (d.plano.value == "BLZ 200"){
		$('#valor').show();
		$("#valor").html("BLZ 200 - <s>R$ 55,45</s> Desconto de 10% para pagamento a vista: R$ 49,90");
		$("#f_vel").html("200");
		$("#f_val").html("R$ 55,45");

	}else if (d.plano.value == "BLZ 400"){
		$('#valor').show();
		$("#valor").html("BLZ 400 - <s>R$ 72,12</s> Desconto de 10% para pagamento a vista: R$ 64,90");
		$("#f_vel").html("400");
		$("#f_val").html("R$ 72,12");

	}else if (d.plano.value == "BLZ 600"){
		$('#valor').show();
		$("#valor").html("BLZ 600 - <s>R$ 88,78</s> Desconto de 10% para pagamento a vista: R$ 79,90");
		$("#f_vel").html("600");
		$("#f_val").html("R$ 88,78");	

	}else if (d.plano.value == "BLZ 800"){
		$('#valor').show();
		$("#valor").html("BLZ 800 - <s>R$ 99,89</s> Desconto de 10% para pagamento a vista: R$ 89,90");
		$("#f_vel").html("800");
		$("#f_val").html("R$ 99,89");	

	}else if (d.plano.value == "BLZ 1 Mega"){
		$('#valor').show();
		$("#valor").html("BLZ 1 Mega - <s>R$ 111,00</s> Desconto de 10% para pagamento a vista: R$ 99,90");
		$("#f_vel").html("1000");
		$("#f_val").html("R$ 111,00");

	}
}
function definir_kit(){

	d = document.form;

	if (d.kit.value == "USB"){
/*
		$('#p1').show();
		$('#p2').show();
*/
		definir_wplano();
		$('#valorKit').show();
		$("#valorKit").html("Custo de instalação R$ 150,00<br />Promoção: custo de equipamento R$ 0,00 (Em comodato).<br />Obs: o uso do kit USB depende de análise técnica para verificar o seu uso.");

	}else if (d.kit.value == "Radio"){

/*
		if((d.plano.value == "BLZ 200") || (d.plano.value == "BLZ 400")){
			document.form.plano.options[2].selected = "2";
			definir_wplano();
		}

		$('#p1').hide();
		$('#p2').hide();
*/
		definir_wplano();
		$('#valorKit').show();
		$("#valorKit").html("Custo de instalação R$ 270,00 a prazo, R$ 250,00 vista!<br />Promoção: custo de equipamento R$ 0,00 (Em comodato).");

	}
}

// CENTRAL

function definir_login(){

	d = document.form1;

	if (d.pessoa.value == "Fisica"){

		$('#cpf').show();
		$('#cnpj').hide();

	}else if (d.pessoa.value == "Juridica"){

		$('#cpf').hide();
		$('#cnpj').show();

	}
	
}