<!--inicio bloco javascript -->




<!-- inicio funcao TOOL TIP -->
	var offsetfromcursorX=15 //Customize x offset of tooltip
	var offsetfromcursorY=15 //Customize y offset of tooltip

	var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
	var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

	document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
	document.write('<img id="dhtmlpointer" src="images/arrow2.gif">') //write out pointer image

	var ie=document.all
	var ns6=document.getElementById && !document.all
	var enabletip=false
	if (ie||ns6)
	var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

	var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

	function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
	tipobj.innerHTML=thetext
	enabletip=true
	return false
	}
	}

	function positiontip(e){
	if (enabletip){
	var nondefaultpos=false
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
	var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

	var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
	var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

	var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<tipobj.offsetWidth){
	//move the horizontal position of the menu to the left by it's width
	tipobj.style.left=curX-tipobj.offsetWidth+"px"
	nondefaultpos=true
	}
	else if (curX<leftedge)
	tipobj.style.left="5px"
	else{
	//position the horizontal position of the menu where the mouse is positioned
	tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
	pointerobj.style.left=curX+offsetfromcursorX+"px"
	}

	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight){
	tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
	nondefaultpos=true
	}
	else{
	tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
	pointerobj.style.top=curY+offsetfromcursorY+"px"
	}
	tipobj.style.visibility="visible"
	if (!nondefaultpos)
	pointerobj.style.visibility="visible"
	else
	pointerobj.style.visibility="hidden"
	}
	}

	function hideddrivetip(){
	if (ns6||ie){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
	}
	}

	document.onmousemove=positiontip
<!-- final funcao TOOL TIP -->




<!-- inicio funcao alternate TABs -->
// return "id" object on all browsers
    function getObject(id) {
        if(document.getElementById) {
            obj = document.getElementById(id);
        }
        else if(document.all) {
            obj = document.all.item(id);
        }
        else {
            obj = null;
        }
        return obj;
    }
    // show "pane#" and set "tab#" as active
    function showTab(id) {
        hideTab();
        activeTab = id;
        getObject("tab" + id).className = "tabActive";
        getObject("pane" + id).className = "tabPaneActive";
    }
    // hide active pane
    function hideTab() {
        getObject("pane" + activeTab).className = "tabPane";
        getObject("tab" + activeTab).className = "tab";
    }
    // set initial tab
    activeTab = 1;
<!-- final funcao alternate TABs -->




<!-- inicio funcao hover menu IE6 -->
ie6Hover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" ie6hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" ie6hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", ie6Hover);
<!-- final funcao hover menu IE6 maldito -->




<!--inicio funcao show/hide layer // swap images -->
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_showHideLayers() { //v3.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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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_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_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];}
}
<!--final funcao show/hide layer -->




<!-- inicio funcao cria cookie -->
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
<!-- final funcao cria cookie -->




<!--inicio funcao abrir janelas -->
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
<!--final funcao abrir janelas -->




<!--inicio formatacao texto no form -->
function txtBoxFormat(campo, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) { // Internet Explorer
nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
nTecla = evtKeyPress.which;
} else {
nTecla = evtKeyPress.which;
if (nTecla == 8) {
return true;
}
}

sValue = campo.value;
// Limpa todos os caracteres de formatação que
// já estiverem no campo.
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ":") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {
sCod += sMask.charAt(i);
mskLen++;
} else {
sCod += sValue.charAt(nCount);
nCount++;
}
i++;
}

campo.value = sCod;
if (nTecla != 8) { // backspace
if (sMask.charAt(i-1) == "9") { // apenas números...
return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
}
} else {
return true;
}
}
<!--final formatacao texto no form -->




<!--inicio funcao alternate rows table -->
// source: http://www.quirksmode.org/dom/getElementsByTagNames.html
function getElementsByTagNames(list,obj) {
	if (!obj) var obj = document;
	var tagNames = list.split(',');
	var resultArray = new Array();
	for (var i=0;i<tagNames.length;i++) {
		var tags = obj.getElementsByTagName(tagNames[i]);
		for (var j=0;j<tags.length;j++) {
			resultArray.push(tags[j]);
		}
	}
	var testNode = resultArray[0];
	if (!testNode) return [];
	if (testNode.sourceIndex) {
		resultArray.sort(function (a,b) {
				return a.sourceIndex - b.sourceIndex;
		});
	}
	else if (testNode.compareDocumentPosition) {
		resultArray.sort(function (a,b) {
				return 3 - (a.compareDocumentPosition(b) & 6);
		});
	}
	return resultArray;
}

/*
 * plaid
 *
 * A JavaScript class for dynamically striping HTML data tables.
 *
 * @author Aaron Collegeman <acollegeman@clutch-inc.com>
 * @version 1.0.0 2006/30/31
 *
 */

