/*************************************************************************
<!--                                                            //-->
<!--  © 2003 - 2008 MotionsMedia Technology and Communications  //-->
<!--  Author: Edward Anthony Gal                                //-->
<!--  All rights reserved                                       //-->
<!--                                                            //-->
<!--  2008-11-30 change - conversion to the new template        //-->
<!--                      based on 88 Redpath                   //-->
*************************************************************************/

/* 
    dw_scrollObj.js  version date: March 2005
    
    GeckoTableBugFix now excludes Safari and Konqueror,
    recent versions of ns/moz (ns7.2 and moz 1.73) don't need it (moz 1.5 does)
    
    contains constructor and basic methods for scrolling layers.
    Use with dw_hoverscroll.js and/or dw_glidescroll.js,
    and for scrollbars: dw_scroll-aux.js and dw_slidebar.js
*/

dw_scrollObjs = {};
dw_scrollObj.speed = 100; // default speed for mouseover scrolling
//  constructor arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
//	id of table or other element that scrolling content is nested in. 
//	ns6+/moz need that extra container to get width for horizontal scrolling.
//	(not needed for vertical scrolling)
function dw_scrollObj(wnId, lyrId, cntId) {
    this.id = wnId; dw_scrollObjs[this.id] = this;
    this.animString = "dw_scrollObjs." + this.id;
    this.load(lyrId, cntId);
}

dw_scrollObj.loadLayer = function(wnId, id, cntId) {
    if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].load(id, cntId);
}

dw_scrollObj.prototype.load = function(lyrId, cntId) {
    if (!document.getElementById) return;
    var wndo, lyr;
    if (this.lyrId) {
        lyr = document.getElementById(this.lyrId);
        lyr.style.visibility = "hidden";
    }
    lyr = document.getElementById(lyrId);
    wndo = document.getElementById(this.id);
    lyr.style.top = this.y = 0; lyr.style.left = this.x = 0;
    this.maxY = (lyr.offsetHeight - wndo.offsetHeight > 0)? lyr.offsetHeight - wndo.offsetHeight: 0;
    this.wd = cntId? document.getElementById(cntId).offsetWidth: lyr.offsetWidth;
    this.maxX = (this.wd - wndo.offsetWidth > 0)? this.wd - wndo.offsetWidth: 0;
    this.lyrId = lyrId; // hold id of currently visible layer
    lyr.style.visibility = "visible";
    this.on_load(); this.ready = true;
}

dw_scrollObj.prototype.on_load = function() {}  

// not this.lyr because ...
dw_scrollObj.prototype.shiftTo = function(lyr, x, y) {
    lyr.style.left = (this.x = x) + "px"; 
    lyr.style.top = (this.y = y) + "px";
}

// remove layers from table for ns6+/mozilla (needed for scrolling inside tables)
dw_scrollObj.GeckoTableBugFix = function() {
    var i, wndo, holderId, holder, x, y;
    var ua = navigator.userAgent;
    if ( ua.indexOf("Gecko") > -1 && ua.indexOf("Firefox") == -1 
        && ua.indexOf("Safari") == -1 && ua.indexOf("Konqueror") == -1 ) {
        dw_scrollObj.hold = []; // holds id's of wndo and its container
        for (i=0; arguments[i]; i++) {
            if ( dw_scrollObjs[ arguments[i] ] ) {
                wndo = document.getElementById( arguments[i] );
                holderId = wndo.parentNode.id;
                holder = document.getElementById(holderId);
                document.body.appendChild( holder.removeChild(wndo) );
                wndo.style.zIndex = 1000;
                x = holder.offsetLeft; y = holder.offsetTop;
                wndo.style.left = x + "px"; wndo.style.top = y + "px";
                dw_scrollObj.hold[i] = [ arguments[i], holderId ];
            }
        }
        window.addEventListener("resize", dw_scrollObj.rePositionGecko, true);
    }
}

// ns6+/mozilla need to reposition layers onresize when scrolling inside tables.
dw_scrollObj.rePositionGecko = function() {
    var i, wndo, holder, x, y;
    if (dw_scrollObj.hold) {
        for (i=0; dw_scrollObj.hold[i]; i++) {
            wndo = document.getElementById( dw_scrollObj.hold[i][0] );
            holder = document.getElementById( dw_scrollObj.hold[i][1] );
            x = holder.offsetLeft; y = holder.offsetTop;
            wndo.style.left = x + "px"; wndo.style.top = y + "px";
        }
    }
}

/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

/* dw_hoverscroll.js  version date: June 2004 
   mouseover scrolling for dw_scrollObj (in dw_scrollObj.js)  */

dw_scrollObj.stopScroll = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].endScroll();
}

// increase speed onmousedown of scroll links
dw_scrollObj.doubleSpeed = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed *= 2;
}

dw_scrollObj.resetSpeed = function(wnId) {
  if ( dw_scrollObjs[wnId] ) dw_scrollObjs[wnId].speed /= 2;
}

// algorithms for time-based scrolling and scrolling onmouseover at any angle adapted from youngpup.net
dw_scrollObj.initScroll = function(wnId, deg, sp) {
  if ( dw_scrollObjs[wnId] ) {
  	 
    var cosine, sine;
    if (typeof deg == "string") {
      switch (deg) {
        case "up"    : deg = 90;  break;
        case "down"  : deg = 270; break;
        case "left"  : deg = 180; break;
        case "right" : deg = 0;   break;
        default: 
          alert("Direction of scroll in mouseover scroll links should be 'up', 'down', 'left', 'right' or number: 0 to 360.");
       }
    } 
    deg = deg % 360;
    if (deg % 90 == 0) {
      cosine = (deg == 0)? -1: (deg == 180)? 1: 0;
      sine = (deg == 90)? 1: (deg == 270)? -1: 0;
    } else {
      var angle = deg * Math.PI/180;
      cosine = -Math.cos(angle); sine = Math.sin(angle);
    }
    dw_scrollObjs[wnId].fx = cosine / ( Math.abs(cosine) + Math.abs(sine) );
    dw_scrollObjs[wnId].fy = sine / ( Math.abs(cosine) + Math.abs(sine) );
    dw_scrollObjs[wnId].endX = (deg == 90 || deg == 270)? dw_scrollObjs[wnId].x:
      (deg < 90 || deg > 270)? -dw_scrollObjs[wnId].maxX: 0; 
    dw_scrollObjs[wnId].endY = (deg == 0 || deg == 180)? dw_scrollObjs[wnId].y: 
      (deg < 180)? 0: -dw_scrollObjs[wnId].maxY;
    dw_scrollObjs[wnId].startScroll(sp);
  }
}

// speed (optional) to override default speed (set in dw_scrollObj.speed)
dw_scrollObj.prototype.startScroll = function(speed) {
  if (!this.ready) return; if (this.timerId) clearInterval(this.timerId);
  this.speed = speed || dw_scrollObj.speed;
  this.lyr = document.getElementById(this.lyrId);
  this.lastTime = ( new Date() ).getTime();
  this.on_scroll_start();  
  this.timerId = setInterval(this.animString + ".scroll()", 10); 
}

dw_scrollObj.prototype.scroll = function() {
  var now = ( new Date() ).getTime();
  var d = (now - this.lastTime)/1000 * this.speed;
  if (d > 0) {
    var x = this.x + this.fx * d; var y = this.y + this.fy * d;
    if (this.fx == 0 || this.fy == 0) { // for horizontal or vertical scrolling
      if ( ( this.fx == -1 && x > -this.maxX ) || ( this.fx == 1 && x < 0 ) || 
        ( this.fy == -1 && y > -this.maxY ) || ( this.fy == 1 && y < 0 ) ) {
        this.lastTime = now;
        this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
      } else {
        clearInterval(this.timerId); this.timerId = 0;
        this.shiftTo(this.lyr, this.endX, this.endY);
        this.on_scroll_end(this.endX, this.endY);
      }
    } else { // for scrolling at an angle (stop when reach end on one axis)
      if ( ( this.fx < 0 && x >= -this.maxX && this.fy < 0 && y >= -this.maxY ) ||
        ( this.fx > 0 && x <= 0 && this.fy > 0 && y <= 0 ) ||
        ( this.fx < 0 && x >= -this.maxX && this.fy > 0 && y <= 0 ) ||
        ( this.fx > 0 && x <= 0 && this.fy < 0 && y >= -this.maxY ) ) {
        this.lastTime = now;
        this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
      } else {
        clearInterval(this.timerId); this.timerId = 0;
        this.on_scroll_end(this.x, this.y);
      }
    }
  }
}

dw_scrollObj.prototype.endScroll = function() {
  if (!this.ready) return;
  if (this.timerId) clearInterval(this.timerId);
  this.timerId = 0;  this.lyr = null;
}

dw_scrollObj.prototype.on_scroll = function() {}
dw_scrollObj.prototype.on_scroll_start = function() {}
dw_scrollObj.prototype.on_scroll_end = function() {}
  
function GetPicture(file)
{
	document.forms[0].BigPicture.src = '../system/ishuttledisplay.asp?hCode=731&sFileName=' + file;
}
function GetAmenity(sUT, sCode)
{
	//alert('wbl_Property_GetFPDetails.asp?sCode=' + sCode + '&sUT=' + sUT );
	top.Amenities.location = 'wbl_Property_GetAmenities.asp?sCode=' + sCode + '&sUT=' + sUT ;
	top.Details.location = 'wbl_Property_GetDetails.asp?sCode=' + sCode + '&sUT=' + sUT ;
}

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo2 = new dw_scrollObj('wn2', 'lyr12', 't12');
  
  
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn2'); 
  
}

function doRequest(scode) 
{
	AspWindow = window.open("wbl_ContactUs.asp?sCode=" + scode ,"optionWin","toolbar=no,resizable=yes,location=no,scrollbars=yes,height=600,width=600,left=50,top=50,alwaysraised=yes");
}

 

/*---------------------------------------------------------------------------------------------------------
 Yardi Common JavaScript Library
 Copyright 1999-2000 (c) Yardi Systems, Inc.

[1] MaskAcct - formats text with the acct mask (i.e. 4500 -> 4500-0000)
[2] Find - find an element in a list
[3] Error - displays an error
[4] Empty - checks if string is empty
[5] ValidLength - checks is string is of a valid length
[6] ValidInt - checks if number is a valid integer
[7] ValidCurrency - checks if number is a valid currency
[8] ValidateDate - checks if object is valid date
[9] ValidPhone - checks if string is valid phone number
[12] ValidMinMax - checks if number is between two values
[13] ValidYesNo - checks if string is = yes or no
[14] WriteMenu - generalized menu writing function
[15] Nav0 - Specifies submit action depending on type of form
[16] GotChange - set bDataChanged = true
[20] MenuWindow - Create a test window
[21] SetCookie - Sets a cookie
[22] GetCookie - Returns a cookie
[23] Find2 - find text in a listbox after the '-'
[25] GetAppName - This function gets the name of the directory imediatly above the current htm file.
[26] UpdateHeader - accumulates amount in target with amount from source - peculiar to batches and movein.
[27] listWindow - puts a list of objects(tenant, prop, etc) in a seperate window
[28] PromptAmount - on double click of amount paid box, puts in amount from amount owed box - peculiar to batches.
[29] EditWindow - puts data from batch receipt screen into a new window for editing - peculiar to batches.
[30] FormatNumber - formats a number with the mask (i.e. 100 -> 100.00)
[31] NonBlank - input box may not be blank
[32] parseNum - strips commas out, executes parseFloat
[33] gotFocus - no op for now
[34] QueryIf - container for call on QueryIf2; for navigation purposes
[35] FT_FinalTest - checks for mandatory fields on sys generated filters
[36] Hand / Help - Changes cursor to a Hand or ? when table cell or image is moused over.
[37] Help for filter screen
[38] OPT_Update - updates boxes on Options screen
[39] SayStates - says the option statements for a state <SELECT
[40] ValidMintMaxt - checks if number is a valid integer & checks if number is between two values MDM000330
[41] MoveIt - moves elements from one list box to an other
[42] CompressIt - Takes out blank elements from a list box
[43] QueryIf2 - this procedure should be in all forms for which you want
                the user to be prompted if they want to save a form
                the one in here is to prevent errors when the current form
                (for what ever reason) doesn't have a QueryIf2
[44] SetFocusOnFirstField - Sets focus(cursor) on the first field of the form (if that field exists)
[45] FormatNumber2 - truncates extra digits from numbers
[46] Round - rounds numbers to 2 digits.
[47] bDelete - Ask the confirmation for delete
[48] Trims spaces before and after string. Usage just as in VB: trim(var.value), 
[49] FormatPhoneNum - guess
[50] PageBreak - printer page break
[51] GetToken - Get the specified param (sToken) from string (sURL)
[52] MaxDay - returns max day for given month/year
[53] PromptEndDate - given date and term, return end date (for leases)
[54] ValidateTime - validates time in hh:mm format
[55] CurrentDate - returns string of current date
[56] CurrentTime - returns string of current time
[57] DateAfter - checks if date1 is after date2
[58] QueryString1 - search for a specific name on the Query or Hash strings of the page's URL and return the value.
[59] OpenWindow2 - called by OpenWindow
[60] OpenWindow - opens a new window, used by form like resident/lease charges
[61] GetStyleSheet - gets the stylesheet name from the cookie and writes a string that includes the name.
[62] Filter - shows filter for object that's on screen, if appropriate
[63] ActiveMenu - Menubar uses this script to check if data on a present form has changed before redirecting.
[64] ExitForm - Checks to make sure to save if data has changed.
[65] TabTo - Forms with tabs use this to navigate
[66] ValidFloat - Similar to ValidCurrency, but allow user to specify number of digits to the right of the decimal.
[67] userList - call ysilist with a 'select' and optional property code and/or optional account code
[68] unMaskAcct = strip '-' or '.' out of account field for passing account code to userlist
[69] Get_Real_Asp_Name = returns ASP name for given iType, for filter button purposes
[71] ClearFilterPrompt = clears out propmt field if user blanks out code field
[72] ValidYear - checks if object is valid year, between 1875 and 2199
[73] ValidateSSN - Checks to see if there are the right amount of numbers. It will allow for 2 dashes (just about anywhere but only 2). A "t" or "T" is allowed at the first character for "temporary" SSN's.
[74] ValidateSSN2 - Test SSN for valid characters, the right amount of numbers and formats with dashes. Will allow HUD temporary, HUD psudo and EIN numbers
[75] StripDashesFmSSN - Strips dashes from SSN but leaves one dash if an EIN
[76] ValidateEmail - Validates email addresses.
[77] isValidMoneyFormat - Test if a string is a valid number like 123.12 or -1,234,567.12
[78] nameWindow - forms in frame[2] determine that name of the parent window. 
[79] Prompt Term - given 2 dates, returns the month diff
[80] DaysDiff - given 2 dates, returns days diff
[81] show_clock - 
[82] isValidInteger - Test if a string is a valid number like 123 or -1,234,567
[83] parseInteger - strips commas (or rather thousand separators) out, executes parseInt
[84] formatInteger - formats a number with the mask (i.e. 100 -> 100.00)
[85] validInteger - checks if number in a field on the form is a valid integer between a min and a max value and formats the number with thousand separators
[86] MaskCateg - formats text with the categ mask (i.e. 110500 -> 1105-00)
[87] addNewNode2Menu - Every time a new record is added this function will added to the nod/tree
[88] ShowMemo - pops up a window of uniform size for memos
[89] getSelectedValue - This function takes a <select> object as input and returns a string holding the selected value
[90] ShowMemo2 - same as ShowMemo but goes directly to memo
[91] ShowMemo3 - same as ShowMemo but goes directly to memo and is for Prospect Contacts
[92] ShowMemo4 - same as ShowMemo but can be called from an ASP page. (needed the ../ in front of iData)
[93] FormatNumberRounded - This function extends function FormatNumber by first rounding the value in numObj
[94] FormatNumber2Rounded - This function extends function FormatNumber2 by first rounding the value in sTest
[95] OpenWindowAsp - Same as OpenWindow but changed location of data.htm due to call from asp
[96] DateAdd(startDate, numDays, numMonths, numYears) - add or subtract days/months/years -ve value will do subtraction
[97] YearAdd(startDate, numYears) - add or subtract years -ve numyears will do subtraction
[98] MonthAdd(startDate, numMonths) - add or subtract months -ve numMonths will do subtraction
[99] DayAdd(startDate, numDays) - add or subtract days -ve numDays will do subtraction
[100] trim function for the built-in JavaScript String object
[101] GoToErrorTab - This function reutrns the user to the the tab where a required field was not completed.

[104] TabClick - For ASP pages with a tabstrip on, when a tab is clicked, hide the div corresponding to the old tab and display the div corresponding to the new tab
[105] GetBlankPage - returns the path to /system/blank.htm use with window.open(GetBlankPage,... to prevent secure/nonsecure warnings over SSL (https) connections 
-----------------------------------------------------------------------------------------------------------*/

