// Re-lê a pagina no caso de netscape
function reloadPage(init) {
  c = navigator.appName
  if (init==true) with (navigator) {
    if (c=="Netscape") {
      document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage;
    }
  } else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);


// Manipulação de SELECTs
function mOption(strId, strText) {
  this.id = strId;
  this.text = strText;
}
function fSetOptions(vOptions, fSelect, strSelected) {
  fSelect.length = vOptions.length;
    for (i=0; i<vOptions.length; i++) {
      fSelect.options[i].value = vOptions[i].id; 
      fSelect.options[i].text = vOptions[i].text;
      if (vOptions[i].id==strSelected)
        fSelect.options[i].selected=true;
      }
}

// Navegador em <select>
function doSel(obj) {
  var i = 0
  for (i = 0; i < obj.length; i++)
    if (obj[i].selected == true)
      if (i != 0) //ignore the first option
        eval(obj[i].value);
}



function isDefined(x) {
  return (eval('typeof('+x+')') != 'undefined' && eval('typeof('+x+')') != 'unknown')
}

function windowWidth() { return (document.layers?(window.innerWidth):(document.body.offsetWidth-20)); }
function windowHeight() { return (document.layers?(window.innerHeight):(document.body.offsetHeight)); }
function documentHeight() { return (is.ie?document.body.scrollHeight:document.height); }
function windowScrollH() { return (is.ie)?((is.ie5)?document.body.scrollLeft:0):(window.pageXOffset); }
function windowScrollV() { return (is.ie)?(document.body.scrollTop):(window.pageYOffset); }
function doc(div) {	return (is.ns)?(document.layers[div].document):(document); }

var x1 = 0
var y1 = 0
function findMouse(e) {
  x1 = (!document.layers) ? event.x+document.body.scrollLeft : e.pageX
  y1 = (!document.layers) ? event.y+document.body.scrollTop : e.pageY
	
	largTotal = windowWidth() - 2
	altTotal = windowHeight() - bug2Height
//	largAtiva = largTotal - bug1Left - bug1Width
//	posxAtiva = ( largAtiva * 100 ) / largTotal
//	pxf = ( x1 * ( posxAtiva / 100 ) ) + ( bug1Left  - 16 )
	
	pxf = ( (x1 > largTotal - 4) ? (largTotal - 4) : ((x1 < 50) ? 50 : x1))
	pyf = ( (y1 > altTotal) ? 438 : y1  * 438 / altTotal)
	
	if (isDefined('bug1')) bug1.moveTo(pxf,bug1Top)
	//altAtiva = 473 - bug2Height
	//xp = ( ( altAtiva * 100 ) / altTotal )
	//yy = ( altAtiva * 0.01 ) * y1
	//pyf = ( altAtiva * 0.01 ) * y1 - bug2Height
	if (isDefined('bug2')) bug2.moveTo(bug2Left,pyf)

}
if (document.layers) document.captureEvents(Event.ONMOUSEMOVE)
document.onmousemove = findMouse

