<!-- Begin
//===============================================================================
// Name:     xpopup.js
// Purpose:  Pop-up text box
// Versioin: 1.1
// Author:   X. Jian
// Usage:
//   1. Insert the below code into the <body> section 
//      <div id=popup_display style= "POSITION: absolute; VISIBILITY: hidden; Z-INDEX: 200"></div>
//      <script language='JavaScript' src='scripts/xpopup.js'></script>
//   2. Add the following inside any link that will contain a popup:
//      onmouseover="showPopup('pop-up message','font-color', 'background-color', fontSize)"; 
//      onmouseout="hidePopup()";
//-------------------------------------------------------------------------------
// History
//  12/20/01 - Version 1.0: Initial coding.
//  12/21/01 - Version 1.1: Adjusting the position of popup so that the pop-up
//             always can be seen.
//  01/14/02 - Check the popup text size before poping up so that the width of 
//             pop-up window can be set if necessary.
//  10/14/03 - Some simplifications made by D. Hoffman (may no longer work with Netscape 4.x)
//	       Also added some comments to make code more readable
//===============================================================================
//alert("dpupup ...");
var newWindow; // global to hold new window reference

/////////////////////////////////////////////////////////////////////
/* The Xoffset and Yoffset is the posistion relative to the mouse pointer location that
	the popup box will appear. popupWidth is self-explanatory. */
/////////////////////////////////////////////////////////////////////
var Xoffset= 10; //-60;    // modify these values to ...
var Yoffset= 10;           // change the popup position.
var popupWidth = 200;      // the width of the pop-up window.
//////////////////////////////////////////////////////////////////////

var popupbox_object;   // reference to the popup object itself, which must be assigned in different ways depending on browser type


////////////////////////////////////////////////////////////////
/* These varibales will tell us what type of browser we are dealing with.
	There are three types we are concerned with, Netscape 4, Netscape 6, and IE 4+
	They all have different data object models
	ns4 is true if document.layers is available, which is only the case in Netscape 4.x
	ns6 is true if getElementById works and document.all does not (Netscape 6.x)
	ie4 is true if document.all works (IE 4+)
	That should take care of all javascript suporting browsers */
/////////////////////////////////////////////////////////////////
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all
//
var AgntUsr=navigator.userAgent.toLowerCase();
var IsIE=AgntUsr.indexOf('msie')!=-1?1:0;  //added by XJian.

//////////////////////////////////////////////////////////////////
//
//-------Get pop-up div style in terms of the different kind of browers.
//
if (ns4)
   popupbox_object=document.popup_display
else if (ns6)
   popupbox_object=document.getElementById("popup_display").style
else if (ie4)
   popupbox_object=document.all.popup_display.style
else 
   popupbox_object=document.getElementById("popup_display").style
	
//alert("popupbox_object = " + popupbox_object + ", IsIE: " + IsIE);
//
//-------Get event
//
if(ns4)
   document.captureEvents(Event.MOUSEMOVE);


document.onmousemove=get_mouse;	// this function (get_mouse) repositions the popup as the mouse moves


// This function is called on the mouseover event and sets the popup content to msg and makes the popup visible
function showPopup(msg,fontColor,bgColor,fontSize){
   //default varibale values
   var fColor = 'black';
   var fSize  = 1;
   var bColor = 'lightyellow';
   //
   // check if background color and font color and size are specified
   //
   if (showPopup.arguments.length > 1) {fColor = fontColor}
   if (showPopup.arguments.length > 2) {bColor = bgColor}
   if (showPopup.arguments.length > 3) {fSize  = fontSize}
   //
   //--------Determine the width of pup-up text
   //
   var optWidth = "width=" + popupWidth;
   fontSizes = new Array(8, 10, 12, 14, 18, 24, 36);
   if (fSize >= 1 && fSize <= 7) {
      var msg_width = (msg.length) * fontSizes[fSize-1];
      if (msg_width < popupWidth) optWidth = '';
   }
   
   //
   // Prepare the pop-up as a table.
   //
   if (county_java == "Kansas")
   {
   var content="<table "+optWidth+" BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
               "BGCOLOR="+bColor+"><tr><td ALIGN=left><FONT COLOR="+fColor+" SIZE="+fSize+">"+
               msg+"</FONT></td></tr></table>";

	
   //
   }
   else
   {

	var content="<table  BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 width=200 "+
               "BGCOLOR="+bColor+"><FONT COLOR="+fColor+" SIZE="+fSize+">"+
               ParseMessage(msg, fSize) +"</FONT></table>";
   
   }
   
   

   if(ns4){popupbox_object.document.write(content);popupbox_object.document.close();}
   if(ns6){document.getElementById("popup_display").innerHTML=content}
   if(ie4){document.all("popup_display").innerHTML=content}
   
   popupbox_object.visibility="visible";
   window.status=msg;
   

}