//[1]
function MaskAcct(obj, acctlen, acctmask, seperator)
{
  /*obj is text box.  obj might have a .isRequired property
  acctlen is length of acct mask not including seperators
  acctmask is the mask (i.e. ????-????)
  seperator is a '-'  or a '.'
  acct masks can have a '-' or a '.' as seperators, but not both
  and may have multiple seperators or no seperators*/


  var sout = "";        // output value
  var idashloc = 0;
  var ss = new String(obj.value);   //converts object to string
  var ilen = ss.length;
  var iSepCount = 0;
  var sTemp = "";


  // check for required field
  if( typeof(obj.isRequired) == "undefined")
    {obj.isRequired = false;} // default not required

  if (ss == "") {
    if (obj.isRequired) {return error(obj, 'Acct number required')}
          }
  if (ss == "") { return true; }

  //remove seperators from input
  for (i = 0; i <= acctlen; i++) {
      idashloc = ss.indexOf(seperator);
      if (idashloc <= 0) { break;  }
      ss = ss.substring(0, idashloc) + ss.substring(idashloc + 1, ss.length);
  }

  //count number of seperators in acctmask
  sTemp = acctmask
  for (i = 0; i <= acctlen; i++) {
      idashloc = sTemp.indexOf(seperator)
      if (idashloc <= 0) {break;}
      sTemp = sTemp.substring(idashloc + 1, sTemp.length)
      iSepCount = iSepCount + 1
  }

  //add zeros to input if input.length <> acctlen
  if (ss.length != acctlen.length) {
    for (i = ss.length; i < acctlen; i++) {
      ss = ss + "0";
    }
  }

  //now, mask it
  i = 0
  idashloc = 0
  while(i < iSepCount) {
    idashloc = idashloc + acctmask.indexOf(seperator)
    if (idashloc <= 0) { break; }
    acctmask = acctmask.substring(idashloc + 1, acctmask.length)
    ss = ss.substring(0, idashloc + i) + seperator + ss.substring(idashloc + i, ss.length + 1);
    i += 1
     }


  obj.value = ss;

  return true;
}

//[2]
// Find an element in the list
// Arguments: 1) the select list, 2) the textbox
function Find(list, text)
{

  // find the first matching
  if( text.value.length > 0){
    for( var i = 0; i < list.length; i++){
      if( list.item(i).text.substr(0,text.value.length).toUpperCase() == text.value.toUpperCase()){
        list.options[i].selected = true;
        return true;
      }
    }
  }
  return false;
}


//[3]
function error(elem, text, bSelect) {
// display the first error
   var ss;

   if (typeof(text)  == "undefined") { window.alert("Undefined error."); this.select()}
   window.alert(text);
   if (typeof(elem)  == "undefined") {return}
   if (elem == "n"){return}
   if (elem.disabled == true) {return}
   if (bSelect != "false") {
      if (bSelect != "combo") {          
      	document.forms[0].elements[elem.name].focus();        
      }

   };
   errorfound = true;
}

//[4]
function Empty(num) {
  if (num == "") return true;
  num = num.toString();		/* ensure variable num is of datatype string before we use string routines */
  for (var i = 0; (i < num.length); i++) {
  	if (num.charAt(i) == " ") continue;
  	else return false; 
  }
  return true;	  
}

//[5]
function ValidLength(item, maxlen) {
   if (Empty(item.value)) return true;
   return (item.Length <= maxlen);
}

//[6]
function ValidInt(numObj)
{
	var sTest = numObj.value;
	var sGUID = GetCookie("bEuroNum");
	var sPattern;
	var bTemp = false;
	
	/* check for numbers like 123 */
	var re = new RegExp("^(-\\d)?\\d*$");
	bTemp = (re.test(sTest)) ? true : bTemp;
	
	/* check for numbers like 1,234 and -123,456,789 */
	sPattern = (sGUID == "true") ? "^-?\\d{1,3}(\\.\\d{3})*$" : "^-?\\d{1,3}(\\,\\d{3})*$";
	re.compile(sPattern);
	bTemp = (re.test(sTest)) ? true : bTemp;
	if (! bTemp)
	{
		error(numObj, "Invalid number");
	}
	return bTemp;
}

//[7]
function ValidCurrency(numObj, iMin, iMax)
{
	var sTest = numObj.value;
	iMin = (iMin == null) ? -1000000000 : iMin;
	iMax = (iMax == null) ?  1000000000 : iMax;

	/* test if number is valid currency format */
	if (Empty(sTest)) {return true;}
	if (! isValidMoneyFormat(sTest, 2))
	{
		error(numObj, "Invalid number.");
		return false;
	}
	
	/* get number back as US format without thousand separator */
	sTest = parseNum(numObj, 2);

	/* test if number is within min and max limits */
	if (! ValidMinMax(sTest, iMin, iMax))
	{
		error(numObj, "Invalid number.");
		return false;
	}
	
	numObj.value = sTest;
	FormatNumber(numObj);
	return true;
}


//[8]
function ValidateDate(obj)
/*  if optional property .isDay is true, input must be:
    mm/dd/yy
    mm/dd/yyyy
    m/d/yy
    m/d/yyyy
    mm/d/yy
    mm/d/yyyy
    m/dd/yy
    m/dd/yyyy
    mmddyy
    mmddyyyy
  otherwise, input must be:
    mm/yy
    mm/yyyy
    m/yy
    m/yyyy
    mmyy
    mmyyyy
  "/" is the only valid seperator
  These are the only known valid inputs. Others might work
  but don't count on it (isn't this enough?)
*/
{
  var ilen;
  var sout;
  var yy, mm, dd;
  var tmp;
  var inumsep;
  var imonth, iyear, iday;
  var serr;
  var isep1, isep2;  //holds position of "/"
  var imstart, imlen;
  var idstart, idlen;
  var iystart, iylen;
  var ss = new String(obj.value);
  var d = new Date();
  var m = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
    var window = 50;  //year cutoff when yy is passed in (i.e. 49 = 2049, 50 = 1950)

        var sGUID = GetCookie("bEuroDate");
    if (sGUID == "true") {bEuro = true}
    else                 {bEuro = false}


  ilen = ss.length;
  iday = 0;  //in case is never gets set below
  
  // check for required field

  if( typeof(obj.isRequired) == "undefined"){
    obj.isRequired = false;   // default not required
  }



  if (ilen == 0) {return true;}

  // check for .isDay
  if( typeof(obj.isDay) == "undefined"){
    obj.isDay = false;      // default to not expecting days - month & year only                           
  }
  else {
      if (obj.isDay == "true") {obj.isDay = true}
      else if (obj.isDay == "false") {obj.isDay = false}
  }
  

  //set error message
  if (bEuro == false) {
    if (obj.isDay) {serr = "Expecting date in mm/dd/yyyy format."}
    else {serr = "Expecting date in mm/yyyy format."}
  }
  else {
    if (obj.isDay) {serr = "Expecting date in dd/mm/yyyy format."}
    else {serr = "Expecting date in mm/yyyy format."}

  }

  // all chars must be numeric or "/"
  inumsep = 0
  for( var i = 0; i < ilen; i++){
    tmp = ss.charAt(i);
    if (tmp == '/') {
      inumsep = inumsep + 1;
      if (inumsep == 1) {isep1 = i}
      else if (inumsep == 2) {isep2 = i}
    }
  }

  //check for valid number of "/"
  if (obj.isDay && inumsep > 2) {error(obj, serr); return false;}
  else if (!obj.isDay && inumsep > 1) {error(obj, serr); return false;}

  //check for valid placement of "/"
  if (inumsep > 0) {
    if (isep1 != 1 && isep1 != 2) {error(obj, serr); return false;}
    }
  if (inumsep > 1) {
    if (isep2 != 3 && isep2 != 4 && isep2 != 5) {error(obj, serr); return false;}
    }


  //set start and length of month, day and year
  if (inumsep == 0) {
    if (ilen == 4) {
      imstart = 0; imlen = 2;
      iystart = 2; iylen = 2;
      }
    else if (ilen == 6 && obj.isDay) {
      imstart = 0; imlen = 2;
      idstart = 2; idlen = 2;
      iystart = 4; iylen = 2;
      }
    else if (ilen == 6 && !obj.isDay) {
      imstart = 0; imlen = 2;
      iystart = 2; iylen = 4;
      }
    else if (ilen == 8) {
      imstart = 0; imlen = 2;
      idstart = 2; idlen = 2;
      iystart = 4; iylen = 4;
      }
    }
  else if (inumsep == 1) {
    imstart = 0; imlen = isep1;
    iystart = isep1  + 1; iylen = ilen - isep1 - 1
    }
  else if (inumsep == 2) {
    imstart = 0; imlen = isep1;
    idstart = isep1  + 1; idlen = isep2 - isep1 - 1
    iystart = isep2 + 1; iylen = ilen - isep2 - 1
    }


  if (obj.isDay != false) {
  if (bEuro==true && obj.isDay.toUpperCase() == 'TRUE') {
    //switch it all around
    ii = imstart
    ij = imlen
    imstart = idstart
    imlen = idlen
    idstart = ii
    idlen = ij
  }
  }


  imonth = parseInt(ss.substr(imstart, imlen), 10);  //10 param sets to base 10 (default is 8!)
                 //without it, "08" and "09" returned 0
  iyear = parseInt(ss.substr(iystart, iylen), 10);
  if (obj.isDay) { iday = parseInt(ss.substr(idstart, idlen), 10) }

  if (isNaN(imonth) || isNaN(iyear) || isNaN(iday)) {error(obj, serr); return false;}

  if (obj.isDay) {serr = "Date out of range."} else {serr = "Expecting date in mm/yy format."}
  if (iylen != 4 && iylen != 2) {error(obj, serr); return false;}
  if (imlen != 1 && imlen != 2) {error(obj, serr); return false;}
  if (obj.isDay) {
  if (idlen != 1 && idlen != 2) {error(obj, serr); return false;}
    }

  if (imonth < 1 || imonth > 12) {error(obj, serr); return false;}
  if (iylen == 4 && (iyear < 1875 || iyear > 2199)) {error(obj, serr); return false;}
  //SA052802  change year range lower limit from 1900 to 1875 for affordable tenants birthdates
  //MRB	      change year range upper limit from 2100 to 2199 for leases in good old England
  if (iylen == 2 && (iyear < 0 || iyear > 99)) {error(obj, serr); return false;}
  if ( (obj.isDay) && (iday < 1 || iday > 31) ) {error(obj, serr); return false;}




  mm = imonth;
  mm = mm > 9 ? mm : "0" + mm.toString();
  dd = iday;
  dd = dd > 9 ? dd : "0" + dd.toString();
  yy = iyear;
  yy = yy > 9 ? yy : "0" + yy.toString();

    if (iyear < 1000) {
    if (parseInt(yy) < window ) {yy = "20" + yy }
    else { yy = "19" +  yy }
    iyear = parseInt(yy)
  }


  //30 days hath November...
  if ((imonth == 1) || (imonth == 3) || (imonth == 5) || (imonth == 7) || (imonth == 8) || (imonth == 10) || (imonth == 12)) {
      if (iday > 31) {error(obj, serr); return false;}
  }
  else if ((imonth == 4) || (imonth == 6) || (imonth == 9) || (imonth == 11) ) {
      if (iday > 30) {error(obj, serr); return false;}
  }
  else if (imonth == 2) {
      //leap year, every 4 years, except centuries that are not evenly
      //divisible by 100
      imod = iyear % 4
      imod2 = iyear % 100
      if (imod == 0 && ( (imod2 != 0) || (iyear % 400 == 0) )) {  
        if (iday > 29) {error(obj, serr); return false;}
      }
      else {
        if (iday > 28) {error(obj, serr); return false;}
      }
  }

if (bEuro == true) {
    if( obj.isDay){
      sout = dd + "/" + mm + "/" + yy;
    }
    else{
      sout = mm + "/" + yy;
    }
}
else {
    if( obj.isDay){
      sout = mm + "/" + dd + "/" + yy;
    }
    else{
      sout = mm + "/" + yy;
    }

}

  obj.value = sout;
  return true;
}

//[9]
function ValidPhone(num) {
        return true;  // todo
        if (Empty(num)) return true;
        for (var i = 0; (i < num.length); i++) {
        if (num.charAt(i) == " ") continue;
        if ((num.charAt(i) >= "0") && (num.charAt(i) <= "9")) continue;
        return false;
}
return true;
}

//[12]
function ValidMinMax(num, mini, maxi) {

        if (Empty(num)) {return true;}                
        return ((num >= mini) && (num <= maxi))
}

//[13]
function ValidYesNo(num) {
        if (Empty(num)) return true;
        if ((num == "Yes") || (num == "No")) return true;
        return false
}



//[14]
// generalized menu write function
  //Menu background elements
  function bgcolorin(elem,name){
      elem.style.backgroundColor = "#cccccc";
      elem.style.cursor = "hand"
  }
  function bgcolorout(elem){
      elem.style.backgroundColor = "#edede2";
  }
  function bgcolorclick(elem){
      elem.style.backgroundColor = "#edede2";
    //parent.menubar.window.document.tracker.currentitem.value = ' ' + elem;
  }

  function bgcolorup(path){
        parent.filter.window.document.location.href = "iData.asp?WCI=begin&action=FILTER&select="+path;
  }


