    var PAGEISDIRTY = false;

    function CheckPageIsDirty()
    {
        if(PAGEISDIRTY==true)
        {
            if(confirm("Are you sure you want to navigate away from this page without saving your changes?\n\nPress OK to continue without saving\n\nOr\n\nPress Cancel to stay on the current page and use the save functionality on the page."))
            {
                return true;
            }
            return false;
        }
        return true;
    }

    // if two digit year input dates after this year considered 20 century.
    var NUM_CENTYEAR = 30;
    // is time input control required by default
    var BUL_TIMECOMPONENT = false;
    // are year scrolling buttons required by default
    var BUL_YEARSCROLL = true;

    var calendars = [];
    var RE_NUM = /^\-?\d+$/;

    function calendar_with_callback(obj_target, callback) {
	    // assigning methods
	    this.gen_date = cal_gen_date2;
	    this.gen_time = cal_gen_time2;
	    this.gen_tsmp = cal_gen_tsmp2;
	    this.prs_date = cal_prs_date2;
	    this.prs_time = cal_prs_time2;
	    this.prs_tsmp = cal_prs_tsmp2;
	    this.popup    = cal_popup_callback;

	    // validate input parameters
	    if (!obj_target)
		    return cal_error("Error calling the calendar: no target control specified");
	    if (obj_target.value == null)
		    return cal_error("Error calling the calendar: parameter specified is not valid target control");
	    this.target = obj_target;
	    this.time_comp = BUL_TIMECOMPONENT;
	    this.year_scroll = BUL_YEARSCROLL;
    this.callback =  callback;   
	    // Initialize the reference to our window
	    this.window = null;

	    // register in global collections
	    this.id = calendars.length;
	    calendars[this.id] = this;
    }

    function calendar2(obj_target) {
	    // assigning methods
	    this.gen_date = cal_gen_date2;
	    this.gen_time = cal_gen_time2;
	    this.gen_tsmp = cal_gen_tsmp2;
	    this.prs_date = cal_prs_date2;
	    this.prs_time = cal_prs_time2;
	    this.prs_tsmp = cal_prs_tsmp2;
	    this.popup    = cal_popup2;

	    // validate input parameters
	    if (!obj_target)
		    return cal_error("Error calling the calendar: no target control specified");
	    if (obj_target.value == null)
		    return cal_error("Error calling the calendar: parameter specified is not valid target control");
	    this.target = obj_target;
	    this.time_comp = BUL_TIMECOMPONENT;
	    this.year_scroll = BUL_YEARSCROLL;

	    // Initialize the reference to our window
	    this.window = null;

	    // register in global collections
	    this.id = calendars.length;
	    calendars[this.id] = this;
    }

    function cal_popup2 (str_datetime, from) {
	    this.dt_current = this.prs_tsmp(str_datetime ? str_datetime : this.target.value);
	    if (! this.dt_current) 
		    {return;}
        if(from)
        {
            var posx = 0;
            var posy = 0;
          
            if (!e) var e = window.event;
            if (e.pageX || e.pageY)
            {
                posx = e.pageX;
                posy = e.pageY;
            }
            else if (e.clientX || e.clientY)
            {
                posx = e.clientX + document.body.scrollLeft
	                + document.documentElement.scrollLeft;
                posy = e.clientY + document.body.scrollTop
	                + document.documentElement.scrollTop;
            }

            if(posx > 550)
            {
                LeftPosition = 550;
            }
            else
            {
                LeftPosition = posx + 110;
            }        
            if(posy > 700)
            {
                    TopPosition = 550;
            }
            else
            {
                TopPosition = posy - 85;
            }
            
        }
        else
        {
            LeftPosition = LeftPosition;
            TopPosition = TopPosition;
        }
        
	    var obj_calwindow = window.open(
		    '/controls/common/calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id + '&callback=' + this.c,
		    'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
		    ',status=no,resizable=no,top=' + TopPosition + ',left=' + LeftPosition + ',dependent=yes,alwaysRaised=yes'
		    );

	    this.window = obj_calwindow;

	    if (null == obj_calwindow)
	    {
		    alert("Unable to create the Calendar popup window.\n" + 
			      "Make sure you do not have a popup blocker active.");
		    return;
	    }

	    obj_calwindow.opener = window;
	    obj_calwindow.focus();
        SimulateModalDialog(obj_calwindow)
    }

    function cal_popup_callback (str_datetime,from,callback) {
	    this.dt_current = this.prs_tsmp(str_datetime ? str_datetime : this.target.value);
	    if (! this.dt_current) 
		    {return;}
        if(from)
        {
            var posx = 0;
            var posy = 0;
            if (!e) var e = window.event;
            if (e.pageX || e.pageY)
            {
                posx = e.pageX;
                posy = e.pageY;
            }
            else if (e.clientX || e.clientY)
            {
                posx = e.clientX + document.body.scrollLeft
	                + document.documentElement.scrollLeft;
                posy = e.clientY + document.body.scrollTop
	                + document.documentElement.scrollTop;
            }
            
            if(posx > 550)
            {
                LeftPosition = 550;
            }
            else
            {
                LeftPosition = posx + 110;
            }        
            if(posy > 700)
            {
                    TopPosition = 550;
            }
            else
            {
                TopPosition = posy - 85;
            }
        }
        else
        {
            LeftPosition = LeftPosition;
            TopPosition = TopPosition;
        }
        
	    var obj_calwindow = window.open(
		    '/controls/common/calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id + '&callback=' + this.callback,
		    'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
		    ',status=no,resizable=no,top=' + TopPosition + ',left=' + LeftPosition + ',dependent=yes,alwaysRaised=yes'
		    );

	    this.window = obj_calwindow;

	    if (null == obj_calwindow)
	    {
		    alert("Unable to create the Calendar popup window.\n" + 
			      "Make sure you do not have a popup blocker active.");
		    return;
	    }

	    obj_calwindow.opener = window;
	    obj_calwindow.focus();
        SimulateModalDialog(obj_calwindow)
    }

    // timestamp generating function
    function cal_gen_tsmp2 (dt_datetime) {
	    return(this.gen_date(dt_datetime) + ' ' + this.gen_time(dt_datetime));
    }

    // date generating function
    function cal_gen_date2 (dt_datetime) {
	    return (
		    (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "/"
		    + (dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/"
		    + dt_datetime.getFullYear()
	    );
    }
    // time generating function
    function cal_gen_time2 (dt_datetime) {
	    return (
 		      (dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
		    + (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes()) + ":"
		    + (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
	    );
    }

    // timestamp parsing function
    function cal_prs_tsmp2 (str_datetime) {
	    // if no parameter specified return current timestamp
	    if (!str_datetime)
		    return (new Date());

	    // if positive integer treat as milliseconds from epoch
	    if (RE_NUM.exec(str_datetime))
		    return new Date(str_datetime);
    		
	    // else treat as date in string format
	    var arr_datetime = str_datetime.split(' ');
	    return this.prs_time(arr_datetime[1], this.prs_date(arr_datetime[0]));
    }

    // date parsing function
    function cal_prs_date2 (str_date) {

	    var arr_date = str_date.split('/');

	    if (arr_date.length != 3) return alert ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
	    if (!arr_date[1]) return alert ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
	    if (!RE_NUM.exec(arr_date[1])) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
	    if (!arr_date[0]) return alert ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
	    if (!RE_NUM.exec(arr_date[0])) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
	    if (!arr_date[2]) return alert ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
	    if (!RE_NUM.exec(arr_date[2])) return alert ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

	    var dt_date = new Date();
	    dt_date.setDate(1);

	    if (arr_date[0] < 1 || arr_date[0] > 12) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed range is 01-12.");
	    dt_date.setMonth(arr_date[0]-1);
    	 
	    if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
	    dt_date.setFullYear(arr_date[2]);

	    var dt_numdays = new Date(arr_date[2], arr_date[0], 0);
	    dt_date.setDate(arr_date[1]);
	    if (dt_date.getMonth() != (arr_date[0]-1)) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

	    return (dt_date)
    }

    // time parsing function
    function cal_prs_time2 (str_time, dt_date) {

	    if (!dt_date) return null;
	    var arr_time = String(str_time ? str_time : '').split(':');

	    if (!arr_time[0]) dt_date.setHours(0);
	    else if (RE_NUM.exec(arr_time[0])) 
		    if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
		    else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
	    else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
    	
	    if (!arr_time[1]) dt_date.setMinutes(0);
	    else if (RE_NUM.exec(arr_time[1]))
		    if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
		    else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
	    else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");

	    if (!arr_time[2]) dt_date.setSeconds(0);
	    else if (RE_NUM.exec(arr_time[2]))
		    if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
		    else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
	    else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");

	    dt_date.setMilliseconds(0);
	    return dt_date;
    }

    function cal_error (str_message) {
	    alert (str_message);
	    return null;
    }

    function mouseposition(e)
    {
        var posx = 0;
        var posy = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)
        {
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY)
        {
            posx = e.clientX + document.body.scrollLeft
	            + document.documentElement.scrollLeft;
            posy = e.clientY + document.body.scrollTop
	            + document.documentElement.scrollTop;
        }

        return posx + "," + posy;
        
        // posx and posy contain the mouse position relative to the document
        // Do something with this information
    }

    //These functions control the behavior of the page link go arrows.

    function liteCaution(spNo) {
	    spNo.style.background="#FFFFFF"; 
	    spNo.style.color="#FF0000"; // #E0FFFF
    }

    function liteGo(spNo) {
	    spNo.style.background="#FFFFFF"; 
	    spNo.style.color="#FF0000"; // #E0FFFF
    }

    function liteOff(spNo) {
	    spNo.style.background="#FFFFFF";
	    spNo.style.color="#003187";
    }

    function tabOn(spNo) {
	    spNo.style.color	= 'blue'; // a light yellow
    }

    function tabOff(spNo) {
	    spNo.style.color	= '#001387';
    }

    function onMouse(spNo) {
	    spNo.style.color	= '#FF0000'; // red
    }

    function offMouse(spNo) {
	    spNo.style.color	= '#001387';
    }

    function tabActiveOff(spNo) {
	    spNo.style.color	= 'blue';
    }

    function linkOn(spNo) {
	    spNo.style.color	= 'blue'; 
	    spNo.style.cursor	= 'hand';
    }

    function linkOff(spNo) {
	    spNo.style.color	= '#08338F';
	    //spNo.style.cursor		= 'normal';
    }

    function buttonOn(spNo) {
	    spNo.style.color	= 'lightblue'; 
	    spNo.style.cursor	= 'hand';
    }

    function buttonOff(spNo) {
	    spNo.style.color	= 'white';
    }

    //Insert new functions here. Please use unique identifiers and comment liberally.

    function AJAX_Call(url,myCondition,myFunction)
    {
	    var http_request = false;

	    if (window.XMLHttpRequest)
	    {
		    http_request = new XMLHttpRequest();
		    if (http_request.overrideMimeType)
		    {
			    http_request.overrideMimeType('text/xml');
		    }
	    }
	    else if (window.ActiveXObject)
	    {
		    try
		    {
			    http_request = new ActiveXObject("Msxml2.XMLHTTP");
		    }
		    catch (e)
		    {
			    try
			    {
				    http_request = new ActiveXObject("Microsoft.XMLHTTP");
			    } catch (e) {}
		    }
	    }

	    if (!http_request)
	    {
		    alert('Giving up :( Cannot create an XMLHTTP instance');
		    return false;
	    }

	    http_request.onreadystatechange = handleStateChange;

	    function handleStateChange()
	    {        
		    if (http_request.readyState == 4)
		    {
			    eval(myFunction+'(http_request,myCondition)');
		    }
	    }

	    http_request.open('GET', url, true);
	    http_request.send(null);

    }

    function popUp(URL) {
    	
	    var	retVal = true;
	    var w;
    	
	    day = new Date();
	    id = day.getTime();
    	
	    w = window.open(URL, id, 'toolbar=0,left=150,top=400,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=300');
	    if (w.location == '' || w.location == null) {
		    alert("Can't launch the Page (" + URL + ")");
		    w.close();
		    retVal = false;
	    }
    	
	    return retVal;
	    //window.reload();
    }

    function handler(e) {
	    e = window.event;
	    alert("Error!! :" + e.type);
    }

    function myPopUp(URL)
    {
	    if (URL == "") {
		    alert("Can't start page!");
	    }
	    else {
		    w = popUp(URL);
		    /* alert("Window closed (" + w + ")");
		    w.close();
		    */
	    }
    }

    function framePopUp(f, URL) 
    {
	    alert("help");
	    alert("f="+f+"url="+URL);
	    alert(frames[0]);
	    f.open(URL);
	    f.close();			
    }
    function listFrames()
    {
    	
    }

    function listProperties(obj) 
    {
	    var nameList = "";
    	
	    for (var i in obj) 
		    nameList += "(" + i + ":" + obj[i] + ")";

	    alert(nameList);
    }

    function listClasses()
    {
	    var classList = "";

	    for (var i in document.styleSheets) 
		    classList += "(" + i + ":" + document.styleSheets[i] + ")";
	    alert(classList);
    }

    function listStyleSheets()
    {
	    var styleSheets = "";

	    alert(document.styleSheets["length"]);

	    for ( styles = 0; styles < document.styleSheets["length"]; styles++)
		    listProperties(document.styleSheets[styles]);
    }

    function myModalPopup(mypage,myname,w,h,a,b,pos,infocus,loc)
    {
        acePopup(mypage,myname,w,h,a,b,pos,infocus,loc)
        SimulateModalDialog(acePopupWindow)
    }

    var acePopupWindow=null;

    function test(obj)
    {
        if(document.getElementById(obj))
        {
            tableobj = document.getElementById(obj);
            newHeight = tableobj.offsetHeight;
            newWidth = tableobj.offsetWidth;
	        window.resizeTo(newWidth+42,newHeight+60);
	        LeftPosition = (screen.width)?(screen.width-newWidth)/2:100;
	        TopPosition = (screen.height)?(screen.height-newHeight)/2:100;
	        window.moveTo(LeftPosition,TopPosition);	
	    }
    }

    function acePopup(mypage,myname,w,h,a,b,pos,infocus,loc)
    {
	    if (pos == 'random')
	    {
		    LeftPosition = (screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		    TopPosition = (screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	    }
	    else if (pos == 'center')
	    {
		    LeftPosition = (screen.width)?(screen.width-w)/2:100;
		    TopPosition = (screen.height)?(screen.height-h)/2-20:100;
	    }
	    else
	    {
		    LeftPosition = a;
		    TopPosition = b;
	    }

	    var settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,dependent=no';

	    acePopupWindow = window.open('',myname,settings);
	    if (null == acePopupWindow)
	    {
		    alert("Unable to create the \"" + myname + "\" popup window.\n" + 
			      "Make sure you do not have a popup blocker active.");
		    return;
	    }

	    if (infocus == 'front')
	    {
		    acePopupWindow.focus();
	    }

	    acePopupWindow.location = mypage;
    	
    }

    /*
    ==================================================================
    LTrim(string) : Returns a copy of a string without leading spaces.
    ==================================================================
    */
    function LTrim(str)
    /*
       PURPOSE: Remove leading blanks from our string.
       IN: str - the string we want to LTrim
    */
    {
       var whitespace = new String(" \t\n\r");

       var s = new String(str);

       if (whitespace.indexOf(s.charAt(0)) != -1) {
          // We have a string with leading blank(s)...

          var j=0, i = s.length;

          // Iterate from the far left of string until we
          // don't have any more whitespace...
          while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
             j++;

          // Get the substring from the first non-whitespace
          // character to the end of the string...
          s = s.substring(j, i);
       }
       return s;
    }

    /*
    ==================================================================
    RTrim(string) : Returns a copy of a string without trailing spaces.
    ==================================================================
    */
    function RTrim(str)
    /*
       PURPOSE: Remove trailing blanks from our string.
       IN: str - the string we want to RTrim

    */
    {
       // We don't want to trip JUST spaces, but also tabs,
       // line feeds, etc.  Add anything else you want to
       // "trim" here in Whitespace
       var whitespace = new String(" \t\n\r");

       var s = new String(str);

       if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
          // We have a string with trailing blank(s)...

          var i = s.length - 1;       // Get length of string

          // Iterate from the far right of string until we
          // don't have any more whitespace...
          while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
             i--;


          // Get the substring from the front of the string to
          // where the last non-whitespace character is...
          s = s.substring(0, i+1);
       }

       return s;
    }

    /*
    =============================================================
    Trim(string) : Returns a copy of a string without leading or trailing spaces
    =============================================================
    */
    function Trim(str)
    /*
       PURPOSE: Remove trailing and leading blanks from our string.
       IN: str - the string we want to Trim

       RETVAL: A Trimmed string!
    */
    {
       return RTrim(LTrim(str));
    }

    window.onerror = null;
    var bName = navigator.appName;
    var bVer = parseInt(navigator.appVersion);
    var NS4 = (bName == "Netscape" && bVer >= 4);
    var IE4 = (bName == "Microsoft Internet Explorer" 
    && bVer >= 4);
    var NS3 = (bName == "Netscape" && bVer < 4);
    var IE3 = (bName == "Microsoft Internet Explorer" 
    && bVer < 4);
    var blink_speed=400;
    var i=0;
     
    if (NS4 || IE4)
    {
	    if (navigator.appName == "Netscape")
	    {
		    layerStyleRef="layer.";
		    layerRef="document.layers";
		    styleSwitch="";
	    }
	    else
	    {
		    layerStyleRef="layer.style.";
		    layerRef="document.all";
		    styleSwitch=".style";
	    }
    }

    function Blink(layerName)
    {
	    if (NS4 || IE4) 
	    { 
		    if(i%2==0)
		    {
			    eval(layerRef+'["'+layerName+'"]'+
			    styleSwitch+'.visibility="visible"');
		    }
		    else
		    {
			    eval(layerRef+'["'+layerName+'"]'+
			    styleSwitch+'.visibility="hidden"');
		    }
	    } 

	    if(i<1)
	    {
		    i++;
	    } 
	    else
	    {
		    i--
	    }

	    setTimeout("Blink('"+layerName+"')",blink_speed);
    }

    //This function will display date & time based on getting the pc offset and comparing it to EST.

    function timeZoneDisplayByID(theField,theDate)
    {
	    var dte = new Date(theDate);
	    var dateCheck = dte.getTime();

	    if (!isNaN(dateCheck))
	    {
		    dte.setTime(dte.getTime() - dte.getTimezoneOffset()*60*1000);
		    var nuDate = new Date(dte);
		    var numonth = nuDate.getMonth() + 1;
		    var nuday = nuDate.getDate();
		    var nuyear = nuDate.getFullYear();
		    var nuhours = nuDate.getHours();

		    if(numonth == 1)
		    {
			    theMonth = "Jan"
		    }
		    if(numonth == 2)
		    {
			    theMonth = "Feb"
		    }
		    if(numonth == 3)
		    {
			    theMonth = "Mar"
		    }
		    if(numonth == 4)
		    {
			    theMonth = "Apr"
		    }
		    if(numonth == 5)
		    {
			    theMonth = "May"
		    }
		    if(numonth == 6)
		    {
			    theMonth = "Jun"
		    }
		    if(numonth == 7)
		    {
			    theMonth = "Jul"
		    }
		    if(numonth == 8)
		    {
			    theMonth = "Aug"
		    }
		    if(numonth == 9)
		    {
			    theMonth = "Sep"
		    }
		    if(numonth == 10)
		    {
			    theMonth = "Oct"
		    }
		    if(numonth == 11)
		    {
			    theMonth = "Nov"
		    }
		    if(numonth == 12)
		    {
			    theMonth = "Dec"
		    }
		    if(nuhours >= 12)
		    { ampm = "PM"
			    if(nuhours > 12)
			    { nuhours = nuhours - 12; }
		    }
		    else
		    { ampm = "AM" }
		    if(nuhours < 10)
		    { nuhours = "0" + nuhours; }
		    var numinutes = nuDate.getMinutes();
		    if(numinutes < 10)
		    { numinutes = "0" + numinutes }
		    var nuseconds = nuDate.getSeconds();
		    if(nuseconds < 10)
		    { nuseconds = "0" + nuseconds }
		    var newDate = theMonth +" "+nuday+", "+nuyear+" "+nuhours+":"+numinutes+":"+nuseconds+" "+ampm;

		    document.getElementById(theField).innerText = newDate;
	    }
	    else
	    {
		    document.getElementById(theField).innerText = "";
	    }
    }

    function timeZoneDisplayDateOnly(theField,theDate)
    {
	    var dte = new Date(theDate);
	    var dateCheck = dte.getTime();

	    if (!isNaN(dateCheck))
	    {
		    dte.setTime(dte.getTime() - dte.getTimezoneOffset()*60*1000);
		    var nuDate = new Date(dte);
		    var numonth = nuDate.getMonth() + 1;
		    var nuday = nuDate.getDate();
		    var nuyear = nuDate.getFullYear();
		    var nuhours = nuDate.getHours();

		    if(nuhours >= 12)
		    { ampm = "PM"
			    if(nuhours > 12)
			    { nuhours = nuhours - 12; }
		    }
		    else
		    { ampm = "AM" }
		    if(nuhours < 10)
		    { nuhours = "0" + nuhours; }
		    var numinutes = nuDate.getMinutes();
		    if(numinutes < 10)
		    { numinutes = "0" + numinutes }
		    var nuseconds = nuDate.getSeconds();
		    if(nuseconds < 10)
		    { nuseconds = "0" + nuseconds }
		    var newDate = numonth+"/"+nuday+"/"+nuyear;

		    document.getElementById(theField).innerText = newDate;
	    }
	    else
	    {
		    document.getElementById(theField).innerText = "";
	    }
    }


    function getCurrentGMT(theField)
    {
	    var gmt = new Date();
	    var gmtmonth = gmt.getUTCMonth() + 1;
	    var gmtday = gmt.getUTCDate();
	    var gmtyear = gmt.getUTCFullYear();
	    var gmthours = gmt.getUTCHours();
	    if(gmthours >= 12)
	    { gmtampm = "PM"
		    if(gmthours > 12)
		    { gmthours = gmthours - 12; }
	    }
	    else
	    { gmtampm = "AM" }
	    if(gmthours < 10)
	    { gmthours = "0" + gmthours; }
	    var gmtminutes = gmt.getUTCMinutes();
	    if(gmtminutes < 10)
	    { gmtminutes = "0" + gmtminutes; }
	    var gmtseconds = gmt.getUTCSeconds();
	    if(gmtseconds < 10)
	    { gmtseconds = "0" + gmtseconds; }
	    var gmtDate = gmtmonth+"/"+gmtday+"/"+gmtyear+" "+gmthours+":"+gmtminutes+":"+gmtseconds+" "+gmtampm

	    document.getElementById(theField).value = gmtDate;
    }

    function getlocalDate(strField,theDate)
    {
	    var lt = new Date(theDate);
	    lt.setTime(lt.getTime() - lt.getTimezoneOffset()*60*1000);
	    var ltmonth = lt.getMonth() + 1;
	    var ltday = lt.getDate();
	    var ltyear = lt.getFullYear();
	    var lthours = lt.getHours();
	    if(lthours >= 12)
	    { ltampm = "PM"
		    if(lthours > 12)
		    { lthours = lthours - 12; }
	    }
	    else
	    { ltampm = "AM" }
	    if(lthours < 10)
	    { lthours = "0" + lthours; }
	    var ltminutes = lt.getMinutes();
	    if(ltminutes < 10)
	    { ltminutes = "0" + ltminutes; }
	    var ltseconds = lt.getSeconds();
	    if(ltseconds < 10)
	    { ltseconds = "0" + ltseconds; }
	    var ltDate = ltmonth+"/"+ltday+"/"+ltyear+" "+lthours+":"+ltminutes+":"+ltseconds+" "+ltampm

	    document.getElementById(strField).value = ltDate;
    }

    function GMTclock()
    {
	    var time = new Date()
	    var gmtMS = time.getTime() 
		    + (time.getTimezoneOffset() * 60000)
	    var gmtTime =  new Date(gmtMS)

	    var hr = gmtTime.getHours()
	    var min = gmtTime.getMinutes()
	    var sec = gmtTime.getSeconds()
	    if(hr < 10)
	    {
		    hr = " " + hr
	    }
	    if(min < 10)
	    {
		    min = "0" + min
	    }
	    if(sec < 10)
	    {
		    sec = "0" + sec
	    }

	    gmt.innerText = hr + ":" + min + ":" + sec;
	    setTimeout("GMTclock()", 1000)
    }

    function Localclock()
    {
	    var time = new Date()
	    var localMS = time.getTime()
	    var localTime =  new Date(localMS)

	    var localhr = localTime.getHours()
	    var localmin = localTime.getMinutes()
	    var localsec = localTime.getSeconds()
	    if(localhr < 10)
	    {
		    localhr = " " + localhr
	    }
	    if(localmin < 10)
	    {
		    localmin = "0" + localmin
	    }
	    if(localsec < 10)
	    {
		    localsec = "0" + localsec
	    }

	    local.innerText = localhr + ":" + localmin + ":" + localsec;
	    setTimeout("Localclock()", 1000)
    }

    function JSFX_FloatTopDiv(startX,startY,divTagName)
    {
	    var ns = (navigator.appName.indexOf("Netscape") != -1);
	    var d = document;
	    function ml(id)
	    {
		    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		    if(d.layers)el.style=el;
			    el.sP=function(x,y)
		    {
			    this.style.left=x;this.style.top=y;
		    }
		    el.x = startX;
		    if (verticalpos=="fromtop")
			    el.y = startY;
		    else
		    {
			    el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
			    el.y -= startY;
		    }
		    return el;
	    }
	    window.stayTopLeft=function()
	    {
		    if (verticalpos=="fromtop")
		    {
			    var pY = ns ? pageYOffset : document.body.scrollTop;
			    ftlObj.y += (pY + startY - ftlObj.y)/2;
		    }
		    else
		    {
			    var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
			    ftlObj.y += (pY - startY - ftlObj.y)/2;
		    }
		    ftlObj.sP(ftlObj.x, ftlObj.y);
		    setTimeout("stayTopLeft()", 10);
	    }
	    ftlObj = ml(divTagName);
	    stayTopLeft();
    }

    function move_box(an, box)
    {
	    var cleft = 0;
	    var ctop = 0;
	    var obj = an;
	    while (obj.offsetParent)
	    {
		    cleft = document.body.clientWidth/4;
		    ctop += obj.offsetTop;
		    obj = obj.offsetParent;
	    }
	    box.style.left = cleft + 'px';
	    ctop += an.offsetHeight + 8;
	    if (document.body.currentStyle && document.body.currentStyle['marginTop'])
		    {
			    ctop += parseInt(document.body.currentStyle['marginTop']);
		    }
	    box.style.top = ctop + 'px';
    }

    function hide_box(href)
    {
	      var boxdiv = document.getElementById(href);
          boxdiv.style.display='none';
    }

    function show_hide_box(an, width, height, borderStyle, href) {
    //  var href = an.href;

      var boxdiv = document.getElementById(href);

      if (boxdiv != null) {
        if (boxdiv.style.display=='none')
        {
          move_box(an, boxdiv);
          boxdiv.style.display='block';
        } else
          boxdiv.style.display='none';
        return false;
      }

      boxdiv = document.createElement('div');
      boxdiv.setAttribute('id', href);
      boxdiv.style.display = 'block';
      boxdiv.style.position = 'absolute';
      boxdiv.style.width = width + 'px';
      boxdiv.style.height = height + 'px';
      boxdiv.style.border = borderStyle;
      boxdiv.style.borderWidth = '1px';

      var contents = document.createElement('iframe');
      contents.scrolling = 'Yes';
      contents.frameBorder = '0';
      contents.style.width = width + 'px';
      contents.style.height = height + 'px';
      contents.src = href;

      boxdiv.appendChild(contents);
      document.body.appendChild(boxdiv);
      move_box(an, boxdiv);

      return false;
    }

    function ExecuteParentCallback(objWindow, strCallbackName, objProperties)
    {
	    // If there is no Window specified, we're done
	    if (null == objWindow)
	    {
		    alert(	"A Window has not been specified.\n" +
				    "No action will be taken.");
		    return;
	    }

	    // If there is no Function Name specified, we're done.
	    if ((null == strCallbackName) || (strCallbackName.length < 1))
	    {
		    alert(	"A Callback Function has not been specified.\n" +
				    "No action will be taken.");
		    return;
	    }

	    // If the Function is not present in the Window then we're done
	    var fnFunction = objWindow[strCallbackName];
	    if (null == fnFunction)
	    {
		    alert(	"The \"" + strCallbackName + "\" Callback \n" + 
				    "does not exist in the Window.\n" + 
				    "No action will be taken.");
		    return;
	    }

    /*
	    // Build the array of arguments for the Callback.
	    // Load the array with the optional arguments.
	    //alert("arguments.length = " + arguments.length);

	    var argArray = new Array();
	    for (var idx = 2; idx < arguments.length; idx++)
	    {
		    argArray[idx - 2] = arguments[idx];
	    }

	    // Execute the function
	    // I don't know why the "apply" isn't working here, so for now, we're stuck 
	    // with one argument only.
	    //fnFunction.apply(null, argArray);
    */

	    // Execute the Callback
	    return (fnFunction(objProperties));
    }

    function textareaLimit(field, maxlimit)
    {
        if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    }

    function convert_date(dtClientID)
    {
        var strDate;
        var strDateArray;
        var strDay;
        var strMonth;
        var strYear;
        var intElementNr;
        var outdate1 = null;
    	
	    field1 = document.getElementById(dtClientID);
        strDate = field1.value;
        //Check only if length is > 1 
        if (strDate.length >= 1) 
        {
	        if (strDate.indexOf("/") != -1) 
            {
	            strDateArray = strDate.split("/");
	            if (strDateArray.length != 3) 
	            {
		            invalid_date(field1);
		            return false;
	            }
	            else 
	            {
	                //Validate format and appropriately assign values 
	                strMonth = strDateArray[0];
		            strDay = strDateArray[1];
		            strYear = strDateArray[2];
	            }
            }
            else
            {
	            invalid_date(field1);
	            return false;
            }
        	
            // Check day and year are numeric
            if ( isNaN(strDay) && isNaN(strMonth) && isNaN(strYear) ) 
            { 
	            invalid_date(field1);
	            return false;  
            }
        	
            //Make d day dd
            if ( strDay.length == 1 ) 
            { 
	            strDay = '0' + strDay;  
            }
        	
            //Make m month mm
            if ( strMonth.length == 1 ) 
            {
	            strMonth = '0' + strMonth;   
            }

            //Make yy year yyyy
            if ( strYear.length == 2 ) 
            {
	            if ( (strYear = validate_year(strYear)) == false ) 
	            {
		            invalid_date(field1);
		            return false;  
	            }
            }
        	
            // Date components are OK
            if ( (strDay.length == 2 || strMonth.length == 2 || strYear.length == 4) == false) 
            {
	            invalid_date(field1);
	            return false;
            }		
        	
            //Validate the date
            if ( (outdate1 = validate_date(strDay, strMonth, strYear)) == false ) 
            {
	            alert("The value " + field1.value + " is not a vaild date.\n\r" +  
			            "Please enter a valid date in the format mm/dd/yyyy");
	            //field1.focus();
	            return false;
            }

            // Redisplay the date in dd/mm/yyyy format
            field1.value = outdate1;
        }
        return true;//All is well
    } //end function

    /******************************************************************
    invalid_date()

    If an entered date is deemed to be invalid, invalid_date() is called to 
    display a warning message to the user.  Also returns focus to the date  
    in question and selects the date for edit.

    Called by convert_date()
    *******************************************************************/
    function invalid_date(inField) 
    {
        alert("The value " + inField.value + " is not in a vaild date format.\n\r" + 
		        "Please enter date in the format mm/dd/yyyy");
        inField.value = "";
        //inField.focus();
    }
    /******************************************************************
    validate_date()

    Validates date output from convert_date().  Checks
    day is valid for month, leap years, month !> 12,.

    *******************************************************************/
    function validate_date(day2, month2, year2)
    {
        var DayArray = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
        var MonthArray = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
        var inpDate = day2 + month2 + year2;
        var filter=/^[0-9]{2}[0-9]{2}[0-9]{4}$/;

        //Check ddmmyyyy date supplied
        if (! filter.test(inpDate))
        {
	        return false;
        }
    	
        /* Check Valid Month */
        filter=/01|02|03|04|05|06|07|08|09|10|11|12/ ;
        if (! filter.test(month2))
        {
	        return false;
        }

        /* Check For Leap Year */
        var N = Number(year2);
        if ( ( N%4==0 && N%100 !=0 ) || ( N%400==0 ) )
        {
	        DayArray[1]=29;
        }
        /* Check for valid days for month */
        for(var ctr=0; ctr<=11; ctr++)
        {
	        if (MonthArray[ctr]==month2)
	        { 
		        if (day2<= DayArray[ctr] && day2 >0)
		        {
			        inpDate = month2 + '/' + day2 + '/' + year2;
			        return inpDate;
		        }
		        else
			        return false;
	        }		
        }
    }
	
    function validate_year(inYear) 
    {
        if ( inYear < 51 ) 
        {
	        inYear = "20" + inYear;
	        return inYear;
        }
        else if ( inYear >= 51 )
        {
	        inYear = "19" + inYear;
	        return inYear;
        }
        else 
        {
	        return false;
        }
    } 

    function formatCurrency(num, includeCents) 
    {
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num))
            num = "0";
            
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents<10)
            cents = "0" + cents;
            
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
            num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
            
        if(includeCents){
            return (((sign)?'':'-') + '$' + num + '.' + cents);
        }else{
            return (((sign)?'':'-') + '$' + num);
        }
    }
    
    /////mytooltip

    var horizontal_offset="5px" //horizontal offset of hint box from anchor link

    var ie5_5=typeof hintboxiframe=='undefined'? 0 : 1
    var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
    var ie=document.all
    var ns6=document.getElementById&&!document.all

    function getposOffset(what, offsettype)
    {
	    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	    var parentEl=what.offsetParent;
	    while (parentEl!=null)
	    {
		    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		    parentEl=parentEl.offsetParent;
	    }
	    return totaloffset;
    }

    function iecompattest()
    {
	    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }

    function clearbrowseredge(obj, whichedge)
    {
	    var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	    if (whichedge=="rightedge")
	    {
		    var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
		    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		    edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
	    }
	    else
	    {
		    var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
		    edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
	    }
	    return edgeoffset
    }

    function mytooltip(menucontents, obj, e, tipwidth)
    {
	    if ((ie||ns6) && document.getElementById("hintbox"))
	    {
		    dropmenuobj=document.getElementById("hintbox")
		    dropmenuobj.innerHTML=menucontents
		    dropmenuobj.style.left=dropmenuobj.style.top=-500
		    if (tipwidth!="")
		    {
			    dropmenuobj.widthobj=dropmenuobj.style
			    dropmenuobj.widthobj.width=tipwidth
		    }
		    dropmenuobj.x=getposOffset(obj, "left")
		    dropmenuobj.y=getposOffset(obj, "top")
		    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		    dropmenuobj.style.visibility="visible"
		    obj.onmouseout=hidetip
		    unhideIframe();
	    }
    }

    function hidetip(e)
    {
	    hideIframe();
	    dropmenuobj.style.visibility="hidden"
	    dropmenuobj.style.left="-500px"
    }

    function createhintbox()
    {
	    var divblock=document.createElement("div")
	    divblock.setAttribute("id", "hintbox")
	    //document.body.appendChild(divblock) This line was causing unwanted new line at the end of the page after the footer.
	    document.forms[0].appendChild(divblock)
    }

    if (window.addEventListener)
	    window.addEventListener("load", createhintbox, false)
    else if (window.attachEvent)
	    window.attachEvent("onload", createhintbox)
    else if (document.getElementById)
	    window.onload=createhintbox

    // Hide IFrame
    function hideIframe()
    {
	    if (ie5_5)
	    {
		    var theIframe = document.getElementById("hintboxiframe")
		    theIframe.style.display = "none";
	    }
    }

    // Unhide IFrame
    function unhideIframe()
    {
	    if (ie5_5)
	    {
		    var theIframe = document.getElementById("hintboxiframe")
		    var theDiv = document.getElementById("hintbox");
		    theIframe.style.width = theDiv.offsetWidth+'px';
		    theIframe.style.height = theDiv.offsetHeight+'px';
		    theIframe.style.top = theDiv.offsetTop+'px';
		    theIframe.style.left = theDiv.offsetLeft+'px';
		    theIframe.style.display = "block";
	    }
    }
