function getScrollY () 
{
	var scrollY = 0;    
	if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop)
		scrollY = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		scrollY = document.body.scrollTop; 
	else if (window.scrollY) scrollY = window.scrollY;
	return scrollY;
}

function PegaPosY() 
{
	var objPosY = MM_findObj("posY");
	if (objPosY != null){
		objPosY.value = getScrollY();
	}
}

function confirma () {
  if (confirm('Confirma a exclusão?')) {
    return true;
  }else{
    return false;
  }
}

function subMenu(id, nivel){
  if (document.getElementById(id).style.display == 'none') {
	document.getElementById(id).style.display = 'inline';
	document.getElementById("img"+id).src = nivel + '../_imagens/estruturaPrincipal/icoMenuMenos.gif';
  } else {
	document.getElementById(id).style.display = 'none';
	document.getElementById("img"+id).src = nivel + '../_imagens/estruturaPrincipal/icoMenuMais.gif';
  }
}

function over(id){
  document.getElementById(id).className = 'mouseOver';
}

function out(id){
  document.getElementById(id).className = 'mouseOut';
}


function filtroLayout(combo){
  document.location.href=combo[combo.selectedIndex].value;
}


function abrir() {
	var windowFeatures = "", nomeArquivo = "", nomeJanela = "", erro = null
	Argumentos = abrir.arguments; noArgumentos = Argumentos.length; nomeArquivo = Argumentos[0]
	for (i = 1; i < noArgumentos; i++) {
		valor = Argumentos[i].substring(2,Argumentos[i].length)
		switch(Argumentos[i].substring(0,2)) {
			case "nj" : nomeJanela = valor; break
			case "to" : windowFeatures += "top=" + valor + ", "; break
			case "le" : windowFeatures += "left=" + valor + ", "; break
			case "he" : windowFeatures += "height=" + valor + ", "; break
			case "wi" : windowFeatures += "width=" + valor + ", "; break
			case "lb" : windowFeatures += "location=" + valor + ", "; break
			case "mb" : windowFeatures += "menubar=" + valor + ", "; break
			case "sc" : windowFeatures += "scrollbars=" + valor + ", "; break
			case "st" : windowFeatures += "status=" + valor + ", "; break
			case "tb" : windowFeatures += "toolbar=" + valor + ", "; break
			case "tt" : windowFeatures += "titlebar=" + valor + ", "; break
			case "re" : windowFeatures += "resizable=" + valor + ", "; break
			default : erro = '"Código de atributo não informado no '+(i+1)+' º argumento (' +Argumentos[i]+ ')"'
		}
	}
	windowFeatures = windowFeatures.substring(0,windowFeatures.lastIndexOf(","))
	if (erro) { alert(erro) } else { novaJanela = window.open(nomeArquivo, nomeJanela, windowFeatures) }
}

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_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

var divName = 'lAtualizando';
var offX = -8;
var offY = -8;

function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}


var arObjCalendarios = null;
function itemCalendario (IdCampo, IdBotao)
{
	this.ppIdCampo = IdCampo;
	this.ppIdBotao = IdBotao;
}

function ExecutaAnimacao(evt) {
	$get('lAtualizando').visibility = 'visible';
	$get('lAtualizando').style.left = (parseInt(mouseX(evt))+offX) + 'px';
	$get('lAtualizando').style.top = (parseInt(mouseY(evt))+offY) + 'px';
	$get('lAtualizando').style.display='block';
}
	
function AtivaAnimacao() {
	document.onmousemove = ExecutaAnimacao;
}

function DesativaAnimacao() {
	document.onmousemove = null;
	$get('lAtualizando').style.display='none';
}

function setData(Objeto,teclapres) {
  var tecla = teclapres.keyCode;
  var vr = Objeto.value;  
  vr = vr.replace( "/", "" );  
  vr = vr.replace( "/", "" );
  vr = vr.replace( "/", "" );
  var tam = vr.length;

  var str = '';

  if( tecla != 9 && tecla != 8 && tecla != 37 && tecla != 39 && tecla != 46 ) {
    if( tam == 1 ) {
      str = vr.substr( 0, 1 );
    }
    if( tam == 2 ) { 
      str = vr.substr( 0, 2 ) + '/';
    }
    if( tam == 3 ) { 
      str = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 1 );
    }
    if( tam == 4 ) {      
      str = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/';
    } 
    if( tam > 4 ) {                
      str = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, tam - 4 );
    }
    Objeto.value = str.substr( 0, 10 );
  }
}