//[15]
function nav0(theValue,AppName) {
// Specifies submit action depending on type of form
// E==Form, F==Filter
// 1 = new
// 2 = save
//3 = jump to
  var bdata =0;
  var errorfound = false
  var ss = "";   
   if (theValue == 2 || theValue == 15) {
   	 if (typeof(document.forms[0].sJump) != "undefined") {document.forms[0].sJump.value = ""}
     if (!FT_FinalTest()) {return false};
     if (typeof(document.forms[0].BSAVE) != "undefined")  {
       document.forms[0].BSAVE.value = "1"
     }
   }  
   else {
     //if new or jump to, we create our version of the built in window that ExitForm will display
     //because if they say they don't want to save data, we need to set BDATACHANGED = 0 
     //otherwise, the DLL will save their data.
     if (typeof(document.forms[0].BDATACHANGED) != "undefined")  {
       bdata = document.forms[0].BDATACHANGED.value 
       if (bdata == 1) {
       	 ss = "You are about to navigate away from this page?"
       	 ss = ss + String.fromCharCode(10, 13)
       	 ss = ss + String.fromCharCode(10, 13)
       	 ss = ss + "Your data has NOT been saved!"
       	 ss = ss + String.fromCharCode(10, 13)
       	 ss = ss + String.fromCharCode(10, 13)
       	 ss = ss + "Press OK to continue, or Cancel to stay on the current page."
         errorfound = (confirm (ss));
         if (!errorfound) {         	
         	 return false;
         }
         else {
           if (typeof(document.forms[0].BSAVE) != "undefined")  {
           	 document.forms[0].BDATACHANGED.value = "0"
             document.forms[0].BSAVE.value = "1"
           }         
         }
       }	
     }
   }
   
    if ((typeof(document.forms[0].DONTSAVE) != "undefined") && (document.forms[0].DONTSAVE.value != "0")) {
        document.forms[0].BDATACHANGED.value = "0";
        window.alert("Form will not be saved");
        }
 
    if (theValue != 3) {
      if (typeof(document.forms[0].BPOSTED) != "undefined")  {
        if (document.forms[0].BPOSTED.value != "0") {     
          window.alert("This page has already been sent.");
          parent.location.href = "iData.asp?WCI=begin&Action=home";
          }
        else {
         document.forms[0].BPOSTED.value = "-1";
        }
      }
    }
    

    if (AppName == "iVista") {return errorfound;}
    if (theValue == 2) {theValue = 0}   //reset to 0 (display)
    document.forms[0].IFUNCTION.value = theValue;
    document.forms[0].ACTION.value = "E";
    if (theValue == 11) {document.forms[0].ACTION.value = "F";} 
    if (theValue == 15) {document.forms[0].BDATACHANGED.value = "0";} 
    if (typeof(document.forms[0].BSAVECLICK) != "undefined")  {
      if (document.forms[0].BSAVECLICK.value!="1") {
        document.forms[0].BSAVECLICK.value = "1";
       }
      else { 
        return true;
      }
    }
    document.forms[0].submit ();
}


//[16]
function gotChange() {        

        document.forms[0].BDATACHANGED.value = "1";
}

//[20]
// Create a test window
function MenuWindow(url) {
  return window.open(url,'newWin','toolbar=no,resizable=yes,location=no,scrollbars=no,width=370,height=300,name=test')
}

//[21]
// Create a cookie with the specified name and value.
function SetCookie(sName, sValue)
{
//  document.cookie = sName + "=" + escape(sValue) + ";";
  var d = new Date();
  d.setFullYear(d.getFullYear()+1);
  document.cookie=sName+"="+escape(sValue)+";"+"expires="+d;
}

//[22]
// Get the specified cookie
function GetCookie(sCookie)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split(";");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sCookie.replace(" ", "") == unescape(aCrumb[0].replace(" ", "")))
      return unescape(aCrumb[1]);
  }

  return null;
}


//[23]
// find text in a listbox after the '-'
function Find2(list, text)
{
  // find the first matching
  if( text.value.length > 0){
    for( var i = 0; i < list.length; i++){
      if (list.item(i).text.toUpperCase().indexOf(text.value.toUpperCase()) > 0) {
        list.options[i].selected = true;
        return true;
      }
    }
  }
  return false;
}


//[25]
// This function gets the name of the directory imediatly above the current htm file.
function GetAppName()
{
  var temp;

  temp = window.location.href;
  temp = temp.substr(0,temp.lastIndexOf("/"));
  temp = temp.substr(temp.lastIndexOf("/")+1);

  return temp;
}

//[27]
function listWindow(url, fieldname, bsub) {

  var newWindow;
  var ii=0;
  var sValue="";
  var ss="";
  
  /* do "URLenocding" of plus (+) sign that the JavaScript function escape() neglects.
     This becomes a problem if the select statement passed contains a plus sign */
  var re = new RegExp("\\+", "g");
  url = url.replace(re, '%2B');
  
  var ij=document.forms[0].elements.length;
  if (ij > 200) {ij = 200}
  var bChangedSave=0;
  //if the field is disabled don't show the list
  if (document.forms[0].elements[fieldname].disabled) {return}
    s1 = GetToken("Parent1", url)
    s2 = GetToken("Parent2", url)
    s3 = GetToken("Parent3", url)
    s4 = GetToken("Parent4", url)
    s5 = GetToken("Parent1Handle", url)
    s6 = GetToken("Parent2Handle", url)
    s7 = "select"
  
  if (typeof(document.forms[0].elements["BSAVE"]) != "undefined") {
  	if (document.forms[0].elements["BSAVE"].value == "0"){  		
  		bChangedSave=1
  	  document.forms[0].elements["BSAVE"].value == "1"
  	}
  }
  
  //note that we don't send values with a #, because the DLL won't get anything after the first #!
  //we just send the first 250 chars, then we'll also send special Parentx tokens
  //don't send Parentx tokens in for loop 
  
  for (ii=0;ii<ij; ii++) {
    if (typeof(document.forms[0].elements["select"]) != "undefined") {
      if (document.forms[0].elements[ii].value !="" && document.forms[0].elements[ii].value.length < 60 && document.forms[0].elements[ii].value.indexOf("#") == -1 )
        {
        if (document.forms[0].elements[ii].name != s1 && document.forms[0].elements[ii].name != s2 && document.forms[0].elements[ii].name != s3 && document.forms[0].elements[ii].name != s4 && document.forms[0].elements[ii].name != s5 && document.forms[0].elements[ii].name != s6 && document.forms[0].elements[ii].name != s7){ 
          /* tr46040: Make sure that values containing special characters like & gets escaped */
          sValue = sValue + "&" + document.forms[0].elements[ii].name + "=" + escape(document.forms[0].elements[ii].value);
        }
      }
    }   
    if (sValue.length > 250) {break}
  }


    url=url+sValue;
    //get special parent tags 

    if (s1 != null) {url = url + "&" + s1 + "=" + document.forms[0].elements[s1].value;}
    if (s2 != null) {url = url + "&" + s2 + "=" + document.forms[0].elements[s2].value;}
    if (s3 != null) {url = url + "&" + s3 + "=" + document.forms[0].elements[s3].value;}
    if (s4 != null) {url = url + "&" + s4 + "=" + document.forms[0].elements[s4].value;}
    if (s5 != null) {url = url + "&" + s5 + "=" + document.forms[0].elements[s5].value;}
    if (s6 != null) {url = url + "&" + s6 + "=" + document.forms[0].elements[s6].value;}
    if (typeof(document.forms[0].elements["select"]) != "undefined") {url = url + "&select=" + document.forms[0].elements["select"].value;}


    newWindow = window.open(GetBlankPage(),'newWin','toolbar=no,resizable=yes,location=no,scrollbars=1,height=30,width=150,left=0,top=0,alwaysraised=yes');
    waiting = '<html><head><title>Yardi Lookup</title><body bgcolor=#CCCCCC><center>'    
    waiting = waiting + '<font size=-1><p>Retrieving Records...</body></html>';
    /*
    //I took out the following becuase it was too tricky to figure out where to load the IMG from    
    
    if (bsub == "-1") {
       waiting = waiting + '<img src="../images/computer_working.gif"><font size=-1><p>Retrieving Records...</body></html>';
      } 
    else {
      waiting = waiting + '<img src="../images/computer_working.gif"><font size=-1><p>Retrieving Records...</body></html>';
    }
    */
    newWindow.document.write(waiting)
    newWindow.location = url+'&data='+document.forms[0].elements[fieldname].value;
    if( typeof newWindow != 'unknown'){
  newWindow.focus();
  }
  if (bChangedSave == 1) {
  document.forms[0].elements["BSAVE"].value == "0"
  }
}


//[30]
function FormatNumber(numObj)
{
	/* called from ValidateCurrency
	   2100    -> 2,100.00
	   2100.   -> 2,100.00
	   2100.1  -> 2,100.10
	   2100.10 -> 2,100.10
	   
	   This function always assume an US number format (. dot as decimal separator) as input
	*/
	
	var sTemp = numObj.value;
	var sDigits = "00";
	
	/* strip thousand separators */
	var re = new RegExp("\\,", "g");
	sTemp = sTemp.replace(re, "");
	
	/* test for decimal part */
	re.compile("^(-?\\d*)\\.(\\d{0,2})");
	if (re.test(sTemp))
	{
		sTemp = ((RegExp.$1 == "-") || (RegExp.$1 == "")) ? RegExp.$1 + "0" : RegExp.$1;
		sDigits = (RegExp.$2 + sDigits).substr(0,2);
	}
	
	var sGUID = GetCookie("bEuroNum");
	var sThousandSep = (sGUID == "true") ? "." : ",";
	var sFractionSep = (sGUID == "true") ? "," : ".";
	
	/* put in thousand separators */
	re.compile("(-?\\d+)(\\d{3})");
	while (re.test(sTemp))
	{
		sTemp = sTemp.replace(re, "$1" + sThousandSep + "$2");
	}
	
	/* put everything together again */
	numObj.value = sTemp + sFractionSep + sDigits;
	
	return;
}

//[31]
function NonBlank(obj) {
  if (obj.value == "") {error(obj, "Field may not be left blank"); return true;}
}

//[32]
function parseNum(numObj, iDigits)
{
	/* strips commas out of numbers, does a parseFloat on it. */
	
	var sTemp = numObj.value;
	iDigits = (iDigits == null) ? 2 : iDigits;
	
	if ((! isValidMoneyFormat(sTemp, iDigits)) || (sTemp == ""))
	{
		/* NOTE that "return false;" actually is the same as "return 0;" */
		return false;
	}
	
	var sGUID = GetCookie("bEuroNum");
	var sThousandSep = (sGUID == "true") ? "\\." : ",";
	var re = new RegExp(sThousandSep, "g");
	sTemp = sTemp.replace(re, "");
	
	/* special considerations for european numbers */
	sTemp = (sGUID == "true") ? sTemp.replace(",", ".") : sTemp;

	return parseFloat(sTemp);
}

//[33]
function gotFocus(theObject) {

}

//[34]
function QueryIf(ref) {

  parent.frames[1].QueryIf2(ref);
  return false;

}


//[35]
function FT_FinalTest() {
  var ij=document.forms[0].elements.length;
  var bb;  

    for (i=0;i<ij; i++) {
      if (document.forms[0].elements[i].type == "select-multiple" && document.forms[0].elements[i].mandatory == "true") {



        bb = false
        for (j=0; j < document.forms[0].elements[i].options.length; j++) {        	
        	if (document.forms[0].elements[i].options[j].selected == true && document.forms[0].elements[i].options[j].text != "") {
        		bb = true
        		break
        	}
        }
        if (bb == false) {error(document.forms[0].elements[i], 'Field may not be blank'); return false}
      }    
      else if (document.forms[0].elements[i].mandatory == "true" && document.forms[0].elements[i].value == "") {




      {error(document.forms[0].elements[i], 'Field may not be blank'); return false}
      }
  }
  return true;
 
}

//[36]
//send "(this)" from function call
function Hand(elem) {
    elem.style.cursor = "hand";
}


function Help(elem){
    elem.style.cursor = "help";
  }


//[37]
function FilterHelp(parm,link)
{
	if (link != "true") {
	  newWindow = window.open('fltrhelp.asp?sfile=' + parm + '&link=' + link,'newWin','toolbar=yes,resizable=yes,location=yes,scrollbars=yes,width=450,height=550,name=FltrHelp')

	  if( typeof newWindow != 'unknown'){newWindow.focus();}
	}
	else {
	  location.href = "fltrhelp.asp?sfile=" + parm + "&link=" + link
	}
 return newWindow;
}

//Help Function for asp forms and filters that reside in the forms directory
function FormFilterHelp(parm,link)
{
	if (link != "true") {
	  newWindow = window.open('../fltrhelp.asp?sfile=' + parm + '&link=' + link,'newWin','toolbar=yes,resizable=yes,location=yes,scrollbars=yes,width=450,height=550,name=FltrHelp')

	  if( typeof newWindow != 'unknown'){newWindow.focus();}
	}
	else {
	  location.href = "../fltrhelp.asp?sfile=" + parm + "&link=" + link
	}
 return newWindow;
}


function openHelpWindow() {
 	help = window.open('../help/wwhelp.htm','','toolbar=yes,resizable=yes,location=no,scrollbars=yes,width=750,height=550,top=0,left=0')
 }


//[39]
//Say the state <OPTION statments
//This functions goes between the <SELECT> and </SELECT> statements
function SayStates()
{
  var ss;
  var states = new Array(
  "AL>Alabama",
  "AK>Alaska",
  "AB>Alberta",
  "AZ>Arizona",
  "AR>Arkansas",
  "BC>British Columbia",
  "CA>California",
  "CO>Colorado",
  "CT>Connecticut",
  "DE>Delaware",
  "FL>Florida",
  "GA>Georgia",
  "HI>Hawaii",
  "ID>Idaho",
  "IL>Illinois",
  "IN>Indiana",
  "IA>Iowa",
  "KS>Kansas",
  "KY>Kentucky",
  "LA>Louisiana",
  "ME>Maine",
  "MB>Manitoba",
  "MD>Maryland",
  "MA>Massachusetts",
  "MI>Michigan",
  "MN>Minnesota",
  "MS>Mississippi",
  "MO>Missouri",
  "MT>Montana",
  "NE>Nebraska",
  "NV>Nevada",
  "NB>New Brunswick",
  "NF>Newfoundland",
  "NH>New Hampshire",
  "NJ>New Jersey",
  "NM>New Mexico",
  "NY>New York",
  "NC>North Carolina",
  "ND>North Dakota",
  "NT>Northwest Territories",
  "NS>Nova Scotia",
  "OH>Ohio",
  "OK>Oklahoma",
  "ON>Ontario",
  "OR>Oregon",
  "PA>Pennsylvania",
  "PE>Prince Edward Island",
  "PQ>Quebec",
  "RI>Rhode Island",
  "SK>Saskatchewan",
  "SC>South Carolina",
  "SD>South Dakota",
  "TN>Tennessee",
  "TX>Texas",
  "UT>Utah",
  "VT>Vermont",
  "VA>Virginia",
  "WA>Washington",
  "DC>Washington DC",
  "WV>West Virginia",
  "WI>Wisconsin",
  "WY>Wyoming",
  "YT>Yukon Territory");

  document.write("<OPTION selected value=% >North America</OPTION>");
  for( ss in states){
    document.write("<OPTION value="+states[ss]+"</OPTION>");
  }
}