function get_mouse(e){
   //
   // Get the current window width and height
   //
   var windowWidth = (ns4||ns6)?window.innerWidth:document.body.clientWidth; //document.style.width; //window.width;
   var windowHeight= (ns4||ns6)?window.innerHeight:document.body.clientHeight;

   //
	//-------------xjian: handle ie 
	//
	if (IsIE) {
     scrollY = (document.documentElement && document.documentElement.scrollTop)? document.documentElement.scrollTop : document.body.scrollTop;
     scrollX = (document.documentElement && document.documentElement.scrollLeft)? document.documentElement.scrollLeft : document.body.scrollLeft;
	  xo = window.event.clientX + scrollX;
     yo = window.event.clientY + scrollY;
	}
	else {
      scrollX = (ns4||ns6)?window.pageXOffset:document.body.scrollLeft;
      scrollY = (ns4||ns6)?window.pageYOffset:document.body.scrollTop;
      xo=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
      yo=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
	}
   //
   //  Determine the pop-up position
   //
   //var xo=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
   x = xo + Xoffset;
   if ((x + popupWidth - scrollX) > windowWidth ) {
      x = scrollX + windowWidth - popupWidth - 2 * Xoffset;
   }
   //
   //var yo=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
   y = yo + Yoffset;

   if ((y + 20 - scrollY) > windowHeight) {
      y = scrollY + windowHeight - 20 - 2 * Yoffset;
   }
	//window.status="xo, x = " + xo + "," + x + ", yo, y = " + yo + "," + y + ", object: " + popupbox_object;
   popupbox_object.left= x + 'px'; //+Xoffset;

   popupbox_object.top=y + 'px';
   
}

/////////////////////////////////////////
// Sets visibility property to hidden
function hidePopup(){
   
   popupbox_object.visibility="hidden";  
   window.status='';
}
///////////////////////////////////////


function PopupNewWindow(msg)
{
   
   if (newWindow) {newWindow.close();}   

   var fColor = 'black';
   var fSize  = 3;
   var bColor = 'lightyellow';
   //
   // check if background color and font color and size are specified
   //
   if (PopupNewWindow.arguments.length > 1) {fColor = fontColor}
   if (PopupNewWindow.arguments.length > 2) {bColor = bgColor}
   if (PopupNewWindow.arguments.length > 3) {fSize  = fontSize}
   
   // Prepare the pop-up as a table.
   //
   var content="<table  BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 width=400 "+
               "BGCOLOR="+bColor+"><tr><th colspan=2>" + county_java + "</th></tr><FONT COLOR="+fColor+" SIZE="+fSize+">"+
               ParseMessagePrint(msg) +"</FONT></table>";
   //
   
   
   var newWindow;
	//alert("newWindow: " + newWindow);
   if (!newWindow)
   {
	
   	 newWindow = window.open("","Printable", 
		"width=450,height=400,toolbar=no,menubar=yes,status=no,copyhistory=no,directories=no,location=no,resizable=yes,scrollbars=yes,top=100,left=600");
	   //alert("hello: " + newWindow);
   	//newWindow.moveTo(600,100);
   }
   newWindow.document.write(content);
	//
	//XJ: add close() make it work with FireFox
	newWindow.document.close();
	//
   newWindow.scrollBy(0,500);
   
   newWindow.focus();
	//
	//XJ: The following statement makes error on FF. Mark it out.
	//
   //newWindow.forward();
   return false;
   //newWindow.document.close();
   //newWindow.document.setfocus();
}

function ParseMessagePrint(msg)
{
	var final_msg = "";
	var parsed_string = msg.split(',');
	for(i=0;i < parsed_string.length;i++)
	{
		parsed_string[i] = parsed_string[i].split(':');
		parsed_string[i][0] = parsed_string[i][0].replace("ft3/s", "ft<sup>3</sup>/s");
		parsed_string[i][1] = parsed_string[i][1].replace("-99", "no data");
		//
		//----------------xjian: show 'designated uses'
		//
		parsed_string[i][1] = parsed_string[i][1].replace(/==/g, ":");
		parsed_string[i][1] = parsed_string[i][1].replace(/\|\|/g, ", ");
		//
		final_msg = final_msg + "<tr><td>" + parsed_string[i][0];
		final_msg = final_msg + "</td><td>" + parsed_string[i][1];
		final_msg = final_msg + "</td></tr>"
	}
	return final_msg;
	
	
}	

function ParseMessage(msg, fsize)
{
	var final_msg = "";
	var parsed_string = msg.split(',');
	for(i=0;i < parsed_string.length;i++)
	{
		parsed_string[i] = parsed_string[i].split(':');
		parsed_string[i][0] = parsed_string[i][0].replace("ft3/s", "ft<sup>3</sup>/s");
		parsed_string[i][1] = parsed_string[i][1].replace("-99", "no data");
		//
		//----------------Add by xjian: show designated uses
		//
		parsed_string[i][1] = parsed_string[i][1].replace(/==/g, ":");
		parsed_string[i][1] = parsed_string[i][1].replace(/\|\|/g, ", ");
		//
		if (i == 0)
		{
			final_msg = final_msg + "<tr><th colspan=2><FONT SIZE="+fsize+">" + parsed_string[i][1];
			final_msg = final_msg + "</FONT></td></tr>"
		}
		else
		{
			//
			//---------------------Xjian: add 'nowrap', 'valign'
			//
			final_msg = final_msg + "<tr><td nowrap='nowrap' valign='top'><FONT SIZE="+fsize+">" + parsed_string[i][0];
			final_msg = final_msg + "</FONT></td><td><FONT SIZE="+fsize+">" + parsed_string[i][1];
			final_msg = final_msg + "</FONT></td></tr>"
		}
	}
	return final_msg;
	
	
}	

//-->

