// JavaScript Document
//////////////////////////////////////////////////////////////////////////////////////
//Bloqueio do botao do mouse

/*document.oncontextmenu = function() {return false;} //Necessario para o Firefox
function right(e) {
	var btn;
	if (e.button && !document.layers) {
		btn = e.button;
	} else if (e.which) {
		btn = e.which;
		
	}
	if (btn == 3 || btn == 2 ) {
		alert("Não é permitido usar o botão direito do mouse!");
		return false;
	}
}*/


//Bloqueio do botao do mouse
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//Bloqueio F5 / CTRL / ALT / seta esq / seta dir
//alt = 18
//ctrl = 17
//seta esq = 37
//seta dire = 39
//f5 = 116
/*function blockKeys(e) { //F5 nao eh bloqueado no IE7
	var key = e.keyCode;
	if ( key == 17 || key == 18 || key == 37 || key == 39 /*|| key == 116 ) {
		alert("Tecla Bloqueada!!");
		e.preventDefault();
		return false;
	}
}*/

//Bloqueio ALT / seta esq / seta dir -IE
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////

/*Onload function*/
/*$(function() {
	$(document).keydown(blockKeys);
	$(document).mousedown(right);
});*/


//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Status msg no Netscape
window.defaultStatus = "--- [ CONSÓRCIO UNILESTE ] ---";
//window.status = "--- [ SAR - JULIO SIMÕES ] ---";
//Status msg
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------//
//Funcao mask utilizada para criar mascaras para campos

function mask(o,opt){
    v_obj=o
    v_opt=opt
    setTimeout("execMask()",1)
}

function execMask(){
    v_obj.value=doMask(v_opt, v_obj.value)
}

function doMask(option, value) {
	if (option == "id") {
		value = value.replace(/[^x\d]/g,"");
	} else {
		value = value.replace(/\D/g,"");
	}
	
	switch (option) {
		case "phone": // (11) 1111-1111
			value=value.replace(/^(\d{2})(\d)/g,"($1) $2");
    		value=value.replace(/(\d{4})(\d)/,"$1-$2");
		break;
		case "vox": // 1111-11
			value=value.replace(/^(\d{4})(\d)/g,"$1-$2");
		break;
		case "zipcode": // CEP: 11111-11
			value=value.replace(/^(\d{5})(\d)/g,"$1-$2");
		break;
		case "date": // 11/11/1111
			value=value.replace(/^(\d{2})(\d)/g,"$1/$2");
			value=value.replace(/(\d{2})(\d)/,"$1/$2");
		break;
		case "decimal": // ...111.111.111,11
			value = value.replace(/(\d)(\d{2})$/g, "$1,$2");
			value = value.replace(/(\d)(\d{3},\d{2})/g, "$1.$2");
			value = value.replace(/(\d)(\d{3}\.\d{3},\d{2})/g, "$1.$2");
		break;
		case "kilo": // ...1111,111
			value=value.replace(/(\d)(\d{3})$/g,"$1,$2");
		break;
		case "cpf": // 111.111.111-11
			value=value.replace(/^(\d{3})(\d)/g, "$1.$2");
			value=value.replace(/(\d{3})(\d)/, "$1.$2");
			value=value.replace(/(\d{3})(\d)/, "$1-$2");
		break;
		case "id": // RG: 11.111.111-1 || 11.111.111-x
			value=value.replace(/^(\d{2})(\d)/g, "$1.$2");
			value=value.replace(/(\d{3})(\d)/, "$1.$2");
			value=value.replace(/(\d{3})(\d|x)/, "$1-$2");
		break;
	}
	return value;
}
// Função utilizada para bloquear a digitação de caracteres que não sejam números
function noDigit( o ){
	var objVal = o.value;
	var objId = o.id;
	
    objVal=objVal.replace(/\D/g,"");  
    document.getElementById( objId ).value= objVal;  
}
//////////////////////////////////////////////////////////////////////////////////////
//Função para formatar números
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//Função números
function IsNumTel(obj,event)
{
    var str = obj.value;
    var Tecla = event.which;
    if(Tecla == null)
        Tecla = event.keyCode;

    //se nao for número nem parentesis ou espaço
    if ( Tecla < 48 || Tecla > 59 ){
        event.returnValue = false;
	alert("Somente números no campo Ramal!!")
        return false;
    }
    //event.returnValue = true;
    //return true;
}
//Função números
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Função para exibir msg na barra de status
//Não aparece a msg mas não mostra o link
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
//Função para exibir msg na barra de status
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Função para exibir data
{
	hoje = new Date()
	dia = hoje.getDate()
	dias = hoje.getDay()
	mes = hoje.getMonth()
	ano = hoje.getYear()

	if (ano < 2000)    // Y2K Fix, Isaac Powell
		ano = ano + 1900; 		
		if (dia < 10)
			dia = "0" + dia

	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"
}