//[40]
function ValidMintMaxt(num,mini,maxi)
{
  var ss = new String(num.value);   //converts object to string
  var ilen = ss.length;
  {
      for (var i = 0; i < ilen; i++)
      {
          if ((ss.charAt(i) < "0") || (ss.charAt(i) > "9")) {error(num, "Invalid number"); return false;}
        }

  if(parseInt(ss) < mini || parseInt(ss) > maxi )
      {
    //alert("Expecting number in range " + mini + " to " + maxi );
    error(num, "Expecting number in range " + mini + " to " + maxi, "false");
    document.forms[0].elements[num.name].focus();
    return false; ;
      }
   }
}

//[41]
function MoveIt(objSource, objTarget) {
var iSourceLen
var iTargetLen

iSourceLen = objSource.length - 1
iTargetLen = objTarget.length - 1
for (i = 0; i <= iSourceLen; i++) {
  if (objSource[i].selected == true) {
    for (j = 0; j <= iTargetLen; j++) {
      if (objTarget[j].text == "") {
        objTarget[j].text = objSource[i].text
        objTarget[j].value = objSource[i].value
        objSource[i].text = ""
        objSource[i].value = ""
        break
      }
    }
  }
}
CompressIt(objSource)
}

//[42]
function CompressIt(obj) {
 //compress the obj array
  var iLen
  var i
  var i2
  var i3

  iLen = obj.length - 1
  i = -1
  do {
    i = i + 1
    if (obj[i].text == "") {
      bNoMore = -1
      for (i2 = i; i2 <= iLen; i2++) {
        if (obj[i2].text != "") {
          bNoMore = 0
      for (i3 = 0; i3 <= iLen - 1 - i; i3++) {
        obj[i + i3].text = obj[i + i3 + 1].text
      obj[i + i3].value = obj[i + i3 + 1].value
      }
      i = -1  //reset loop to first list item
      break
    }
    }
    if (bNoMore == -1) {return}
    }
  }
  while (i < iLen);
}

//[43]
function QueryIf2(ref,AppName) {
  var bdata = "0";
  var bsaveable = "-1";//TR26529
  var errorfound = false
  if (typeof(document.forms[0].elements["SAVEABLE"]) != "undefined") {//TR26529
    bsaveable = document.forms[0].elements["SAVEABLE"].value;//TR26529
  }//TR26529
  if (typeof(document.forms[0].elements["BDATACHANGED"]) != "undefined") {
    bdata = document.forms[0].elements["BDATACHANGED"].value;
    if ((bdata == "1") && (bsaveable != "0")) {//if (bdata == "1") {TR26529
      errorfound = (confirm ("Do you wish to save changed data ?"));
      if (errorfound) {
        if (AppName == "iVista") {document.forms[0].sAction.value="Save";}
        document.forms[0].submit ();
        return;
      }
    }
  }
  location.href = ref;
}

//[44]
function SetFocusOnFirstField(txtFormName, txtFirstFieldName) {
    //Set Focus on the First Field on the Form
    
    if (typeof ( eval('document.' + txtFormName + '.' + txtFirstFieldName )) == "undefined") {return;} ;
    if (eval('document.' + txtFormName + '.' + txtFirstFieldName + '.disabled') == true) {return}
    if (eval('document.' + txtFormName + '.' + txtFirstFieldName)) {
      eval('document.' + txtFormName + '.' + txtFirstFieldName + '.focus()');
    }
}

//[45]
function FormatNumber2(sTest)
{
	/*
	   2100.0000001    -> 2100.00
	   
	   This function always assume an US number format (. dot as decimal separator) as input
	*/
	
	var iDigits = "00";
	
	/* test for decimal part */
	var re = new RegExp("(-?[0-9\\,]*)\\.?(\\d*)");
	if (re.test(sTest))
	{
		sTest = RegExp.$1;
		iDigits = (RegExp.$2 + iDigits).substr(0,2);
	}
	
	var sGUID = GetCookie("bEuroNum");
	var sFractionSep = (sGUID == "true") ? "," : ".";
	
	/* put everything together again */
	return (sTest + sFractionSep + iDigits);
}






//[46]
function Round(num) {


    return Math.round((num) * 100) / 100

}

//[47]
//Ask the confirmation for delete
function bDelete() {
  bok = (confirm ("Are you sure you want to delete this ?"));
  return bok ;
}

//[48]
//Trims spaces before and after string. Usage trim(var.value)
function trim ( inputStringTrim ) {
  fixedTrim = "";
  for (x=0; x < inputStringTrim.length; x++) {
    ch = inputStringTrim.charAt(x);
    if (ch != " ") break;
  }
  for (y = inputStringTrim.length-1; y>=0; y--) {
    ch = inputStringTrim.charAt(y);
    if (ch != " ") break;
  }
  if (x>y) 
       {fixedTrim = ""}
  else 
       {fixedTrim = inputStringTrim.substr(x,y-x+1)};
  return fixedTrim;
}

//[49]
function FormatPhoneNum(txtFieldName, PhoneNum) {
  var sPhoneNum = "";
  var sNewPhoneNum = "";
  var sOrigPhoneNum = PhoneNum.value;
   var sGUID = GetCookie("BINTERNATIONAL");
  if (sGUID == "true") {return}
  if (Empty(PhoneNum.value)) 
  {
  	PhoneNum.value = "";
  	return true;
  }
  if (txtFieldName == '') {txtFieldName = PhoneNum.name}
  /* --loop through to get just the numbers and not special characters */
  for (var i = 0; i <= PhoneNum.value.length; i++) {
    if ((PhoneNum.value.charAt(i) >= "0") && (PhoneNum.value.charAt(i) <= "9")) {
      sPhoneNum = sPhoneNum  + PhoneNum.value.charAt(i);
    }
  }
  if (sPhoneNum != "") {
    if (sPhoneNum.substring(7,15) == "") { 
      sNewPhoneNum = sPhoneNum.substring(0, 3) + "-" + sPhoneNum.substring(3, 7);
    }
    else
    {
      sNewPhoneNum = '(' + sPhoneNum.substring(0, 3) + ') ' + sPhoneNum.substring(3, 6) + "-" + sPhoneNum.substring(6, 10);
      if (sPhoneNum.substring(10, 15) != "") { sNewPhoneNum = sNewPhoneNum + " x" + sPhoneNum.substring(10, 15); }
    }
  }
  else  /* Display error message */
  {    
      return error(PhoneNum, "Not a valid Phone Number");  
  }

  document.forms[0].elements[txtFieldName].value = sNewPhoneNum;

  if (sOrigPhoneNum != sNewPhoneNum) { gotChange(); }
}


//[50]
// printer page break
function PageBreak(){
	document.write("<p class='pagebreak'>");
}

//[51]
// Get the specified param (sToken) from string (sURL)
function GetToken(sToken, sURL)
{

  var aCookie = sURL.split("&");


  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    sToken = sToken.toUpperCase();
    aCrumb[0] = aCrumb[0].toUpperCase();
    if (sToken.replace(" ", "") == aCrumb[0].replace(" ", ""))
      return unescape(aCrumb[1]);
  }

  return null;
}

//[52]
function MaxDay(imonth, iyear){
//returns max day of month
  if ((imonth == 1) || (imonth == 3) || (imonth == 5) || (imonth == 7) || (imonth == 8) || (imonth == 10) || (imonth == 12)) 
    {return 31;}
  else if ((imonth == 4) || (imonth == 6) || (imonth == 9) || (imonth == 11) ) 
    {return 30;}
  else if (imonth == 2) {
      //leap year, every 4 years, except centuries that are not evenly
      //divisible by 100
      imod = iyear % 4
      imod2 = iyear % 100
      if (imod == 0 && ( (imod2 != 0) || (iyear % 400 == 0) )) 
        {return 29;}
      else 
        {return 28;}
  }
}

//[53]
function PromptEndDate (start, term, obj, type, rounddate){
  var dt = new Date(start.value)
  var ii = new Number(term.value);    //term in months
  var itype = new Number(type.value);
  var irounddate = new Number(rounddate.value);
  
  //If you don't set the day to 1 unexpected behavior happens when 
  //you add 1 month to for example 1/31. The date will be 3/3 instead of 2/28!
  
  var month = 0;
  var day = 0;
  var year = 0;

  if (ii == 0) {return}
  if (isNaN(dt)) {return}
  if (dt <= 0) {return}
  
  ii = dt.getMonth() + ii;
  
  if(itype == 0) {  	    // None
     day = dt.getDate() 
     day = day - 1
  } else if (itype == 1) {  //EOM     
     if (dt.getDate()  > irounddate) {
     	 ii = ii + 1   // Bump the month up
     }
     day = 0
  } else {                  //Previous EOM
     day = 0
  };
  
  dt.setDate(1);
  if (day == 0) {
     dt.setMonth(ii)
  } else {
     dt.setMonth(ii+1)
  };
  month = dt.getMonth()
  year = dt.getYear()
  if (month == 0) {month = 12; year = year - 1}
  if (day == 0) {day = MaxDay(month, year)}
  if (day > MaxDay(month, year)) {day = MaxDay(month, year)}
  
  ss = month + "/" + day + "/" + year;
  obj.value = ss;
}
//[54]
function ValidateTime(sTime) {
	var iColon=0;
	var iBeforeNum=0;
	var iAfterNum=0;
	var iFoundColon=0;
	var sAfterNum=''
	var sBeforeNum=''
  var s1 = "";
  var ss = new String(sTime.value);   //converts object to string

  if (Empty(ss)) {return true;}
  if (ss.indexOf(":") == -1) {
    if (ss.length == 3) {ss = ss.substring(0, 1) + ":" + ss.substring(1, 3)}
    else if (ss.length == 4) {ss = ss.substring(0, 2) + ":" + ss.substring(2, 4)}
  }

  for (var i = 0; (i < ss.length); i++) {
    if (ss.charAt(i) == ":") {
    	iColon = iColon + 1;
    	if (iColon > 1) return error(sTime, "Invalid time.");        // only allow one colon
    	if ((i != 1) && (i != 2)) return error(sTime, "Invalid time.");  //colon in correct position
    	iFoundColon = 1;
		}
		else {
        s1 = ss.charAt(i)
        s1 = s1.toUpperCase() 
        //only allow number or am/pm
        if (s1 >= "0" && s1 <= "9") {
  				if (iFoundColon == 1) {iAfterNum = iAfterNum + 1; sAfterNum = sAfterNum + ss.charAt(i)}
  				else {iBeforeNum = iBeforeNum + 1; sBeforeNum = sBeforeNum + ss.charAt(i)}
        } 
        else if (s1 == "A" || s1 == "P" || s1 == "M" || s1 == " ") {} //OK
        else {return error(sTime, "Invalid time.");}        
		}
//		if (i > 5) return error(sTime, "Invalid time.");
	}
	if (iAfterNum != 2) return error(sTime, "Invalid time.");
	if (iBeforeNum ==1) {
		if ((sBeforeNum >= "1") && (sBeforeNum <= "9")) {}
		else {return error(sTime, "Invalid time.");}
		}
	else {
		if ((sBeforeNum >= "01") && (sBeforeNum <= "12")) {}
		else {return error(sTime, "Invalid time.");}
		}
	if ((sAfterNum >= "0") && (sAfterNum <= "59")) {}
	else {return error(sTime, "Invalid time.");}
  sTime.value = ss
	return true;
}

//[55]
function CurrentDate() {
  var dt = new Date()
  var month = 0;
  var day = 0;
  var year = 0;
  var ss;

  month = dt.getMonth() + 1
  year = dt.getYear()
  day = dt.getDate()
  ss = month + "/" + day + "/" + year;
  return ss;

}

//[56]
function CurrentTime() {
  var dt = new Date();
  var hour = 0;
  var minute = 0;
  var ampm;
  var ss;
  var zero = "";

 hour = dt.getHours()
  if (hour > 12) {hour = hour - 12; ampm = " PM"}
  else {ampm = " AM"}
  minute = dt.getMinutes()
  if (minute <= 9) {zero = "0"}
  ss = hour + ":" + zero + minute + ampm
  return ss
}

//[57]
function DateAfter(sdt1, sdt2) {
  //returns true is sdt1 is after sdt2
  var sGUID = GetCookie("bEuroDate");

  if (sGUID == "true") {
    	var ss1;
    	var ss2;
    	ss1 = sdt1.value.substring(3,5) + '/' + sdt1.value.substring(0,2) + '/' + sdt1.value.substring(6,10)
    	ss2 = sdt2.value.substring(3,5) + '/' + sdt2.value.substring(0,2) + '/' + sdt2.value.substring(6,10)
  	var dt1 = new Date(ss1)
  	var dt2 = new Date(ss2)
  
  	if (dt1 >= dt2) {
  		return false;
  	}
  	return true;
  };  
  
  
  
  
  var dt1 = new Date(sdt1.value)
  var dt2 = new Date(sdt2.value)

  if (dt1 >= dt2) {return false;}
  return true;
}
//[58]
function QueryString1( param )
{
  var begin,end;
  if(self.location.search.length>1)
  {
    begin=self.location.search.indexOf(param) +param.length+1;
    end=self.location.search.indexOf("&",begin);
    if(end==(-1)) end=self.location.search.length;
    return(self.location.search.substring(begin,end));
  }
  else if(self.location.hash.length>1)
  {
    begin=self.location.hash.indexOf(param) +param.length+1;
    end=self.location.hash.indexOf("&",begin);
    if(end==(-1)) end=self.location.hash.length;
    return(self.location.hash.substring(begin,end));
  }
  else return("");
}

//[59]
function OpenWindow2(url) {
	dataWin.focus();      
  dataWin.frames[0].location = url 
}

//[60]
function OpenWindow(url, parm) {
  //use this function for all sub data forms (like resident/lease charges)
  //this function uses setTimeout method to wait 1000 msecs after the window.open command
  //to give the window time to get fully created.  
  ss = "";
  bGotError = 0;  
  ii = 1;
  ij = 0;
  sparm = "";
   
  if (typeof(parm) == "undefined") {
  	//find the middle of the screen based on height and width
    if (window.screen) {
	  var ah = screen.availHeight - 30;
	  var aw = screen.availWidth - 10;
	
	  var xc = (aw - 780) / 2;
	  var yc = (ah - 425) / 2;
	
	  str = ",left=" + xc + ",screenX=" + xc;
	  str = str + ",top=" + yc + ",screenY=" + yc;
	}
	sparm = 'toolbar=no,resizable=yes,location=no,scrollbars=no' + str + ',height=425,width=780,alwaysraised=yes'
  }
  else (sparm = parm)  
  //close window if it is open
  if(typeof(dataWin) == "object") {dataWin.close()}
  dataWin = window.open('forms/data.htm','dataWin',sparm);      
  window.setTimeout("OpenWindow2('" + url + "')", 1000);  
}


//[61]
function GetStyleSheet()  {
  css = "";
	css = GetCookie("StyleSheet")
	if (css != null) {
		css = css + ".css"
	}
	else if (css == null) {
		css = "ysi.css"
	}
	// must include all possible directories that we may be in, instead of sending a parameter every time through.
	line1 = "<LINK REL=STYLESHEET TYPE=TEXT/CSS HREF=" + css + ">"
	line2 = "<LINK REL=STYLESHEET TYPE=TEXT/CSS HREF=SYSTEM/" + css + ">"
	line3 = "<LINK REL=STYLESHEET TYPE=TEXT/CSS HREF=../SYSTEM/" + css + ">"
  document.writeln (line1)
	document.writeln (line2)
	document.writeln (line3)
}

