// JavaScript Document
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_dmenu(objname) {
  var a=MM_dmenu.arguments;
  for (i=0; i<a.length; i++) {var obj = MM_findObj(a[i]); if(obj && obj.style) obj.style.display = ""; }
}

function MM_dmenuh() {
  var a=MM_dmenuh.arguments;
  for (i=0; i<a.length; i++) {var obj = MM_findObj(a[i]); if(obj && obj.style) obj.style.display = "none"; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  aditfeat = '';
  if (features.indexOf('width')!=-1) {
    temp = features.substring(features.indexOf('width')+6);
    w = temp.substring(0, temp.indexOf(','));
  }
  if (features.indexOf('height')!=-1) {
    temp = features.substring(features.indexOf('height')+7);
    h = (temp.indexOf(',')!=-1)?(temp.substring(0, temp.indexOf(','))):(temp);
  }
  if (features.indexOf('scrollbars=yes')!=-1) aditfeat = ',scrollbars=yes';
  if (features.indexOf('resizable')!=-1) aditfeat = aditfeat + ',resizable';
  
  wl = (screen.width - w) / 2;
  wt = (screen.height - h) / 2;
  featt = 'height='+h+',width='+w+',top='+wt+',left='+wl+aditfeat;
  window.open(theURL,winName,featt);
}

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

function FormataValor(input) {
	num = input.value.replace(/[^0-9]+/g,'').toString().split('').reverse().join('');
	tam = num.length;

	if (tam > 2) {
		numtemp = num.substring(0, 2) + ',' + num.substring(2,tam);
		num = numtemp;
		if (tam > 5) {
			numtemp = num.substring(0, 6) + '.' + num.substring(6, num.length);
			num = numtemp;
			if (tam > 8) {
				numtemp = num.substring(0, 10) + '.' + num.substring(10, num.length);
				num = numtemp;
				if (tam > 11) {
					numtemp = num.substring(0, 14) + '.' + num.substring(14, num.length);
					num = numtemp;
				}
			}
		}
	}
	input.value = num.toString().split('').reverse().join('');
}

// CENTRALIZA POPUPS
var version4 = (navigator.appVersion.charAt(0) == "4"); 
var popupHandle;
function closePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close();
}
function displayPopup(position,url,name,height,width,evnt) {
// position=1 POPUP: makes screen display up and/or left, down and/or right 
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center
var properties = "toolbar = 0, location = 0, height = " + height;
properties = properties + ", width=" + width;
var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
if(navigator.appName == "Microsoft Internet Explorer") {
screenY = document.body.offsetHeight;
screenX = window.screen.availWidth;
}
else {
screenY = window.outerHeight
screenX = window.outerWidth
}
if(position == 1)	{ // if POPUP not CENTER
cursorX = evnt.screenX;
cursorY = evnt.screenY;
padAmtX = 10;
padAmtY = 10;
if((cursorY + height + padAmtY) > screenY) {
// make sizes a negative number to move left/up
padAmtY = (-30) + (height * -1);
// if up or to left, make 30 as padding amount
}
if((cursorX + width + padAmtX) > screenX)	{
padAmtX = (-30) + (width * -1);	
// if up or to left, make 30 as padding amount
}
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = cursorX + padAmtX;
topprop = cursorY + padAmtY;
}
else {
leftprop = (cursorX - pageXOffset + padAmtX);
topprop = (cursorY - pageYOffset + padAmtY);
   }
}
else{
leftvar = (screenX - width) / 2;
rightvar = (screenY - height) / 2;
if(navigator.appName == "Microsoft Internet Explorer") {
leftprop = leftvar;
topprop = rightvar;
}
else {
leftprop = (leftvar - pageXOffset);
topprop = (rightvar - pageYOffset);
   }
}
if(evnt != null) {
properties = properties + ", left = " + leftprop;
properties = properties + ", top = " + topprop;
}
closePopup();
popupHandle = open(url,name,properties);
}

function click() {
  if (event.button==2) {
    alert('Código fonte indisponível!')
  }
}
document.onmousedown=click