/*******************************************************************
*****                                                       *******
*****     Arquvio SCRIPTS.JS elaborado e codificado pela    *******
*****                   Equipe Univelox                     *******
*****                 www.univelox.com.br                   *******
*****         Fabio Bugança - buganca@gmail.com             *******
*****                                                       *******
*****                                                       *******
*****     Este arquivo poderá ser utilizado para fins       *******
*****     comerciais ou não desde que sejam mantidos        *******
*****     os devidos créditos, preservando assim, o         *******
*****     conteúdo intelectual nele contido.                *******
*****                                                       *******
*****                                    Equipe Univelox    *******
*****                                                       *******
*******************************************************************/

// constantes
site = "http://www.migtelecom.com.br/";

// Escrever data do dia na página
	hoje = new Date();
    dia = hoje.getDate();
    dias = hoje.getDay();
    mes = hoje.getMonth();
    ano = hoje.getYear();
	horas = hoje.getHours();
	minutos = hoje.getMinutes();
	cumprimento = new String();
		
	if(hoje.getMinutes() < 10){ 
		pad = "0";}
		else 
		pad = "";
	if((hoje.getHours() >=6) && (hoje.getHours() <=9)){ 
		cumprimento = "Bom dia!";
		}
	if((hoje.getHours() >=10) && (hoje.getHours() <=11)){
		cumprimento = "Bom dia!";
		}
	if((hoje.getHours() >=12) && (hoje.getHours() <=17)){
		cumprimento = "Boa tarde!";
		} 
	if((hoje.getHours() >=18) && (hoje.getHours() <=23)){
		cumprimento = "Boa noite!";
		}
	if((hoje.getHours() >=0) && (hoje.getHours() <=3)){
		cumprimento = "Bom dia!";
		}
	if((hoje.getHours() >=4) && (hoje.getHours() <=5)){
		cumprimento = "Bom dia!";
		}

    if (dia < 10)
                dia = "0" + dia;

    if (ano < 2000)
                ano = "19" + ano;

function CriaArray (n) {
	this.length = n }

    NomeDia = new CriaArray(7)
	NomeDia[0] = "Domingo";
	NomeDia[1] = "Segunda-feira";
	NomeDia[2] = "Ter&ccedil;a-feira";
	NomeDia[3] = "Quarta-feira";
	NomeDia[4] = "Quinta-feira";
	NomeDia[5] = "Sexta-feira";
	NomeDia[6] = "S&aacute;bado";

    NomeMes = new CriaArray(12)
	NomeMes[0] = "janeiro";
	NomeMes[1] = "fevereiro";
	NomeMes[2] = "mar&ccedil;o";
	NomeMes[3] = "abril";
	NomeMes[4] = "maio";
	NomeMes[5] = "junho";
	NomeMes[6] = "julho";
	NomeMes[7] = "agosto";
	NomeMes[8] = "setembro";
	NomeMes[9] = "outubro";
	NomeMes[10] = "novembro";
	NomeMes[11] = "dezembro"

//função para exibir a data na página.

function exibeData()
{
	if (ano == '19107') 
 		ano = '2007';
	document.write (cumprimento + " Hoje é " + NomeDia[dias]  + ", " + dia + " de " + NomeMes[mes] + " de " + ano + ".");
}// Fecha exibeData


function validaEmail( email )
{
	
	result = false;
	result = ( email != null );
	result = result && ( email.indexOf("@") != -1 );
	result = result && ( email.lastIndexOf(".") > email.indexOf( "@" ) );
	return result;
	
}// fecha a função validaEmail(email)