//[62]
function Filter() {
  var itype = 0;
  var isubtype = 0;
  var ifunction = 0;  
  var res = -1;
  var sref = "";
  var sstatus = "";

  //debugger  
  if (typeof(parent.frames[2].document.forms[0]) == "undefined") {return;}
  if (typeof(parent.frames[2].document.forms[0].elements["ITYPE"]) == "undefined") {return;}
  if (typeof(parent.frames[2].document.forms[0].elements["ISUBTYPE"]) != "undefined") {isubtype = parent.frames[2].document.forms[0].elements["ISUBTYPE"].value}
  if (typeof(parent.frames[2].document.forms[0].elements["Res"]) != "undefined") {res = parent.frames[2].document.forms[0].elements["Res"].value}
  itype = parent.frames[2].document.forms[0].elements["ITYPE"].value    
  //trans default to ifunction = 2, ignore
  if (itype == 16 || itype == 15 || itype == 13 || itype == 30 || itype == 191 || itype == 63 || itype == 37) {
    if (ifunction == 2) {ifunction = 0}
  }
  else {
    if (typeof(parent.frames[2].document.forms[0].elements["IFUNCTION"]) != "undefined") {ifunction = parent.frames[2].document.forms[0].elements["IFUNCTION"].value}
  }  
  if (itype == 1) {
    if (typeof(parent.frames[2].document.forms[0].elements["CMBSTATUS"]) != "undefined") {sstatus = parent.frames[2].document.forms[0].elements["CMBSTATUS"].value}
    if (sstatus == "Applicant" || sstatus == "Canceled" || sstatus == "Wait List" || sstatus == "Denied") {
    	itype = 192
    }	
  }  
  //alert(itype)
  //alert(isubtype)
  //alert(ifunction)
  if (itype == 0) {return}      
  if (isubtype != 0) {return}    
  if (ifunction != 0) {return}      
  sref = "../"
  sref = sref + Get_Real_Asp_Name(itype) + ".asp"
  sref = sref + "?WCI=begin&action=f&iType=" + itype 
  if (res != -1) {sref = sref + "&Res=" + res}
  parent.frames[2].location.href = sref
}

//[63]
function ActiveMenu(ref,sTarget) {
		
		if (sTarget == "parent") {parent.location.href = ref}
		else if (sTarget != "parent") {parent.frames[2].location.href = ref}
    return;	
try {
	var i = 0; var bReturn = false; var bSave = true
	if (typeof(parent.frames[2].document[0]) != "undefined") {
		if (typeof(parent.frames[2].document[0].elements["BDATACHANGED"]) == "undefined") {bReturn=true}
		if (typeof(parent.frames[2].document[0].elements["BSAVE"]) == "undefined") {bReturn=true; bSave=false}
		if (typeof(parent.frames[2].document[0].elements["SAVEABLE"]) != "undefined" && parent.frames[2].document[0].elements["SAVEABLE"].value=="0") {bReturn=true}
	}
	else if (typeof(parent.frames[2].document[0]) == "undefined"){
		bReturn = true ; bSave = false	
	}
	if (bReturn) {
		if (bSave) {
			parent.frames[2].document[0].elements["BSAVE"].value = "1";
		}
		if (sTarget == "parent") {parent.location.href = ref}
		else if (sTarget != "parent") {parent.frames[2].location.href = ref}
	}
	else if (!bReturn) {
	  	for (var i=0; i < 15; i++)  {
			if (parent.frames[2].document[0].elements[i].type != "hidden" && parent.frames[2].document[0].elements[i].disabled != true) {
				parent.frames[2].document[0].elements[i].focus()
				break;
			}
		}
		bdata = parent.frames[2].document[0].elements["BDATACHANGED"].value;
		if ( bdata == "1") {
	    	errorfound = (confirm ("Do you wish to save changed data 1 ?"));
			if (errorfound) {
				parent.frames[2].document[0].elements["BSAVE"].value = "1";
				parent.frames[2].document.forms[0].submit()
			}			
			if (!errorfound) {
				parent.frames[2].document[0].elements["BSAVE"].value = "1";
				if (sTarget == "parent") {parent.location.href = ref}
				else if (sTarget != "parent") {parent.frames[2].location.href = ref}
			}
			return;
		}
		if (sTarget == "parent") {parent.location.href = ref}
		else if (sTarget != "parent") {parent.frames[2].location.href = ref}
	}   
}
catch (dummy){
	if (sTarget == "parent") {parent.location.href = ref}
	else if (sTarget != "parent") {parent.frames[2].location.href = ref}
}
}

//[64]
function ExitForm(sForm) {
  //this routine will prompt if user has changed data without saving
  //BSAVE is required form variable.  Caller should set it = 1 if he wants to bypass this routine
  //i.e. if user hits save or if user hits something like prompt charges on detailed receipts.
  //NOTE:  common routine nav0 will set BSAVE = 1.
  //       if user click on a listWindow hRef, we'll do an early return
  //SAVEABLE is an optional form variable.  This routine will honor it.
  //note that if your link is an href, the unload will happen before you get to set bsave 

	var ii = 0 ; 		
	if (typeof(document.forms[0].elements["BDATACHANGED"]) == "undefined") {return}	
	if (typeof(document.forms[0].elements["BSAVE"]) == "undefined") {return}	
	if (typeof(document.forms[0].elements["SAVEABLE"]) != "undefined" && document.forms[0].elements["SAVEABLE"].value=="0") {return}
	if (typeof(document.forms[0].elements["BSAVE"]) != "undefined" && document.forms[0].elements["BSAVE"].value=="1") {document.forms[0].elements["BSAVE"].value="0"; return}	
  if (typeof(document.activeElement.href) != "undefined") {
	  if (document.activeElement.href.indexOf("listWindow") > 0) {return}
	  if (document.activeElement.href.indexOf("show_calendar") > 0) {return}
	  if (document.activeElement.href.indexOf("SpellWindow") > 0) {return}
	}
	//trigger a onBlur, which will trigger the BDATACHANGED, in case they made a change without leaving the control	
	if (typeof(document.activeElement) != "undefined" && typeof(document.activeElement.name) != "undefined") {
	  document.activeElement.blur()
	}	  
	if (document.forms[0].elements["BDATACHANGED"].value == "1") { 				
	  event.returnValue="Your data has NOT been saved!";     			
	}	
}

//[65]
function TabTo(TabNumber) {
  if (typeof(document.forms[0].elements["BSAVE"]) != "undefined") {document.forms[0].elements["BSAVE"].value="1"}		
  location.href = "#" + TabNumber
}

//[66]
function ValidFloat(numObj, iDigits, iMin, iMax)
{


	var sTest = numObj.value;
  
  if (iMin == undefined) {iMin = -1000000000}
  if (iMax == undefined) {iMax = 1000000000}
	iDigits = (iDigits == null) ? 10 : iDigits;

	var errMsg = "Number must be between " + iMin + " and " + iMax + " and have no more than " + iDigits 
	if (iDigits == 1) {errMsg += " digit."}
	else {errMsg += " digits."}
	
	/* test if number is valid currency format */
	if (Empty(sTest)) { return true; }
	if (! isValidMoneyFormat(sTest, iDigits))
	{
		error(numObj, errMsg);
		event.returnValue = false
		return false;
	}
	
	/* get number back as US format without thousand separator */
	sTest = parseNum(numObj, iDigits);	
	
	
	if (! ValidMinMax(sTest, iMin, iMax))
	{
		error(numObj, errMsg);
		event.returnValue = false
		return false;
	}
	
	return true;
}

//[67]
function UserList(selcol,propcode,acctcode,where,aspname,formname){
	var sSelect = "";
	var sunmask;
	var stemp = "";
	sSelect = document.forms[0].elements[selcol].value;

	i = sSelect.indexOf("[HPROP]")
	if (i > 0){ 
		if (typeof(document.forms[0].elements[propcode]) == "undefined") 
		{
			alert("Cannot display list without property");
			return;
		 }
	}	
     while (i > 0) {
		sSelect = sSelect.substring(0,i)+ "(select hmy from property where scode = '" + document.forms[0].elements[propcode].value + "')" + sSelect.substring(i+7);
	    i = sSelect.indexOf("[HPROP]")
	}

	 i = sSelect.indexOf("[HACCT]")
	if (i > 0){
		if (typeof(document.forms[0].elements[acctcode]) != "undefined") {
			stemp = sSelect.substring(0,i)
			stemp +="(select hmy from acct where scode = '" + unMaskAcct(acctcode) 
			stemp +=  "' and hChart = (select hChart from lockout where hprop = (select hmy from property where scode = '" + document.forms[0].elements[propcode].value + "')))" + sSelect.substring(i+7)
			sSelect = stemp
		   }
		else
		    {
			alert("Cannot display list without account");
			return;
		   }
	}
         listWindow(trim(aspname)+'.ASP?WCI=begin&action=ysilist&field='+where+'&select='+sSelect+'&label=List&framename='+trim(formname)+'&PromptDesc=0',where)
}
//[68]
function unMaskAcct(acct){
	var AcctOut = new String(document.forms[0].elements[acct].value)

	j = AcctOut.indexOf(" ")
       if (j < 0) 
       	{j = AcctOut.length}

       AcctOut=AcctOut.substring(0,j)
	isep =AcctOut.indexOf("-");
       while (isep >  0) {  
       	AcctOut=AcctOut.substring(0, isep) + AcctOut.substring(isep + 1, AcctOut.length)
       	isep =AcctOut.indexOf("-");
       	}
       isep =AcctOut.indexOf(".");    
  	while  (isep >  0) {  
  		AcctOut=AcctOut.substring(0, isep) + AcctOut.substring(isep + 1, AcctOut.length)
  		isep =AcctOut.indexOf(".");    
  		}
     return  AcctOut 
}

