    var indata;
    var spot;
    var OK2Exit = false;
            
function ConfirmExit()
        {
	/* If OK2Exit is false then you can't go.  
	We need to control how the user leaves the page because there may be a pending update.
  	OK2Exit is set to true on all links on the Budget Template page.  It is OK to leave
	by way of a link because if you click there then the change event will fire for any
	pending update and we are OK.  If the user clicks on the back or close buttons the
	change event will not fire and any pending update will not get to the server.  This
	feature is turned on by code in OnBeforeUnload.js.  If we don't want the feature 
	(and this is the case when the budget templat is in display mode) then OnBeforeUnload.js
	is not included on the web page and this feature is moot.  
	*/
        if (OK2Exit == false) 
            return "You should not leave this page by way of the back or close buttons because your last change may not be saved.  Use options from the menu bar."
        }

function ProcessField_Callback(response)
	{
	    /*
	    Process the data returning from the server.
	    The data must be a string in the form xxx;yyy;xxx;yyy;error;message;
	    where xxx is the id of a field on this page
	    and yyy is the value to display in that field.
	    The data must come in pairs and must be terminated with semi-colons.
	    The id "error" is a special case when it exists the value "message"
            is displayed in an alert box.  
	    This routine works in conjunction with the "nextword" function
	    and require two global variables - indata and spot.
	    */
        var nextfield;
        var nextvalue;
        var debugvalue="";
	//document.getElementById("status").innerHTML = "";
        indata = response.value;
        //                       alert('Data sent from the host: ' + indata);
        spot = 0;
        while (spot > -1) 
            {
	        nextfield = nextword();
	        nextvalue = nextword();
		               //alert("Next Field: " + nextfield + ".  Next Value: " + nextvalue);
	        if (nextfield == "status") 
	           { 
		      //document.getElementById("status").innerHTML = nextvalue;
                      //alert("Warning: " + nextvalue);
		   } else {
                      if (nextfield == "error")
                         {
                            alert(nextvalue)
                         } else {
	    	            document.getElementById(nextfield).value = nextvalue;
	                 }
                   }
                               //alert("spot " + spot);
    	    }
                               //alert(debugvalue);
		               //document.getElementById("debug").innerHTML = debugvalue;
        }

function nextword()
        {
        /*
        Return the next word in a string.
        The string is a global variable called indata.
        The global variable spot is also required.
        */
        var result;
        spot = indata.indexOf(";");
        result = indata.slice(0, spot);
        spot = spot + 1
        if (spot < indata.length)
    	    {
            indata = indata.slice(spot, indata.length);
    	    } else {
	        spot = -1;
    	    }
        return(result);
        }

function popUp(URL) {
        /*
	This displays a popup window for a link.
        The link looks like this...
        <A HREF="javascript:popUp('http://www.something.xxx/somepage.yyy')">Click Here</A>
	*/
        day = new Date();
        id = day.getTime();
        eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=1,width=700,height=600,left=100,top=100');");
        }

function Mid(str, start, len)
	{
	/* Return part of a string */
	if (start < 0 || len < 0) return "";
	var iEnd, iLen = String(str).length;
	if (start + len > iLen)
	      iEnd = iLen;
	else
	      iEnd = start + len;
	return String(str).substring(start,iEnd);
	}

function closeWindow()
{
  // Close the current window
  window.close();
}

function xxxshowme( me, event )
{
  var elem;

  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( me );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[me];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[me];

  elem.style.display = 'block';
  elem.style.top = event.clientY - 10;
  elem.style.left = event.clientX - 10;
}

function xxxhideme(me) {
  getmebyid(me).style.display = 'none';
}

function xxxgetmebyid(me) {
  var elem;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( me );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[me];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[me];
  return elem;
}

function xxxmouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}

function xxxmouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id, parent)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	ddmenuitem.style.left = parent.offsetLeft;
	ddmenuitem.style.top = parent.offsetTop + 20;
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