function openPagePHP ( id )
{

	pagina = site + "news/popup.php?id=" + id;
	window.open(pagina,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,height=350, width=500');

}// fecha open page php

function validador()
{
	
	var nome = document.formContato.nome.value;
	var email = document.formContato.email.value;
	var departamento = document.formContato.depto.value;
	var msg = document.formContato.msg.value;

	
	if ( nome == "" )
		{
			alert ("Por favor, preencha corretamente o campo NOME.");
			document.formContato.nome.focus();
		}
		else if ( !validaEmail(email) )
				{
					alert ("Por favor, preencha corretamente o campo E-MAIL.");
					document.formContato.email.focus();
				}
				else if ( departamento == "" )
						{
							alert ("Por favor, preencha corretamente o campo DEPARTAMENTO.");
							document.formContato.depto.focus();
						}
						else if ( msg == "" )
								{
									alert ("Por favor, preencha corretamente o campo MENSAGEM.");
									document.formContato.msg.focus();	
								}
								else
									{
										document.formContato.submit();
									}

}// fecha função validador()


function validaLogin()
{

	var user = document.forms[0].user.value;
	var senha = document.forms[0].senha.value;
	
	if ( user == "" )
		{
			alert ("Digite um nome de usuário!");
			document.forms[0].user.focus();
			return false;
		}
		else if ( senha == "" )
						{
							alert ("Digite uma senha!");
							document.forms[0].senha.focus();
							return false;
						}
}// fecha função validaLogin()

function validaNews()
{
	
	// Associando valores do documento a variaveis da função validador() e validaEmail().
	var titulo = document.forms[0].titulo.value;
	var fonte = document.forms[0].fonte.value;
	var news = document.forms[0].news.value;

	
	if ( titulo == "" )
		{
			alert ("Por favor, preencha TÍTULO da notícia.");
			document.forms[0].titulo.focus();
		}
		else if ( fonte == "" )
				{
					alert ("Por favor, preencha a FONTE da sua notícia.");
					document.forms[0].cidade.focus();
				}
				else if ( news == "" )
						{
							alert ("Por favor, preencha o TEXTO da sua notícia.");
							document.forms[0].news.focus();	
						}
						else
							{
								document.forms[0].grava.value = true;
								document.forms[0].submit();
							}

}// fecha função validanews()


function validaCadastro()
{
if (document.cadastro.nome_cad.value == "")
	{
		alert ("Digite seu nome.");
		document.cadastro.nome_cad.focus();
		return false;
	}
	else if (document.cadastro.email_cad.value == "")
	{
		alert ("Digite seu email.");
		document.cadastro.email_cad.focus();
		return false;
	}
	else if (document.cadastro.tel_cad.value == "")
	{
		alert ("Digite seu telefone.");
		document.cadastro.tel_cad.focus();
		return false;
	}	
	else if (document.cadastro.cidade_cad.value == "")
	{
		alert ("Digite sua cidade.");
		document.cadastro.cidade_cad.focus();
		return false;
	}	
	else if (document.cadastro.login_cad.value == "")
	{
		alert ("Digite seu login.");
		document.cadastro.login_cad.focus();
		return false;
	}
} //fecha validacao de cadastro de usuarios

function abretempo()
	{
		window.open('http://www.glb.com.br/tempo_include/clima_pop.asp?Cod_Cidade=180&Cod_Est=11', 'Tempo',	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,height=420,width=600');
	}
	
function ajaxInit() {
var req;

try {
 req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
 try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(ex) {
  try {
   req = new XMLHttpRequest();
  } catch(exc) {
   alert("Esse browser não tem recursos para uso do Ajax");
   req = null;
  }
 }
}

return req;
} // Fecha AjaxInit

function setaCookie(servico,acao) {
 ajax = ajaxInit();
 if(ajax) {
   ajax.open("GET", "scriptAjax.php?servico=" + servico + "&acao=" +  acao, true);
   ajax.onreadystatechange = function() {
     if(ajax.readyState == 4) {
       if(ajax.status == 200) {
		   var resultado = ajax.responseText;
		   //alert ("js funcionando !!!!!!\n" + resultado);
		 Fabio = "Você é o Cara !!!";
       } else {
         alert(ajax.statusText);
       }
     }
   }
   ajax.send(null);
 }
} // fecha a funcao setaCookies() - Ajax

function saibaMais()
{
	window.open('saibamais.html','Univelox','scrollbars=no,width=300,height=310' ) ;
} // fecha function saiba mais

function navega(opt)
	{
		ajax = ajaxInit();
			if(ajax) 
				{
   					ajax.open("GET", "includes/selecionaConteudo.php?conteudo=" + opt, true);
   					ajax.onreadystatechange = function() {
     					if(ajax.readyState == 4) {
       						if(ajax.status == 200) {
		   						var resultado = ajax.responseText;
								var resultado1 = document.getElementById('conteudo');
		 						var resultado2 = resultado; //aki vai um ajax.responseText;
		 						resultado1.innerHTML = resultado2; //resultado1.innerHTML + '<br>' + resultado2;
									} 
										else 
											{
         										alert(ajax.statusText);
       										}
     								}
   							}
   							ajax.send(null);
 				}
	
	}
	
function validaLoginEmail()
{
	var user = document.login.login_username.value;
	var senha = document.login.secretkey.value;
	
	if ( user == "" )
		{
			alert ("Digite um nome de usuário!");
			document.login.login_username.focus();
			return false;
		}
		else if ( senha == "" )
						{
							alert ("Digite uma senha!");
							document.login.secretkey.focus();
							return false;
						}
}// fecha função validaLoginEmail()


function validaLoginCentral()
{
	
	var user = document.form_autentica.autentica[UserName].value;
	var senha = document.form_autentica.autentica[Password].value;
	
	if ( user == "" )
		{
			alert ("Digite um nome de usuário !!!");
			document.form_autentica.autentica[UserName].focus();
			return false;
		}
		else if ( senha == "" )
						{
							alert ("Digite uma senha !!!");
							document.form_autentica.autentica[Password].focus();
							return false;
						}
						else document.form_autentica.submit();
}// fecha função validaLoginCentral()

function validaAssineJa()
{
	
	var nome = document.formPlanos.nome.value;
	var email = document.formPlanos.email.value;
	var ender = document.formPlanos.endereco.value;
	var num = document.formPlanos.numero.value;
	var bairro = document.formPlanos.bairro.value;
	var cep = document.formPlanos.cep.value;
	var cidade = document.formPlanos.cidade.value;
	var telefone = document.formPlanos.telefone.value;
	var celular = document.formPlanos.celular.value;
	var plano = document.formPlanos.plano.value;
	var obs = document.formPlanos.obs.value;
	var acordo = document.formPlanos.acordo.value;
	
	var alerta = "Os seguintes campos estão faltando ou incorretos:\n";
	
	if ( nome == "" )
		{
			alerta = alerta + "Nome:\n";
		}
		
	if ( !validaEmail(email) )
		{
			alerta = alerta + "E-mail:\n";
		}
		
	if ( ender == "" )
		{
			alerta = alerta + "Endereço:\n";
		}	
	
	if ( num == "" )
		{
			alerta = alerta + "Número:\n";
		}
		
	if ( bairro == "" )
		{
			alerta = alerta + "Bairro:\n";
		}	
		
	if ( cep == "" )
		{
			alerta = alerta + "CEP:\n";
		}
		
	if ( telefone == "" )
		{
			alerta = alerta + "Telefone:\n";
		}
		
	if ( document.formPlanos.acordo.checked	== false )
		{
			alerta = alerta + "\nVocê deve estar de acordo com o contrato\nde prestação de serviços para proseguir.";	
		}
		
	if (alerta == "Os seguintes campos estão faltando ou incorretos:\n")
		{
			document.formPlanos.submit();
		}
		else 
			{
				alert (alerta);			
			}
		
}// fecha função validaAssineJa()

function detalhesPlanos()
{
	window.open('planos_detalhes.php', 'Planos', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,height=300,width=442');
} // fecha function detalhes dos planos

function fazNada()
{
	Fabio = "Essa função não faz nada";	
} // fecha funcao Faz Nada

function carregaValor()
{
	var plano = document.formPlanos.plano.value;
	
	if (document.formPlanos.velocidade[0].checked == true)
		{
			var velocidade = document.formPlanos.velocidade[0].value;
		} else if (document.formPlanos.velocidade[1].checked == true)
			{
				var velocidade = document.formPlanos.velocidade[1].value;
			} else if (document.formPlanos.velocidade[2].checked == true)
				{
					var velocidade = document.formPlanos.velocidade[2].value;
				}
	
	if ((plano == "UniLight - Noturno + Final de semana + feriados") && (velocidade == "100K"))
	{
		valor = "R$ 39,90";
	}
	else if ((plano == "UniLight - Noturno + Final de semana + feriados") && (velocidade == "200K"))
	{
		valor = "R$ 49,90";
	}
	else if ((plano == "UniLight - Noturno + Final de semana + feriados") && (velocidade == "300K"))
	{
		valor = "R$ 59,90";
	}
	
	if ((plano == "UniPlus - Internet 24 Horas") && (velocidade == "100K"))
	{
		valor = "R$ 58,00";
	}
	else if ((plano == "UniPlus - Internet 24 Horas") && (velocidade == "200K"))
	{
		valor = "R$ 68,00";
	}
	else if ((plano == "UniPlus - Internet 24 Horas") && (velocidade == "300K"))
	{
		valor = "R$ 98,00";
	}
	
	var resultado = valor;
	var resultado1 = document.getElementById('valorMensalidade');
	var resultado2 = resultado;
	resultado1.innerHTML = resultado2;	

} // Fecha Function Carrega Valor

function valorInstalacao(valor)
{
	var resultado = valor;
	var resultado1 = document.getElementById('Instalacao');
	var resultado2 = resultado;
	resultado1.innerHTML = resultado2;	
} // Fecha Function Valor Instalacao

function mesesFree(valor)
{
	var resultado = valor;
	var resultado1 = document.getElementById('mesesFree');
	var resultado2 = resultado;
	resultado1.innerHTML = resultado2;	
} // Fecha Function Valor Instalacao

// 2 proximas Funcoes do SquirrelMail
function squirrelmail_loginpage_onload() {
  document.login.js_autodetect_results.value = '1';
  var textElements = 0;
  for (i = 0; i < document.login.elements.length; i++) {
    if (document.login.elements[i].type == "text" || document.login.elements[i].type == "password") {
      textElements++;
      if (textElements == 1) {
        document.login.elements[i].focus();
        break;
      }
    }
  }
} // Fecha a function squirrelmail

// Aumentando e diminuindo tamanho da fonte na pagina
//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div' );

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
		if ( sz < 0 ) sz = 0;
			if ( sz > 6 ) sz = 6;
			startSz = sz;
				if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
					cEl.style.fontSize = szs[ sz ];
						for ( i = 0; i < tgs.length; i++ ) 
							{
								cTags = cEl.getElementsByTagName( tgs[ i ] );
									for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
							}
} // fecha aumento e diminuicao de fontes na pagina

function abreJanela()
{
	window.open('popup.html','Univelox','scrollbars=no,width=300,height=240' ) ;
} // fecha a functin Abre Janela

function validaPromocao()
{
	
	var nome = document.formcadastro.nome.value;
	var email = document.formcadastro.email.value;
	var telefone = document.formcadastro.telefone.value;
	var cidade = document.formcadastro.cidade.value;

	
	if ( nome == "" )
		{
			alert ("Por favor, preencha corretamente o campo NOME.");
			document.formcadastro.nome.focus();
		}
		else if ( !validaEmail(email) )
				{
					alert ("Por favor, preencha corretamente o campo E-MAIL.");
					document.formcadastro.email.focus();
				}
				else if ( telefone == "" )
						{
							alert ("Por favor, preencha corretamente o campo TELEFONE.");
							document.formcadastro.telefone.focus();
						}
						else if ( cidade == "" )
								{
									alert ("Por favor, preencha corretamente o campo CIDADE.");
									document.formcadastro.cidade.focus();	
								}
								else
									{
										document.formcadastro.submit();
									}

}// fecha função validaPromocao()

// Abaixo scripts para trabalhar com camadas
window.defaultStatus='Univelox - Internet Banda Larga';
refer='';
rexit=0;

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
// fim dos scripts de camadas, usados no popUp

function liberaCampo(id)
{

	
	if ( id == 1 )
		{
			if ( document.formContato.cliente.value == "sim" )
				{
					
					document.formContato.titular.disabled = false;
				}
				else
				{
					document.formContato.titular.disabled = true;
					document.formContato.titular.value = "";
					
				}
		}
		
} // Libera Campo

function abreDivSimples(div)
{
	if (document.getElementById(div).style.display == 'block')
	{
		document.getElementById(div).style.display = 'none';
		setaCookie(div,'ocultar');
	}
	else 
	{
		document.getElementById(div).style.display = 'block';
		setaCookie(div,'exibir')
	}
} // abreDivSimples