//[69]
function Get_Real_Asp_Name(itype) {
  sref = "iData"
  //debugger  
  if (itype == 1) { sref  = "iData"}         //tenant
  else if (itype == 2) { sref  = "iData"}    //owner
  else if (itype == 3) { sref  = "iData"}    //property
  else if (itype == 4) { sref  = "iData"}    //unit
  else if (itype == 5) { sref  = "iData"}    //vendor
  else if (itype == 7) { sref  = "iData"}    //account
  else if (itype == 10) { sref  = "iData"}   //unittype
  else if (itype == 13) { sref  = "iData"}   //charge
  else if (itype == 14) { sref  = "iData"}   //bank
  else if (itype == 15) { sref  = "iData"}   //receipt
  else if (itype == 16) { sref  = "iData"}   //journal
  else if (itype == 21) { sref  = "iData"}   //regular acct
  else if (itype == 22) { sref  = "iData"}   //total acct
  else if (itype == 23) { sref  = "iData"}   //prospect
  else if (itype == 25) { sref  = "iMMW"}    //WO
  else if (itype == 26) { sref  = "iMMW"}    //PO
  else if (itype == 27) { sref  = "iMMW"}    //stock
  else if (itype == 28) { sref  = "iMMW"}    //asset
  else if (itype == 29) { sref  = "iMMW"}    //recur wo
  else if (itype == 30) { sref  = "iData"}   //payable
  else if (itype == 33) { sref  = "iData"}   //cash acct
  else if (itype == 36) { sref  = "iData"}   //budget
  else if (itype == 37) { sref  = "iData"}   //recur JE
  else if (itype == 63) { sref  = "iData"}   //recur pay
  else if (itype == 42) { sref  = "iMMW"}    //recur PO
  else if (itype == 65) { sref  = "iCMW"}    //Job
  else if (itype == 66) { sref  = "iCMW"}    //Change Orders
  else if (itype == 67) { sref  = "iCMW"}    //Category
  else if (itype == 68) { sref  = "iCMW"}    //regular categ
  else if (itype == 69) { sref  = "iCMW"}    //total categ  
  else if (itype == 73) { sref  = "iData"}   //worksheet
  else if (itype == 74) { sref  = "iData"}   //lease charge
  else if (itype == 76) { sref  = "iCMW"}    //Job List 
  else if (itype == 83) { sref  = "iData"}   //sqft
  else if (itype == 88) { sref  = "iData"}   //memo
  else if (itype == 91) { sref  = "iCMW"}    //Contract
  else if (itype == 93) { sref  = "iData"}   //roommate
  else if (itype == 94) { sref  = "iCMW"}   //draw worksheet
  else if (itype == 124) { sref  = "iCMW"}    //Model  
  else if (itype == 127) { sref  = "iCMW"}    //Job Cost Adjustment  
  else if (itype == 137) { sref  = "iCMW"}    //Grant
  else if (itype == 138) { sref  = "iCMW"}    //Grant List
  else if (itype == 141) { sref  = "iAffordable"}     //hmprop
  else if (itype == 142) { sref  = "iAffordable"}     //hmsumm
  else if (itype == 143) { sref  = "iAffordable"}     //hmfamily
  else if (itype == 144) { sref  = "iAffordable"}     //hmincome
  else if (itype == 163) { sref  = "iData"}  //post acct
  else if (itype == 164) { sref  = "iData"}  //ar acct
  else if (itype == 165) { sref  = "iData"}  //ap acct
  else if (itype == 171) { sref  = "iPHA"}   //H8INCOME 
  else if (itype == 172) { sref  = "iPHA"}   //H8PUBLIC 
  else if (itype == 173) { sref  = "iPHA"}   //H8CERTIF 
  else if (itype == 174) { sref  = "iPHA"}   //H8VOUCH  
  else if (itype == 175) { sref  = "iPHA"}   //H8MODREH 
  else if (itype == 176) { sref  = "iPHA"}   //H8MANUF  
  else if (itype == 177) { sref  = "iPHA"}   //H8MUTUAL 
  else if (itype == 178) { sref  = "iPHA"}   //H8FSS    
  else if (itype == 179) { sref  = "iPHA"}   //H8SUMM   
  else if (itype == 180) { sref  = "iPHA"}   //H8FAMILY 
  else if (itype == 184) { sref  = "iMMW"}   //pur req
  else if (itype == 186) { sref  = "iMMW"}   //wo template
  else if (itype == 188) { sref  = "iMMW"}   //inventory
  else if (itype == 189) { sref  = "iMMW"}   //supplier
  else if (itype == 191) { sref  = "iData"}  //check
  else if (itype == 192) { sref = "iData"}   //applicant
  else if (itype == 231) { sref  = "iAffordable"}  //hmtenant
  else if (itype == 233) { sref  = "iAffordable"}  //hmcontract
  else if (itype == 234) { sref  = "iAffordable"}  //hmunit
  else if (itype == 238) { sref  = "iPHA"}         //H8PARAM
  else if (itype == 239) { sref  = "iAffordable"}  //building  
  else if (itype == 241) { sref  = "iAffordable"}  //letters 
  else if (itype == 242) { sref  = "iAffordable"}  //correspondent
  else if (itype == 243) { sref  = "iPHA"}         //H8STPR
  else if (itype == 244) { sref  = "iAffordable"}  //HMTAXCR 
  else if (itype == 245) { sref  = "iAffordable"}  //HMTAXRULE 
  else if (itype == 246) { sref  = "iInspect"}     //INSPECTION 
  else if (itype == 247) { sref  = "iInspect"}     //INSPEMPLOYEE 
  else if (itype == 248) { sref  = "iInspect"}     //INSPVENDOR 
  else if (itype == 249) { sref  = "iInspect"}     //INSPUNIT  
  else if (itype == 250) { sref  = "iInspect"}     //INSPTENANT  
  else if (itype == 251) { sref  = "iPHA"}         //H8XLETTER  
  else if (itype == 252) { sref  = "iPHA"}         //H8LETTER  
  else if (itype == 253) { sref  = "iPHA"}         //H8CORRESPONDENT  
  else if (itype == 254) { sref  = "iPHA"}         //H8HOMEOWNERSHIP  
  else if (itype == 270) { sref  = "iPHA"}         //FSSSERVICES
  else if (itype == 271) { sref  = "iPHA"}         //FSSGOALS
  else if (itype == 272) { sref  = "iPHA"}         //FSSPROVIDERS
  else if (itype == 273) { sref  = "iPHA"}         //FSSPROVIDERCONTACTS
  else if (itype == 274) { sref  = "iPHA"}         //FSSPROVIDERSERVICES
  else if (itype == 275) { sref  = "iPHA"}         //FSSQUESTIONNAIRE
  else if (itype == 276) { sref  = "iPHA"}         //FSSQUESTIONRESPONSE
  else if (itype == 277) { sref  = "iPHA"}         //FSSNEED
  else if (itype == 278) { sref  = "iPHA"}         //FSSCONTRACT
  else if (itype == 279) { sref  = "iPHA"}         //FSSASSESSMENTSHEET
  else if (itype == 280) { sref  = "iPHA"}         //FSSQTEMPLATE
  else if (itype == 281) { sref  = "iPHA"}         //FSSQSESSION  
  else if (itype == 285) { sref  = "iInspect"}     //IGMSTR 
  else if (itype == 286) { sref  = "iInspect"}     //IGDET 
  else if (itype == 287) { sref  = "iInspect"}     //IGTYPEHDR 
  else if (itype == 288) { sref  = "iInspect"}     //IGLEVELNAMES 
  else if (itype == 289) { sref  = "iInspect"}     //IGRATING 
  else if (itype == 290) { sref  = "iInspect"}     //IGRATINGDET 
  else if (itype == 291) { sref  = "iInspect"}     //IGHELP 
  else if (itype == 292) { sref  = "iInspect"}     //IGRATINGRESP 
  else if (itype == 293) { sref  = "iInspect"}     //IGOBSER 
  else if (itype == 294) { sref  = "iInspect"}     //IGDETAIL 
  else if (itype == 295) { sref  = "iInspect"}     //IGSUBDET 
  else if (itype == 296) { sref  = "iPHA"}         //H8FLATRENT
  else if (itype == 297) { sref  = "iPHA"}         //H8FLATRENTDET
  else if (itype == 298) { sref  = "iPHA"}         //H8PMTSTD
  else if (itype == 299) { sref  = "iPHA"}         //H8PMTSTDDET
  else if (itype == 300) { sref  = "iAssist"}      //WLINCLIMIT  
  else if (itype == 301) { sref  = "iAssist"}      //WLINCLIMITDET  
  else if (itype == 302) { sref  = "iWait"}        //WLPREFERENCE
  else if (itype == 303) { sref  = "iWait"}        //WLAPPLIC
  else if (itype == 304) { sref  = "iWait"}        //WLAPPLICPREFS
  else if (itype == 305) { sref  = "iWait"}        //WLWAITLISTWLAPPLIC
  else if (itype == 306) { sref  = "iWait"}        //WLWAITLISTPREFS
  else if (itype == 307) { sref  = "iWait"}        //WLWAITLIST
  else if (itype == 308) { sref  = "iWait"}        //WLINCLIMITXREF
  else if (itype == 314) { sref  = "iPHA"}         //UTLOCALITY
  else if (itype == 315) { sref  = "iPHA"}         //UTILSERV
  else if (itype == 316) { sref  = "iPHA"}         //UTALLOW
  else if (itype == 317) { sref  = "iPHA"}         //UTALLOWDET
  else if (itype == 318) { sref  = "iPHA"}         //UTALLOWSUBDET
  else if (itype == 319) { sref  = "iPHA"}         //UTRESP
  else if (itype == 320) { sref  = "iPHA"}         //UTBUILDINGTYPE
  else if (itype == 321) { sref  = "iPHA"}         //H8FAMILYSUMMARY
  else if (itype == 322) { sref  = "iPHA"}         //H8FAMILYMEMBERS
  else if (itype == 323) { sref  = "iPHA"}         //H8FAMILYINCOME
  else if (itype == 324) { sref  = "iPHA"}         //H8FAMILYASSETS
  else if (itype == 325) { sref  = "iPHA"}         //H8FAMILYFSS
  else if (itype == 326) { sref  = "iPHA"}         //H8FAMILYEXPENSES
  else if (itype == 327) { sref  = "iPHA"}         //H8CENSUSTRACT
  else if (itype == 328) { sref  = "iPHA"}         //H8CENSUSTRACTDET
  else if (itype == 330) { sref  = "iPHA"}         //H8PROP
  else if (itype == 331) { sref  = "iPHA"}         //H8UNIT
  else if (itype == 364) { sref  = "iWait"}        //WAITLISTSETUP
  else if (itype == 365) { sref  = "iWait"}        //WAITLISTGENERATE
  else if (itype == 366) { sref  = "iWait"}        //WAITLISTSELECTION
  else if (itype == 10914) { sref  = "iAffordable"}   //HM_I_SPLCLM
  else if (itype == 374) { sref  = "iPHA"}         //EXUTALLOW
  else if (itype == 375) { sref  = "iPHA"}         //EXUTALLOWDET
  else if (itype == 376) { sref  = "iPHA"}         //EXUTALLOWSUBDET
  else if (itype == 450) { sref  = "IPHA"}         //RCHUDFACTOR
  else if (itype == 335) { sref  = "iRGI"}         //RGPROP
  else if (itype == 356) { sref  = "iRGI"}         //RGUNIT
  else if (itype == 332) { sref  = "iRGI"}         //RGSUMM
  else if (itype == 500) { sref  = "IPHA"}         //H8PRHABATE
  else { sref  = "iData"}
  return sref  
}  

//[70]
// Get the specified cookie
function GetField(sUrl, sField) {
  //sUrl = "&field1=value1&field2=value2"
  //sField = "field1"
  
  var aValues = sUrl.split("&");
  for (var i=0; i < aValues.length; i++)
  {
    var aField= aValues[i].split("=");
    if (sField.replace(" ", "") == unescape(aField[0].replace(" ", "")))
      return unescape(aField[1]);
  }

  return null;
}

//[71]
function ClearFilterPrompt(obj)  {
  var ss;
  
  ss = 'DESC' + obj.name
  if (typeof(document.forms[0].elements[ss]) != 'undefined') {document.forms[0].elements[ss].value = ""}  
}

//[72]
function ValidYear(obj)
{
  var ss = new String(obj.value);   //converts object to string
  var ilen = ss.length;
  var iyear;
  var serr = "Invalid Year";
  var min = 1875;
  var max = 2100;
  var window = 50
  
  if (Empty(obj.value)) {return true;}
  if (ilen != 4 && ilen != 2)
  {
    error(obj, serr);
    return false;
  }
  for (var i = 0; i < ilen; i++)
  {
    if ((ss.charAt(i) < "0") || (ss.charAt(i) > "9"))
    {
       error(num, serr); 
       return false;
    }
  }
  iyear = parseInt(ss, 10);
  if (ilen == 2)
  {
    if (iyear < window )
    {
      iyear = 2000 + iyear;
    } 
    else
    {
      iyear = 1900 +  iyear;
    }
  }
  else if (iyear < min || iyear > max)
  {
    error(obj, serr);
    return false;
  }
  obj.value = iyear.toString();
  return true;
}

//[73]
// Does not reformat on the browser. Just checks to see if there are the right
// amount of numbers. It will allow for 2 dashes (just about anywhere but only 2).
function ValidateSSN(num) {
		ii = 0;
		newssn = "";
		dashes = 0;
		ssn = num.value;
    if (Empty(ssn)) return "";
    for (var i = 0; (i < ssn.length); i++) {
			if (i != 0) {
		  		if (((ssn.charAt(i) < "0") || (ssn.charAt(i) > "9")) && (ssn.charAt(i) != "-")) return error(num, "Invalid SSN");
			}
	        if (ssn.charAt(i) == "-") {
				dashes = dashes + 1;
				if (dashes > 2)	return error(ssn,"Invalid SSN",false);
				if (dashes == 2) {
					newssn = newssn + ssn.substring(ii,i);
					newssn = newssn + ssn.substring(i+1);
					if (newssn.length != 9) return error(num, "Invalid SSN") ;
				}
				if (dashes < 2) newssn = newssn + ssn.substring(ii,i);
				ii = i + 1;
			}
		}
		if (newssn != "") ssn = newssn;
		if (ssn.length != 9) return error(num, "Invalid SSN", false) ;
    return ssn
}

      
//[74]      
//Test SSN for valid characters and the right amount of numbers.
//SSN may be entered as 123-45-6789, 123456789 - Real SSN all digits
//SSN may be entered as A23-45-6789, A23456789 - HUD 58 psudo SSN where the first digit may be capital A - Z
//SSN may be entered as T23-45-6789, T23456789 - temporary SSN where the first digit may be a "T" or "t"
//EIN must be entered as 12-3456789
//Will format SSN with "-"s 
//If sTxt is a EIN then function will leave one "-" in the third position
//If sTxt is a SSN then function will leave and/or add two "-" at position 4 and 7

function ValidateSSN2(num) {
  dashes = 0;
  ssn = num.value.toUpperCase();
  if (Empty(ssn)) return "";
	if (((ssn.charAt(0) < "a") || (ssn.charAt(0) > "z")) && ((ssn.charAt(0) < "A") || (ssn.charAt(0) > "Z")) && ((ssn.charAt(0) < "0") || (ssn.charAt(0) > "9"))) {
    return error(num, "Invalid SSN - First character is invalid");
	};
  for (var i = 0; (i < ssn.length); i++) {
    if (i != 0) {
  		if (((ssn.charAt(i) < "0") || (ssn.charAt(i) > "9")) && (ssn.charAt(i) != "-")) return error(num, "Invalid SSN - Contains an invalid character");
  	};
    if (ssn.charAt(i) == "-") {
      dashes = dashes + 1;
		};
	}; 
  if (dashes > 2) return error(ssn,"Invalid SSN - Too many dashes",false);
  if (dashes == 1) {
	  if ((ssn.charAt(0) < "0") || (ssn.charAt(0) > "9")) {
      return error(num, "Invalid SSN - First character is invalid");
	};
  
  };
	if (ssn.length != (9 + dashes)) return error(num, "Invalid SSN - Invalid length", false);
		
  if (ssn.length == 9) {
    ssn = ssn.substring(0, 3) + "-" + ssn.substring(3, 5) + "-" + ssn.substring(5, 9);
  };  
  num.value = ssn;
  return ssn;
}

//[75] 
function StripDashesFmSSN(ssn) {
  if ((ssn.length == 9) || (ssn.length == 10))
  {
    return ssn
  }
  else if (ssn.length == 11)
  {
    return ssn.substring(0, 3) + ssn.substring(4, 6) + ssn.substring(6, 11)
  }      
}  

//[76]
function ValidateEmail(email) {
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // invalid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	var str = email.value; 
	if(str == ""){return;}
	var emailaddrs = str.split(",");
	for (var i=0; i < emailaddrs.length; i++) {
	  if (!reg1.test(emailaddrs[i]) && reg2.test(emailaddrs[i])) {}
		else {
		  alert("\"" + emailaddrs[i] + "\" is an invalid e-mail address.");
		  email.focus();
		  email.select();
		  return false;
		}
	}
}

//[77]
function isValidMoneyFormat(sTest, iDigits)
{
	var sGUID = GetCookie("bEuroNum");
	var sPattern;
	var bTemp = false;
	
	/* check for numbers like 123 and -123.45 */
	sPattern = (sGUID == "true") ? "^-?\\d*\\,?\\d{0," + iDigits + "}$" : "^-?\\d*\\.?\\d{0," + iDigits + "}$";
	var re = new RegExp(sPattern);
	bTemp = (re.test(sTest)) ? true : bTemp;
	
	/* check for numbers like 1,234 and -123,456,789.01 */
	sPattern = (sGUID == "true") ? "^-?\\d{1,3}(\\.\\d{3})*(\\,\\d{0," + iDigits + "})?$" : "^-?\\d{1,3}(\\,\\d{3})*(\\.\\d{0," + iDigits + "})?$";
	re.compile(sPattern);
	bTemp = (re.test(sTest)) ? true : bTemp;
	
	/* last check. Special case sTest="-" */
	bTemp = (sTest == "-") ? false : bTemp;
		
	return bTemp;
}


//[78]

function nameWindow(sName) {
  parent.document.title = 'Yardi Systems, Inc. - ' + sName
}
function unNameWindow() {
  parent.document.title = 'Yardi Systems, Inc.'
}

//[79]
function PromptTerm (start, end, obj, type){
  var dtEnd = new Date(end.value)  
  var dtStart = new Date(start.value)

  iStartM = dtStart.getMonth() + 1
  iEndM = dtEnd.getMonth() + 1  
  
  iStartY = dtStart.getYear()
  iEndY = dtEnd.getYear()
  iDiff = ((iEndY - iStartY) * 12) + (iEndM - iStartM) + 1
  if (iDiff <= 0) {error(obj, 'Lease from date must be after lease to date.'); return false;}  
  obj.value = iDiff
  
  
}


//[80]
function DaysDiff (start, end) {
	var dtFrom = new Date(start.value)
	var dtTo = new Date(end.value)
	return (dtTo - dtFrom) / 86400000  //number of milliseconds in a day...
	
}


//[81]
function show_clock(Dest){
 	//Dest is where time value goes
 	newWindow=window.open(GetBlankPage(),'Timer','width=420,height=140,status=no,resizable=no,top=225,left=175'); 
	newWindow.location='../time.asp?Dest='+Dest;
	if( typeof newWindow != 'unknown'){
  		newWindow.focus();
  	}
}


//[82]
function isValidInteger(sTest)
{
	var sGUID = GetCookie("bEuroNum");
	var sPattern;
	var bTemp = false;
	
	/* check for numbers like 123 and -123.45 */
	sPattern = (sGUID == "true") ? "^-?\\d*$" : "^-?\\d*$";
	var re = new RegExp(sPattern);
	bTemp = (re.test(sTest)) ? true : bTemp;
	
	/* check for numbers like 1,234 and -123,456,789.01 */
	sPattern = (sGUID == "true") ? "^-?\\d{1,3}(\\.\\d{3})*$" : "^-?\\d{1,3}(\\,\\d{3})*$";
	re.compile(sPattern);
	bTemp = (re.test(sTest)) ? true : bTemp;
	
	/* last check. Special case sTest="-" */
	bTemp = (sTest == "-") ? false : bTemp;
		
	return bTemp;
}


//[83]
function parseInteger(numObj)
{
	/* strips commas out of numbers, does a parseInt on it. */
	
	var sTemp = numObj.value;
	
	if ((! isValidInteger(sTemp)) || (sTemp == ""))
	{
		/* NOTE that "return false;" actually is the same as "return 0;" */
		return false;
	}
	
	var sGUID = GetCookie("bEuroNum");
	var sThousandSep = (sGUID == "true") ? "\\." : ",";
	var re = new RegExp(sThousandSep, "g");
	sTemp = sTemp.replace(re, "");
	
	return parseInt(sTemp);
}