function plaid() {

	// some sensible row-color defaults
	var _evenRowColor = 'white';
	var _oddRowColor = '#eee';
	var _specialRowColor = 'black';
	var _reverseSpecialRowTextColor = true;
	var _specialColColor = 'black';
	var _reverseSpecialColTextColor = true;
	var _evenOverlapColor = '#bbb';
	var _oddOverlapColor = '#ddd';
	var _overlapOnClass = null;
	var _paintOverlap = false;

	/*
	 * Performs the formatting configured in this plaid object.
	 * @className Optional; only fix those tables with this class name
	 */
	this.stripe = function(className) {

		var allTables = getElementsByTagNames('table');

		for (var i=0; i<allTables.length; i++) {
			var table = allTables[i];

			if (className && table.className != className)
				continue;

			var tbody;

			for (var c=0; c<table.childNodes.length; c++)
				if (table.childNodes[c].nodeName.toLowerCase() == 'tbody')
					tbody = table.childNodes[c];

			var rowCount = 0;
			var overlapOnCol = new Array();
			for (var c=0; c<tbody.childNodes.length; c++) {

				if (tbody.childNodes[c].nodeName.toLowerCase() == 'tr') {
					var tr = tbody.childNodes[c];
					if (rowCount % 2 == 0)
						tr.style.backgroundColor = _evenRowColor;
					else
						tr.style.backgroundColor = _oddRowColor;

					if (_paintOverlap) {
						var colCount = 0;
						for (var col=0; col<tr.childNodes.length; col++) {
							var node = tr.childNodes[col];
							var nodeName = node.nodeName.toLowerCase();
							if (nodeName == 'th' || nodeName == 'td') {
								//if ((_overlapOnClass && (node.className == _overlapOnClass || overlapOnCol[col] == true)) || (!_overlapOnClass && colCount % 2 != 0)) {
								if ((_overlapOnClass && (node.className == _overlapOnClass || overlapOnCol[colCount])) || (!_overlapOnClass && colCount % 2 != 0)) {
									overlapOnCol[colCount] = true;
									if (rowCount % 2)
										node.style.backgroundColor = _evenOverlapColor;
									else
										node.style.backgroundColor = _oddOverlapColor;
								}
								colCount++;
							}
						}
					}

					rowCount++;
				}
			}
		}
	}

	this.setEvenRowColor = function(color) {
		_evenRowColor = color;
	}

	this.setOddRowColor = function(color) {
		_oddRowColor = color;
	}

	this.setSpecialRowColor = function(color) {
		_specialRowColor = color;
	}

	this.setReverseSpecialRowTextColor = function(color) {
		_reverseSpecialRowTextColor = color;
	}

	this.setSpecialColColor = function(color) {
		_specialColColor = color;
	}

	this.setReverseSpecialColTextColor = function(color) {
		_specialColTextColor = color;
	}

	this.setEvenOverlapColor = function(color) {
		_evenOverlapColor = color;
	}

	this.setOddOverlapColor = function(color) {
		_oddOverlapColor = color;
	}

	this.setOverlapOnClass = function(color) {
		_overlapOnClass = color;
		_paintOverlap = true;
	}

	this.setPaintOverlap = function(b) {
		_paintOverlap = b;
	}

}
<!--final funcao alternate rows table -->




<!--inicio funcao consumo -->
function calcula(valor) {
  var isCheck, consumo;
  eval("isCheck = document.consumo.check_" + valor + ".checked");
  if(isCheck) {
    eval("var pot = document.consumo.pot_" + valor + ".value");
    eval("var qnt = document.consumo.qnt_" + valor + ".value");
    eval("var dia = document.consumo.dia_" + valor + ".value");
    eval("var min = document.consumo.min_" + valor + ".value");
	consumo = (pot*qnt*dia*min)/(60*1000); 
	consumo = formatNumberToShow(consumo, 2, ",", false);
	eval("document.consumo.cns_" + valor + ".value = '" + consumo + "'");
  } else {
    eval("document.consumo.cns_" + valor + ".value = ''");
  }

  calcula_todos();
}

function calcula_todos() {
  var total=0;
  
  for(var i=0; i < document.consumo.elements.length/6-1; i++) {   
    eval("if(document.consumo.cns_" + i + ".value!='') total += Number(document.consumo.cns_" + i + ".value.replace(/,/g,'.'))");
  }
  
  document.consumo.total.value = formatNumberToShow(total, 2, ",", false);
}



  function formatNumberToShow(dblValue, iDecimal, sDSeparator, flgCurrency) {
    var sResult = "";
    if (dblValue != null) {
      var re = /\,/g;
      var sCurrency = new String("R$").toString();
      var sValue = new String(dblValue).replace(re, ".").toString();
      var sParts;

      // Split Number
      sValue += ".";
      sParts = new String(sValue).split(".");

      // Format Result
      while (new String(sParts[1]).length < iDecimal)        sParts[1] += "0";
      sParts[1] = new String(sParts[1]).substr(0, iDecimal);
      sResult = ((flgCurrency == true) ? sCurrency  + " " : "") + sParts[0] + ((iDecimal > 0) ? sDSeparator: "") + sParts[1];
      }

    // Return Result
    return(sResult);
    }
<!--final funcao consumo -->




<!--fim bloco javascript -->

