function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var isNav, isIE, indVisivel
var browser = navigator.appName

indVisivel = false;

// Descobre o browser
if (browser == "Microsoft Internet Explorer") { 
  isIE = true;
}
else {
  isNav = true;
} 


// Monitora teclas
  if (isIE) { 

    function alert_keycode(){

      // Se for CTRL + SHIFT + H mostra ou esconde o assistente
      if (event.keyCode == 8) {
        if (indVisivel == false) {
          Assistente.style.visibility='';
          indVisivel = true;
        }
        else{
          Assistente.style.visibility='hidden';
          indVisivel = false;
        }
      }

    }

    document.onkeypress=alert_keycode;
  }
  else {

    document.captureEvents(Event.KEYPRESS)

    function processkey(e){

      // Se for CTRL + SHIFT + H mostra ou esconde o assistente
      if (e.which == 8) {
	      if (indVisivel == false) {
          document.Assistente.visibility='show';
          indVisivel = true;
        }
        else{
          document.Assistente.visibility='hidden';     
          indVisivel = false;
        }
      }

    }

    document.onkeypress=processkey;
  }

// Funcao para mudar o texto do assitente

function mudaAssistente(strTexto) {

  if (strTexto == null) {
    strTexto = "Estou aqui para ajud&aacute;-lo durante sua navega&ccedil;&atilde;o.";
  }

  if (isIE) {
    TextoAssistente.innerHTML = '<font face="Verdana, Arial, Helvetica, sans-serif" size="1">'+strTexto+'</font>';
  }
  else {
    document.Assistente.document.TextoAssistente.document.write('<font face="Verdana, Arial, Helvetica, sans-serif" size="1">'+strTexto+'</font>');
    document.Assistente.document.TextoAssistente.document.close();
  }

}

/***************************/
/* Funções criadas por mim */
/***************************/


//-> Funções de data
	function cDate(){
		this.day;
		this.month;
		this.year;
		this.delimiter = "-";
		this.toYMD = toYMD;
		this.toDMY = toDMY;

	}

	function toYMD(){
		var D,M,Y,S;
		D = this.day;
		M = this.month;
		Y = this.year;
		S = this.delimiter;
		return (Y+S+M+S+D);
	}

	function toDMY(){
		var D,M,Y,S;
		D = this.day;
		M = this.month;
		Y = this.year;
		S = this.delimiter;
		return (D+S+M+S+Y);
	}



//-> Funções de data-hora
	function cDateHour(){
		this.day;
		this.month;
		this.year;
		this.hour;		
		this.delimiter = "-";
		this.delimiter1 = " ";		
		this.toYMDH = toYMDH;
		this.toDMYH = toDMYH;

	}

	function toYMDH(){
		var D,M,Y,H,S,B;
		D = this.day;
		M = this.month;
		Y = this.year;
		H = this.hour;
		B = this.delimiter;
		S = this.delimiter1;
		return (Y+B+M+B+D+S+H);
	}

	function toDMYH(){
		var D,M,Y,H,S,B;
		D = this.day;
		M = this.month;
		Y = this.year;
		H = this.hour;
		B = this.delimiter;
		S = this.delimiter1;
		return (D+B+M+B+Y+S+H);
	}




/*---------------------------------------*/
/* 		Classe de validação de Datas			 */	
/*---------------------------------------*/
function mDate(){
	this.strDay = "Favor preencha corretamente o valor do campo Dia."
	this.strMonth = "Favor preencha corretamente o valor do campo Mês."
	this.strYear = "Favor preencha corretamente o valor do campo Ano."
	this.error = false;
	this.lowerYear = 1899;
	this.day;
	this.month;
	this.year;
	this.objDay;
	this.objMonth;
	this.objYear;
	this.obr = false;
	this.sep = "/";
	this.printDate = printDMY;
	this.printDMY = printDMY;
	this.printMDY = printMDY;
	this.isYear = isYear;
	this.isMonth = isMonth;
	this.isDay = isDay;
	this.isDate = isDate;
	this.isNull = isNull;
	this.setDay = setDay;
	this.setMonth = setMonth;
	this.setYear = setYear;
	this.setDateDMY = setDateDMY;
	this.vetComp = new Array(2,4,1,4,3,4,3,4,4,3,4,3,4);
}

function printYMD(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = year+sep+month+sep+day;
	}
	return ret;
}

function printDMY(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = day+sep+month+sep+year;
	}
	return ret;
}

function printMDY(){
	var ret = "";
	with(this){
		if (isNull() && !this.obr) return ret;
		if (isDate())	ret = month+sep+day+sep+year;
	}
	return ret;
}

function isNull(){
	if (this.day == "" && this.month == "" && this.year == "") return true;
	return false;
}

function isYear(){
	if (this.year > this.lowerYear) return true;
	return false;
}

function isMonth(){
	if (this.month > 0 && this.month < 13) return true;
	return false;
}

function isDay(){
	var upperDays;
	if (Number(this.year)%Number(4) == 0 && Number(this.month) == 2){
		upperDays = Number(28)+Number(this.vetComp[0]);
	}else{
		upperDays = Number(28)+Number(this.vetComp[Number(this.month)]);
	}
	if (this.day > 0 && this.day < upperDays) return true;
	return false;
}