//[84]
function formatInteger(numObj)
{
	/* called from validInteger
	   2100    -> 2,100
	   
	   This function always assume an US number format (. dot as decimal separator) as input
	*/
	
	var sTemp = numObj.value;
	
	/* strip thousand separators */
	var re = new RegExp("\\,", "g");
	sTemp = sTemp.replace(re, "");
	
	var sGUID = GetCookie("bEuroNum");
	var sThousandSep = (sGUID == "true") ? "." : ",";
	var sFractionSep = (sGUID == "true") ? "," : ".";
	
	/* put in thousand separators */
	re.compile("(-?\\d+)(\\d{3})");
	while (re.test(sTemp))
	{
		sTemp = sTemp.replace(re, "$1" + sThousandSep + "$2");
	}
	
	/* put everything together again */
	numObj.value = sTemp;
	
	return;
}


//[85]
function validInteger(numObj, iMin, iMax)
{
	var sTest = numObj.value;
	iMin = (iMin == null) ? -1000000000 : iMin;
	iMax = (iMax == null) ?  1000000000 : iMax;
	
	/* test if number is valid currency format */
	if (Empty(sTest)) {return true;}
	if ( ! isValidInteger(sTest))
	{
		error(numObj, "Invalid Integer.");
		return false;
	}
	
	/* get number back as US format without thousand separator */
	sTest = parseInteger(numObj);
	
	/* test if number is within min and max limits */
	if (! ValidMinMax(sTest, iMin, iMax))
	{
		error(numObj, "Expecting number in range " + iMin + " to " + iMax);
		return false;
	}
	
	numObj.value = sTest;
	formatInteger(numObj);
	return true;
}

//[86]
function MaskCateg(obj, categlen, categmask, seperator)
{
  /*obj is text box.  obj might have a .isRequired property
  categlen is length of categ mask not including seperators
  categmask is the mask (i.e. ????-????)
  seperator is a '-'  or a '.'
  categ masks can have a '-' or a '.' as seperators, but not both
  and may have multiple seperators or no seperators*/


  var sout = "";        // output value
  var idashloc = 0;
  var ss = new String(obj.value);   //converts object to string
  var ilen = ss.length;
  var iSepCount = 0;
  var sTemp = "";


  // check for required field
  if( typeof(obj.isRequired) == "undefined")
    {obj.isRequired = false;} // default not required

  if (ss == "") {
    if (obj.isRequired) {return error(obj, 'Categ number required')}
          }
  if (ss == "") { return true; }

  //remove seperators from input
  for (i = 0; i <= categlen; i++) {
      idashloc = ss.indexOf(seperator);
      if (idashloc <= 0) { break;  }
      ss = ss.substring(0, idashloc) + ss.substring(idashloc + 1, ss.length);
  }

  //count number of seperators in categmask
  sTemp = categmask
  for (i = 0; i <= categlen; i++) {
      idashloc = sTemp.indexOf(seperator)
      if (idashloc <= 0) {break;}
      sTemp = sTemp.substring(idashloc + 1, sTemp.length)
      iSepCount = iSepCount + 1
  }

  //add zeros to input if input.length <> categlen
  if (ss.length != categlen.length) {
    for (i = ss.length; i < categlen; i++) {
      ss = ss + "0";
    }
  }

  //now, mask it
  i = 0
  idashloc = 0
  while(i < iSepCount) {
    idashloc = idashloc + categmask.indexOf(seperator)
    if (idashloc <= 0) { break; }
    categmask = categmask.substring(idashloc + 1, categmask.length)
    ss = ss.substring(0, idashloc + i) + seperator + ss.substring(idashloc + i, ss.length + 1);
    i += 1
     }


  obj.value = ss;

  return true;
}


