/* fw.js
 * Surface Water Management, Public Works, Snohomish County
 * Emilio Mayorga, 11/26/2003
 */


// ======================= Page Age stuff ==============================
var dt_pgload = new Date();

function InitPageAgeTest(pgupdate_timestamp)
{
  var dt_pgdiff = (dt_pgload - pgupdate_timestamp) / (1000*60); // in minutes
  
  if (dt_pgdiff > 60)
  {
		if (document.all) // IE 4+
		{
			divPageAge = document.all['PageAgeWarning'];
		}
		else if (document.getElementById) // Mozilla and other browsers supporting the W3C DOM
		{
			divPageAge = document.getElementById('PageAgeWarning');
		}

		divPageAge.style.display = 'inline';
	}
}

// ======================= DrawTextBox ==============================
// constants for DrawTextBox (could be set in the HTML page?)
var posoffset = 5;
var PopupTip_wrap_fr = 0.7;

function DrawTextBox(theVar, area_elem, state) 
{
	// parse the area coords attribute, extract hotspot x & y
	coords_array = area_elem.coords.split(",");
	x = parseInt(coords_array[0]);
	y = parseInt(coords_array[1]);

	if (document.all) // IE 4+
	{
		divPopupTip = document.all['PopupTip'];
		divPopupTip_style = divPopupTip.style;
		divPopupTip.innerHTML = theVar;
		
		divMapImg = document.all['theMapImage'];

		PopupTip_width = parseInt(divPopupTip.currentStyle.width);
	}
	else
	{	
		if (document.getElementById) // Mozilla and other browsers supporting the W3C DOM
		{
			divPopupTip = document.getElementById('PopupTip');
			divPopupTip_style = divPopupTip.style;
			divPopupTip.innerHTML = theVar;

  		divMapImg = document.getElementById('theMapImage');

      vw = document.defaultView;
      divPopupTip_currStyle = vw.getComputedStyle(divPopupTip, "");
      PopupTip_width = parseInt(divPopupTip_currStyle.getPropertyValue("width"));
		}
		else // Netscape 4 (not tested!)
		{
			divPopupTip = document.layers['PopupTip'];
			divPopupTip_style = divPopupTip;
			divPopupTip.document.write(theVar);
			divPopupTip.document.close();
		}

		divPopupTip_style.fontSize='small';
	}

	if (divMapImg.style.paddingLeft)
	  {x += parseInt(divMapImg.style.paddingLeft);}
	if ( x > (parseInt(divMapImg.style.width) - PopupTip_wrap_fr*PopupTip_width))
		{x -= PopupTip_wrap_fr*PopupTip_width;}

	divPopupTip_style.visibility = (state == 0) ? 'hidden' : 'visible';
	divPopupTip_style.left = x + posoffset + "px";
	divPopupTip_style.top  = y + posoffset + "px";
	//theLay.bgColor='#FFF8DC';  this was for Netscape 4?
}

