var Winds_Timer = 0;
var Winds_Element = 0;

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

  return true
}


function aOver(el) { 
  pOver(el,0);
}

function pOver(el,p) {
  if(!el) { return; }
  if(p == "undefined") { p = 1; }

  clearTimeout(Winds_Timer);
  if(p == 0) { 
    Winds_Timer = setTimeout("show(\"infoBoxWind\",\""+el.getAttribute("href")+"\",110,120)",100);
  } else { 
    Winds_Timer = setTimeout("show(\"infoBoxPrecip\",\""+el.getAttribute("href")+"\",110,65)",100);
  }
}

function show(n,lnk,wide,tall) { 
  if(!n) { return; }

  Winds_Element = n;
  var w = document.getElementById(n);
  if(!w) { 
    var newWind = document.createElement("div");
    newWind.setAttribute("id",n);
    var newText = document.createTextNode("");
    newWind.appendChild(newText);

    document.body.appendChild(newWind);
    w = document.getElementById(n);
    if(!w) { alert("Still no info box"); }
  }

  var i = lnk.indexOf(".php");
  if(i < 0) { return; }
  lnk = n+lnk.substr(i);

  w.style.cursor = "crosshair";
  w.style.position = "absolute";
  w.style.top  = (tempY+2)+"px";
  w.style.left = (tempX+20)+"px";
  w.style.height = (tall+2) + "px";
  w.style.width  = (wide+2) + "px";
  w.style.border = "dashed black 1px";
  w.style.paddingLeft = "0px";
  w.style.paddingRight = "0px";
  w.style.paddingTop = "0px";
  w.innerHTML = "<img src=\""+lnk+"\" width=\"100%\" height=\"100%\" alt=\"\" />";
  w.style.display = "";
}


function hide(n) { 
  if(!n) { return; }
  var el = document.getElementById(n);
  if(!el) { return; }
  el.style.display = "none";
}

function aOut() { 
  var w = document.getElementById(Winds_Element);
  if(!w) { return; }

  clearTimeout(Winds_Timer);
  Winds_Timer = setTimeout("hide('"+Winds_Element+"')",100);
}

function showHourNavigation(n){
	var open;
	var close;
	
	if( !n ) {return;}
	if (n==1){
		open = "currenttime";
		close = "querytime";
	}
	else {
		open = "querytime";
		close = "currenttime";
	}
	var el = document.getElementById(open);
	if( !el ) {return;}
	el.style.display = "block";
	el = document.getElementById(close);
	if( !el ) {return;}
	el.style.display = "none";
}