function escreveData(){
	document.write (dia + " de " + NomeMes[mes] + " de " + ano)
}

function escreveDia (){
	document.write (NomeDia[dias])
}
//Função para exibir data
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//Função para exibir bom dia, tarde e noite
var hoje = new Date();
var hours = hoje.getHours();
var saudacao = '';
if (hours >=0 && hours <12){
saudacao = "Bom dia"};
if(hours >=12 && hours <18){
	saudacao = "Boa tarde"};
//if(hours >18 && hours <=23){
if(hours >=18){
	saudacao = "Boa noite";};
function escreveSaudacao(){
	document.write (saudacao)
}
//Função para exibir bom dia, tarde e noite
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Funções Dreamweaver
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//Funções Dreamweaver
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Site
//////////////////////////////////////////////////////////////////////////////////////
//Iframe
function iframeAutoHeight(quem){
    //by Micox - elmicox.blogspot.com - elmicox.com - webly.com.br  
    if(navigator.appName.indexOf("Internet Explorer")>-1){ //ie sucks
        var func_temp = function(){
            var val_temp = quem.contentWindow.document.body.scrollHeight + 5
            quem.style.height = val_temp + "px";
        }
        setTimeout(function() { func_temp() },100) //ie sucks
    }else{
        var val = quem.contentWindow.document.body.parentNode.offsetHeight + 5
        quem.style.height= val + "px";
    }    
}
//Iframe
//////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////
//Funções ShowHide
function showHide(param){
   var trComum = document.getElementById("comum");
   var trVale = document.getElementById("vale");
   var trEscolar = document.getElementById("escolar");
   var trEspecial = document.getElementById("especial");
   var trSenior = document.getElementById("senior");
	if(param == "1"){
		trComum.style.display="";
		trVale.style.display="none";
		trEscolar.style.display="none";
		trEspecial.style.display="none";
		trSenior.style.display="none";
	}
	if(param == "2"){
		trComum.style.display="none";
		trVale.style.display="";
		trEscolar.style.display="none";
		trEspecial.style.display="none";
		trSenior.style.display="none";
	}
	if(param == "3"){
		trComum.style.display="none";
		trVale.style.display="none";
		trEscolar.style.display="";
		trEspecial.style.display="none";
		trSenior.style.display="none";
	}
	if(param == "4"){
		trComum.style.display="none";
		trVale.style.display="none";
		trEscolar.style.display="none";
		trEspecial.style.display="";
		trSenior.style.display="none";
	}
	if(param == "5"){
		trComum.style.display="none";
		trVale.style.display="none";
		trEscolar.style.display="none";
		trEspecial.style.display="none";
		trSenior.style.display="";
	}
}
//Funções ShowHide
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//Funções ShowHideBusca
function showHideBusca(param){
   var trBusca = document.getElementById("Busca");
   var trBuscaAvancada = document.getElementById("BuscaAvancada");
	if(param == "1"){
		trBusca.style.display="none";
		trBuscaAvancada.style.display="";
	}
}
//Funções ShowHideBusca
//////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////
//Funções ShowHideItinerário
function showHideItinerario(param) {
   var trInfo = document.getElementById("Info");
   var trInfoIda = document.getElementById("InfoIda");
   var trInfoVolta = document.getElementById("InfoVolta");
	if(param == "1"){
		trInfo.style.display="none";
		if(trInfoIda != null) trInfoIda.style.display="";
		if(trInfoVolta != null) trInfoVolta.style.display="";
	}
}
//Funções ShowHideBusca
//////////////////////////////////////////////////////////////////////////////////////
//Site
//////////////////////////////////////////////////////////////////////////////////////