function isDate(){
	with(this){
		if (!isYear() ){
			objYear.focus();
			alert(strYear);
			objYear.value = "";
			error = true;
			return false;
		}
		if (!isMonth()){
			objMonth.focus();
			alert(strMonth);
			objMonth.value = "";
			error = true;
			return false;
		}
		if (!isDay()){
			objDay.focus();
			alert(strDay);
			objDay.value = "";
			error = true;
			return false;
		}
	}
	return true;
}

function setDay(objText){
	this.day = objText.value;
	this.objDay = objText;
	return;
}

function setMonth(objText){
	this.month = objText.value;
	this.objMonth = objText;
	return;
}

function setYear(objText){
	this.year = objText.value;
	this.objYear = objText;
	return;
}

function setDateDMY(objDay, objMonth, objYear){
	this.day = objDay.value;
	this.objDay = objDay;
	this.month = objMonth.value;
	this.objMonth = objMonth;
	this.year = objYear.value;
	this.objYear = objYear;
	return;
}


//-> Funções de string

	function estarVazio(objText){
	 	return !objText.value.match(/[a-zA-Z0-9]/g);
	}

	function serNumero(objText){
	 	return objText.value.match(/[0-9]/g);
	}
	
//-> Funções de conteudo

    function verInformacao(lcodArea, lcodItem){
      with(document.formConteudo){
				method = "get";
        action = "conteudo.php";
        codArea.value = lcodArea;
        codItem.value = lcodItem;
        if ( (lcodArea == 0 || lcodArea == -1) && (lcodItem == 0) ) {
          location.href='inicial.php'
        }else{
          submit();
        }
      }
      return;
    }


//-> Funções de conteudo

    function alterarMural(lcodArea){
      with(document.formConteudo){
        action='alterar_mural.php';
        codArea.value = lcodArea;
        submit();
      }
      return;
    }    
    
    function inserirItem(lcodArea){
      with(document.formConteudo){
        action='administracao/conteudo/principal.php';
        codArea.value = lcodArea;
        submit();
      }
      return;
    }        

//-> Função usada na gerencia das aplicações de conteudo

	function selecionarArea(strPaginaDestino, codAreaArg){
		with(document.form){
			codArea.value = codAreaArg;
			action = strPaginaDestino;
			submit();
		}
		return;
	}

function saltarCampo(campo_atual, event, tamanho_maximo, campo_proximo){
    var tecla;
    var vr;

    if (isNav)
        tecla = event.which;
    else
        tecla = event.keyCode;

    vr = campo_atual.value;
    tam = vr.length;

    if (tam >= tamanho_maximo && tecla >= 48)
        campo_proximo.focus();
}

	function retirarEspeciais(strEntrada){
		return strEntrada.replace(/\||;|'/g,"");
	}


 	function filtrarMaiusculas(evt){
	  if (isNav)
	    tecla = evt.which;
		else
	    tecla = evt.keyCode;
		if (tecla < 65){tecla = 0;}
		if (tecla > 123){tecla = 0;}
		if (tecla > 89 && tecla < 97){tecla = 0;}
		if (tecla > 96 && tecla < 123){tecla -= 32;}
	  if (isNav)
	    evt.which = tecla;
		else
	    evt.keyCode = tecla;
		return;
	}

 	function selecionarList(objList, numValor){
		var i;
		for(i=0; i < objList.length; i++){
			if(objList.options[i].value == numValor){
				objList.selectedIndex = i;
				return;
			}
		}
		return;
	}

 	function filtrarNumeros(evt){
	  if (isNav)
	    tecla = evt.which;
		else
	    tecla = evt.keyCode;
		if (tecla < 48 || tecla > 57){tecla = 0;}
	  if (isNav)
	    evt.which = tecla;
		else
	    evt.keyCode = tecla;
		return;
	}

   	function baixarArquivo(strIn){
		with(formConteudo){
			strNomeArquivo.value = strIn;
			action = "download.php"
			submit();
		}
		return;
	}
	
	function Item(name, subItens){
    	this.name = name;
    	this.subItens = subItens;
    }
    
    function subItem(value, name){
    	this.name = name;
    	this.value = value;
	}

	function trocarCombos2(strForm ,strListPai, strListFilho, arrDados)
    {
    	var i;
    	objListPai = eval("document."+ strForm +"."+ strListPai);
    	objListFilho = eval("document."+ strForm +"."+ strListFilho);
    	objListFilho.length = 0;
    	for(i = 0; i < arrDados[objListPai.value].subItens.length; i++){
    		tmpOption = new Option ();
    		tmpOption.text = arrDados[objListPai.value].subItens[i].name;
    		tmpOption.value = arrDados[objListPai.value].subItens[i].value;
    		objListFilho.options[i] = tmpOption;
    	}
    	objListFilho.selectedIndex = 0;
    	return;
    }
	
	function trocarCombos(strForm ,strListPai, strListFilho, arrDados)
    {
    	var i;
    	objListPai = eval("document."+ strForm +"."+ strListPai);
    	objListFilho = eval("document."+ strForm +"."+ strListFilho);
    	objListFilho.length = 0;
		//alert (arrDados.length);
    	for(i = 0; i < arrDados[objListPai.value].length; i++){
    		tmpOption = new Option ();
    		tmpOption.text = arrDados[objListPai.value][i].name;
    		tmpOption.value = arrDados[objListPai.value][i].value;
    		objListFilho.options[i] = tmpOption;
    	}
    	objListFilho.selectedIndex = 0;
    	return;
    }

