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);

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; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function redimensiona_tabela_principal()
{
	//document.getElementById('conteudo').width  = document.body.clientWidth;
	//alert(document.body.clientHeight);
	document.getElementById('conteudo').height = document.body.clientHeight;
}

function redimensiona_div( id, offset )
{	
	//alert(document.body.clientHeight);
	altura = document.body.clientHeight - offset +"px"; //alert(altura);
	if( document.getElementById(id) )
		document.getElementById(id).style.height = altura;
	return true;
}

function repos_div_left( id, offset )
{
	posicao = document.body.clientWidth - offset;
	if( document.getElementById(id) )
		document.getElementById(id).style.left = posicao + "px";
	return true;	
		
}

function redim_div_width( id, offset )
{
	//alert(document.body.clientWidth);
	largura = document.body.clientWidth - offset +"px"; //alert(id+largura);
	if( document.getElementById(id) )
		document.getElementById(id).style.width = largura;
	return true;
}

function redim_img_width( id, offset )
{
	largura = (document.body.clientWidth - offset) / 2;
	if( document.getElementById(id) )
		document.getElementById(id).width = largura;
	return true;	
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		menu_01_over = newImage("/images/menu_01-over.gif");
		menu_02_over = newImage("/images/menu_02-over.gif");
		menu_03_over = newImage("/images/menu_03-over.gif");
		menu_04_over = newImage("/images/menu_04-over.gif");
		menu_05_over = newImage("/images/menu_05-over.gif");
		preloadFlag = true;
	}
}

function mascara( campo, mascara, posicao )
{
	var c = campo.value.length;
	if( c == posicao )
	{
		campo.value += mascara;
	}
}


function getkey(e)
{
	if (window.event)
		 return window.event.keyCode;
	else if (e)
		 return e.which;
	else
		 return null;
}

function goodchars( e, goods )
{
	var key, keychar;
	key = getkey(e);
	if (key == null)
		return true;
	
	// get character
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods   = goods.toLowerCase();
	
	// check goodkeys
	if( goods.indexOf( keychar ) != -1 )
		return true;
	
	// control keys
	if( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
	
	return false;
}