//[87]
function addNewNode2Menu()
{
	if  (sNewNodeDesc == '') 
	{
		/* not a new node, so don't try to add anything to the left menu */
		return;
	}
	var sUrl = location.href;
	var sQuery = location.search;
	
	/* find our sParent for this form */
	var sParent = '';
	var re = /&sParent1=([^&]*)&/gi;
	if ( ! re.test(sQuery) )
	{
		/* could not find sParent. Abort the process of adding node */
		sParent = sParent1;
		if (sParent == '')
		{
			return;
		}
	}
	else
	{
		sParent = RegExp.$1;
	}
	
	re.compile("(&|\\?)" + sParent + "=\\d*&", "i");
	if (re.test(sUrl))
	{
		sUrl = sUrl.replace(re, "$1" + sParent + "=" + hMy + "&");
	}
	
	re.compile(sParent + "=\\d+&", 'i');
	if (re.test(sQuery))
	{
		sQuery = sQuery.replace(re, sParent + "=\\d+&");
	}
	sQuery = sQuery.replace('?', '');
	sQuery = sQuery.replace('.', '\\.');
	
	var myFrame = parent.menu;
	var sTemp = myFrame.document.body.outerHTML;
	
	re.compile("&amp;", 'gi');
	if (re.test(sTemp))
	{
		sTemp = sTemp.replace(re, '&');
	}
	
	re.compile(sQuery, "i");
	if ( ! re.test(sTemp) )
	{
		/* left side menu does not contain nodes like the one we have in the right frame, therefore abort. */
		myFrame.document.close();
		myFrame = null;
		return;
	}
	
	/* get rid of immediate script to execute QueryIf() and load right-hand frame */
	re.compile("[<]Script Language=JavaScript\>\\n\\s*QueryIf\\([^)]*\\);\\n\</script\>", 'i');
	if (re.test(sTemp))
	{
		sTemp = RegExp.leftContext + ' ' + RegExp.rightContext;
	}
	
	re.compile("QueryIf\\(", 'gi');
	if (re.test(sTemp))
	{
		sTemp = sTemp.replace(re, 'QueryIfVista(');
	}
	
	var re2 = /(<td.*height=3.*><img src=['"][^"]*images\/transparent_dot\.gif['"]><input type=HIDDEN name=NavInfo>)/i;
	if (re2.test(sTemp))
	{
		sTemp = sTemp.replace(re2, "<td class=tree_line nowrap onMouseOver=bgcolorin(this) onMouseOut=bgcolorout(this) onMouseUp='return QueryIfVista(\"" + sUrl + "\");'>&nbsp;<img src=\"images/leaf.gif\"><A title=\"" + sNewNodeDesc + "\">&nbsp;" + sNewNodeDesc + " </A></td></tr><tr>" + RegExp.$1);
		
		/* rewrite the left side menu */
		myFrame.document.open();
		myFrame.document.clear();
		myFrame.document.write('<html><head><title>Yardi Systems, Inc. Voyager</title></head>');
		myFrame.document.write(sTemp);
		myFrame.document.write('</html>\n');
	}
	
	/* the document should be closed, but there seems to be a problem that everything has not been written and downloaded before closing the document, thus it is commented out */
/*	myFrame.document.close();
	myFrame = null; */
	
	/* scroll to the buttom of the menu */
	myFrame.scrollTo(0, 9999);
	
	return;
}

//[88]
function ShowMemo(iFileType, hMy) { 
	MemoWindow = window.open('iData.ASP?WCI=begin&Action=D&iType=88&iFileType=' + iFileType + '&hFileRcd='+ hMy ,'MemoWindow','toolbar=no,scrollbars=no,resizable=yes,location=no,height=600,width=585,left=100,top=100,alwaysraised=yes');
}


//[89]
function getSelectedValue(myDropDown)
{
	/* This function takes a <select> object as input and returns a string holding the selected value */
	
	/* this function is for <select> elements only. And it does not support multiselect */
	if (myDropDown.type != 'select-one')
	{
		return '';
	}
	
	return myDropDown.options[myDropDown.selectedIndex].value;
}

//[90]
function ShowMemo2(hMemo) {
	MemoWindow = window.open('iData.ASP?WCI=begin&Action=D&iType=88&hMy='+ hMemo,'MemoWindow','toolbar=no,scrollbars=no,resizable=yes,location=no,height=600,width=585,left=80,top=140,alwaysraised=yes');
}

//[91]
//TR# 47444 Not sure why this height is 400 (not original 700, but I will leave) - Changed rest to 600
function ShowMemo3(hMemo,hProspect) {
	MemoWindow = window.open("Prospect2_memo.asp?hMy=" + hMemo + "&hProspect=" + hProspect,'MemoWindow','toolbar=no,scrollbars=no,resizable=yes,location=no,height=400,width=500,left=80,top=140,alwaysraised=yes');
}

//[92]
function ShowMemo4(iFileType, hMy) { 
	MemoWindow = window.open('../iData.ASP?WCI=begin&Action=D&iType=88&iFileType=' + iFileType + '&hFileRcd='+ hMy ,'MemoWindow','toolbar=no,scrollbars=no,resizable=yes,location=no,height=700,width=585,left=100,top=100,alwaysraised=yes');
}

//[93]
function FormatNumberRounded(numObj)
{
	/*
		This function extends function FormatNumber by first rounding the value in numObj
		
		ex.:	Original value in numObj.value is 1234.0266
				After call to FormatNumberRounded value in numObj.value is 1,234.03
	*/
	
	numObj.value = Round(numObj.value);
	
	FormatNumber(numObj);
}

//[94]
function FormatNumber2Rounded(sTest)
{
	/*
		This function extends function FormatNumber2 by first rounding the value in sTest
		
		ex.:	sTest is 1234.0266
				FormatNumber2Rounded returns 1234.03
	*/
	
	var sTemp = Round(sTest);
	
	return FormatNumber2(sTemp);
}


//[95]
function OpenWindowAsp(url, parm) {
	//This is different than OpenWindow becasue it's called from asp and location of data.htm is different 
  ss = "";
  bGotError = 0;  
  ii = 1;
  ij = 0;
  sparm = "";
   
  if (typeof(parm) == "undefined") {
  	//find the middle of the screen based on height and width
    if (window.screen) {
	  var ah = screen.availHeight - 30;
	  var aw = screen.availWidth - 10;
	
	  var xc = (aw - 780) / 2;
	  var yc = (ah - 425) / 2;
	
	  str = ",left=" + xc + ",screenX=" + xc;
	  str = str + ",top=" + yc + ",screenY=" + yc;
	}
	sparm = 'toolbar=no,resizable=yes,location=no,scrollbars=no' + str + ',height=425,width=780,alwaysraised=yes'
  }
  else (sparm = parm)  
  //close window if it is open
  if(typeof(dataWin) == "object") {dataWin.close()}
  dataWin = window.open('data.htm','dataWin',sparm);      
  window.setTimeout("OpenWindow2('" + url + "')", 1000);  
}
//[96] DateAdd(startDate, numDays, numMonths, numYears) - add or subtract days/months/years -ve value will do subtraction
function DateAdd(startDate, numDays, numMonths, numYears)
{
	var returnDate = new Date(startDate.getTime());
	var yearsToAdd = numYears;
	
	var month = returnDate.getMonth()	+ numMonths;
	if (month > 11)
	{
		yearsToAdd = Math.floor((month+1)/12);
		month -= 12*yearsToAdd;
		yearsToAdd += numYears;
	}
	returnDate.setMonth(month);
	returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);
	
	returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
	
	return returnDate;

}
//[97] YearAdd(startDate, numYears) - add or subtract years -ve numyears will do subtraction
function YearAdd(startDate, numYears)
{
		return DateAdd(startDate,0,0,numYears);
}
//[98] MonthAdd(startDate, numMonths) - add or subtract months -ve numMonths will do subtraction
function MonthAdd(startDate, numMonths)
{
		return DateAdd(startDate,0,numMonths,0);
}
//[99] DayAdd(startDate, numDays) - add or subtract days -ve numDays will do subtraction
function DayAdd(startDate, numDays)
{
		return DateAdd(startDate,numDays,0,0);
}

//[100] trim function for the built-in JavaScript String object
String.prototype.trim = function()
{
   return this.replace(/^\s*|\s*$/g, "");
}


//[101] This function reutrns the user to the the tab where a required field was not completed.
function GoToErrorTab() {  //TR#54088
  /**
    This function returns the user to the the tab where a required field was not completed.
    In order to use this function the DIV tag for the tab must have an id assigned to it that matches the 
      "myTabStrip_"+id of the corresponding TD in the tabStrip tabTable.  For example:
      
      <DIV class="TAB2" ...>
        <table id="myTabStrip_tabtable" ...>
	  <tr>
 	    <td class="TAB_START" nowrap="nowrap">&nbsp;</td>
 	    <td id="myTabStrip_contactsTab" nowrap="nowrap" align="Center" onClick="JavaScript:TabClick(this, 'contactsTab');" class="tab_active2" onMouseOver="Hand(this)">Contacts</td>
 	    <td id="myTabStrip_schedulingTab" nowrap="nowrap" align="Center" onClick="JavaScript:TabClick(this, 'schedulingTab');" class="tab_right2" onMouseOver="Hand(this)">Scheduling</td>
 	    <td id="myTabStrip_resultsTab" nowrap="nowrap" align="Center" onClick="JavaScript:TabClick(this, 'resultsTab');" class="tab_right2" onMouseOver="Hand(this)">Results</td>
 	    <td class="TAB_END" style="width:100%;">&nbsp;<input name="myTabStrip:ActiveCell" id="myTabStrip_ActiveCell" type="hidden"></td>
	  </tr>
        </table>
	<DIV id="contactsTab" class="TabBody" ...> ...  </DIV>
 	<DIV id="schedulingTab" class="TabBody" ...>  ...  </DIV>     
 	<DIV id="resultsTab" class="TabBody" ...>  ... </DIV>
      </DIV>     
  */
  
  var parent;
  var requiredElement;
  var gotMatch = false;
  var ii = document.forms[0].elements.length;
  
  for (i=0;i<ii; i++) {
    if (document.forms[0].elements[i].mandatory == "true" && document.forms[0].elements[i].value == "") {
      requiredElement = document.forms[0].elements[i]
      parent = requiredElement.parentElement

      while (gotMatch == false) {
        parent = parent.parentElement
        if ((parent.className.toString().toUpperCase() == "TABBODY") || (parent.tagName == "FORM")) {
          gotMatch = true;
        }
      }
      if (parent.className.toString().toUpperCase() == "TABBODY") {
        TabClick(document.getElementById("myTabStrip_"+parent.id), parent.id); 
      }
    }
  }
  return;
}   

// [104]
// TabClick - For ASP pages with a tabstrip on, when a tab is clicked, hide the div corresponding to the old tab and display the div corresponding to the new tab
function TabClick(tabClicked, target) {

    var tabs;
    var i;
    var iCount;
    var parent;
    var divs;
    var TabStripName;
    var j;
    var top;
        var left;
    var width;
    var height;
   
   
    if (tabClicked == null) {return}
    j = tabClicked.id.indexOf("_")
    TabStripName = tabClicked.id.substring(0, j)
    parent = tabClicked.parentElement
    tabs = parent.childNodes

    for (i = 0; i < tabs.length; i++) {               
        if (tabs[i].className == "tab_active2") {
			// Get the tab strip div
			var oDiv = GetParentByTag(tabs[i], "DIV");

			// Get the TOP value from the active DIV.  We used to 
            // have the following line, but I don't think we need it anymore.
            // + parseInt(document.all(target).firstChild.style.top) 
            top = parseInt(oDiv.offsetTop) + 30
            }
        if (tabs[i].id == tabClicked.id) {tabs[i].className = "tab_active2"}
        else if (tabs[i].className == "tab_active2") {tabs[i].className = "tab_right2"}
    }

    divs = document.body.getElementsByTagName("DIV");
    for (i = 0; i < divs.length; i++) {               
        if (divs[i].className == "TabBody") {
            if (divs[i].id == target) {
                divs[i].style.visibility = "visible"
                divs[i].style.top = top 
            }
            
            else {
                // This is to get around an apparent bug.  If we don't have this line,
                // then a ghost frame of the hidden tables shows up on the visible div.
                divs[i].style.top = top 
                divs[i].style.visibility = "inherit"; 
                divs[i].style.visibility = "hidden"}
        }   
   } 
   document.all(TabStripName + "_ActiveCell").value = tabClicked.id; 
}
    
function GetParentByTag(obj, tagName) {
    do {
       if (obj.parentElement == null) {return;}
       if (obj.parentElement.tagName == tagName) {return obj.parentElement}   
       obj = obj.parentElement
    }  
    while (true);   
}

function ValidateTime2(objTime)
{
	/* Given an html form element that supposedly holds a time value, check that the time entered is valid and format it according to
	   the format stored in the db for the user. Ex: "h:mm tt".
	   
	   If time entered is not valid, an "Invalid Time" error msg. is dsiplayed.
	    */
	var sTime = new String( trim(objTime.value) );
	
	if ( Empty(sTime) )
	{
		return true;
	}		
	
	if ( ! IsValidTime(sTime) )
	{
		return error(objTime, "Invalid time format.");
	}
	
	objTime.value = FormatTime(sTime)
	
	/* Range checking */
	if ( typeof(objTime.rangeStartId) != "undefined")
	{
		// I'm the end date of the range.
		var startTextBox = document.all(objTime.rangeStartId);
		var startDate;
		var endDate;
		
		if (startTextBox.value != "") {startDate = new Date("01/01/2001 " + startTextBox.value);}
		if (objTime.value != "") {endDate = new Date("01/01/2001 " + objTime.value);}
		
		// If the dates aren't in order, show error message.
		if (endDate < startDate) {error(objTime, "End time must be after start time."); objTime.value = startTextBox.value; SetInitialFocus(objTime); return false;}
		
		// If the start date is blank, set it to the end date.
		else if (isNaN(startDate) || startTextBox.value == "") {startTextBox.value = objTime.value; SetInitialFocus(endTextBox);}
		
		// If I'm blank, set me to the start date value
		else if (isNaN(endDate)) {objTime.value = startTextBox.value;}
	}
	else if ( typeof(objTime.rangeEndId) != "undefined")
	{
		// I'm the start date of the range.
		var endTextBox = document.all(objTime.rangeEndId);
		var startDate;
		var endDate;
		
		if (objTime.value != "") {startDate = new Date("01/01/2001 " + objTime.value);}
		if (endTextBox.value != "") {endDate = new Date("01/01/2001 " + endTextBox.value);}
		    
	}
	
	return true;
}


function IsValidTime(sTime)
{
	/* Given a string, validate if the string holds a valid time.
	   Return true if time is valid format and within the 24-hour clock. Otherwise return false.
	   
	   Valid formats are:
	   		The format stored in the db for this user. Ex: "h:mm tt"
	   		1am
	   		112am
	   		1:12am
	   		01am
	   		0112am
	   		01:12am
	   		0112	(Military)
	   		1312	(Military)
	 */
	
	var arrayTime = GetHourMinuteAmPm(sTime);
	if (arrayTime == null)
	{
		return false;
	}
	
	/* are we running 12 or 24 hour clock? */
	var dMaxHour = (arrayTime["AmPm"] == "") ? 23: 12;
	var dMinHour = (arrayTime["AmPm"] == "") ?  0:  1;
	
	if ( ! ValidMinMax(arrayTime["hours"], dMinHour, dMaxHour) ) { return false; }
	if ( ! ValidMinMax(arrayTime["minutes"],      0,       59) ) { return false; }
	
	return true;
}


function GetHourMinuteAmPm(sTime)
{
	/* Given a string, try to find a match that contains hours, minutes and AM/PM.
	   Return an array: arrayTime["hours"], arrayTime["minutes"] and arrayTime["AmPm"]. Return null if no match is found.
	 */
	 
	var dHours = 0;
	var dMinutes = 0;
	var sAmPm = "";
	var arrayTime = new Array(3);
	
	/* First check if we match the users selected time format */
	var sTimeFormat = GetTimeFormat();
	var sTimeFormatRegExPattern = TimeFormatToRegExPattern(sTimeFormat);
	var sTimeFormatRegExReplacement = TimeFormatToRegExReplacement(sTimeFormat);
	
	var re = new RegExp("^" + sTimeFormatRegExPattern + "$", "i");
	
	if ( ! re.test(sTime) )
	{
		/* No match. Try matching more generic time formats as specified above. */
		re = new RegExp("^(\\d{1,2}):?(\\d{2})?\\s*(AM|PM)?$", "i");
		
		if ( ! re.test(sTime) )
		{
			/* Still no match, so user must have entered invalid format. */
			return null;
		}
		
		arrayTime["hours"] = parseInt(RegExp.$1, 10);
		arrayTime["minutes"] = parseInt( (RegExp.$2 == "") ? "0": RegExp.$2 , 10);
		arrayTime["AmPm"] = RegExp.$3;
	}
	else
	{
		sTime = sTime.replace(re, sTimeFormatRegExReplacement);
		
		re = new RegExp("<hours>(\\d{1,2})</hours>", "i");
		arrayTime["hours"] = (re.test(sTime)) ? parseInt(RegExp.$1, 10) : -1;
		
		re = new RegExp("<minutes>(\\d{1,2})</minutes>", "i");
		arrayTime["minutes"] = (re.test(sTime)) ? parseInt(RegExp.$1, 10) : -1;
		
		re = new RegExp("<amPm>(AM|PM)</amPm>", "i");
		arrayTime["AmPm"] = (re.test(sTime)) ? RegExp.$1 : "";
		
		if ( ((arrayTime["AmPm"]).toUpperCase() == "PM") && (arrayTime["hours"] > 12) )
		{
			arrayTime["hours"] += 12;
		}
		
		if (arrayTime["hours"] >= 24)
		{
			/* back to midnight */
			arrayTime["hours"] = 0;
		}
	}
	
	return arrayTime;
}

/* ******************************************************** */
/*            Time validation and formatting                */
/* ******************************************************** */

function GetTimeFormat()
{
	/* Return the time format string stored in the cookie TimeFormat */
	
	var sTimeFormat = GetSubCookie("Culture", "TimeFormat");
	
	if (sTimeFormat == null)
	{
		sTimeFormat = "";
	}
	
	var re = new RegExp("(h{1,2}|m{1,2}|tt)", "g");
	sTimeFormat = sTimeFormat.replace(re, "{$1}");
	
	return (sTimeFormat == "") ? "{h}:{mm} {tt}": sTimeFormat;
}

function TimeFormatToRegExPattern(sTimeFormat)
{
	/* Replace a time format (as it is returned from function GetTimeFormat) into a RegEx pattern
	   If sTimeFormat is "{h}:{mm}{tt}", this function will return "(\\d{1,2}):(\\d{1,2})(AM|PM)",
	   which can be used to instantiate a new RegEx object.
	 */
	
	var re = new RegExp("\\{h{1,2}\\}", "i");
	sTimeFormat = sTimeFormat.replace(re, "(\\d{1,2})");
	
	re = new RegExp("\\{m{1,2}\\}", "i");
	sTimeFormat = sTimeFormat.replace(re, "(\\d{1,2})");
	
	re = new RegExp("\\{tt\\}", "i");
	return sTimeFormat.replace(re, "(AM|PM)");
}


function TimeFormatToRegExReplacement(sTimeFormat)
{
	/* Replace a time format (as it is returned from function GetTimeFormat) into a RegEx replacement string
	   If sTimeFormat is "{h}:{mm}{tt}", this function will return "<hours>{h}</hours>:<minutes>{mm}</minutes><amPm>{tt}</amPm>",
	   which can be used in "someString.replace(re, ourReturnValue)"
	 */
	
	var re = new RegExp("(\\{h{1,2}\\})", "i");
	sTimeFormat = sTimeFormat.replace(re, "<hours>$1</hours>");
	
	re = new RegExp("(\\{m{1,2}\\})", "i");
	sTimeFormat = sTimeFormat.replace(re, "<minutes>$1</minutes>");
	
	re = new RegExp("\\{tt\\}", "i");
	sTimeFormat = sTimeFormat.replace(re, "<amPm>{tt}</amPm>");
	
	for (var i = 1; i <= 3; i++)
	{
		re = new RegExp("\\{[hmt]{1,2}\\}", "i");
		sTimeFormat = sTimeFormat.replace(re, "\$" + i);
	}
	
	return sTimeFormat;
}


// Get the specified cookie
function GetSubCookie(sCookie, sSubKey) {

  // get an array of cookies.
  var cookies = document.cookie.split(";");
  for (var i=0; i < cookies.length; i++)  {
    // if this is the cookie we're looking for.
    if (trim(cookies[i]).indexOf(sCookie) == 0) {
        // now get an array of sub cookies.  At this point, the 
        // cookie will look like: "MyCookie=SubCookieA=1&SubCookieB=2"
        var subCookies = cookies[i].replace(sCookie + "=", "").split("&");
        for (var j=0; j < cookies.length; j++) {
            if (trim(subCookies[j].split("=")[0]) == trim(sSubKey)) {
                return subCookies[j].split("=")[1]
            }
        }
    }
 }   
    
  return null;
}

function FormatTime(sTime)
{
	/* Given a string that holds a valid time (has to be validated by function IsValidTime or other).
	   Return a string with hours, minutes and maybe AM/PM, formatted as stored in the db for this user. Ex: "h:mm tt"
	*/
	var arrayTime = GetHourMinuteAmPm(sTime);
	if (arrayTime == null)
	{
		return false;
	}
	
	if ( ((arrayTime["AmPm"]).toUpperCase() == "PM") && (arrayTime["hours"] < 12) )
	{
		arrayTime["hours"] += 12;
	}
	
	if ( ((arrayTime["AmPm"]).toUpperCase() == "AM") && (arrayTime["hours"] >= 12) )
	{
		/* back to midnight */
		arrayTime["hours"] = 0;
	}
	
	arrayTime["AmPm"] = (arrayTime["AmPm"] != "") ? (arrayTime["AmPm"]).toUpperCase() : (arrayTime["hours"] >= 12) ? "PM" : "AM";
	
	var sTimeFormat = GetTimeFormat();
	
	if ( sTimeFormat.match("{tt}") )
	{
		/* we're displaying 12 hour clock */
		if (arrayTime["hours"] > 12)
		{
			arrayTime["AmPm"] = "PM";
			arrayTime["hours"] -= 12;
		}
		
		if (arrayTime["hours"] == 0)
		{
			arrayTime["AmPm"] = "AM";
			arrayTime["hours"] = 12;
		}
	}
	
	sTimeFormat = sTimeFormat.replace("{h}", arrayTime["hours"]);
	sTimeFormat = sTimeFormat.replace("{hh}", LeftPad((arrayTime["hours"]).toString(), "0", 2));
	sTimeFormat = sTimeFormat.replace("{m}", arrayTime["minutes"]);
	sTimeFormat = sTimeFormat.replace("{mm}", LeftPad((arrayTime["minutes"]).toString(), "0", 2));
	sTimeFormat = sTimeFormat.replace("{tt}", arrayTime["AmPm"]);
	
	return sTimeFormat;
}

function LeftPad(sToBePadded, sPad, dFinalLength)
{
	var sTemp = "";
	for (i = 0; i < dFinalLength - sToBePadded.length; i++)
	{
		sTemp += sPad.toString();
	}
	
	return sTemp.concat(sToBePadded);
}

function AutoSizeWindow() {

    // Only size the window if
    // 1.  There's an opener.
    // 2.  The opener is valid.
    // 3.  It hasn't already been sized.


    var bIsFrames = false
    if (parent.document.location.href.indexOf("FramesNav.aspx") >= 0) {
        bIsFrames = true
    }
    var myWindow = window

    if (bIsFrames) {
        myWindow = parent.window
    }

    if (typeof(myWindow) == "undefined") {return}
    if (myWindow.opener == null) {return}
    if (myWindow.document.body.clientWidth > 150 && myWindow.document.body.clientHeight) {
    	if (document.getElementById("bResizePageOnLoad") == null || document.getElementById("bResizePageOnLoad").value != "true") {
    		return;
    	}
    }

/*

    // We no longer move the window, but this might come back someday.

    // Move the window below and to the right of the opener.
    if (typeof(myWindow.opener.opener) != "undefined") {
        // If the opener is a pop-up, then we don't need to subtract the toolbar height.
        // We also don't need to add 30, because screenTop starts at the beginning of the client
        // area, which is right below the window title bar.
        var top = myWindow.opener.screenTop
    }
    else {
        // NOTE: We no longer know the toolbar height, so we go with a hard coded value of 146.
        // If the opener is a pop-up, then we do need to subtract the toolbar height.  We need to
        // add back 30px because the toolbarHeight includes the window title bar.
        //var top = window.opener.screenTop - parseInt(window.opener.document.all("toolbarHeight").value) + 30
        var toolbarHeight = 146
        var top = myWindow.opener.screenTop - toolbarHeight + 30
    }

    var left = myWindow.opener.screenLeft - 220

    // TEMP: We need to figure out how wide the side toolbar is, if there's a toolbar at all.
    // For now, don't move the window at all.
    //window.moveTo(left, top);

*/

    var width = 0
    var height = 0
    var extraWidth = 30
    var extraHeight = 55
    var tooWide = false
    var tooTall = false

    // More extra width to account for the side frame and frame border.
    if (bIsFrames) {
        extraWidth = 320
    }


    // Size the screen to be either
    //  1. As big as it needs to be to display without scroll bars
    //  2. As much screen size as we have available.

    if ((screen.availWidth - myWindow.screenLeft) >= document.body.scrollWidth + extraWidth) {
        width = document.body.scrollWidth + extraWidth
    }
    else {
        width = screen.availWidth - myWindow.screenLeft
        tooWide = true
    }

    if ((screen.availHeight - myWindow.screenTop) >= document.body.scrollHeight + extraHeight) {
        height = document.body.scrollHeight + extraHeight
    }
    else {
        height = screen.availHeight - myWindow.screenTop
        tooTall = true
    }

    // Strange, but true...
    if (tooTall && !tooWide) {width += 20; height += 20}

    myWindow.moveTo(100, 100);
    myWindow.resizeTo(width, height);


    // Scroll to the top/left
    if (bIsFrames) {
        parent.document.body.scrollLeft = 0
        parent.document.body.scrollTop = 0
    }
    else {
        document.body.scrollLeft = 0
        document.body.scrollTop = 0
    }
}

// [105]
// GetBlankPage - returns the path to /system/blank.htm use with window.open(GetBlankPage,... to prevent secure/nonsecure warnings over SSL (https) connections 
function GetBlankPage() 
	{
	var blank = "/" + location.pathname.split("/")[1] + '/system/blank.htm';
	return blank;
	}

