//*******************************************************************************************
//
//  dotJ Javascript Library
//
//  Copyright(c) 2001-2008 DotJ Software Inc
//  ALL RIGHTS RESERVED
//
//  The contents of this file is protected by U.S. and International Copyright Laws.
//  Unauthorized use of the code contained in this file is strictly prohibited unless
//  permission is explicitly granted by DotJ Software.
//
//  JavaScript library to support all of the dotJ tags.
//  This library contains code that needs to match with the equivalent Java code.
//  Therefore, edit this code at your own risk!
//
//  author: dotJ Software
//  since: version 2.0
//
//*******************************************************************************************

var DotJ_JSVersion = "2.9";

// See http://www.webreference.com/tools/browser/javascript.html
var DotJ_agt            = navigator.userAgent.toLowerCase();
var DotJ_appVer         = navigator.appVersion.toLowerCase();
var DotJ_is_minor       = parseFloat(DotJ_appVer);
var DotJ_is_major       = parseInt(DotJ_is_minor,10);

var DotJ_is_opera       = (DotJ_agt.indexOf("opera") != -1);
var DotJ_is_opera2      = (DotJ_agt.indexOf("opera 2") != -1 || DotJ_agt.indexOf("opera/2") != -1);
var DotJ_is_opera3      = (DotJ_agt.indexOf("opera 3") != -1 || DotJ_agt.indexOf("opera/3") != -1);
var DotJ_is_opera4      = (DotJ_agt.indexOf("opera 4") != -1 || DotJ_agt.indexOf("opera/4") != -1);
var DotJ_is_opera5      = (DotJ_agt.indexOf("opera 5") != -1 || DotJ_agt.indexOf("opera/5") != -1);
var DotJ_is_opera6      = (DotJ_agt.indexOf("opera 6") != -1 || DotJ_agt.indexOf("opera/6") != -1);
var DotJ_is_opera7      = (DotJ_agt.indexOf("opera 7") != -1 || DotJ_agt.indexOf("opera/7") != -1);
var DotJ_is_opera8      = (DotJ_agt.indexOf("opera 8") != -1 || DotJ_agt.indexOf("opera/8") != -1);
var DotJ_is_opera9      = (DotJ_agt.indexOf("opera 9") != -1 || DotJ_agt.indexOf("opera/9") != -1);

var DotJ_is_opera5up    = (DotJ_is_opera && !DotJ_is_opera2 && !DotJ_is_opera3 && !DotJ_is_opera4);
var DotJ_is_opera6up    = (DotJ_is_opera && !DotJ_is_opera2 && !DotJ_is_opera3 && !DotJ_is_opera4 && !DotJ_is_opera5);
var DotJ_is_opera7up    = (DotJ_is_opera && !DotJ_is_opera2 && !DotJ_is_opera3 && !DotJ_is_opera4 && !DotJ_is_opera5 && !DotJ_is_opera6);
var DotJ_is_opera8up    = (DotJ_is_opera && !DotJ_is_opera2 && !DotJ_is_opera3 && !DotJ_is_opera4 && !DotJ_is_opera5 && !DotJ_is_opera6 && !DotJ_is_opera7);
var DotJ_is_opera9up    = (DotJ_is_opera && !DotJ_is_opera2 && !DotJ_is_opera3 && !DotJ_is_opera4 && !DotJ_is_opera5 && !DotJ_is_opera6 && !DotJ_is_opera7 && !DotJ_is_opera8);

var DotJ_is_mac = (DotJ_agt.indexOf("mac")!=-1);
var DotJ_iePos  = DotJ_appVer.indexOf('msie');
if (DotJ_iePos !=-1) {
	if (DotJ_is_mac) {
		var DotJ_iePos = DotJ_agt.indexOf('msie');
		DotJ_is_minor = parseFloat(DotJ_agt.substring(DotJ_iePos+5,DotJ_agt.indexOf(';',DotJ_iePos)));
	}
	else DotJ_is_minor = parseFloat(DotJ_appVer.substring(DotJ_iePos+5,DotJ_appVer.indexOf(';',DotJ_iePos)));
	DotJ_is_major = parseInt(DotJ_is_minor,10);
}

var DotJ_is_konq = false;
var DotJ_kqPos   = DotJ_agt.indexOf('konqueror');
if (DotJ_kqPos !=-1) {
	DotJ_is_konq  = true;
	DotJ_is_minor = parseFloat(DotJ_agt.substring(DotJ_kqPos+10,DotJ_agt.indexOf(';',DotJ_kqPos)));
	DotJ_is_major = parseInt(DotJ_is_minor,10);
}

var DotJ_is_getElementById   = (document.getElementById) ? "true" : "false";
var DotJ_is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
var DotJ_is_documentElement = (document.documentElement) ? "true" : "false";

var DotJ_is_safari = (DotJ_agt.indexOf('safari')!=-1)?true:false;
var DotJ_is_khtml  = (DotJ_is_safari || DotJ_is_konq);

var DotJ_is_gecko  = ((!DotJ_is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
var DotJ_is_gver = 0;
if (DotJ_is_gecko) DotJ_is_gver = navigator.productSub;

var DotJ_is_fb = ((DotJ_agt.indexOf('mozilla/5')!=-1) && (DotJ_agt.indexOf('spoofer')==-1) &&
                 (DotJ_agt.indexOf('compatible')==-1) && (DotJ_agt.indexOf('opera')==-1)  &&
                 (DotJ_agt.indexOf('webtv')==-1) && (DotJ_agt.indexOf('hotjava')==-1)     &&
                 (DotJ_is_gecko) && (navigator.vendor=="Firebird"));
var DotJ_is_fx = ((DotJ_agt.indexOf('mozilla/5')!=-1) && (DotJ_agt.indexOf('spoofer')==-1) &&
                 (DotJ_agt.indexOf('compatible')==-1) && (DotJ_agt.indexOf('opera')==-1)  &&
                 (DotJ_agt.indexOf('webtv')==-1) && (DotJ_agt.indexOf('hotjava')==-1)     &&
                 (DotJ_is_gecko) && ((navigator.vendor=="Firefox")||(DotJ_agt.indexOf('firefox')!=-1)));
var DotJ_is_moz   = ((DotJ_agt.indexOf('mozilla/5')!=-1) && (DotJ_agt.indexOf('spoofer')==-1) &&
				(DotJ_agt.indexOf('compatible')==-1) && (DotJ_agt.indexOf('opera')==-1)  &&
				(DotJ_agt.indexOf('webtv')==-1) && (DotJ_agt.indexOf('hotjava')==-1)     &&
				(DotJ_is_gecko) &&  (!DotJ_is_fb) && (!DotJ_is_fx) &&
				((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));

if ((DotJ_is_moz)||(DotJ_is_fb)||(DotJ_is_fx)) {
	var DotJ_is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
	if(DotJ_is_fx&&!DotJ_is_moz_ver) {
	    DotJ_is_moz_ver = DotJ_agt.indexOf('firefox/');
	    DotJ_is_moz_ver = DotJ_agt.substring(DotJ_is_moz_ver+8);
	    DotJ_is_moz_ver = parseFloat(DotJ_is_moz_ver);
	}
	if(!(DotJ_is_moz_ver)) {
	    DotJ_is_moz_ver = DotJ_agt.indexOf('rv:');
	    DotJ_is_moz_ver = DotJ_agt.substring(DotJ_is_moz_ver+3);
	    DotJ_is_paren   = DotJ_is_moz_ver.indexOf(')');
	    DotJ_is_moz_ver = DotJ_is_moz_ver.substring(0,DotJ_is_paren);
	}
	DotJ_is_minor = DotJ_is_moz_ver;
	DotJ_is_major = parseInt(DotJ_is_moz_ver,10);
}
var DotJ_is_fb_ver = DotJ_is_moz_ver;
var DotJ_is_fx_ver = DotJ_is_moz_ver;

var DotJ_is_nav = ((DotJ_agt.indexOf('mozilla')!=-1) && (DotJ_agt.indexOf('spoofer')==-1) &&
				   (DotJ_agt.indexOf('compatible') == -1) && (DotJ_agt.indexOf('opera')==-1) &&
				   (DotJ_agt.indexOf('webtv')==-1) && (DotJ_agt.indexOf('hotjava')==-1) &&
				   (!DotJ_is_khtml) && (!(DotJ_is_moz)) && (!DotJ_is_fb) && (!DotJ_is_fx));

// Netscape6 is mozilla/5 + Netscape6/6.0!!!
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
// Changed this to use navigator.vendor/vendorSub - dmr 060502
// var nav6Pos = agt.indexOf('netscape6');
// if (nav6Pos !=-1) {
if ((navigator.vendor) && ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&& (DotJ_is_nav)) {
	DotJ_is_major = parseInt(navigator.vendorSub,10);
	// here we need is_minor as a valid float for testing. We'll
	// revert to the actual content before printing the result.
	DotJ_is_minor = parseFloat(navigator.vendorSub);
}

var DotJ_is_nav2        = (DotJ_is_nav && (DotJ_is_major == 2));
var DotJ_is_nav3        = (DotJ_is_nav && (DotJ_is_major == 3));
var DotJ_is_nav4        = (DotJ_is_nav && (DotJ_is_major == 4));
var DotJ_is_nav4up      = (DotJ_is_nav && (DotJ_is_minor >= 4));
var DotJ_is_navonly     = (DotJ_is_nav && ((DotJ_agt.indexOf(";nav") != -1) || (DotJ_agt.indexOf("; nav") != -1)) );
var DotJ_is_nav6        = (DotJ_is_nav && (DotJ_is_major == 6));
var DotJ_is_nav6up      = (DotJ_is_nav && (DotJ_is_minor >= 6));
var DotJ_is_nav5        = (DotJ_is_nav && (DotJ_is_major == 5) && !DotJ_is_nav6);
var DotJ_is_nav5up      = (DotJ_is_nav && (DotJ_is_minor >= 5));
var DotJ_is_nav7        = (DotJ_is_nav && (DotJ_is_major == 7));
var DotJ_is_nav7up      = (DotJ_is_nav && (DotJ_is_minor >= 7));
var DotJ_is_nav8        = (DotJ_is_nav && DotJ_is_major == 8);
var DotJ_is_nav8up      = (DotJ_is_nav && DotJ_is_minor >= 8);

var DotJ_is_ie   = ((DotJ_iePos!=-1) && (!DotJ_is_opera) && (!DotJ_is_khtml));
var DotJ_is_ie3  = (DotJ_is_ie && (DotJ_is_major < 4));

var DotJ_is_ie4   = (DotJ_is_ie && DotJ_is_major == 4);
var DotJ_is_ie4up = (DotJ_is_ie && DotJ_is_minor >= 4);
var DotJ_is_ie5   = (DotJ_is_ie && DotJ_is_major == 5);
var DotJ_is_ie5up = (DotJ_is_ie && DotJ_is_minor >= 5);

var DotJ_is_ie5_5  = (DotJ_is_ie && (DotJ_agt.indexOf("msie 5.5") !=-1));
var DotJ_is_ie5_5up =(DotJ_is_ie && DotJ_is_minor >= 5.5);

var DotJ_is_ie6   = (DotJ_is_ie && DotJ_is_major == 6);
var DotJ_is_ie6up = (DotJ_is_ie && DotJ_is_minor >= 6);

var DotJ_is_ie7   = (DotJ_is_ie && DotJ_is_major == 7);
var DotJ_is_ie7up = (DotJ_is_ie && DotJ_is_minor >= 7);

var DotJ_is_hotjava = (DotJ_agt.indexOf("hotjava") != -1);
var DotJ_is_hotjava3 = (DotJ_is_hotjava && (DotJ_is_major == 3));
var DotJ_is_hotjava3up = (DotJ_is_hotjava && (DotJ_is_major >= 3));

var DotJ_js;
if (DotJ_is_nav2 || DotJ_is_ie3) DotJ_js = 1.0;
else if (DotJ_is_nav3) DotJ_js = 1.1;
else if ((DotJ_is_opera5)||(DotJ_is_opera6)) DotJ_js = 1.3;
else if (DotJ_is_opera7up) DotJ_js = 1.5;
else if (DotJ_is_khtml) DotJ_js = 1.5;
else if (DotJ_is_opera) DotJ_js = 1.1;
else if ((DotJ_is_nav4 && (DotJ_is_minor <= 4.05)) || DotJ_is_ie4) DotJ_js = 1.2;
else if ((DotJ_is_nav4 && (DotJ_is_minor > 4.05)) || DotJ_is_ie5) DotJ_js = 1.3;
else if (DotJ_is_nav5 && !(DotJ_is_nav6)) DotJ_js = 1.4;
else if (DotJ_is_hotjava3up) DotJ_js = 1.4;
else if (DotJ_is_nav6up) DotJ_js = 1.5;

else if (DotJ_is_nav && (DotJ_is_major > 5)) DotJ_js = 1.4;
else if (DotJ_is_ie && (DotJ_is_major > 5)) DotJ_js = 1.3;
else if (DotJ_is_moz) DotJ_js = 1.5;
else if (DotJ_is_fb||DotJ_is_fx) DotJ_js = 1.5;
else DotJ_js = 0.0;
if ((DotJ_agt.indexOf("mac")!=-1) && DotJ_is_ie5up) DotJ_js = 1.4;
if (DotJ_is_nav6up) {
	DotJ_is_minor = navigator.vendorSub;
}

//alert('agent=[' + DotJ_agt + ']' + '\nappVer=[' + DotJ_appVer + ']' + '\nmajor=[' + DotJ_is_major + '] minor=[' + DotJ_is_minor + ']' +
//	  '\nisKonq=' + DotJ_is_konq + ', isSafari=' + DotJ_is_safari + ', isKhtml=' + DotJ_is_khtml + ', isGecko=' + DotJ_is_gecko +
//	  ', isMozilla=' + DotJ_is_moz + ', isFirefox=' + DotJ_is_fx +', isNav=' + DotJ_is_nav +
//	  '\nMozilla version=[' + DotJ_is_moz_ver + ']' +
//	  '\nIE info: ie4: ' + DotJ_is_ie4 + ', ie5: ' + DotJ_is_ie5 + ', ie5_5: ' + DotJ_is_ie5_5 + ', ie6: ' + DotJ_is_ie6 + ', ie7: ' + DotJ_is_ie7 +
//	  '\nJavascript version=' + DotJ_js + ', Mac: ' + DotJ_is_mac);

var DotJ_KEY_SHIFT = 16;
var DotJ_KEY_CTRL = 17;
var DotJ_KEY_ALT = 18;
var DotJ_KEY_SPACE = 32;
var DotJ_KEY_LEFT = 37;
var DotJ_KEY_UP = 38;
var DotJ_KEY_RIGHT = 39;
var DotJ_KEY_DOWN = 40;
var DotJ_MOUSE_CLICK = 1000;  // arbitrary constant definition

var DotJ_LOG = false;

//************************   OBJECT FACTORY   ************************

/**
 * Make an object if it is undefined or null.
 * @param {Object} obj Object to test.
 * @param {String} objType Type of object to make.
 * @return {Object} A newly created object if not in existence, otherwise returns the same object.
 */
var DotJ_makeObject = function(obj, objType) {
    if (typeof obj == 'undefined' || obj == null) {
        return eval('new ' + objType);
    }
    return obj;
};

//******************************   GRID   *******************************

DotJ_Grid.isValidationCommand = function(command) {
	return !(command == 'cancel' || command == 'custom:delete' || command == 'delete' || command == 'deselectall' || command == 'edit' ||
             command == 'page' || command == 'refresh' || command == 'select' || command == 'selectall' || command == 'sort');
};

DotJ_Grid.getCSField = function() {
	return eval("this.form.elements['" + this.csFieldName + "']");
};

DotJ_Grid.selectedCount = function() {
	if (this.iSelectedCount == null) {
		return this.rows.selectedCount();
	} else {
		return this.iSelectedCount;
	}
};

DotJ_Grid.selectRow = function(firstPass) {
	this.rows.select(firstPass);
};

DotJ_Grid.selectCurrentRow = function(objRow, lastKey) {
	this.rows.selectCurrentRow(objRow, lastKey);
};

DotJ_Grid.selectPreviousRow = function(objRow, lastKey) {
	this.rows.selectPreviousRow(objRow, lastKey);
};

DotJ_Grid.selectNextRow = function(objRow, lastKey) {
	this.rows.selectNextRow(objRow, lastKey);
};

DotJ_Grid.setClientState = function (command) {
    var csField = this.getCSField();
	var fixed = 'grid=' + this.name + DotJ_PAIR_DELIMITER +
				'cmd=' + command;

	var selParms = this.rows.getSelectedParms();
	csField.value = fixed + DotJ_PAIR_DELIMITER + selParms;
};

DotJ_Grid.setKeyField = function(row, keyField) {
	this.rows.setKeyField(row, keyField);
};

function DotJ_isRowToBeSelected(lastKey, multiselect) {
	if (multiselect && lastKey == DotJ_KEY_SPACE) {
		return true;
	} else if (!multiselect || lastKey == DotJ_MOUSE_CLICK) {
		return true;
	}
	return false;
}

DotJ_Grid.getSelectorId = function(rowId) {
	var parts = rowId.split('_');
	var i, result = '';
	for (i = 0; i < parts.length - 1; i++) {
		if (i > 0) result = result + '_';
		result = result + parts[i];
	}

    parts = result.split('_');
    result = '';
    for (i = 0; i < parts.length; i++) {
        if (i != (parts.length-2)) {
            if (i > 0) result = result + '_';
            result = result + parts[i];
        }
    }

	return result.replace('_ROW_', '_SEL_');
};

DotJ_Grid.getBodyId = function(hdrRowId, row) {
	// hdr format is DotJ_{gridName}_HDR_{col}  -->  DotJ_{gridName}_COL_{row}_{col}
	if (hdrRowId.indexOf('HDR_SEL') != -1) {
		hdrRowId = hdrRowId.replace('_SEL', '_' + row);
		hdrRowId = hdrRowId.replace('HDR_', 'SEL_');
		return hdrRowId;
	}

	hdrRowId = hdrRowId.replace('_HDR_', '_COL_');
	var parts = hdrRowId.split('_');
	var i, result = '';
	for (i = 0; i < parts.length; i++) {
		if (i > 0) result = result + '_';
		if (i == (parts.length-1)) result = result + row + '_';
		result = result + parts[i];
	}

	return result;
};

DotJ_Grid.showRowArrow = function(rowId, display) {
	if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') return;
	if (!this.showSelectorColumn) return;
	var sDiv = this.getSelectorId(rowId);
	if (DotJ_getObj(sDiv + '_div') != null) sDiv = sDiv + '_div';
	var oDiv = DotJ_getObj(sDiv);
	if (display) {
		if (DotJ_isRowToBeSelected(this.lastKey, this.multiselect)) {
			this.tempSelectorHtml = oDiv.innerHTML;
			DotJ_setText(sDiv, this.selRowImg);
		}
	} else {
        if (typeof(this.tempSelectorHtml) != 'undefined') {
            DotJ_setText(sDiv, this.tempSelectorHtml);
        }
	}
};

DotJ_Grid.style = function(styleName) {
	return this.stylePrefix + styleName;
};

DotJ_Grid.selectGridRowCommon = function(objRow, doPost) {
	var i = this.rows.findRow(objRow.id);
	if (i != -1 && !this.rows.rows[i].selectable) return;
	if (this.inEditMode && this.currentRowObj && this.currentRowObj.id == objRow.id) return;

	var parts = objRow.id.split("_");
	var row = parts[3];
	var absoluteRow = parts[4];
	var keyFields = parts[5];
	if (doPost) {
		this.submitFunc(this.name, 'select', absoluteRow, keyFields);
	} else {
		this.currentRowObj = objRow;
		this.currentRow = row;
		this.hiliteRow();
		if (this.multiselect && (this.lastKey == DotJ_KEY_UP || this.lastKey == DotJ_KEY_DOWN)) {
			;
		} else {
			this.selectRow(false);
		}
		this.setKeyField(row, keyFields);
		this.setClientState('select');
		if (this.inEditMode) {
			this.submitFunc(this.name, 'select', absoluteRow, keyFields);
		}
	}
};

function DotJ_makeNewStyle(objGrid, objRow, style) {
	// Parameter style should be checked if typeof is 'undefined'.  Caller needs to do this.
	var iOld = (objGrid.showSelectorColumn) ? 1 : 0;
	var iNew = 0;

	var newStyle = style;
	if (typeof(style) == 'string') {
		newStyle = new Array(objRow.cells.length);
		for (iNew = 0; iNew < newStyle.length; iNew++)
			newStyle[iNew] = style;
	}

    return newStyle;
}

function DotJ_changeEachCellStyle(objGrid, objRow, i, hiliting, stateMgr, newStyle) {
    var cell = objRow.cells[i];
    if (cell != null && DotJ_Trim(cell.innerHTML).length == 0) cell.innerHTML = '&nbsp;';

    var isRowToBeSelected = (objGrid.isRowToBeSelected) ? objGrid.isRowToBeSelected : DotJ_isRowToBeSelected(objGrid.lastKey, objGrid.multiselect);

    // This could be smarter if there are multiple nested elements , but will do for now.
    if (cell.childNodes && cell.childNodes.length > 0 && cell.childNodes.item(0).nodeType == 1) {
        var child = cell.childNodes.item(0);
        if (child.tagName.toLowerCase() == 'b' && child.childNodes && child.childNodes.length > 0 && child.childNodes.item(0).nodeType == 1)
            child = child.childNodes.item(0);
        if (child.tagName.toLowerCase() == 'nobr' && child.childNodes && child.childNodes.length > 0 && child.childNodes.item(0).nodeType == 1)
            child = child.childNodes.item(0);
        if (child.className != '' && (isRowToBeSelected || hiliting)) {
            stateMgr.queueSetting(child.id,'className',child.className,child);
            child.className = child.className + ' ' + newStyle[i];
        }
    }

    if (isRowToBeSelected || hiliting) {
        stateMgr.queueSetting(cell.id,'className',cell.className,cell);
        cell.className = newStyle[i];
        if (objGrid.textoverflow != 'none' && cell.className.indexOf(' ' + objGrid.overflowName) == -1) cell.className = cell.className + ' ' + objGrid.overflowName;
    }
}

DotJ_Grid.changeRowStyle = function(objRow, style, selecting, hiliting, row) {
	if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') return;
    if (typeof(style) == 'undefined') return;

    var newStyle = DotJ_makeNewStyle(this, objRow, style);

	var rowIndex = row-1;
	var stateMgr = null;
	if (hiliting) {
		stateMgr = this.rows.rows[rowIndex].hottrackStateMgr;
	} else {
		stateMgr = this.rows.rows[rowIndex].selectedStateMgr;
		this.rows.rows[rowIndex].hottrackStateMgr.restoreAllSettings();
	}

	var start = (this.showSelectorColumn) ? 1 : 0;
	for (var i = start; i < objRow.cells.length; i++) {
        DotJ_changeEachCellStyle(this, objRow, i, hiliting, stateMgr, newStyle);
	}

    newStyle = null;
};

DotJ_Grid.hiliteRow = function() {
	if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') return;
	this.restoreChanges();

	var objRow = this.currentRowObj;
	if (objRow == null || objRow.id == '') return;

	for (var i = 0; i < objRow.cells.length; i++) {
		if (i == 0 && !this.pixelHack) {
			this.pixelHack = true;
            if (this.divBody.style.height != '') {
                this.divBody.style.height = parseInt(this.divBody.style.height,10) + 2 * parseInt(DotJ_GRID_CURRENTROW_BORDERWIDTH,10);
            }
		}
		var oDiv = objRow.cells[i];
		if (oDiv != null && DotJ_Trim(oDiv.innerHTML).length == 0) oDiv.innerHTML = '&nbsp;';
		if (i == 0) {
			if (this.showSelectorColumn) {
				var sDiv = this.getSelectorId(objRow.id);
				oDiv = DotJ_getObj(sDiv);
			}
			DotJ_borderTopBottomLeft(this.changes, oDiv, DotJ_GRID_CURRENTROW_BORDERCOLOR, DotJ_GRID_CURRENTROW_BORDERWIDTH, DotJ_GRID_CURRENTROW_BORDERSTYLE);
		} else if (i == objRow.cells.length-1) {
			DotJ_borderTopBottomRight(this.changes, oDiv, DotJ_GRID_CURRENTROW_BORDERCOLOR, DotJ_GRID_CURRENTROW_BORDERWIDTH, DotJ_GRID_CURRENTROW_BORDERSTYLE);
		} else {
			DotJ_borderTopBottom(this.changes, oDiv, DotJ_GRID_CURRENTROW_BORDERCOLOR, DotJ_GRID_CURRENTROW_BORDERWIDTH, DotJ_GRID_CURRENTROW_BORDERSTYLE);
		}
	}
};

DotJ_Grid.restoreChanges = function() {
	if (this.changes == null) return;

	var change, i = this.changes.length - 1;

	while (i >= 0) {
		change = this.changes[i];
		if (change != null) {
			s = 'DotJ_getObj("' + change.id + '").' + change.property + ' = "' + change.value + '"';
			eval(s);
			this.changes[i] = null;
		}
		i--;
	}
	this.changes.length = 0;
};

DotJ_Grid.checkForForm = function() {
	if (this.form == null) this.form = DotJ_FindParentForm('DotJ_' + this.name + '_NAM');

	if (this.form == null) {
		var msg = "dotJ Javascript Error: Grid '" + this.name + "' is not contained within an HTML <form>.\n\nPlease put it under one before proceeding.";
		alert(msg);
		return false;
	}
	return true;
};

function DotJ_measure(start, end) {
    return (end.getTime() - start.getTime()) / 1000;
}

DotJ_Grid.selectAllRows = function() {
	if (!this.multiselect) {
		var msg = "dotJ Error: You must enable multiselect capability to programmatically select all the rows in the grid.\n\nPlease set multiselect to 'true' to proceed.";
		alert(msg);
		return;
	}

	this.lastKey = DotJ_MOUSE_CLICK;

    this.isRowToBeSelected = DotJ_isRowToBeSelected(this.lastKey, this.multiselect);

	var lastId = this.rows.selectAllRows();

	if (!this.postonselect) {
		this.lastKey = 0;
		if (lastId != null) {
			var objField = DotJ_findFormField(lastId + '_focus');
			if (objField != null) {
				DotJ_toggleDisplay(objField);
				objField.focus();
				DotJ_toggleDisplay(objField);
			}
		}
	}
};

DotJ_Grid.deselectAllRows = function() {
	this.lastKey = DotJ_MOUSE_CLICK;

	var lastId = this.rows.deselectAllRows();

	if (!this.postonselect) {
		this.lastKey = 0;
		if (lastId != null) {
			var objField = DotJ_findFormField(lastId + '_focus');
			if (objField != null) {
				DotJ_toggleDisplay(objField);
				objField.focus();
				DotJ_toggleDisplay(objField);
			}
		}
	}
};

function DotJ_getBgColor(e) {
  var v=DotJ_getStyle(e,'background-color');
  while (!v || v=='transparent' || v=='#000000' || v=='rgba(0, 0, 0, 0)'){
    if(e==document.body) v='#fff'; else {
      e=e.parentNode;
      v=DotJ_getStyle(e,'background-color');
    }
  }
  return v;
}

DotJ_Grid.bind = function(adjustSize, override) {
	this.divContainer = DotJ_getObj('DotJ_' + this.name + '_CONT');
	this.divHdr       = DotJ_getObj('DotJ_' + this.name + '_HDR');
	this.divBody      = DotJ_getObj('DotJ_' + this.name + '_BODY');
	if (this.divHdr != null)  this.tblHdr      = this.divHdr.getElementsByTagName('table')[0];
	if (this.divBody != null) this.tblBody     = this.divBody.getElementsByTagName('table')[0];
	if (this.tblHdr != null)  this.tblHdrCols  = this.tblHdr.tBodies[0].rows[0].cells;
	if (this.tblBody != null) this.tblBodyCols = this.tblBody.tBodies[0].rows[0].cells;

	this.divContainer.tabIndex = '0';

	if (adjustSize || override) {
		this.adjustSize(override);
	} else {
        if (this.divBody.offsetWidth < this.divBody.scrollWidth) {
			this.divBody.style.height = this.divBody.offsetHeight + DotJ_SCROLLBAR_WIDTH;
		}
	}

	this.setCellTitles();
	this.bindEventHandlers();

	return 0;
};

DotJ_Grid.setCellTitles = function() {
	if (this.tblBody != null) {
		var rows = this.tblBody.tBodies[0].rows.length;
		for (var row = 0; row < rows; row++) {
			for (var col = 0; col < this.tblBody.tBodies[0].rows[row].cells.length; col++) {
				var cell = this.tblBody.tBodies[0].rows[row].cells[col];
				var elText = cell;
				while (elText != null && elText.nodeType != 3) {
					elText = elText.firstChild;
				}

				if (elText != null) {
					if (elText.parentNode.offsetWidth > cell.offsetWidth) {
						cell.title = elText.nodeValue;
					}
				}
			}
		}
	}
};

function DotJ_Grid_OnClick(e) {
    var el = YAHOO.util.Event.getTarget(e);
    if (this != null) this.OnClick(el);
}

function DotJ_Grid_OnKeyDown(e) {
    if (this != null) {
        var keyCode = YAHOO.util.Event.getCharCode(e);
        if (this.handleKeyEvent(keyCode)) return true;
        if (window.event) {
            window.event.cancelBubble = true;
        } else {
            e.preventDefault(); e.stopPropagation();
        }
        return false;
    }

    return true;
}

DotJ_Grid.bindEventHandlers = function() {
	var grid = this;

	if (this.divBody != null && this.divHdr != null && this.divBody != null) {
		this.divBody.onscroll = function() {
			if (grid.divHdr) {
				grid.adjustHeaders(true);
			}
		};
	}

	if (!this.readOnly) {
        YAHOO.util.Event.addListener(this.divContainer.id,'click',DotJ_Grid_OnClick, this, true);
        YAHOO.util.Event.addListener(this.divContainer.id,'keydown',DotJ_Grid_OnKeyDown, this, true);
	}
};

DotJ_Grid.OnClick = function(el) {
	if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') return;
	if (el != null && (el.tagName.toLowerCase() == 'nobr' || el.tagName.toLowerCase() == 'img')) el = el.parentNode;
    if (el != null && el.id.indexOf('_SEL_') != -1 && el.tagName.toLowerCase() == 'div') el = el.parentNode;
    if (el != null && el.tagName.toLowerCase() == 'nobr') el = el.parentNode;
	if (el == null || el.id.length == 0) return;
    if (el != null && el.id.indexOf('SEL_0_div') != -1) return;
	var parts = el.id.split("_");
	if (parts[2] == 'COL' || parts[2] == 'SEL') {
		var objRow = el.parentNode;
		var objGrid = DotJ_gridArray.get(parts[1]);
//		var rowIndex = objGrid.rows.findRow(objRow.id);
		objGrid.lastKey = DotJ_MOUSE_CLICK;
		objGrid.selectGridRowCommon(objRow, objGrid.postonselect);
		objGrid.lastKey = 0;
	}
};

DotJ_Grid.handleKeyEvent = function(keyCode) {
	if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') return true;
	if (this.readOnly || this.postonselect || this.inEditMode) return true;

	if (keyCode == DotJ_KEY_UP) {                       // Up
		this.lastKey = keyCode;
		this.selectPreviousRow(null, this.lastKey);
		this.lastKey = 0;
	} else if (keyCode == DotJ_KEY_DOWN) {              // Down
		this.lastKey = keyCode;
		this.selectNextRow(null, this.lastKey);
		this.lastKey = 0;
	} else if (keyCode == DotJ_KEY_SPACE) {             // Space bar
		this.lastKey = keyCode;
		this.selectCurrentRow(null, this.lastKey);
		this.lastKey = 0;
	} else {
		return true;
	}

	return false;
};

DotJ_Grid.adjustSize = function(override) {
	this.scrollTop = this.divBody.scrollTop;
	if (this.divContainer.offsetWidth >= 4) {
		if (this.divHdr != null)  this.tblHdr      = this.divHdr.getElementsByTagName('span')[0];
		if (this.tblHdr != null)  this.tblHdrCols  = this.tblHdr.getElementsByTagName('span');

		if (this.divHdr != null) this.divHdr.style.padding = '0px';

		if (override) {
			var hScrollbar = !((this.divBody.offsetHeight - this.divBody.clientHeight) < (DotJ_SCROLLBAR_WIDTH / 2));
			var scrollbarWidth = (hScrollbar) ? DotJ_SCROLLBAR_WIDTH : 0;

			if (this.tblBody.offsetHeight <= (this.divBody.offsetHeight - scrollbarWidth)) {
	            this.divBody.style.height = this.tblBody.offsetHeight + scrollbarWidth + 'px';
	            this.divContainer.style.height = parseInt(this.divBody.style.height,10) + 'px';
	        }
			return;
		}

		// Size the body element
        var bodyHeight = this.divContainer.clientHeight - this.divHdr.offsetHeight;
        if (bodyHeight >= 0) { this.divBody.style.height = bodyHeight + 'px'; }
        //if (DotJ_is_ie) this.divBody.style.height = this.divHdr.offsetHeight + bodyHeight + 'px';

		this.tblBody.style.width = this.divBody.clientWidth + 'px';
		// Size the header table
        this.tblHdr.style.width = this.divHdr.style.width = this.divBody.clientWidth + DotJ_SCROLLBAR_WIDTH + 'px';

		DotJ_borderAll(null, this.divHdr, '#ffffff', '0px', 'solid');
		DotJ_borderAll(null, this.tblHdr, '#ffffff', '0px', 'solid');

        if (this.tblHdr.offsetWidth > parseInt(this.divHdr.style.width,10)) {
            this.tblHdr.style.width = 'auto';
        }

		// Put a top border on the header.
		var celllinesBgColor = '#cccccc';
	    if (this.divContainer != null) {
			celllinesBgColor = DotJ_getBgColor(this.divContainer);
		    DotJ_borderTop(null, this.divHdr, celllinesBgColor, '1px', 'solid');
		    DotJ_borderRight(null, this.divHdr, celllinesBgColor, '1px', 'solid');
		}

		var hScrollbar = !((this.divBody.offsetHeight - this.divBody.clientHeight) < (DotJ_SCROLLBAR_WIDTH / 2));
		var scrollbarWidth = (hScrollbar) ? DotJ_SCROLLBAR_WIDTH : 0;

        if (this.tblBody.offsetHeight <= (parseInt(this.divBody.style.height,10) - scrollbarWidth)) {
            this.divBody.style.height = this.tblBody.offsetHeight + scrollbarWidth + 'px';
            this.tblBody.style.width = this.divBody.clientWidth + 'px';
            this.tblHdr.style.width = this.divBody.clientWidth + 'px';
            this.divHdr.style.width = this.divBody.clientWidth + 'px';
        }

        // Size the header columns. also, set the padding left and right to be the same for the selectors cell in the header.
        if (this.tblBodyCols) {
	        this.tblHdr.style.tableLayout = 'auto';
	        this.tblBody.style.tableLayout = 'auto';
	        if (this.showSelectorColumn) {
		        this.tblHdrCols[0].style.paddingLeft = DotJ_getStyle(this.tblBodyCols[0],'padding-left');
		        this.tblHdrCols[0].style.paddingRight = DotJ_getStyle(this.tblBodyCols[0],'padding-right');
	        }
	        this.adjustHeaders(false);
        }
    }
};

DotJ_Grid.adjustHeaders = function(isScroll) {
	// Was this the result of a vertical scroll?
	if (this.divBody.scrollTop != this.scrollTop) {
		this.scrollTop = this.divBody.scrollTop;
		return;
	}
	this.scrollTop = this.divBody.scrollTop;

	var w, leftPos = 0 - this.divBody.scrollLeft;
	var len = this.tblHdrCols.length;
	var cellBody, maxHeight = -1;
	var paddingTop = 0, paddingBottom = 0;
	for (var i = 0; i < len; i++) {
		if (!isScroll) {
			if (DotJ_is_ie) this.tblHdrCols[i].style.overflowX = 'hidden';
			else if (DotJ_MozillaFamily()) this.tblHdrCols[i].style.overflow = '-moz-scrollbars-none';
			this.tblHdrCols[i].style.position = 'absolute';
			this.tblHdrCols[i].style.height = '100%';
		}
		this.tblHdrCols[i].style.left = leftPos + 'px';
		if (DotJ_MozillaFamily() && (i == (len-1))) {
			paddingTop = DotJ_getStyle(this.tblHdrCols[i],'padding-top');
			paddingBottom = DotJ_getStyle(this.tblHdrCols[i],'padding-bottom');
		}
		if (this.tblHdrCols[i].clientHeight > maxHeight) maxHeight = this.tblHdrCols[i].clientHeight;
		if (this.tblHdrCols[i].id.indexOf('_SEP_') == -1) {
            var absoluteRow1 = (this.pageSize * (this.page-1)) + 1;
            var bodyId;
            if (this.tblHdrCols[i].id.indexOf('HDR_SEL') != -1) bodyId = this.getBodyId(this.tblHdrCols[i].id, absoluteRow1);
            else bodyId = this.getBodyId(this.tblHdrCols[i].id, '1');
			cellBody = DotJ_getObj(bodyId);
			if (cellBody != null) {
				w = cellBody.offsetWidth;
				if (w < 1) w = 30;
				if (!isNaN(w)) {
					this.tblHdrCols[i].style.width = w + 'px';
					if (i == (len-1)) {
						this.tblHdrCols[i].style.width = w + DotJ_SCROLLBAR_WIDTH + 'px';
					}
				}
				leftPos += w;
			}
		} else {
			leftPos += this.tblHdrCols[i].offsetWidth;
		}
	}

	if (!isScroll) this.tblHdr.style.height = maxHeight - parseInt(paddingTop,10) - parseInt(paddingBottom,10);
};

function DotJ_Grid(gridName, rowCount, page, pageSize, stamp, stylePrefix, selectedRowId, selectedKeyField, multiselect, requiresForm, showSelectorColumn, supportVerticalScrolling, hottrack, postonselect, readOnly, override) {
	this.checkForForm = DotJ_Grid.checkForForm;

	this.changes = new Array();
	this.name = gridName;
	this.rowCount = rowCount;
	this.page = page;
	this.pageSize = pageSize;
	this.form = null;
	if (requiresForm) this.checkForForm();
	this.stamp = stamp;
	this.rows = new DotJ_RowsArray(this, rowCount);
	this.selectedRowId = selectedRowId;
	this.selectedKeyField = selectedKeyField;
	this.selectedRowOldStyle = "";
	this.multiselect = multiselect;
	this.stylePrefix = stylePrefix;
	this.requiresForm = requiresForm;
	this.showSelectorColumn = showSelectorColumn;
	this.supportVerticalScrolling = supportVerticalScrolling;
	this.hottrack = hottrack;
	this.postonselect = postonselect;
	this.readOnly = readOnly;
	this.iSelectedCount = null;
    this.isRowToBeSelected = null;
	this.pixelHack = false;

    this.isValidationCommand = DotJ_Grid.isValidationCommand;
	this.getCSField = DotJ_Grid.getCSField;
	this.selectedCount = DotJ_Grid.selectedCount;
	this.selectRow = DotJ_Grid.selectRow;
	this.selectAllRows = DotJ_Grid.selectAllRows;
	this.deselectAllRows = DotJ_Grid.deselectAllRows;
	this.selectGridRowCommon = DotJ_Grid.selectGridRowCommon;
	this.selectCurrentRow = DotJ_Grid.selectCurrentRow;
	this.selectPreviousRow = DotJ_Grid.selectPreviousRow;
	this.selectNextRow = DotJ_Grid.selectNextRow;
	this.setClientState = DotJ_Grid.setClientState;
	this.setKeyField = DotJ_Grid.setKeyField;
	this.getSelectorId = DotJ_Grid.getSelectorId;
	this.getBodyId = DotJ_Grid.getBodyId;
	this.showRowArrow = DotJ_Grid.showRowArrow;
	this.style = DotJ_Grid.style;
	this.changeRowStyle = DotJ_Grid.changeRowStyle;
	this.hiliteRow = DotJ_Grid.hiliteRow;
	this.restoreChanges = DotJ_Grid.restoreChanges;
	this.bind = DotJ_Grid.bind;
	this.setCellTitles = DotJ_Grid.setCellTitles;
	this.bindEventHandlers = DotJ_Grid.bindEventHandlers;
	this.handleKeyEvent = DotJ_Grid.handleKeyEvent;
	this.OnClick = DotJ_Grid.OnClick;
	this.adjustSize = DotJ_Grid.adjustSize;
	this.adjustHeaders = DotJ_Grid.adjustHeaders;
	this.submitFunc = eval('DotJ_' + gridName.replace('.', '_') + '_Submit');

	this.bind(this.supportVerticalScrolling && rowCount > 0, override);
}

//****************************   GRIDARRAY  *****************************

function DotJ_GridArray(){
	this.grids = new Array();
}

DotJ_GridArray.prototype.add = function (objGrid){
	this.grids[this.grids.length] = objGrid;
};

DotJ_GridArray.prototype.get = function(name) {
	for (var i = 0; i < this.grids.length; i++) {
		if (this.grids[i].name == name) {
			return this.grids[i];
		}
	}

	return null;
};

var DotJ_gridArray;
// If not defined, nullify the variable (many thanks to Dan Salas of BAE Systems!)
if (typeof(DotJ_gridArray) == 'undefined'){
	DotJ_gridArray = null;
}
if (DotJ_gridArray == null){
	DotJ_gridArray = new DotJ_GridArray();
}

//****************************   ROWSARRAY  *****************************

DotJ_RowsArray.setRowId = function (row, rowId, selectable) {
	if (row >= 0 && row < this.rows.length) {
		var theRow = this.rows[row];
		if (theRow != null) {
			theRow.rowId = rowId;
			theRow.selectable = selectable;
		}
	}
};

DotJ_RowsArray.hasASelectedRow = function () {
	for (var i = 0; i < this.rows.length; i++) {
		if (this.rows[i].selected) return true;
	}
	return false;
};

DotJ_RowsArray.selectedCount = function () {
	var count = 0;
	for (var i = 0; i < this.rows.length; i++) {
		if (this.rows[i].selected) count++;
	}
	return count;
};

DotJ_RowsArray.deselect = function () {
	if (this.grid.multiselect) {
		var objRow = this.grid.currentRowObj;
		var row = this.grid.currentRow;
//        alert('row=' + objRow.id + ', selected=' + this.rows[row-1].selected)
//		temp = this.rows[row-1].selected;
		if (this.rows[row-1].selected) {
			this.rows[row-1].hottrackStateMgr.restoreAllSettings();
			this.rows[row-1].selectedStateMgr.restoreAllSettings();
			if (this.grid.lastKey == DotJ_MOUSE_CLICK || this.grid.lastKey == DotJ_KEY_SPACE) {
				this.rows[row-1].selected = false;
			}
			this.grid.showRowArrow(objRow.id, this.rows[row-1].selected);
		}
		//alert('desel: was ' + temp + ' and became ' + this.rows[row-1].selected)
	} else {
		for (var i = 0; i < this.rows.length; i++) {
			var objRow = this.rows[i].objRow;

			if (objRow != null) {
				this.grid.showRowArrow(objRow.id, false);
				this.rows[i].hottrackStateMgr.restoreAllSettings();
				this.rows[i].selectedStateMgr.restoreAllSettings();
				this.rows[i].selected = false;
				if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') {
					var chk = DotJ_findFormField('DotJ_' + this.grid.name + '_CHK_' + (i+1) + '_chk');
					if (chk != null) chk.checked = false;
				}
			}
		}
	}
};

DotJ_RowsArray.getSelectedParms = function() {
	var selRows = DotJ_EMPTY_STRING, selKeyFields = DotJ_EMPTY_STRING;
	var deselRows = DotJ_EMPTY_STRING, deselKeyFields = DotJ_EMPTY_STRING;
	for (var i = 0; i < this.rows.length; i++) {
		if (this.rows[i].selected) {
			if (selRows == DotJ_EMPTY_STRING) {
				selRows = '' + (i+1);
				selKeyFields = this.rows[i].keyField;
			} else {
				selRows = selRows + DotJ_ITEM_DELIMITER + (i+1);
				selKeyFields = selKeyFields + DotJ_ITEM_DELIMITER + this.rows[i].keyField;
			}
			//alert('row ' + (i+1) + ' is selected, selKeyFields=' + selKeyFields)
		} else {
			if (this.rows[i].initiallySelected) {
				if (deselRows == DotJ_EMPTY_STRING) {
					deselRows = '' + (i+1);
					deselKeyFields = this.rows[i].keyField;
				} else {
					deselRows = deselRows + DotJ_ITEM_DELIMITER + (i+1);
					deselKeyFields = deselKeyFields + DotJ_ITEM_DELIMITER + this.rows[i].keyField;
				}
			}
		}
	}

	return  'p1=' + selRows + DotJ_PAIR_DELIMITER + 'p2=' + selKeyFields + DotJ_PAIR_DELIMITER +
			'p3=' + deselRows + DotJ_PAIR_DELIMITER + 'p4=' + deselKeyFields;
};

DotJ_RowsArray.selectAllRows = function () {
	var lastId = null;

    var objRow, parts, row, keyField;
	for (var i = 0; i < this.rows.length; i++) {
		lastId = this.rows[i].rowId;
		if (!this.rows[i].selected && this.rows[i].selectable) {
			parts = lastId.split("_");
			row = parts[3];
			keyField = parts[5];
            objRow = DotJ_getObj(lastId);
			if (objRow != null) {
				this.grid.currentRowObj = objRow;
				this.grid.currentRow = row;
				if (!this.grid.postonselect && !this.grid.inEditMode && i == (this.rows.length-1)) {
					this.grid.hiliteRow();
				}
				this.grid.selectRow(true);
				this.grid.setKeyField(row, keyField);
				if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') {
					var temp = 'DotJ_' + this.grid.name + '_CHK_' + (i+1) + '_chk';
					var chk = eval("this.grid.form.elements['" + temp + "']");
					if (chk != null) chk.checked = true;
				}
			}
		}
	}
    this.grid.setClientState('select');
    var csField = this.grid.getCSField();

	if (this.grid.postonselect || this.grid.inEditMode) {
		this.grid.submitFunc(this.grid.name, 'selectall', '', '');
	}

	return lastId;
};

DotJ_RowsArray.deselectAllRows = function () {
	var lastId = null;

	for (var i = 0; i < this.rows.length; i++) {
		if (i == 0) lastId = this.rows[i].rowId;
		if (this.rows[i].selected || (this.grid.postonselect || this.grid.inEditMode)) {
			var parts = this.rows[i].rowId.split("_");
			var row = parts[3];
			var keyField = parts[5];
			var objRow = DotJ_getObj(this.rows[i].rowId);
			if (objRow != null) {
				if (!this.grid.postonselect && !this.grid.inEditMode) {
					this.grid.showRowArrow(objRow.id, false);
					this.rows[i].selectedStateMgr.restoreAllSettings();
				}
				if (this.grid.postonselect || this.grid.inEditMode) selected = true;
				else if (this.rows[i].selected) this.rows[i].selected = false;
				if (DotJ_GRID_ROW_SELECTION_METAPHOR == 'checkbox') {
                    var temp = 'DotJ_' + this.grid.name + '_CHK_' + (i+1) + '_chk';
                    var chk = eval("this.grid.form.elements['" + temp + "']");
					if (chk != null) chk.checked = false;
				}
			}
		}
	}

    this.grid.setClientState('deselect');

	if (this.grid.postonselect || this.grid.inEditMode) {
		this.grid.submitFunc(this.grid.name, 'deselectall', '', '');
	}

	return lastId;
};

DotJ_RowsArray.select = function (firstPass) {
	var objRow = this.grid.currentRowObj;
	var row = this.grid.currentRow;
	if (typeof(this.rows[row-1]) == 'undefined') return;

	var wasSelected = this.rows[row-1].selected;
	this.rows[row-1].rowId = objRow.id;

	this.deselect();

	if (!wasSelected) {
		this.rows[row-1].objRow = objRow;
		if (firstPass) this.rows[row-1].initiallySelected = true;
		if (DotJ_isRowToBeSelected(this.grid.lastKey, this.grid.multiselect)) {
			this.rows[row-1].selected = true;

			if (objRow.id != "") {
				if (!this.grid.postonselect && !this.grid.inEditMode) {
					this.grid.showRowArrow(objRow.id, true);
					this.grid.changeRowStyle(objRow, this.grid.style('SelectedRow'), true, false, row);
				}
			}
		}
	}

//    alert('sel: ' + this.rows[row-1].selected)
};

DotJ_RowsArray.findRow = function (rowId) {
	for (var i = 0; i < this.rows.length; i++) {
		if (this.rows[i].rowId == rowId) {
			return i;
		}
	}
	return -1;
};

DotJ_RowsArray.selectCurrentRow = function (objRow, lastKey) {
	if (typeof(this.grid.currentRowObj) == 'undefined') return;
	this.grid.selectGridRowCommon(this.grid.currentRowObj, false);
};

DotJ_RowsArray.selectPreviousRow = function (objRow, lastKey) {
	if (typeof(this.grid.currentRowObj) == 'undefined') return;
	var i = this.findRow(this.grid.currentRowObj.id);
	if (i != -1) {
		var done = false;
		while (!done) {
			i--;
			if (i < 0) {
				done = true;
			} else if (i >= 0) {
				var row = this.rows[i];
				if (row.selectable) {
					if (row.objRow == null)
						row.objRow = DotJ_getObj(row.rowId);
					if (row.objRow != null) {
						this.grid.selectGridRowCommon(row.objRow, false);
						done = true;
					}
				}
			}
		}
	}
};

DotJ_RowsArray.selectNextRow = function (objRow, lastKey) {
	if (typeof(this.grid.currentRowObj) == 'undefined') return;
	var i = this.findRow(this.grid.currentRowObj.id);
	if (i != -1) {
		var done = false;
		while (!done) {
			i++;
			if (i >= this.rows.length) {
				done = true;
			} else if (i < this.rows.length) {
				var row = this.rows[i];
				if (row.selectable) {
					if (row.objRow == null)
						row.objRow = DotJ_getObj(row.rowId);
					if (row.objRow != null) {
						this.grid.selectGridRowCommon(row.objRow, false);
						done = true;
					}
				}
			}
		}
	}
};

DotJ_RowsArray.setKeyField = function(row, keyField) {
	if (typeof(this.rows[row-1]) == 'undefined') return;
	this.rows[row-1].keyField = keyField;
};

function DotJ_RowsArray(grid, rowCount) {
	this.grid = grid;
	this.rows = new Array(rowCount);
	for (var i = 0; i < this.rows.length; i++) {
		this.rows[i] = new DotJ_Row(false, '', (i+1), '');
	}

	this.hasASelectedRow = DotJ_RowsArray.hasASelectedRow;
	this.selectedCount = DotJ_RowsArray.selectedCount;
	this.deselect = DotJ_RowsArray.deselect;
	this.getSelectedParms = DotJ_RowsArray.getSelectedParms;
	this.select = DotJ_RowsArray.select;
	this.selectAllRows = DotJ_RowsArray.selectAllRows;
	this.deselectAllRows = DotJ_RowsArray.deselectAllRows;
	this.findRow = DotJ_RowsArray.findRow;
	this.selectCurrentRow = DotJ_RowsArray.selectCurrentRow;
	this.selectPreviousRow = DotJ_RowsArray.selectPreviousRow;
	this.selectNextRow = DotJ_RowsArray.selectNextRow;
	this.setKeyField = DotJ_RowsArray.setKeyField;
	this.setRowId = DotJ_RowsArray.setRowId;
}

//******************************    ROW   *******************************

function DotJ_Row(selected, rowId, row, keyField) {
	this.selected = selected;
	this.rowId = rowId;
	this.row = row;
	this.keyField = keyField;
	this.objRow = null;
	this.initiallySelected = false;
	this.selectedStateMgr = new DotJ_StateMgr();
	this.hottrackStateMgr = new DotJ_StateMgr();
    this.div = null;
    this.selectable = false;
}

//****************************** SETTING  *******************************

function DotJ_Setting(id, property, value, obj) {
	this.id = id;
	this.property = property;
	this.value = value;
	this.obj = obj;
}

//**************************** GRID GLOBALS  ****************************

function DotJ_gridKeyDown(objRow, doPost) {
	if (doPost) return true;
	if (!DotJ_is_ie4up) return true;
	var parts = objRow.id.split("_");
	var objGrid = DotJ_gridArray.get(parts[1]);
	if (objGrid.inEditMode) return true;

	if (event && event.keyCode == DotJ_KEY_SPACE) {
		objGrid.lastKey = DotJ_KEY_SPACE;
		objGrid.selectCurrentRow(objRow, objGrid.lastKey);
		objGrid.lastKey = 0;
	} else if (event && event.keyCode == DotJ_KEY_UP) {
		objGrid.lastKey = DotJ_KEY_UP;
		objGrid.selectPreviousRow(objRow, objGrid.lastKey);
		objGrid.lastKey = 0;
		return false;
	} else if (event && event.keyCode == DotJ_KEY_DOWN) {
		objGrid.lastKey = DotJ_KEY_DOWN;
		objGrid.selectNextRow(objRow, objGrid.lastKey);
		objGrid.lastKey = 0;
		return false;
	}
	return true;
}

function DotJ_toggleSelectAllGridRows(chkBox, grid) {
	var objGrid = DotJ_gridArray.get(grid);
	if (objGrid != null) {
		if (chkBox && chkBox.checked) {
			objGrid.selectAllRows();
		} else {
			objGrid.deselectAllRows();
		}
	}
}

function DotJ_selectAllGridRows(grid) {
	var objGrid = DotJ_gridArray.get(grid);
	if (objGrid != null) {
		objGrid.selectAllRows();
	}
}

function DotJ_deselectAllGridRows(grid) {
	var objGrid = DotJ_gridArray.get(grid);
	if (objGrid != null) {
		objGrid.deselectAllRows();
	}
}

function DotJ_selectGridRow(objRow) {
	var parts = objRow.id.split("_");
	var objGrid = DotJ_gridArray.get(parts[1]);
	var rowIndex = objGrid.rows.findRow(objRow.id);
	var selected = objGrid.rows.rows[rowIndex].selected;
	objGrid.lastKey = DotJ_MOUSE_CLICK;
	objGrid.selectGridRowCommon(objRow, objGrid.postonselect);
	objGrid.lastKey = 0;
	var chk = DotJ_findFormField('DotJ_' + objGrid.name + '_CHK_' + parts[3] + '_chk');
	if (chk != null) chk.checked = !selected;
}

function DotJ_selectGridRow2(grid, absoluteRows, keyFields) {
	var objGrid = DotJ_gridArray.get(grid);
	var arrRows = absoluteRows.split(DotJ_ITEM_DELIMITER);
	var arrKeyFields = keyFields.split(DotJ_ITEM_DELIMITER);
	objGrid.lastKey = DotJ_MOUSE_CLICK;
	var lastId = null;

	for (var i = 0; i < arrRows.length; i++) {
		var row = (objGrid.pageSize == 0) ? arrRows[i]: (arrRows[i] - (objGrid.pageSize * (objGrid.page-1)));
		lastId = 'DotJ_' + objGrid.name + '_ROW_' + row + '_' + arrRows[i] + '_' + arrKeyFields[i];
		//alert('pagesize=' + objGrid.pageSize + ', row=' + row + ', lastid=' + lastId)
		var objRow = DotJ_getObj(lastId);
		if (objRow != null) {
			objGrid.currentRowObj = objRow;
			objGrid.currentRow = row;
			objGrid.hiliteRow();
			objGrid.selectRow(true);
			objGrid.setKeyField(row, arrKeyFields[i]);
			objGrid.setClientState('select');
		}
	}
	objGrid.lastKey = 0;
	if (lastId != null) {
		var objField = DotJ_findFormField(lastId + '_focus');
		if (objField != null) {
			var isHidden = DotJ_isHidden(objField);
			if (!isHidden) {
				DotJ_toggleDisplay(objField);
				objField.focus();
				DotJ_toggleDisplay(objField);
			}
		}
	}
}

function DotJ_hottrack(objRow, hilite) {
	var parts = objRow.id.split("_");
	var row = parts[3];
	var objGrid = DotJ_gridArray.get(parts[1]);
	if (objGrid.showSelectorColumn && !objGrid.inEditMode) {
		var objField = DotJ_findFormField(objRow.id + '_focus');
		if (objField != null) {
			DotJ_toggleDisplay(objField);
			objField.focus();
			DotJ_toggleDisplay(objField);
		}
	}

	if (hilite) {
		objGrid.changeRowStyle(objRow, objGrid.style('RowHilite'), true, true, row);
	} else {
		var rowIndex = objGrid.rows.findRow(objRow.id);
		objGrid.rows.rows[rowIndex].hottrackStateMgr.restoreAllSettings();
	}
}

function DotJ_gridDoAction(grid, action, confirmText, dhtml, minRowsSelected, maxRowsSelected) {
	var objGrid = DotJ_gridArray.get(grid);
	var csField = objGrid.getCSField();
	var selectedValue = '';
	if (dhtml) {
		if (csField.value != '') {
			var arr = csField.value.split(DotJ_PAIR_DELIMITER);
			if (arr.length >= 4) {
				var p1 = arr[2].split('=');
				var p2 = arr[3].split('=');
				if (p1[1] != DotJ_EMPTY_STRING) {
					selectedValue = p1[1] + DotJ_PAIR_DELIMITER + p2[1];
				}
			}
		}
	} else {
		if (objGrid.selectedRowId != '-1') {
			selectedValue = objGrid.selectedRowId + DotJ_PAIR_DELIMITER + objGrid.selectedKeyField;
			if (selectedValue == DotJ_PAIR_DELIMITER) selectedValue = '';
		}
	}

//    alert('minRowsSelected=' + minRowsSelected + ',selectedCount=' + objGrid.selectedCount() + ',dhtml=' + dhtml +
//	      ',action=' + action + ',selectedValue=' + selectedValue +
//            '\n\nRESULT=' +
//            (objGrid.selectedCount() < minRowsSelected))

	if (maxRowsSelected == null || typeof(maxRowsSelected) == 'undefined') maxRowsSelected = -1;

	if (objGrid.selectedCount() < minRowsSelected) {
		var temp = objGrid.MSG_NO_ROW_SELECTED.replace("{minrowsselected}", minRowsSelected);
		alert(temp);
		return false;
	} else if (maxRowsSelected != -1 && objGrid.selectedCount() > maxRowsSelected) {
		var temp = objGrid.MSG_MAXROWS_SELECTED.replace("{maxrowsselected}", maxRowsSelected);
		alert(temp);
		return false;
	} else {
		var arr = selectedValue.split(DotJ_PAIR_DELIMITER);
		var param1 = arr[0];
		var param2 = arr[1];
		if (typeof(param2) == 'undefined') param2 = DotJ_EMPTY_STRING;
		if (param1 != DotJ_EMPTY_STRING) {
			var doSubmit = true;
			if (action == 'delete' && param1 == "") doSubmit = false;
			if (doSubmit && confirmText.length > 0) {
				doSubmit = confirm(confirmText);
			}

			if (doSubmit) {
				objGrid.submitFunc(grid,action,param1,param2);
				return true;
			}
			return false;
		}
	}
	return false;
}

function DotJ_gridChangePage(grid, selectField) {
	var objGrid = DotJ_gridArray.get(grid);
	var pageNum=1;
	for (var i = 0; i < selectField.options.length; i++) {
		if (selectField[i].selected) {
			pageNum = selectField[i].value;
		}
	}
	objGrid.submitFunc(grid, 'page', pageNum, '');
}

//***********************************************************************

function DotJ_borderBottomRight(changes, el, color, width, style) {
	DotJ_borderBottom(changes, el, color, width, style);
	DotJ_borderRight(changes, el, color, width, style);
}

function DotJ_borderTopBottomRight(changes, el, color, width, style) {
	DotJ_borderTop(changes, el, color, width, style);
	DotJ_borderBottom(changes, el, color, width, style);
	DotJ_borderRight(changes, el, color, width, style);
}

function DotJ_borderTopBottomLeft(changes, el, color, width, style) {
	DotJ_borderTop(changes, el, color, width, style);
	DotJ_borderBottom(changes, el, color, width, style);
	DotJ_borderLeft(changes, el, color, width, style);
}

function DotJ_borderTopLeft(changes, el, color, width, style) {
	DotJ_borderTop(changes, el, color, width, style);
	DotJ_borderLeft(changes, el, color, width, style);
}

function DotJ_borderTopBottom(changes, el, color, width, style) {
	DotJ_borderTop(changes, el, color, width, style);
	DotJ_borderBottom(changes, el, color, width, style);
}

function DotJ_borderAll(changes, el, color, width, style) {
	DotJ_borderTop(changes, el, color, width, style);
	DotJ_borderBottom(changes, el, color, width, style);
	DotJ_borderLeft(changes, el, color, width, style);
	DotJ_borderRight(changes, el, color, width, style);
}

function DotJ_borderTop(changes, el, color, width, style) {
	if (changes != null) {
		var change;
		change = new DotJ_Setting(el.id, 'style.borderTopWidth', el.style.borderTopWidth);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderTopStyle', el.style.borderTopStyle);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderTopColor', el.style.borderTopColor);
		changes[changes.length] = change;
	}

	el.style.borderTopWidth = width;
	el.style.borderTopStyle = style;
	el.style.borderTopColor = color;
}

function DotJ_borderBottom(changes, el, color, width, style) {
	if (changes != null) {
		var change;
		change = new DotJ_Setting(el.id, 'style.borderBottomWidth', el.style.borderBottomWidth);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderBottomStyle', el.style.borderBottomStyle);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderBottomColor', el.style.borderBottomColor);
		changes[changes.length] = change;
	}

	el.style.borderBottomWidth = width;
	el.style.borderBottomStyle = style;
	el.style.borderBottomColor = color;
}

function DotJ_borderRight(changes, el, color, width, style) {
	if (changes != null) {
		var change;
		change = new DotJ_Setting(el.id, 'style.borderRightWidth', el.style.borderRightWidth);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderRightStyle', el.style.borderRightStyle);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderRightColor', el.style.borderRightColor);
		changes[changes.length] = change;
	}

	el.style.borderRightWidth = width;
	el.style.borderRightStyle = style;
	el.style.borderRightColor = color;
}

function DotJ_borderLeft(changes, el, color, width, style) {
	if (changes != null) {
		var change;
		change = new DotJ_Setting(el.id, 'style.borderLeftWidth', el.style.borderLeftWidth);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderLeftStyle', el.style.borderLeftStyle);
		changes[changes.length] = change;
		change = new DotJ_Setting(el.id, 'style.borderLeftColor', el.style.borderLeftColor);
		changes[changes.length] = change;
	}

	el.style.borderLeftWidth = width;
	el.style.borderLeftStyle = style;
	el.style.borderLeftColor = color;
}

//***********************************************************************

function DotJ_getScrollbarWidth() {
    var result = 16;
    var el = DotJ_getObj('DotJ_scrollbarHack');
    if (el != null) {
        el.parentNode.removeChild(el);
    }

    el = document.createElement('div');
    el.id = 'DotJ_scrollbarHack';
    el.style.overflow = 'auto';
    el.style.width = '40px';
    el.style.height = '40px';
    document.body.appendChild(el);

    var width1 = parseInt(el.clientWidth, 10);
    el.style.overflow = 'scroll';
    DotJ_setText('DotJ_scrollbarHack', 'abcde fghij klmno pqrst uvwxyz abcde fghij klmno pqrst uvwxyz');
    var width2 = parseInt(el.clientWidth, 10);
    result = width1 - width2;
    document.body.removeChild(el);
    return result;
}

function DotJ_setCursorToPointer(el) {
    if (el == null) return;
	if (DotJ_is_ie4up) YAHOO.util.Dom.setStyle(el, 'cursor', 'hand');
	else YAHOO.util.Dom.setStyle(el, 'cursor', 'pointer');
}

function DotJ_setCursorToDefault(el) {
	if (el != null) YAHOO.util.Dom.setStyle(el, 'cursor', 'default');
}

function DotJ_setCursorToMove(el) {
	if (el != null) YAHOO.util.Dom.setStyle(el, 'cursor', 'move');
}

function DotJ_setOpacity(el, opacity) {
    if (opacity == -1) opacity = 100;
    opacity = opacity / 100;
    YAHOO.util.Dom.setStyle(el, 'opacity', opacity);
}

//***********************************************************************

function DotJ_taMaxlength(field, maxlength) {
	if (field.value.length > maxlength)
		field.value = field.value.substring(0, maxlength);
}

function DotJ_FindParentForm(elName) {
	var theForm = null;
	var obj = DotJ_getObj(elName);
	while (obj != null && obj.nodeName != null && obj.nodeName.toLowerCase() != 'form')
		obj = obj.parentNode;
	if (obj != null && obj.nodeName != null && obj.nodeName.toLowerCase() == 'form')
		theForm = obj;
	return theForm;
}

function DotJ_findFormFieldOnForm(fieldName, form) {
	if (form == null) return null;

	var objField = null, iElement = 0;

	for (iElement = 0; iElement < form.elements.length; iElement++) {
		var tempId = form.elements[iElement].name;
		if (typeof(tempId) == 'undefined' || tempId == '') tempId = form.elements[iElement].id;
		if (typeof(tempId) == 'undefined' || tempId == '') {
			;
		} else {
			if (tempId.toLowerCase() == fieldName.toLowerCase()) {
				objField = form.elements[iElement];
				break;
			}
		}
	}

	return objField;
}

function DotJ_findFormField(fieldName) {
	var objField = null, form, iForm = 0, iElement = 0;
	var forms = document.forms;
	if (typeof(fieldName) == 'undefined' || fieldName == null || fieldName == '') return null;

	for (iForm = 0; iForm < forms.length; iForm++) {
		form = forms[iForm];

		for (iElement = 0; iElement < form.elements.length; iElement++) {
			var tempId = form.elements[iElement].name;
			if (typeof(tempId) == 'undefined' || tempId == '') tempId = form.elements[iElement].id;
			if (typeof(tempId) == 'undefined' || tempId == '') {
				;
			} else {
				if (tempId.toLowerCase() == fieldName.toLowerCase()) {
					objField = form.elements[iElement];
					break;
				}
			}
		}
	}

	if (objField == null) objField = DotJ_getObj(fieldName);

	return objField;
}

function DotJ_getObj(elName) {
	return YAHOO.util.Dom.get(elName);
}

function DotJ_DHTMLSupport() {
	return DotJ_is_ie4up || DotJ_MozillaFamily();

}

function DotJ_MozillaFamily() {
	return DotJ_is_nav6up || DotJ_is_moz || DotJ_is_fx || DotJ_is_safari;

}

function DotJ_Onfocus(field,msg,tipalignment,tipStyle,dhtml) {
	if (typeof(field) == 'undefined') return;
	if (dhtml) DotJ_ChangeBackground(field,DotJ_INPUT_BGCOLOR_ON);
	if (DotJ_DHTMLSupport()) {
		if (msg == null || msg == '')
			;
		else
			DotJ_ShowTip(field,msg,tipalignment,tipStyle,true);
	}
}
function DotJ_Onblur(field,dhtml) {
	if (typeof(field) == 'undefined') return;
	if (dhtml) DotJ_ChangeBackground(field,DotJ_INPUT_BGCOLOR_OFF);
	if (DotJ_DHTMLSupport()) {
		DotJ_hideElement(DotJ_tipDiv);
		if (DotJ_tipDiv_shield != null) DotJ_tipDiv_shield.hide();
	}
}
function DotJ_ChangeBackground(field,color) {
	if (typeof(field) == 'undefined') return;
	if (DotJ_DHTMLSupport()) {
		if (field.type.toLowerCase() != 'radio' && field.type.toLowerCase() != 'checkbox')
			if (DotJ_is_nav4) field.bgColor=color;
			else field.style.background=color;
	}
}
function DotJ_GetBackground(el) {
	if (typeof(el) == 'undefined') return;
	if (DotJ_DHTMLSupport()) {
		if (el.type.toLowerCase() != 'radio' && el.type.toLowerCase() != 'checkbox')
			if (DotJ_is_nav4) return el.bgColor;
			else return el.style.background;
	}
}

function DotJ_bindEvent(control, eventName, func) {
	if (eventName.charAt(0) == 'o' && eventName.charAt(1) == 'n') eventName = eventName.substring(2);
	YAHOO.util.Event.addListener(control,eventName,func,null,false);
}

function DotJ_unbindEvent(control, eventName, func) {
	if (eventName.charAt(0) == 'o' && eventName.charAt(1) == 'n') eventName = eventName.substring(2);
	YAHOO.util.Event.removeListener(control,eventName,func);
}

function DotJ_stackJavaScriptEvent(control,eventName,func) {
	if (control == null || typeof(control) == 'undefined') return;
	var evt = eval("control." + eventName);
	var sEvt = "";
	if (typeof(evt) == 'function' ) {
		sEvt = evt.toString();
		sEvt = sEvt.substring(sEvt.indexOf("{") + 1, sEvt.lastIndexOf("}"));
		sEvt = DotJ_Trim(sEvt);
	}
	var f;
	f = new Function(func + "; " + sEvt);
	var tagName = control.tagName;
	if (typeof(tagName) == 'undefined') tagName = control[0].tagName;
    if (DotJ_MozillaFamily() && tagName.toLowerCase() == 'body')
		eval("control." + eventName + " = f()");
	else
		eval("control." + eventName + " = f");
}

function DotJ_findAnchorItem(item) {
	var obj = DotJ_getObj(item);

	if (obj == null) {
		obj = DotJ_findFormField(item);
	}

	return obj;
}

function DotJ_setText(id, text) {
	DotJ_writeLayer(DotJ_getObj(id), text);
}

function DotJ_isHidden(el) {
	if (DotJ_getDisplay(el) == "none") return true;
	if (DotJ_getVisibility(el) == "hide" || DotJ_getVisibility(el) == "hidden") return true;
	var parent = el.parentNode;
	while (null != parent) {
		if (DotJ_getDisplay(parent) == "none") return true;
		if (DotJ_getVisibility(parent) == "hide" || DotJ_getVisibility(parent) == "hidden") return true;
		parent = parent.parentNode;
	}

	return false;
}

function DotJ_displayElement(element) {
    if (element == null) return;
	YAHOO.util.Dom.setStyle(element, 'visibility', 'visible');
}

function DotJ_getVisibility(element) {
    if (DotJ_is_nav4) return element.visibility;
    else if (DotJ_is_ie4up && typeof(element.style) != 'undefined') return element.style.visibility;
    else if (DotJ_MozillaFamily() && typeof(element.style) != 'undefined') return element.style.visibility;
    return '';
}

function DotJ_getDisplay(element) {
	if (element == null || ((DotJ_is_nav4 && element.display == null) || ((DotJ_is_ie4up || DotJ_MozillaFamily()) && element.style == null))) return '';
	if (DotJ_is_nav4) return element.display;
	else if (DotJ_is_ie4up) return element.style.display;
	else if (DotJ_MozillaFamily()) return element.style.display;
}

function DotJ_hideElement(obj) {
    if (obj == null) return;
    var element;
    if (DotJ_isArray(obj) == false) {
        element = obj;
        YAHOO.util.Dom.setStyle(element, 'visibility', 'hidden');
    } else {
    	for (var i = 0; i < obj.length; i++) {
    	    element = obj[i];
    	    if (element != null) YAHOO.util.Dom.setStyle(element, 'visibility', 'hidden');
	    }
    }
}

function DotJ_toggleDisplay(element) {
	var collapsed = true;
	if (DotJ_DHTMLSupport()) {
		if (element.style.display == "") {
			element.style.display = "none";
			collapsed = true;
		} else {
			element.style.display= "";
			collapsed = false;
		}
	}
	return collapsed;
}

function DotJ_getWidth(el) {
	return el.offsetWidth;
}

function DotJ_getHeight(el) {
	return el.offsetHeight;
}

function DotJ_ShowTip(field,msg,tipalignment,tipStyle,isTip){
	if (null == field || null == msg)
		return;
	if (null == DotJ_tipDiv)
		return;
	var cssStyle = 'tooltip';
	if (null != tipStyle && tipStyle.length > 0)
		cssStyle = tipStyle;
	if (isTip) {
		DotJ_tipDiv.className = cssStyle;
	} else {
		DotJ_tipDiv.backgroundColor = "red";
		DotJ_tipDiv.color = "white";
	}
	DotJ_writeLayer(DotJ_tipDiv,unescape(msg));
	DotJ_placeElement(DotJ_tipDiv,field,tipalignment);
	DotJ_displayElement(DotJ_tipDiv);
	if (DotJ_tipDiv_shield != null) DotJ_tipDiv_shield.refresh();
}
function DotJ_writeLayer(lay, html) {
	if (DotJ_is_nav4) {
		var l = lay.document;
		l.write(html);
		l.close();
	} else if (DotJ_is_ie4up) {
		lay.innerHTML = html;
	} else if (DotJ_MozillaFamily()) {
		var r = document.createRange();
		r.setStartBefore(lay);
		var f = r.createContextualFragment(html);
		while (lay.hasChildNodes()) {
			lay.removeChild(lay.lastChild);
		}
		lay.appendChild(f);
	}
}
function DotJ_placeElement(el,inField,alignment) {
	var field = inField;
	if (typeof(field.id) == 'undefined') field = inField[0];
	var tempAlignment='bottom';
	if (null != alignment && alignment.toLowerCase() == 'right')
		tempAlignment = 'right';
	else if (null != alignment && alignment.toLowerCase() == 'top')
		tempAlignment = 'top';
	else if (null != alignment && alignment.toLowerCase() == 'left')
		tempAlignment = 'left';

	var c;

	if (field.type.toLowerCase() == 'radio') {
		c = DotJ_getAnchorPosition(field, field.id + "_tippos");
	} else {
		c = DotJ_getAnchorPosition(field, field.name + "_tippos");
	}

	var x = c.x;
	var y = c.y;

	if (DotJ_MozillaFamily()) {
		if (field.tagName.toLowerCase() == 'input' && (field.type == 'text' || field.type == 'password')) {
			y = y + DotJ_getHeight(field) - 2;
		} else if (field.tagName.toLowerCase() == 'input' && field.type == 'checkbox') {
			y = y + 8;
			x = x + 3;
		} else if (field.tagName.toLowerCase() == 'input' && field.type == 'radio') {
			x = x + 3;
		} else if (field.tagName.toLowerCase() == 'select') {
			y = y + 4;
		}
        if (DotJ_is_safari && (field.tagName.toLowerCase() == 'textarea' || field.tagName.toLowerCase() == 'select' || field.type == 'radio')) {
            y = y + DotJ_getHeight(field);
            if (field.type == 'radio') y = y + 5;
        }
    }

	if (DotJ_is_nav4) {
		DotJ_moveTo(el, x, y);
	} else {
		if (tempAlignment == 'top') {
			DotJ_moveTo(el, x, y-field.offsetHeight-el.offsetHeight);
		} else if (tempAlignment == 'right') {
			DotJ_moveTo(el, x+field.offsetWidth+2, y-field.offsetHeight);
		} else if (tempAlignment == 'left') {
			DotJ_moveTo(el, x-el.offsetWidth, y-field.offsetHeight);
		} else {
			DotJ_moveTo(el, x, y+2);
		}
	}
}

function DotJ_getStyle(el,styleProp) {
	var normalize = function(IEProperty) {
		var pos = -1;
		while ((pos = IEProperty.indexOf('-')) != -1) {
			IEProperty = IEProperty.substring(0, pos) + IEProperty.substring(pos+1, pos+2).toUpperCase() + IEProperty.substring(pos+2);
		}

		return IEProperty;
	};

	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[normalize(styleProp)];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function DotJ_getAnchorPosition(anchor, anchorName) {
	var x = 0, y = 0;
	if (DotJ_DHTMLSupport()) {
		var obj = DotJ_getObj(anchorName);
		x = DotJ_getX(obj);
		y = DotJ_getY(obj);
	} else if (DotJ_is_nav4) {
		for (var i=0; i < document.anchorNames.length; i++) {
			if (document.anchorNames[i].name == anchorName) {
				x = document.anchorNames[i].x;
				y = document.anchorNames[i].y;
				break;
			}
		}
	}

	// Normalize a bit
	//if (DotJ_MozillaFamily()) y = y + 3;
	if (DotJ_is_ie4up) y = y + anchor.offsetHeight;
	if (DotJ_is_nav4) y = y + 23;

	var pos = new Object();
	pos.x = x;
	pos.y = y;
    return pos;
}
function DotJ_getX(element) {
	return YAHOO.util.Dom.getX(element);
}

function DotJ_getY(element) {
	return YAHOO.util.Dom.getY(element);
}
function DotJ_getPos(el,which) {
	iPos = 0;
	while (el != null) {
		iPos += el["offset" + which];
		el = el.offsetParent;
	}
	return iPos;
}
function DotJ_getSmartX(x, anchorWidth, objWidth, margin) {
	var winoffset = (DotJ_is_ie4up) ? document.body.scrollLeft : self.pageXOffset;
	var clientWidth = (DotJ_is_ie4up) ? document.body.clientWidth : self.innerWidth;

	if ( (x + objWidth) > (winoffset + clientWidth) ) {
		return x - margin - objWidth;    // left
	} else {
		return x + anchorWidth + margin; // right
	}
}

function DotJ_getClientHeight() {
	if (self.innerHeight) {
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} else if (document.body) {
		return document.body.clientHeight;
	}
}

function DotJ_getSmartY(y, anchorHeight, objHeight, margin) {
	var scrolloffset = (DotJ_is_ie4up) ? document.body.scrollTop : self.pageYOffset;
	var clientHeight = DotJ_getClientHeight();

	var bottomDiff = (scrolloffset + clientHeight) - (y + anchorHeight + margin + objHeight);

	// Room on the bottom?
	if (bottomDiff > 0) {
		return y + anchorHeight + margin; // below
	}

	var topDiff = (y - margin - objHeight) - (scrolloffset);

	if (topDiff > 0) {
		return y - margin - objHeight;    // above
	}

	return y + anchorHeight + margin; // below
}

function DotJ_moveTo(element,x,y) {
	var pos = [x, y];
	YAHOO.util.Dom.setXY(element, pos);
}

function DotJ_moveToY(element,y) {
    YAHOO.util.Dom.setY(element, y);
//	if (DotJ_is_nav4) {
//		element.top = y;
//	} else if (DotJ_is_ie4up) {
//		element.style.top = y;
//	} else if (DotJ_MozillaFamily()) {
//		element.style.top = y + "px";
//	}
}

function DotJ_setDate(theForm,yyField,mmField,ddField,targetField,fmt) {
	var dayField = eval("theForm.elements['" + ddField + "']");
	var yy = eval("theForm.elements['" + yyField + "'].value");
	var daysInFeb = DotJ_daysInFebruary(yy);
	var mm = eval("theForm.elements['" + mmField + "'].value");
	var dd = dayField.value;

	if (daysInFeb == 29) {
		if (mm == 2 && dd > 29)
			dayField.selectedIndex = 28;
		else if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && (dd > 30))
			dayField.selectedIndex = 29;
	} else {
		if (mm == 2 && dd > 28)
			dayField.selectedIndex = 27;
		else if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && (dd > 30))
			dayField.selectedIndex = 29;
	}

	dd = dayField.value;
	var date = DotJ_makeDate(yy, mm, dd, fmt);
	var targetField = eval("theForm.elements['" + targetField + "']");
	targetField.value = date;
}

function DotJ_AutoTab(theForm, keyChar, field, maxlen) {
	if (keyChar != 9 && keyChar != 16) {
		if (field.value.length + 1 <= maxlen) {
			field.focus();
		} else {
			var nextField;
			for (i=0; i < theForm.elements.length; i++) {
				if (field.name == theForm.elements[i].name) {
					if (i + 1 < theForm.elements.length) {
						nextField = i + 1;
						var fieldType = theForm.elements[nextField].type;
						if (fieldType == 'hidden')
							nextField = nextField + 1;
						theForm.elements[nextField].focus();
					}
				}
			}
		}
	}
}

function DotJ_makeSlots() {
	var arr = new Array(43);
	var i;
	for (i = 0; i < 43; i++)
		arr[i] = '';
	return arr;
}

function DotJ_safeJSString(s) {
	if (s == null || s == "null") return '';
	if (s.indexOf("'") == -1 && s.indexOf('"') != -1) return "'" + s + "'";
	if (s.indexOf("'") != -1 && s.indexOf('"') == -1) return '"' + s + '"';
	if (s.indexOf("'") != -1 && s.indexOf('"') != -1) return '"' + s.replace('"', '&quot;') + '"';

	return "'" + s + "'";
}

function DotJ_Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function DotJ_Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function DotJ_Trim(s) {
	while (''+s.charAt(0)==' ' || ''+s.charAt(0)=='\n')
		s = s.substring(1,s.length);
	while (''+s.charAt(s.length-1)==' ' || ''+s.charAt(s.length-1)=='\n')
		s=s.substring(0,s.length-1);
	return s;
}

function DotJ_getRadioButtonValue (radio) {
	for (var i = 0; i < radio.length; i++) {
		if (radio[i].checked) { break; }
	}
	if (i == radio.length)
		return "";
	else
		return radio[i].value;
}

function DotJ_isEmpty (s) {
	return ((s == null) || (s.length == 0));
}

function DotJ_isWhitespace (s) {
	var whitespace = " \t\n\r";
	var i;
	if (DotJ_isEmpty(s)) return true;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}

function DotJ_bindControl(control,func) {
	if (control == null || typeof(control) == 'undefined') return;
	var evt;
	if (control.tagName.toUpperCase() == 'FORM') evt = control.onsubmit;
	else if (control.type.toLowerCase() == 'radio') evt = control.onclick;
	else evt = control.onchange;
	var sEvt = "";
	if (typeof(evt) == 'function' ) {
		sEvt = evt.toString();
		sEvt = sEvt.substring(sEvt.indexOf("{") + 1, sEvt.lastIndexOf("}"));
	}
	var f, tmp;
	if (control.tagName.toUpperCase() == 'FORM') {
		tmp = DotJ_Trim(sEvt);
		if (tmp == '') tmp = 'true';
		else {
			tmp = tmp.replace(/^return /,'');
			tmp = tmp.replace('this','document.' + control.name);
		}
		if (tmp.toLowerCase().indexOf('javascript:',0) != -1) tmp = tmp.substring(11);
		f = new Function("var undefined;\nvar isValid = " + func + " \nvar urRc = " + tmp + "\nif (urRc == undefined)\n  return isValid;\nelse\n  return urRc && isValid;");
	} else {
		f = new Function(func + " " + sEvt);
	}
	if (control.tagName.toUpperCase() == 'FORM') control.onsubmit = f;
	else if (control.type.toLowerCase() == 'radio') control.onclick = f;
	else control.onchange = f;
}
function DotJ_ValidatorOnChange(validators, fieldName) {
	if (validators == null) return true;
	var i, msg, rc = true;
	for (i = 0; i < validators.length; i++) {
		if (validators[i].fieldName == fieldName) {
    		validators[i].valid = true;
    	}
	}

	for (i = 0; i < validators.length; i++) {
		if (validators[i].fieldName == fieldName) {
			msg = DotJ_ValidatorValidate(validators, validators[i], false);
			if (!validators[i].valid) {
				if (DotJ_useAlert() && msg != '') {
					alert(msg);
				}
				rc = false;
				break;
			}
		}
	}
	return rc;
}
function DotJ_useAlert() {
    return DotJ_ALERT_BEHAVIOUR == 'alert';
}

var DotJ_focusField = null;
function DotJ_timerFocus() {
	if (DotJ_focusField != null) {
		var isHidden = DotJ_isHidden(DotJ_focusField);
		if (!isHidden) {
			DotJ_focusField.focus();
			var tag = DotJ_focusField.tagName.toLowerCase();
			if (tag == 'input' || tag == 'textarea')
				DotJ_focusField.select();
		}
		DotJ_focusField = null;
	}
	setTimeout("DotJ_timerFocus()", 250);
}
setTimeout("DotJ_timerFocus()", 250);

function DotJ_ValidatorValidate(validators, val, onsubmit) {
	if (typeof(val.field) == 'undefined') return true;
	val.valid = eval(val.func + '(val)');
	return DotJ_ValidatorUpdateDisplay(validators, val, onsubmit);
}

function DotJ_positionFieldValidators(tabId) {
	if (DotJ_validators) {
		var i;
		for (i = 0; i < DotJ_validators.length; i++) {
			var validators = DotJ_validators[i];
			if (typeof(validators) == 'undefined') return;
			var j;
			for (j = 0; j < validators.length; j++) {
				if (validators[j].tabId == tabId) {
					if (!validators[j].placed) {
						var fieldElement = DotJ_getObj(validators[j].name);
						DotJ_placeElement(fieldElement,validators[j].field,validators[j].alignment);
						validators[j].placed = true;
					}
				}
			}
		}
	}
}

function DotJ_ValidatorUpdateDisplay(validators, val, onsubmit) {
	var resultMsg = '';
	var fieldElement = DotJ_getObj(val.name);
	var valid = true;
	var i, firstMsg;
	if (val.hmsg == '') firstMsg = val.msg;
	else firstMsg = new String(val.hmsg);
	for (i = 0; i < validators.length; i++) {
		if (validators[i].fieldName == val.fieldName) {
			if (valid && !validators[i].valid) {
				if (validators[i].hmsg == '') firstMsg = validators[i].msg;
				else firstMsg = new String(validators[i].hmsg);
				validators[i].hmsg = '';
			}
		    valid = valid && validators[i].valid;
		}
	}

	var type = val.field.type;
	if (typeof(type) == 'undefined') type = val.field[0].type;

	if (valid) {
		if (!DotJ_useAlert()) {
			DotJ_hideElement(fieldElement);
			if (val.shield != null) val.shield.hide();
			if (DotJ_FIELDVALIDATOR_ERROR_CHANGEFIELDCLASSNAME) {
				if (type.toLowerCase() == 'radio' || type.toLowerCase() == 'checkbox') {
					for (i = 0; i < val.field.length; i++) {
						var label = DotJ_getObj(val.field[i].id + '_label');
						if (label != null) {
							DotJ_stateMgr.restoreSettings(label.id);
						}
					}
				} else if (type.toLowerCase() == 'select-one' || type.toLowerCase() == 'select-multiple') {
					var tblSelect = DotJ_getObj('DotJ_tbl' + val.field.name);
					if (tblSelect != null) {
						DotJ_stateMgr.restoreSettings(tblSelect.id);
					}
				} else {
					DotJ_stateMgr.restoreSettings(val.field.name);
				}
				if (val.tabOnId != null) {
					var tabOnImg = DotJ_getObj(val.tabOnId);
					if (tabOnImg != null) {
						DotJ_stateMgr.restoreSettings(tabOnImg.name);
					}
				}
				if (val.tabOffId != null) {
					var tabOffImg = DotJ_getObj(val.tabOffId);
					if (tabOffImg != null) {
						DotJ_stateMgr.restoreSettings(tabOffImg.name);
					}
				}
			}
		}
	} else {
		if (DotJ_FIELDVALIDATOR_ERROR_CHANGEFIELDCLASSNAME && !DotJ_useAlert()) {
			if (type.toLowerCase() == 'radio' || type.toLowerCase() == 'checkbox') {
				for (i = 0; i < val.field.length; i++) {
					if (val.fieldName == val.field[i].id) {
						var label = DotJ_getObj(val.field[i].id + '_label');
						if (label != null) {
							DotJ_stateMgr.queueSetting(label.id, 'className', label.className, label);
							label.className = 'fieldError';
						}
					}
				}
			} else if (type.toLowerCase() == 'select-one' || type.toLowerCase() == 'select-multiple') {
				var tblSelect = DotJ_getObj('DotJ_tbl' + val.field.name);
				if (tblSelect != null) {
					DotJ_stateMgr.queueSetting(tblSelect.id, 'className', tblSelect.className, tblSelect);
					tblSelect.className = 'fieldError';
				}
			} else {
				DotJ_stateMgr.queueSetting(val.field.name, 'className', val.field.className, val.field);
				val.field.className = 'fieldError';
			}
			if (val.tabOnId != null) {
				var tabOnImg = DotJ_getObj(val.tabOnId);
				if (tabOnImg != null) {
					DotJ_stateMgr.queueSetting(tabOnImg.name, 'className', tabOnImg.className, tabOnImg);
					tabOnImg.className = 'fieldError';
				}
			}
			if (val.tabOffId != null) {
				var tabOffImg = DotJ_getObj(val.tabOffId);
				if (tabOffImg != null) {
					DotJ_stateMgr.queueSetting(tabOffImg.name, 'className', tabOffImg.className, tabOffImg);
					tabOffImg.className = 'fieldError';
				}
			}
		}
		if (type.toLowerCase() != 'radio' && type.toLowerCase() != 'checkbox') {
			DotJ_focusField = val.field;
		}
		if (!DotJ_useAlert())
			DotJ_writeLayer(fieldElement, firstMsg);
		resultMsg = firstMsg;

		if (!DotJ_useAlert()) {
			if (!val.placed) {
				DotJ_placeElement(fieldElement,val.field,val.alignment);
				if (!DotJ_isHidden(val.field)) {
					val.placed = true;
				}
			}
			DotJ_displayElement(fieldElement);
			if (val.shield != null) val.shield.refresh();
		}
	}
	return resultMsg;
}
function DotJ_GetFieldValue(val) {
	var result = '';
	var type = val.field.type;
	var undefined, count=0;
	if (type == undefined) type = val.field[0].type;
	if (type.toLowerCase() == "select-one" || type.toLowerCase() == "select-multiple") {
		for (var i = 0; i < val.field.options.length; i++) {
			if (val.field[i].selected) {
				count = count + 1;
				if (count == 1)
					result = val.field[i].value;
				else
					result = result + DotJ_ITEM_DELIMITER + val.field[i].value;
			}
		}
	} else if (type.toLowerCase() == "radio") {
		result = DotJ_getRadioButtonValue(val.field);
	} else {
		result = DotJ_Trim(val.field.value);
	}
	return result;
}
function DotJ_RequiredFieldValidator(val) {
	var value = DotJ_GetFieldValue(val);
	var type = val.field.type;
	var undefined;
	if (type == undefined) type = val.field[0].type;
	if (type.toLowerCase() == "select-one" || type.toLowerCase() == "select-multiple") {
		if (value == val.initValue || value == '') return false;
		else return true;
	} else if (type.toLowerCase() == "radio") {
		return !DotJ_isEmpty(value);

	} else {
		val.field.value = DotJ_Trim(value);
		if (DotJ_isEmpty(val.field.value) || DotJ_isWhitespace(val.field.value)) {
			return false;
		}
		if (val.field.value.length < val.minlength) {
			val.hmsg = DotJ_ERROR_MINLENGTH;
			val.hmsg = val.hmsg.replace('{minlength}',val.minlength);
			return false;
		}
	}
	return true;
}
function DotJ_AutoFieldValidator(val) {
	return DotJ_ValidateField(val.field, val.datatype, val.msg);
}

function DotJ_CustomFieldValidator(val) {
	var sValue = DotJ_GetFieldValue(val);
	var f = val.customFunc;
	var rc = DotJ_invoke(f, sValue); // Generated from tags
	if (rc == "true") {
		return true;
	} else if (rc == "false") {
		return false;
	} else {
		var msg = 'dotJ Javascript Error: client side function ' + f + ' does not exist.\n\nJavaScript Exception: ';
		msg = msg + rc;
		alert(msg);
		return false;
	}
}
function DotJ_RegularExpressionValidator(val) {
	var sValue = DotJ_GetFieldValue(val);
	if (sValue == '') return true;
	var re = new RegExp(val.regexp);
	var isMatch = re.exec(sValue);
	return (isMatch != null && sValue == isMatch[0]);
}

DotJ_Validator.onMove = function(type, args) {
	var validator = args[0].obj;
    if (validator != null) {
        //if (validator.shadow != null) validator.shadow.refresh();
        if (validator.shield != null) validator.shield.refresh();
    }
};

function DotJ_Validator(id, name, fieldName, field, datatype, msg, func, initValue, customFunc, minlength, regexp, alignment, tabId, tabOnId, tabOffId, movable) {
	this.id = id;
	this.name = name;
	this.fieldName = fieldName;
	this.field = field;
	this.datatype = datatype;
	this.msg = msg;
	this.hmsg = '';
	this.func = func;
	this.initValue = initValue;
	this.valid = true;
	this.customFunc = customFunc;
	this.minlength = minlength;
	this.regexp = regexp;
	this.alignment = alignment;
	this.tabId = tabId;
	this.tabOnId = tabOnId;
	this.tabOffId = tabOffId;
	this.movable = movable;
	this.placed = false;
	this.shield = null;
	this.proxy = null;

	if (DotJ_is_ie4up && !DotJ_is_ie7up) {
		this.shield = new DotJ_IEShield(this.id + '_IEShield', DotJ_getObj(id));
	}

    if (this.movable) {
        this.proxy = new DotJ_Proxy(this.name, this.name, this.movable, this, DotJ_Validator.onMove, null);
    }
}

function DotJ_ValidateField(f, datatype, msg) {
	if (datatype == "" || datatype == "select" || datatype == "radiogroup")
		return true;
	f.value = DotJ_Trim(f.value);
	if (DotJ_isEmpty(f.value) || DotJ_isWhitespace(f.value))
		return true;
	if (datatype == "alphanumeric") {
		return DotJ_isAlphanumeric(f.value);
	} else if (datatype == "alphabetic") {
		return DotJ_isAlphabetic(f.value);
	} else if (datatype == "zip") {
		return DotJ_isZIPCode(f.value);
	} else if (datatype == "state") {
		f.value = f.value.toUpperCase();
		return DotJ_isStateCode(f.value);
	} else if (datatype == "usphone") {
		return DotJ_isUSPhoneNumber(f.value);
	} else if (datatype == "email") {
		return DotJ_isEmail(f.value);
	} else if (datatype == "ssn") {
		return DotJ_isSSN(f.value);
	} else if (datatype == "year") {
		return DotJ_isYear(f.value);
	} else if (datatype == "integer") {
		return DotJ_isInteger(f.value);
	} else if (datatype == "signedinteger") {
		return DotJ_isSignedInteger(f.value);
	} else if (datatype == "positiveinteger") {
		return DotJ_isPositiveInteger(f.value);
	} else if (datatype == "nonnegativeinteger") {
		return DotJ_isNonnegativeInteger(f.value);
	} else if (datatype == "negativeinteger") {
		return DotJ_isNegativeInteger(f.value);
	} else if (datatype == "nonpositiveinteger") {
		return DotJ_isNonpositiveInteger(f.value);
	} else if (datatype == "double") {
		return DotJ_isDouble(f.value);
	} else if (datatype == "signeddouble") {
		return DotJ_isSignedDouble(f.value);
	} else if (datatype == "positivedouble") {
		return DotJ_isPositiveDouble(f.value);
	} else if (datatype == "nonnegativedouble") {
		return DotJ_isNonnegativeDouble(f.value);
	} else if (datatype == "negativedouble") {
		return DotJ_isNegativeDouble(f.value);
	} else if (datatype == "nonpositivedouble") {
		return DotJ_isNonpositiveDouble(f.value);
	} else if (datatype == "date1" || datatype == "date2" || datatype == "date3" || datatype == "date4" || datatype == "date5" ||
			   datatype == "date6" || datatype == "date7" || datatype == "date8" || datatype == "date9" || datatype == "date10" ||
			   datatype == "date11" || datatype == "date12" || datatype == "date13" || datatype == "date14") {
		return (DotJ_isDate(f.value, datatype, null) != null);
	} else if (datatype == "date15" || datatype == "date16" || datatype == "date17" || datatype == "date18") {
		return (DotJ_isDate(f.value, datatype, eval(f.name.replace('.', '_') + '_months')) != null);
	} else if (datatype == "textarea") {
		return true;
	}
}

function DotJ_isArray (obj) {
    return obj != null && obj.length != null;
}

function DotJ_isInteger (s) {
	var re = /^(\+|\-)?\d+$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isSignedInteger (s) {
	var re = /^(\+|\-){1}\d+$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isPositiveInteger (s) {
	return (DotJ_isInteger(s) && parseInt(s,10) > 0);
}

function DotJ_isNegativeInteger (s) {
	return (DotJ_isInteger(s) && parseInt (s,10) < 0);
}

function DotJ_isNonnegativeInteger (s) {
	return (DotJ_isInteger(s) && parseInt (s,10) >= 0);
}

function DotJ_isNonpositiveInteger (s) {
	return (DotJ_isInteger(s) && parseInt (s,10) <= 0);
}

function DotJ_isDouble (s) {
	var i;
	var seenDecimalPoint = false;
	if (s == ".") return false;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c == ".") && !seenDecimalPoint) seenDecimalPoint = true;
		else if (!DotJ_isDigit(c)) return false;
	}
	return true;
}

function DotJ_isSignedDouble (s) {
	if ((s.charAt(0) == "-") || (s.charAt(0) == "+"))
		return (DotJ_isDouble(s.substring(1, s.length)));
	else
		return false;
}

function DotJ_isPositiveDouble (s) {
	return (DotJ_isDouble(s) && parseFloat(s) > 0);
}

function DotJ_isNegativeDouble (s) {
	return (DotJ_isDouble(s) && parseFloat (s) < 0);
}

function DotJ_isNonnegativeDouble (s) {
	return (DotJ_isDouble(s) && parseFloat (s) >= 0);
}

function DotJ_isNonpositiveDouble (s) {
	return (DotJ_isDouble(s) && parseFloat (s) <= 0);
}

function DotJ_isDigit (c) {
	return ((c >= "0") && (c <= "9"));
}

function DotJ_isStateCode(s) {
	var re = /^AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MN|NC|ND|NE|NH|NJ|NM|NV|NY|OH|OK|OR|PA|PR|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isZIPCode (s) {
	var re = /(^\d{5}$)|(^\d{9}$)|(^\d{5}-\d{4}$)/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isUSPhoneNumber (s) {
	var re = /^(\([1-9][0-9]{2}\)\s?)?[1-9][0-9]{2}-[0-9]{4}$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isShortYear (s) {
	var re = /^\d{2}$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isYear (s) {
	var re = /^\d{4}$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isEmail (s) {
	var re = /^([a-zA-Z0-9']+)([\-_.]([a-zA-Z0-9']+))*@[a-zA-Z0-9][\w\.\-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isSSN (s) {
	var re = /(^\d{3}-\d{2}-\d{4}$)|(^\d{9}$)/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isAlphabetic (s) {
	var re = /^[a-zA-Z]*$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_isAlphanumeric (s) {
	var re = /^[a-zA-Z0-9]*$/;
	var isMatch = re.exec(s);
	return (isMatch != null && s == isMatch[0]);
}

function DotJ_getDateFormat (t) {
	if (t == "date1")
		return "MM/DD/YYYY";
	else if (t == "date2")
		return "MM-DD-YYYY";
	else if (t == "date3")
		return "YYYY/MM/DD";
	else if (t == "date4")
		return "YYYY-MM-DD";
	else if (t == "date5")
		return "MMDDYYYY";
	else if (t == "date6")
		return "YYYYMMDD";
	else if (t == "date7")
		return "MMDDYY";
	else if (t == "date8")
		return "MM/DD/YY";
	else if (t == "date9")
		return "MM-DD-YY";
	else if (t == "date10")
		return "DDMMYYYY";
	else if (t == "date11")
		return "DD/MM/YYYY";
	else if (t == "date12")
		return "DD-MM-YYYY";
	else if (t == "date13")
		return "MM.DD.YYYY";
	else if (t == "date14")
		return "DD.MM.YYYY";
	else if (t == "date15")
		return "DD-MMM-YYYY";
	else if (t == "date16")
		return "DD-MMM-YY";
	else if (t == "date17")
		return "DD MMM YYYY";
	else if (t == "date18")
		return "DD MMM YY";
	else
		return "";
}

function DotJ_makeDate (YYYY, mm, dd, fmt, months) {
	var MM = "" + mm;
	var DD = "" + dd;
	if (MM.length == 1) MM = "0" + MM;
	if (DD.length == 1) DD = "0" + DD;

	if (fmt == "date1") {
		return MM + "/" + DD + "/" + YYYY;
	} else if (fmt == "date2") {
		return MM + "-" + DD + "-" + YYYY;
	} else if (fmt == "date3") {
		return YYYY + "/" + MM + "/" + DD;
	} else if (fmt == "date4") {
		return YYYY + "-" + MM + "-" + DD;
	} else if (fmt == "date5") {
		return MM + "" + DD + "" + YYYY;
	} else if (fmt == "date6") {
		return YYYY + "" + MM + "" + DD;
	} else if (fmt == "date7") {
		var temp = "" + YYYY;
		return MM + "" + DD + "" + temp.substring(2);
	} else if (fmt == "date8") {
		var temp = "" + YYYY;
		return MM + "/" + DD + "/" + temp.substring(2);
	} else if (fmt == "date9") {
		var temp = "" + YYYY;
		return MM + "-" + DD + "-" + temp.substring(2);
	} else if (fmt == "date10") {
		return DD + "" + MM + "" + YYYY;
	} else if (fmt == "date11") {
		return DD + "/" + MM + "/" + YYYY;
	} else if (fmt == "date12") {
		return DD + "-" + MM + "-" + YYYY;
	} else if (fmt == "date13") {
		return MM + "." + DD + "." + YYYY;
	} else if (fmt == "date14") {
		return DD + "." + MM + "." + YYYY;
	} else if (fmt == "date15") {
		var tempMM = MM;
		if (months != null && months.length >= 12) tempMM = months[parseInt(MM,10)];
		return DD + "-" + tempMM + "-" + YYYY;
	} else if (fmt == "date16") {
		var tempYY = DotJ_Right(YYYY, 2);
		var tempMM = MM;
		if (months != null && months.length >= 12) tempMM = months[parseInt(MM,10)];
		return DD + "-" + tempMM + "-" + tempYY;
	} else if (fmt == "date17") {
		var tempMM = MM;
		if (months != null && months.length >= 12) tempMM = months[parseInt(MM,10)];
		return DD + " " + tempMM + " " + YYYY;
	} else if (fmt == "date18") {
		var tempYY = DotJ_Right(YYYY, 2);
		var tempMM = MM;
		if (months != null && months.length >= 12) tempMM = months[parseInt(MM,10)];
		return DD + " " + tempMM + " " + tempYY;
	} else {
		return "";
	}
}

function DotJ_getMonthFromName (months, name) {
	var index = -1;
	if (months == null || name == null) return index;

	for (var i = 0; i < months.length; i++) {
		if (name.toUpperCase() == months[i].toUpperCase()) {
			index = i;
			break;
		}
	}

	return index;
}

function DotJ_isMonth (s) {
	return DotJ_isIntegerInRange (s, 1, 12);
}

function DotJ_isDay (s) {
	return DotJ_isIntegerInRange (s, 1, 31);
}

function DotJ_isIntegerInRange (s, a, b) {
	if (!DotJ_isInteger(s)) return false;
	var num = s - 0;
	return ((num >= a) && (num <= b));
}

function DotJ_daysInFebruary (year) {
	return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DotJ_isDate (theDate, inFormat, monthsArray) {
	var format = inFormat.toLowerCase();
	var year, month, day, delim;
	var isYear = null;
	if (format == "date1" || format == "date3" || format == "date8" || format == "date11")
		delim = '/';
	else if (format == "date2" || format == "date4" || format == "date9" || format == "date12" || format == "date15" || format == "date16")
		delim = '-';
	else if (format == "date13" || format == "date14")
		delim = '.';
	else if (format == "date17" || format == "date18")
		delim = ' ';
	if (format == "date1" || format == "date2" || format == "date8" || format == "date9" || format == "date13") {
		var pos1 = theDate.indexOf(delim);
		if (pos1 == -1) return null;
		month = theDate.substring(0, pos1);
		var pos2 = theDate.lastIndexOf(delim);
		if (pos2 == pos1) return null;
		day = theDate.substring(pos1+1, pos2);
		year = theDate.substring(pos2+1, theDate.length);
		if (format == "date8" || format == "date9") {
			isYear = DotJ_isShortYear(year);
		}
	} else if (format == "date3" || format == "date4") {
		var pos1 = theDate.indexOf(delim);
		if (pos1 == -1) return null;
		year = theDate.substring(0, pos1);
		var pos2 = theDate.lastIndexOf(delim);
		if (pos2 == pos1) return null;
		month = theDate.substring(pos1+1, pos2);
		day = theDate.substring(pos2+1, theDate.length);
	} else if (format == "date11" || format == "date12" || format == "date14" || format == "date15" || format == "date16" || format == "date17" || format == "date18") {
		var pos1 = theDate.indexOf(delim);
		if (pos1 == -1) return null;
		day = theDate.substring(0, pos1);
		var pos2 = theDate.lastIndexOf(delim);
		if (pos2 == pos1) return null;
		month = theDate.substring(pos1+1, pos2);
		year = theDate.substring(pos2+1, theDate.length);
		if (format == "date16" || format == "date18") {
			isYear = DotJ_isShortYear(year);
		}
	} else if (format == "date5") {
		if (theDate.length != 8) return null;
		month = theDate.substring(0, 2);
		day = theDate.substring(2, 4);
		year = theDate.substring(4, 8);
	} else if (format == "date6") {
		if (theDate.length != 8) return null;
		year = theDate.substring(0, 4);
		month = theDate.substring(4, 6);
		day = theDate.substring(6, 8);
	} else if (format == "date7") {
		if (theDate.length != 6) return null;
		month = theDate.substring(0, 2);
		day = theDate.substring(2, 4);
		year = theDate.substring(4, 6);
		isYear = DotJ_isShortYear(year);
	} else if (format == "date10") {
		if (theDate.length != 8) return null;
		day = theDate.substring(0, 2);
		month = theDate.substring(2, 4);
		year = theDate.substring(4, 8);
	}

	if (isYear == null) isYear = DotJ_isYear(year);

	var intMonth = -1;
	if (format == "date15" || format == "date16" || format == "date17" || format == "date18") {
		intMonth = DotJ_getMonthFromName(monthsArray, month);
	} else {
		intMonth = parseInt(month,10);
	}

	if (!(isYear && intMonth != -1 && DotJ_isDay(day))) return null;
	var intYear = parseInt(year,10);
	if (intYear < 45) {
		intYear = 2000 + intYear;
	} else if (intYear < 100) {
		intYear = 1900 + intYear;
	}
	var intDay = parseInt(day,10);
	if (intDay > DotJ_daysInMonth[intMonth-1]) return null;
	if ((intMonth == 2) && (intDay > DotJ_daysInFebruary(intYear))) return null;
	return new Date(intYear, intMonth-1, intDay);
}

function DotJ_countSelects() {
	var count = 0, form, iForm = 0, iElement = 0;
	var forms = document.forms;

	for (iForm = 0; iForm < forms.length; iForm++) {
		form = forms[iForm];

		for (iElement = 0; iElement < form.elements.length; iElement++) {
			if (form.elements[iElement].tagName.toLowerCase() == 'select') {
				count++;
			}
		}
	}

	return count;
}

function DotJ_makeNewURL(url, param, newValue, oldValue) {
	var baseURL = url;
	var queryString = null;

	if (url != null) {
		var pos = url.indexOf('?');
		if (pos != -1) {
			baseURL = url.substring(0, pos);
			queryString = url.substring(pos + 1);
		}

		return baseURL + "?" + DotJ_makeNewQueryString(queryString, param, newValue, oldValue);
	} else {
		return url;
	}
}

function DotJ_makeNewQueryString(queryString, param, newValue, oldValue) {
	var newQueryString = null;

	if (queryString == null || queryString.length == 0) {
		newQueryString = param + "=" + newValue;
	} else {
		var temp = param + "=";
		if (queryString.substring(temp.length) == temp) {
			newQueryString = queryString.replace(param + "=" + oldValue, param + "=" + newValue);
		} else if (queryString.indexOf("&" + param + "=") != -1) {
			newQueryString = queryString.replace("&" + param + "=" + oldValue,
												 "&" + param + "=" + newValue);
		} else {
			newQueryString = queryString + "&" + param + "=" + newValue;
		}
	}

	return newQueryString;
}

//*********  SELECT MOVER FUNCTIONS ***********

function DotJ_moveOptions(srcList, destList, sortBy, moveAll) {
	if ((srcList.selectedIndex == -1) && (!moveAll)) {
		return;
	}

	var newDestList = new Array(destList.options.length);
	var len = 0;

	for (len = 0; len < destList.options.length; len++) {
		if (destList.options[len] != null) {
			newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[len].defaultSelected, destList.options[len].selected);
		}
	}

	for (var i = 0; i < srcList.options.length; i++) {
		if (srcList.options[i] != null && (srcList.options[i].selected || moveAll)) {
			newDestList[len] = new Option(srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, false);
			len++;
		}
	}

	if (sortBy == 'values')
		newDestList.sort(DotJ_compareOptionValues);
	else if (sortBy == 'text') {
		newDestList.sort(DotJ_compareOptionText);
	}

	for (var j = 0; j < newDestList.length; j++) {
		if (newDestList[j] != null) {
			destList.options[j] = newDestList[j];
		}
	}

	for (var ii = srcList.options.length - 1; ii >= 0; ii--) {
		if (srcList.options[ii] != null && (srcList.options[ii].selected || moveAll)) {
			srcList.options[ii] = null;
		}
	}
}

function DotJ_compareOptionValues(a, b) {
	var x = a.value;
	var y = b.value;
	return DotJ_compare(x, y);
}

function DotJ_compareOptionText(a, b) {
	var x = a.text;
	var y = b.text;
	return DotJ_compare(x, y);
}

function DotJ_compare(a, b) {
	var rc;
	var numA = parseFloat(a);
	var numB = parseFloat(b);
	if (isNaN(numA) || isNaN(numB)) {
		if (a > b) {
			rc = 1;
		} else if (a < b) {
			rc = -1;
		} else {
			rc = 0;
		}
	} else {
		rc = (numA - numB);
	}
	//alert('a=' + a + ',b=' + b + ',numA=' + numA + ',numB=' + numB + ',rc=' + rc);
	return rc;
}

function DotJ_moveItem(list, to) {
	var index = list.selectedIndex;
	var total = list.options.length-1;
	if (index == -1) return false;
	if (to == +1 && index == total) return false;
	if (to == -1 && index == 0) return false;
	var items = new Array;
	var values = new Array;
	for (i = total; i >= 0; i--) {
		items[i] = list.options[i].text;
		values[i] = list.options[i].value;
	}
	for (i = total; i >= 0; i--) {
		if (index == i) {
			list.options[i + to] = new Option(items[i],values[i], 0, 1);
			list.options[i] = new Option(items[i + to], values[i + to]);
			i--;
		} else {
			list.options[i] = new Option(items[i], values[i]);
		}
	}
	list.focus();
}

//*********  DESKTOPALERT FUNCTIONS ***********

DotJ_DesktopAlert.handleAjaxSuccess = function(o) {
    if (typeof(o.responseXML) != 'undefined') {
        var onloadEvent = DotJ_ajax.getXmlValue(o.responseXML, "Message/OnloadEvent");
        if (typeof onloadEvent != 'undefined' || onloadEvent.length > 0) {
            eval(onloadEvent + "(o.responseXML);");
        }

        var desktopAlert = o.argument[0];

        desktopAlert.setUrl(DotJ_ajax.getXmlValue(o.responseXML, "Message/RpcUrl"));
        desktopAlert.setSender(DotJ_ajax.getXmlValue(o.responseXML, "Message/Sender"));
        desktopAlert.setSubject(DotJ_ajax.getXmlValue(o.responseXML, "Message/Subject"));
        desktopAlert.setMessageText(DotJ_ajax.getXmlValue(o.responseXML, "Message/MessageText"));
        desktopAlert.setRefreshInterval(DotJ_ajax.getXmlValue(o.responseXML, "Message/RefreshInterval"));
        desktopAlert.setDisplayDuration(DotJ_ajax.getXmlValue(o.responseXML, "Message/DisplayDuration"));
        desktopAlert.setLocation(DotJ_ajax.getXmlValue(o.responseXML, "Message/Location"));
        desktopAlert.setTransparency(DotJ_ajax.getXmlValue(o.responseXML, "Message/Transparency"));
        desktopAlert.setMainIcon(DotJ_ajax.getXmlValue(o.responseXML, 'Message/MainIcon'));
        var shortcutIcon = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut1/Icon');
        var shortcutUrl = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut1/Url');
        var shortcutTarget = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut1/Target');
        desktopAlert.setShortcut(1, shortcutIcon, shortcutUrl, shortcutTarget);
        shortcutIcon = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut2/Icon');
        shortcutUrl = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut2/Url');
        shortcutTarget = DotJ_ajax.getXmlValue(o.responseXML, 'Message/Shortcut2/Target');
        desktopAlert.setShortcut(2, shortcutIcon, shortcutUrl, shortcutTarget);
        desktopAlert.setOverrideUserPlacement(DotJ_ajax.getXmlValue(o.responseXML, 'Message/OverrideUserPlacement'));

        desktopAlert.show();

        var timeout = DotJ_DesktopAlert.timeout(desktopAlert);
        desktopAlert.timer = setTimeout(timeout, desktopAlert.refreshInterval * 1000);
	}
};

DotJ_DesktopAlert.timeout = function(desktopAlert) {
    return (function(){
        desktopAlert.checkMessages();
    });
};

function DotJ_DesktopAlert_close(id) {
    var desktopAlert = DotJ_objectArray.get(id);
    if (desktopAlert != null) desktopAlert.close();
}

function DotJ_DesktopAlert_hiliteButton(e) {
    var el = YAHOO.util.Event.getTarget(e);
    if (this != null) this.hiliteButton(el);
}

function DotJ_DesktopAlert_unhiliteButton(e) {
    if (this != null) this.unhiliteButton();
}

DotJ_DesktopAlert.onMove = function(type, args) {
	var desktopAlert = args[0].obj;
    if (desktopAlert != null) {
        //if (desktopAlert.shadow != null) desktopAlert.shadow.refresh();
        if (desktopAlert.shield != null) desktopAlert.shield.refresh();
    }
};

function DotJ_DesktopAlert(id, displayDuration, transparency, location, movable, height, width, url, initialInterval, stylePrefix) {
    this.id = id;
    this.div = DotJ_getObj(id);
    this.displayDuration = displayDuration;
    this.transparency = transparency;
    this.lastLocation = location;
    this.location = location;
    this.movable = movable;
    this.height = height;
    this.width = width;
    this.url = url;
    this.initialInterval = initialInterval;
    this.stylePrefix = stylePrefix;
    this.shadow = null;
    this.proxy = null;

    this.TOP_LEFT     = 'topleft';
    this.TOP_RIGHT    = 'topright';
    this.BOTTOM_LEFT  = 'bottomleft';
    this.BOTTOM_RIGHT = 'bottomright';   

    this.originalX = -1;
    this.originalY = -1;

    this.stateMgr = new DotJ_StateMgr();

    YAHOO.util.Event.addListener(this.id + '_close','mouseover',DotJ_DesktopAlert_hiliteButton, this, true);
    YAHOO.util.Event.addListener(this.id + '_close','mouseout',DotJ_DesktopAlert_unhiliteButton, this, true);

    if (DotJ_is_ie4up && !DotJ_is_ie7up) {
        this.shield = new DotJ_IEShield(this.id + '_IEShield', this.div);
    }

    if (this.movable) {
        this.proxy = new DotJ_Proxy(this.id, this.id + '_titlebar', this.movable, this, 
                                    DotJ_DesktopAlert.onMove, null);
    }

    var timeout = DotJ_DesktopAlert.timeout(this);
    this.timer = setTimeout(timeout, this.initialInterval * 1000);

    DotJ_objectArray.add(this);
}

DotJ_DesktopAlert.prototype.style = function(styleName) {
	return this.stylePrefix + styleName;
};

DotJ_DesktopAlert.prototype.setSender = function(value) {
    if (value != null) DotJ_setText(this.id + '_sender', value);
};

DotJ_DesktopAlert.prototype.setSubject = function(value) {
    if (value != null) DotJ_setText(this.id + '_subject', value);
};

DotJ_DesktopAlert.prototype.setMessageText = function(value) {
    if (value != null) DotJ_setText(this.id + '_msgText', value);
};

DotJ_DesktopAlert.prototype.setLocation = function(value) {
    if (value != null) this.location = value;
};

DotJ_DesktopAlert.prototype.setRefreshInterval = function(value) {
    if (value != null) this.refreshInterval = parseInt(value,10);
};

DotJ_DesktopAlert.prototype.setDisplayDuration = function(value) {
    if (value != null) this.displayDuration = parseInt(value,10);
};

DotJ_DesktopAlert.prototype.setTransparency = function(value) {
    if (value != null) this.transparency = parseInt(value,10);
};

DotJ_DesktopAlert.prototype.setUrl = function(value) {
    if (value != null) this.url = value;
};

DotJ_DesktopAlert.prototype.setShortcut = function(nbr, shortcutIcon, shortcutUrl, shortcutTarget) {
    if (shortcutIcon != null && shortcutUrl != null) {
        var html = "<a href='" + shortcutUrl + "'";
        if (shortcutTarget != null) html = html + " target='" + shortcutTarget + "'";
        html = html + ">" + shortcutIcon + "</a>";
        DotJ_setText(this.id + '_shortcut' + nbr, html);
        var el = DotJ_getObj(this.id + '_shortcut' + nbr);
        var imgColl = el.getElementsByTagName('img');
        if (imgColl != null) {
            var img = imgColl.item(0);
            if (img.style.border != '') img.style.border='';
            if (img.border == '') img.border=0;
            img.className = img.className + ' ' + this.style('Icon');

            YAHOO.util.Event.removeListener(img,'mouseover',DotJ_DesktopAlert_hiliteButton);
            YAHOO.util.Event.removeListener(img,'mouseout',DotJ_DesktopAlert_unhiliteButton);

            YAHOO.util.Event.addListener(img,'mouseover',DotJ_DesktopAlert_hiliteButton, this, true);
            YAHOO.util.Event.addListener(img,'mouseout',DotJ_DesktopAlert_unhiliteButton, this, true);
        }
    }
};

DotJ_DesktopAlert.prototype.setMainIcon = function(value) {
	if (value != null) DotJ_setText(this.id + '_mainIcon', value);
};

DotJ_DesktopAlert.prototype.setOverrideUserPlacement = function(value) {
    if (value != null) this.overrideUserPlacement = value;
};

DotJ_DesktopAlert.prototype.checkMessages = function() {
    var me = this;
    var callback = {
      success:  DotJ_DesktopAlert.handleAjaxSuccess,
      failure:  DotJ_handleAjaxFailure,
      argument: [me]
    };

    DotJ_ajax.getXml(this.url, callback);
};

DotJ_DesktopAlert.prototype.close = function() {
    var el = this.div;

    var anim = new YAHOO.util.Anim(el.id, { opacity: { to: 0 } }, 0.65, YAHOO.util.Easing.easeOut);
    var handler = function (type, args) {
        DotJ_hideElement(el);
    };
    anim.onComplete.subscribe(handler);
    anim.animate();

	if (this.shield != null) this.shield.hide();
};

DotJ_DesktopAlert.prototype.show = function() {
    if (this.fader == null) this.fader = new DotJ_AutoFader(this.id, this.div, null, this.displayDuration, this.transparency, this.shield, this.shadow);
    this.fader.displayDuration = this.displayDuration;
    this.fader.transparency = this.transparency;
    this.fader.reset();

    this.place();

    DotJ_displayElement(this.div);

    if (this.shadow != null) this.shadow.show();
    if (this.shadow != null) this.shadow.refresh();
	if (this.shield != null) this.shield.refresh();
    if (this.proxy != null) this.proxy.resize();
};

DotJ_DesktopAlert.prototype.place = function() {
    if (this.originalX == -1 || this.overrideUserPlacement.toLowerCase() == 'true' ||
        (this.originalX != -1 && this.location != this.lastLocation &&
                                 this.originalX == DotJ_getX(this.div) && this.originalY == DotJ_getY(this.div))) {
        var clientWidth = (DotJ_is_ie4up) ? document.body.clientWidth : self.innerWidth;
        var clientHeight = (DotJ_is_ie4up) ? document.body.clientHeight : self.innerHeight;
        var x,y;
        var yMargin = this.height * (1/4);
        if (yMargin < 20) yMargin = 20;
        var xMargin = yMargin; // * (clientWidth / clientHeight);

        if (this.location == this.TOP_RIGHT) {
            x = clientWidth - this.width - xMargin;
            y = yMargin;
        } else if (this.location == this.TOP_LEFT) {
            x = xMargin;
            y = yMargin;
        } else if (this.location == this.BOTTOM_LEFT) {
            x = xMargin;
            y = clientHeight - this.height - yMargin;
        } else {
            x = clientWidth - this.width - xMargin;
            y = clientHeight - this.height - yMargin;
        }

        DotJ_moveTo(this.div, x, y);
        this.originalX = x;
        this.originalY = y;
        this.lastLocation = location;

        if (this.shadow != null) this.shadow.refresh();
    }
};

DotJ_DesktopAlert.prototype.hiliteButton = function(el) {
    this.stateMgr.queueSetting(el.id, 'className', el.className, el);
    el.className = this.style('IconHover');
};

DotJ_DesktopAlert.prototype.unhiliteButton = function() {
    this.stateMgr.restoreAllSettings();
};

//*******************************  AUTO FADER  *********************************

DotJ_AutoFader.fade = function(autoFader) {
    return (function(){
        autoFader.fadeHelper();
    });
};

DotJ_AutoFader.timeout = function(autoFader) {
    return (function(){
        autoFader.timeoutHelper();
    });
};

function DotJ_AutoFader(id, div, divParts, displayDuration, transparency, shield, shadow) {
	this.id = id + '_fader';
	this.div = div;
	if (divParts == null) this.divParts = div;
	else this.divParts = divParts;
	this.displayDuration = displayDuration;
	this.transparency = parseInt(transparency,10);
	this.shield = shield;
    this.shadow = shadow;
    this.isMouseOverMe = false;
	this.fading = false;

    this.opacity = 100 - this.transparency;
    if (this.opacity != 100)
	    DotJ_setOpacity(this.divParts, this.opacity);

    DotJ_objectArray.add(this);

    this.div.onmouseover = this.onMouseOver;
	this.div.onmouseout = this.onMouseOut;

	this.pastDuration = false;

    var fnTimeout = DotJ_AutoFader.timeout(this);
    setTimeout(fnTimeout, this.displayDuration * 1000);
}

DotJ_AutoFader.prototype.timeoutHelper = function() {
    this.pastDuration = true;
	if (!this.isMouseOverMe) {
        if (this.shadow != null) this.shadow.hide();
		this.fading = true;
        var fnTimeout = DotJ_AutoFader.fade(this);
		this.timer = setTimeout(fnTimeout, 10);
	}
};

DotJ_AutoFader.prototype.fadeHelper = function() {
	if (this.isMouseOverMe) return;
	this.opacity = this.opacity - 5;
   	DotJ_setOpacity(this.divParts, this.opacity);
	if (this.opacity <= 0) {
		clearTimeout(this.timer);
		DotJ_hideElement(this.divParts);
		if (this.shield != null) this.shield.hide();
	} else {
		if (this.fading)
            var fnTimeout = DotJ_AutoFader.fade(this);
            this.timer = setTimeout(fnTimeout, 100);
	}
};

DotJ_AutoFader.prototype.reset = function() {
	this.fading = false;
	this.opacity = 100 - this.transparency;
    if (this.opacity == 100) this.opacity = 99;
   	DotJ_setOpacity(this.divParts, this.opacity);
	this.pastDuration = false;
	this.clear();
    var fnTimeout = DotJ_AutoFader.timeout(this);
    setTimeout(fnTimeout, this.displayDuration * 1000);
};

DotJ_AutoFader.prototype.clear = function() {
    clearTimeout(this.timer);
};

DotJ_AutoFader.prototype.onMouseOver = function(e) {
	var obj = DotJ_objectArray.get(this.id + '_fader');
	if (obj != null) {
        obj.isMouseOverMe = true;
        if (obj.fading) {
            if (obj.shadow != null) obj.shadow.show();
		    obj.opacity = 100 - obj.transparency;
            if (this.opacity != 100)
                DotJ_setOpacity(obj.divParts, obj.opacity);
	        obj.fading = false;
		}
    }
};

DotJ_AutoFader.prototype.onMouseOut = function(e) {
	var obj = DotJ_objectArray.get(this.id + '_fader');
	if (obj != null && obj.id == (this.id + '_fader'))
	    obj.isMouseOverMe = false;
	if (obj.pastDuration && !obj.isMouseOverMe) {
        if (obj.shadow != null) obj.shadow.hide();
		obj.fading = true;
        var fnTimeout = DotJ_AutoFader.fade(obj);
		obj.timer = setTimeout(fnTimeout, 10);
	}
};

//*********  CALENDAR FUNCTIONS ***********

DotJ_Calendar.render = function() {
	var firstDay = new Date(this.year,this.month-1,1);
	this.computeDaySlots(firstDay);
	this.renderMonth();
	this.renderDays(firstDay);
};

DotJ_Calendar.computeDaySlots = function(firstDay) {
	var theFirstDay = DotJ_computeDay(firstDay.getDay(), this.firstDayOfWeek);
	var lastDay = this.computeLastDay() + theFirstDay;

	for (var counter = 1; counter <= 42; counter++) {
		if (counter > theFirstDay && counter <= lastDay) {
			this.daySlots[counter] = counter - theFirstDay;
		} else {
			this.daySlots[counter] = '';
		}
	}
};

function DotJ_computeDay(day, firstDayOfWeek) {
	var result = day;
	result = result - (firstDayOfWeek-1);
	if (result < 0) result = result + 7;
	return result;
}

DotJ_Calendar.computeLastDay = function() {
	var lastDay = DotJ_daysInMonth[this.month-1];
	if (this.month == 2) {
		lastDay = DotJ_daysInFebruary(this.year);
	}
	return lastDay;
};

DotJ_Calendar.searchForEvent = function(day) {
	var i = 0;
	if (this.events) {
		for (i = 0; i < this.events.length; i++) {
			if (this.year == this.events[i].date.getFullYear() &&
				this.month == (this.events[i].date.getMonth()+1) &&
				day == this.events[i].date.getDate()) {
				return i;
			}
		}
	}
	return -1;
};

function DotJ_findSunday(year, month) {
	var i = 0;
	for (i = 1; i <= 7; i++) {
		var dt = new Date(year, month, i);
		if (dt.getDay() == 0) return i;
	}
    return 1;
}

DotJ_Calendar.renderDays = function(firstDay) {
	var clsName, eventId = -1, html;

    var hidePrevYYIcon = false;
	if (this.startDate != null) {
		var tempStartDate = new Date(this.startDate.getFullYear(), this.startDate.getMonth(), 1);
		var prevYearCutoff = new Date(this.year, this.month-1, 1);
		prevYearCutoff.setYear(prevYearCutoff.getFullYear()-1);
		var dayDiff = Math.floor((tempStartDate.getTime() - prevYearCutoff.getTime()) / 1000 / 60 / 60 / 24);
        hidePrevYYIcon = (dayDiff > 0) ? true : false;
        //alert('prevYearCutoff=' + prevYearCutoff + ',dayDiff=' + dayDiff + ',hidePrevYYIcon=' + hidePrevYYIcon);
	}

    var hideNextYYIcon = false;
	if (this.endDate != null) {
		var nextYearCutoff = new Date(this.year, this.month-1, 1);
		nextYearCutoff.setYear(nextYearCutoff.getFullYear()+1);
		dayDiff = Math.floor((nextYearCutoff.getTime() - this.endDate.getTime()) / 1000 / 60 / 60 / 24);
        hideNextYYIcon = (dayDiff > 0) ? true : false;
        //alert('nextYearCutoff=' + nextYearCutoff + ',dayDiff=' + dayDiff + ',hideNextYYIcon=' + hideNextYYIcon);
    }

    var hidePrevMMIcon = false;
    var hideNextMMIcon = false;

	var theFirstDay = DotJ_computeDay(firstDay.getDay(), this.firstDayOfWeek);
	var Sunday = DotJ_findSunday(this.year, this.month-1);
	var SundayColumn = Sunday + theFirstDay;
	if (SundayColumn >= 7) SundayColumn = SundayColumn - 7;
	var SaturdayColumn = SundayColumn - 1;
	if (SaturdayColumn == -1) SaturdayColumn = 6;

	for (i = 1; i <= 42; i++) {
		var emptyCell = (this.daySlots[i] == '') ? true : false;

		clsName = this.style('Weekday');
		if (this.hiliteToday && this.year == DotJ_today.getFullYear() &&
			(this.month-1) == DotJ_today.getMonth() &&
			(i - theFirstDay) == DotJ_today.getDate()) {
			clsName = this.style('CurrentDay');
		} else {
			if ((i % 7 == SundayColumn) || (i % 7 == SaturdayColumn)) {
				clsName = this.style('Weekend');
            }
		}

		if (this.year == this.selectedYear &&
		   (this.month) == this.selectedMonth &&
		   (i - theFirstDay) == this.selectedDay) {
			clsName = this.style('SelectedDay');
		}

		html = "";
		eventId = this.searchForEvent((i - theFirstDay));
		if (eventId != -1 && this.mode == 'fixed') {
			clsName = this.style('Event');
			html = html + "<a class='" + clsName + "'";
			if (this.events[eventId].target != null)
				html = html + " target='" + this.events[eventId].target + "'";

			if (this.events[eventId].url != null) {
				var oldValue = DotJ_param_date;
				var tempDate = this.events[eventId].date;
				var newURL = DotJ_makeNewURL(this.events[eventId].url, "dotjdate",
											 DotJ_makeDate(tempDate.getFullYear(), tempDate.getMonth()+1, tempDate.getDate(), this.format), oldValue);
				if (this.events[eventId].description != null) {
					oldValue = DotJ_param_description;
					newURL = DotJ_makeNewURL(newURL, "dotjdesc", escape(this.events[eventId].description), oldValue);
				}
				if (this.events[eventId].key != null) {
					oldValue = DotJ_param_key;
					newURL = DotJ_makeNewURL(newURL, "dotjkey", escape(this.events[eventId].key), oldValue);
					if (this.events[eventId].keyname != null) {
					    oldValue = this.events[eventId].key;
					    newURL = DotJ_makeNewURL(newURL, this.events[eventId].keyname, escape(this.events[eventId].key), oldValue);
					}
				}
				html = html + " href='" + newURL + "'";
			}

			if (this.events[eventId].description != null) {
				html = html + " title=" + DotJ_safeJSString(this.events[eventId].description);
			}
			html = html + ">";
		}

        if (!emptyCell && this.startDate != null) {
            if (this.year < this.startDate.getFullYear()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hidePrevMMIcon = true;
            } else if (this.year == this.startDate.getFullYear() && (this.month-1) < this.startDate.getMonth()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hidePrevMMIcon = true;
            } else if (this.year == this.startDate.getFullYear() && (this.month-1) == this.startDate.getMonth() && (i - theFirstDay) < this.startDate.getDate()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hidePrevMMIcon = true;
            }
        }

        if (!emptyCell && this.endDate != null) {
            if (this.year > this.endDate.getFullYear()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hideNextMMIcon = true;
            } else if (this.year == this.endDate.getFullYear() && (this.month-1) > this.endDate.getMonth()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hideNextMMIcon = true;
            } else if (this.year == this.endDate.getFullYear() && (this.month-1) == this.endDate.getMonth() && (i - theFirstDay) > this.endDate.getDate()) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
                hideNextMMIcon = true;
            }
        }

        if (!emptyCell && !this.weekendsSelectable) {
            if ((i % 7 == SundayColumn) || (i % 7 == SaturdayColumn)) {
                clsName = clsName + ' ' + this.style('NonselectableDay');
            }
        }

		if (emptyCell) html = html + "&nbsp;";
		else html = html + this.daySlots[i];

		if (eventId != -1 && this.mode == 'fixed')
			html += "</a>";

		var cell = this.getCalTDId(i);
		var objCell = DotJ_getObj(cell);
		DotJ_setText(cell, html);
		objCell.className = clsName;
		if (this.mode == 'fixed') {
			DotJ_setCursorToDefault(objCell);
		} else {
			if (emptyCell) {
				DotJ_setCursorToDefault(objCell);
			} else if (clsName.indexOf('NonselectableDay') == -1) {
				DotJ_setCursorToPointer(objCell);
			} else {
				DotJ_setCursorToDefault(objCell);
			}
		}
	}

	if (this.hdrPrevMM) {
		this.hdrPrevMM.innerHTML = this.hdrPrevMMInnerHTML;
		if (hidePrevMMIcon) this.hdrPrevMM.innerHTML = this.hdrPrevMMBlankInnerHTML;
	}

	if (this.hdrNextMM) {
		this.hdrNextMM.innerHTML = this.hdrNextMMInnerHTML;
		if (hideNextMMIcon) this.hdrNextMM.innerHTML = this.hdrNextMMBlankInnerHTML;
	}

	if (this.hdrPrevYY) {
		this.hdrPrevYY.innerHTML = this.hdrPrevYYInnerHTML;
		if (hidePrevYYIcon) this.hdrPrevYY.innerHTML = this.hdrPrevYYBlankInnerHTML;
	}

	if (this.hdrNextYY) {
		this.hdrNextYY.innerHTML = this.hdrNextYYInnerHTML;
		if (hideNextYYIcon) this.hdrNextYY.innerHTML = this.hdrNextYYBlankInnerHTML;
	}
};

function DotJ_doPrev(cal,unit) {
	if (unit == 'm') cal.decMonth();
	else cal.decYear();
	cal.render();
}

function DotJ_gotoToday(cal) {
	cal.selectedYear = DotJ_today.getFullYear();
	cal.year = DotJ_today.getFullYear();
	cal.selectedMonth = DotJ_today.getMonth() + 1;
	cal.month = DotJ_today.getMonth() + 1;
	cal.selectedDay = DotJ_today.getDate();
	cal.day = DotJ_today.getDate();
	cal.render();
}

function DotJ_doNext(cal,unit) {
	if (unit == 'm') cal.incMonth();
	else cal.incYear();
	cal.render();
}

DotJ_Calendar.decMonth = function() {
	this.month -= 1;
	if (this.month <= 0) {
		this.month = 12;
		this.decYear();
	}
};

DotJ_Calendar.incMonth = function() {
	this.month += 1;
	if (this.month >= 13) {
		this.month = 1;
		this.incYear();
	}
};

DotJ_Calendar.decYear = function() {
	this.year -= 1;
};

DotJ_Calendar.incYear = function() {
	this.year += 1;
};

DotJ_Calendar.renderMonth = function() {
	DotJ_setText(this.getCalHdrId(), '&nbsp;' + this.months[this.month] + ' ' + this.year + '&nbsp;');
};

DotJ_Calendar.hide = function() {
	var el = this.div;
	DotJ_hideElement(el);
	this.visible = false;
	if (this.shield != null) this.shield.hide();
};

DotJ_Calendar.toggle = function() {
	var el = this.div;

	if (DotJ_getVisibility(el) == "show" || DotJ_getVisibility(el) == "visible" || DotJ_getVisibility(el) == "") {
		this.hide();
    } else {
		DotJ_displayElement(el);
		this.visible = true;
		if (this.shield != null) this.shield.refresh();
	}
};

DotJ_Calendar.show = function(field,anchor) {
	var objField = DotJ_findFormField(field);
	if (objField == null && this.label == null) {
		var msg = "dotJ Javascript Error: Cannot locate form field '" + field + "'. \n\nThe item must be under a <form> tag.";
		alert(msg);
		return;
	}

	var inputDate;
	if (this.label == null) {
		inputDate = DotJ_isDate(objField.value, this.format, this.months);
	} else {
		var tempDate = DotJ_isDate(this.label.innerHTML, this.format, this.months);
		inputDate = (tempDate == null) ? DotJ_today : tempDate;
	}

	if (inputDate == null) {
		this.year = DotJ_today.getFullYear();
		this.month = DotJ_today.getMonth()+1;
		this.selectedDay = null;
	} else {
		this.selectedYear = inputDate.getFullYear();
		this.year = inputDate.getFullYear();
		this.selectedMonth = inputDate.getMonth() + 1;
		this.month = inputDate.getMonth() + 1;
		this.selectedDay = inputDate.getDate();
		this.day = inputDate.getDate();
	}

	var calHeight = DotJ_getHeight(this.div);

	var objAnchor = DotJ_findAnchorItem(anchor);
	var x=0, y=0, anchorHeight, margin;
	if (objAnchor != null && objAnchor.tagName.toLowerCase() == 'a') {
		var c = DotJ_getAnchorPosition(objAnchor, objAnchor.id);
		var x1 = DotJ_getX(this.label);
		var y1 = DotJ_getY(this.label);
		x = (DotJ_is_ie4up) ? x1 : c.x;  // Bug in IE?
		y = (DotJ_is_ie4up) ? y1 : c.y;  // Bug in IE?
		anchorHeight = DotJ_getHeight(objAnchor);
		margin = (anchorHeight / 3);
		y = DotJ_getSmartY(y, anchorHeight, calHeight, margin);
	} else {
		anchorHeight = DotJ_getHeight(objAnchor);
		margin = (anchorHeight / 3);
		x = DotJ_getX(objAnchor);
		y = DotJ_getSmartY(DotJ_getY(objAnchor), anchorHeight, calHeight, margin);
	}

	if (!this.placed) {
		DotJ_moveTo(this.div, x, y);
		this.placed = true;
	}

	if (this.parent.singleMode) {
		this.parent.hide(this);
	}

	this.render();
	this.toggle();
};

DotJ_Calendar.selectDay = function(cellId,field,fmt) {
	var cell = DotJ_getObj(cellId);
	var day = cell.innerHTML;
	if (!DotJ_isPositiveInteger(day) || cell.className.indexOf('NonselectableDay') != -1) return;
	if (this.label == null) {
		var parentForm = DotJ_FindParentForm(this.id);
		var objField;
		if (parentForm != null) {
			objField = DotJ_findFormFieldOnForm(field, parentForm);
		} else {
			objField = DotJ_findFormField(field);
		}
		objField.value = DotJ_makeDate(this.year, this.month, day, fmt, this.months);
		if (typeof(objField.onchange) == 'function') {
			objField.onchange();
		}
	} else {
		var selDate = DotJ_makeDate(this.year, this.month, day, fmt, this.months);
		this.label.innerHTML = selDate;
		if (this.labelId != '') {
			var objLbl = DotJ_findFormField(this.labelId);
			if (objLbl != null) objLbl.value = selDate;
		}
	}
	this.selectedYear = this.year;
	this.selectedMonth = this.month;
	this.selectedDay = day;
	this.toggle();
};

DotJ_Calendar.clear = function(field) {
	if (field == null || field == '') return;
	var objField = DotJ_findFormField(field);
	if (objField == null && this.label == null) {
		var msg = "dotJ Javascript Error: Cannot locate form field '" + field + "'. \n\nThe item must be under a <form> tag.";
		alert(msg);
		return;
	}

	if (objField.value != '') {
		objField.value = '';
		if (typeof(objField.onchange) == 'function') {
			objField.onchange();
		}
		this.year = DotJ_today.getFullYear();
		this.month = DotJ_today.getMonth()+1;
		this.selectedDay = null;
		this.toggle();
	}
};

DotJ_Calendar.getCalId = function() {
	return this.id;
};

DotJ_Calendar.getCalHdrId = function() {
	return this.getCalId() + "_hdr";
};

DotJ_Calendar.getCalTDId = function(day) {
	return this.getCalId() + "_TD_" + day;
};

DotJ_Calendar.style = function(styleName) {
	return this.stylePrefix + styleName;
};

DotJ_Calendar.computePrevHdrWidth = function() {
	this.hdrPrevYY = DotJ_getObj(this.id + '_HdrPrevYY');
	if (this.hdrPrevYY != null) {
		this.hdrPrevYYWidth = DotJ_getWidth(this.hdrPrevYY);
		this.hdrPrevYYInnerHTML = this.hdrPrevYY.innerHTML;
		this.hdrPrevYYBlankInnerHTML = "<img src='" + DotJ_IMG_SPACER + "' height='1' width='" + this.hdrPrevYYWidth + "'>";
	}
	this.hdrPrevMM = DotJ_getObj(this.id + '_HdrPrevMM');
	if (this.hdrPrevMM != null) {
		this.hdrPrevMMWidth = DotJ_getWidth(this.hdrPrevMM);
		this.hdrPrevMMInnerHTML = this.hdrPrevMM.innerHTML;
		this.hdrPrevMMBlankInnerHTML = "<img src='" + DotJ_IMG_SPACER + "' height='1' width='" + this.hdrPrevMMWidth + "'>";
	}
};

DotJ_Calendar.computeNextHdrWidth = function() {
	this.hdrNextYY = DotJ_getObj(this.id + '_HdrNextYY');
	if (this.hdrNextYY != null) {
		this.hdrNextYYWidth = DotJ_getWidth(this.hdrNextYY);
		this.hdrNextYYInnerHTML = this.hdrNextYY.innerHTML;
		this.hdrNextYYBlankInnerHTML = "<img src='" + DotJ_IMG_SPACER + "' height='1' width='" + this.hdrNextYYWidth + "'>";
	}
	this.hdrNextMM = DotJ_getObj(this.id + '_HdrNextMM');
	if (this.hdrNextMM != null) {
		this.hdrNextMMWidth = DotJ_getWidth(this.hdrNextMM);
		this.hdrNextMMInnerHTML = this.hdrNextMM.innerHTML;
		this.hdrNextMMBlankInnerHTML = "<img src='" + DotJ_IMG_SPACER + "' height='1' width='" + this.hdrNextMMWidth + "'>";
	}
};

function DotJ_isACalImage(img) {
	var calFound = false;
	var parent = img.offsetParent;
	if (parent != null && DotJ_calArray.get(parent.id) != null) calFound = true;

	while (null != parent) {
		parent = parent.offsetParent;
		if (parent != null && DotJ_calArray.get(parent.id) != null) calFound = true;
	}
	return calFound;
}

DotJ_Calendar.onMove = function(type, args) {
	var cal = args[0].obj;
    if (cal != null) {
        //if (cal.shadow != null) cal.shadow.refresh();
        if (cal.shield != null) cal.shield.refresh();
    }
};

function DotJ_Calendar(id, format, mode, year, month, selectedDay, hiliteToday, stylePrefix, label, labelId, startDate, endDate, firstDayOfWeek, movable, weekendsSelectable) {
	this.id = id;
	this.div = DotJ_getObj(id);
	this.format = format;
	this.mode = mode;
	this.year = year;
	this.month = month;
	this.selectedYear = year;
	this.selectedMonth = month;
	this.selectedDay = selectedDay;
	this.hiliteToday = hiliteToday;
	this.events = null;
	this.months = null;
	this.daySlots = null;
	this.visible = false;
	this.stylePrefix = stylePrefix;
	this.label = label;
	this.labelId = labelId;
	this.startDate = null;
	if (startDate != null) this.startDate = DotJ_isDate(startDate, this.format);
	if (endDate != null) this.endDate = DotJ_isDate(endDate, this.format);
	this.firstDayOfWeek = firstDayOfWeek;
	this.movable = movable;
    this.weekendsSelectable = weekendsSelectable;
	this.parent = null;
	this.placed = false;
	this.shield = null;
    this.proxy = null;

	if (DotJ_is_ie4up && !DotJ_is_ie7up) {
		this.shield = new DotJ_IEShield(this.id + '_IEShield', this.div);
	}

	if (this.movable && mode == 'popup') {
        this.proxy = new DotJ_Proxy(this.id, this.id + '_dnd', this.movable, this, 
                                    DotJ_Calendar.onMove, null);
	}

	this.style = DotJ_Calendar.style;
	this.render = DotJ_Calendar.render;
	this.renderMonth = DotJ_Calendar.renderMonth;
	this.renderDays = DotJ_Calendar.renderDays;
	this.computeDaySlots = DotJ_Calendar.computeDaySlots;
	this.computeLastDay = DotJ_Calendar.computeLastDay;
	this.searchForEvent = DotJ_Calendar.searchForEvent;
	this.decMonth = DotJ_Calendar.decMonth;
	this.incMonth = DotJ_Calendar.incMonth;
	this.decYear = DotJ_Calendar.decYear;
	this.incYear = DotJ_Calendar.incYear;
	this.hide = DotJ_Calendar.hide;
	this.show = DotJ_Calendar.show;
	this.toggle = DotJ_Calendar.toggle;
	this.selectDay = DotJ_Calendar.selectDay;
	this.clear = DotJ_Calendar.clear;
	this.getCalId = DotJ_Calendar.getCalId;
	this.getCalHdrId = DotJ_Calendar.getCalHdrId;
	this.getCalTDId = DotJ_Calendar.getCalTDId;
	this.computePrevHdrWidth = DotJ_Calendar.computePrevHdrWidth;
	this.computeNextHdrWidth = DotJ_Calendar.computeNextHdrWidth;
}

function DotJ_Event(date, target, url, description, key, keyname) {
	this.date = date;
	this.target = target;
	this.url = url;
	this.description = description;
	this.key = key;
	this.keyname = keyname;
}

DotJ_CalArray.add = function (objCal){
	this.cals[this.cals.length] = objCal;
	objCal.parent = this;
};

DotJ_CalArray.get = function(name) {
	for (var i = 0; i < this.cals.length; i++) {
		if (this.cals[i].name == name) {
			return this.cals[i];
		}
	}

	return null;
};

DotJ_CalArray.clear = function() {
	this.cals.length = 0;
};

DotJ_CalArray.hide = function(objCal) {
	for (var i = 0; i < this.cals.length; i++) {
		if (objCal && (objCal != this.cals[i])) {
			this.cals[i].hide();
		}
	}
};

function DotJ_CalArray() {
	this.singleMode = false;
	this.cals = new Array();

	this.add = DotJ_CalArray.add;
	this.get = DotJ_CalArray.get;
	this.clear = DotJ_CalArray.clear;
	this.hide = DotJ_CalArray.hide;
}

var DotJ_calArray;
if (typeof(DotJ_calArray) == 'undefined'){
	DotJ_calArray = null;
}
if (DotJ_calArray == null){
	DotJ_calArray = new DotJ_CalArray();
}

//******************************   STATE MANAGER   *******************************

DotJ_StateMgr.queueSetting = function(id,property,value,obj) {
	var change,i=0,found=false;

	while (i < this.changes.length) {
		change = this.changes[i];
		if (change != null && change.id == id && change.property == property && change.obj == obj) {
			found = true;
			break;
		}
		i++;
	}

	if (!found) {
		change = new DotJ_Setting(id, property, value, obj);
		this.changes[this.changes.length] = change;
	}
};

DotJ_StateMgr.restoreSettings = function(id) {
	if (this.changes == null) return;

	var change, i = this.changes.length - 1, changeCount = 0;

	while (i >= 0) {
		change = this.changes[i];
		if (change != null && change.id == id) {
			s = 'change.obj.' + change.property + ' = "' + change.value + '"';
			eval(s);
//			alert('Restored setting for id ' + id + ': ' + s);
			this.changes[i] = null;
			changeCount++;
		}
		i--;
	}
	//alert('old length=' + this.changes.length + ', new length=' + (this.changes.length - changeCount));
	//this.changes.length = this.changes.length - changeCount;
};

DotJ_StateMgr.restoreAllSettings = function() {
	if (this.changes == null) return;

	var change, i = this.changes.length - 1;

	while (i >= 0) {
		change = this.changes[i];
		if (change != null) {
			s = 'change.obj.' + change.property + ' = "' + change.value + '"';
			eval(s);
			if (DotJ_LOG) DotJ_logDebug('restoring [' + change.obj.id + '].' + change.property + ' back to ' + change.value);
			this.changes[i] = null;
		}
		i--;
	}
	this.changes.length = 0;
};

DotJ_StateMgr.reset = function() {
	if (this.changes == null) return;

	var i = this.changes.length - 1;

	while (i >= 0) {
		this.changes[i] = null;
		i--;
	}
	this.changes.length = 0;
};

DotJ_StateMgr.alert = function() {
	var change,i=0;
	var s = '';

	while (i < this.changes.length) {
		change = this.changes[i];
		if (change == null)
			s = s + 'null\n';
		else
			s = s + 'id=' + change.id + ', property=' + change.property + ', value=' + change.value + ', obj=' + change.obj + '\n';
		i++;
	}
	alert('Current Queued settings:\n-------------------------------------\n' + s)
};

function DotJ_StateMgr() {
	this.changes = new Array();

	this.queueSetting = DotJ_StateMgr.queueSetting;
	this.restoreSettings = DotJ_StateMgr.restoreSettings;
	this.restoreAllSettings = DotJ_StateMgr.restoreAllSettings;
	this.reset = DotJ_StateMgr.reset;
	this.alert = DotJ_StateMgr.alert;
}

var DotJ_stateMgr;
if (typeof(DotJ_stateMgr) == 'undefined'){
	DotJ_stateMgr = null;
}
if (DotJ_stateMgr == null){
	DotJ_stateMgr = new DotJ_StateMgr();
}

//*******************************  PROXY  *******************************

function DotJ_Proxy(anchorComponentId, handleId, movable, parent, onMoveFn, onShowFn) {
    this.anchorComponentId = anchorComponentId;
    this.handleId = handleId;
    this.parent = parent;
    this.div = DotJ_getObj(anchorComponentId + '_proxy');
    this.divAnchor = DotJ_getObj(anchorComponentId);

    if (onShowFn != null) {
        this.onShow = new YAHOO.util.CustomEvent("onShow");
        this.onShow.subscribe(onShowFn);
    }

    if (movable) {
        this.onMove = new YAHOO.util.CustomEvent("onMove");
        this.onMove.subscribe(onMoveFn);

        var proxy = this;
        var parent2 = parent;
        this.dnd = new YAHOO.util.DDProxy(this.divAnchor, '', { dragElId: this.div.id } );
        this.dnd.setHandleElId(this.handleId);

        this.dnd.onMouseUp = function(e) {
            proxy.onMove.fire({obj: parent2});
        };
    }
};

DotJ_Proxy.prototype.BORDERMARGIN = 5;

DotJ_Proxy.onResize = function(e, proxy) {
    if (proxy != null) proxy.resize();
};

DotJ_Proxy.prototype.resize = function() {
    var Dom = YAHOO.util.Dom;
    if (this.dnd) {
        this.dnd.resetConstraints();
        this.dnd.setXConstraint(Dom.getX(this.anchorComponentId) - this.BORDERMARGIN,
                                Dom.getViewportWidth() - this.BORDERMARGIN - Dom.getX(this.anchorComponentId) - DotJ_getWidth(DotJ_getObj(this.anchorComponentId)));
        this.dnd.setYConstraint(Dom.getY(this.anchorComponentId) - this.BORDERMARGIN,
                                Dom.getViewportHeight() - this.BORDERMARGIN - Dom.getY(this.anchorComponentId) - DotJ_getHeight(DotJ_getObj(this.anchorComponentId)));
    }
};

DotJ_Proxy.prototype.close = function(x, y, width, height) {
    var Dom = YAHOO.util.Dom;
    var pos = [Dom.getX(this.divAnchor), Dom.getY(this.divAnchor)];
    Dom.setXY(this.div.id, pos);
    this.div.style.width = DotJ_getWidth(this.divAnchor);
    this.div.style.height = DotJ_getHeight(this.divAnchor);
    DotJ_displayElement(this.div);

    // Minimize the proxy div element
    var attributes = {
        points: {
            to: [x, y]
        },
        width: { to: width },
        height: { to: height }
    };

    var elProxy = this.div;
    var anim = new YAHOO.util.Motion(elProxy.id, attributes, 0.4, YAHOO.util.Easing.easeOut);
    var handler = function (type, args) {
        DotJ_hideElement(elProxy);
    };
    anim.onComplete.subscribe(handler);
    anim.animate();

    YAHOO.util.Event.removeListener(window,'resize',DotJSF.widget.Proxy.onResize);
};

DotJ_Proxy.prototype.show = function() {
    YAHOO.util.Event.addListener(window,'resize',DotJ_Proxy.onResize,this,true);

    DotJ_displayElement(this.div);

    // Maximize the proxy element
    var Dom = YAHOO.util.Dom;
    var attributes = {
        points: {
            to: [Dom.getX(this.divAnchor), Dom.getY(this.divAnchor)]
        },
        width: { to: DotJ_getWidth(this.divAnchor) },
        height: { to: DotJ_getHeight(this.divAnchor) }
    };

    var proxy = this;
    var anim = new YAHOO.util.Motion(this.div.id, attributes, 0.4, YAHOO.util.Easing.easeOut);
    var handler = function (type, args) {
        DotJ_setOpacity(proxy.div, 50);
        if (proxy.onShow != null) {
            proxy.onShow.fire({obj: proxy.parent});
        }
        DotJ_hideElement(proxy.div);
    };
    anim.onComplete.subscribe(handler);
    anim.animate();

    this.resize();
};

//**************************   TABCONTAINER   **************************

DotJ_TabContainer.checkForForm = function() {
	if (this.form == null) this.form = DotJ_FindParentForm('DotJ_' + this.id);
	if (this.form == null) {
		var msg = "dotJ Javascript Error: TabContainer '" + this.id + "' is not contained within an HTML <form>.\n\nPlease put it under one before proceeding.";
		alert(msg);
		return false;
	}
	return true;
};

function DotJ_TabContainer(tabContainerId, tabCount, stamp, dhtml) {
	this.checkForForm = DotJ_TabContainer.checkForForm;

	this.tabs = new Array();
	this.id = tabContainerId;
	this.tabCount = tabCount;
	this.form = null;
	this.checkForForm();
	this.stamp = stamp;
	this.dhtml = dhtml;
	this.selectedTabId = 1;

	this.submitFunc = eval('DotJ_' + tabContainerId.replace('.', '_') + '_Submit');
}

DotJ_TabContainer.prototype.addTab = function (tabName){
	this.tabs[this.tabs.length] = tabName;
};

DotJ_TabContainer.prototype.getCSField = function() {
	return eval("this.form.elements['" + this.csFieldName + "']");
};

DotJ_TabContainer.prototype.setClientState = function (command, param1, param2) {
	if (param1 == '') param1 = DotJ_EMPTY_STRING;
	if (param2 == '') param2 = DotJ_EMPTY_STRING;
	var csField = this.getCSField();
	var fixed = 'tab=' + this.id + DotJ_PAIR_DELIMITER +
				'cmd=' + command;

	var selParms = 'p1=' + param1 + DotJ_PAIR_DELIMITER + 'p2=' + param2;
	csField.value = fixed + DotJ_PAIR_DELIMITER + selParms;
};

function DotJ_displayTab(tabContainerId, tabName) {
    var objTabContainer = DotJ_objectArray.get(tabContainerId);

	if (objTabContainer != null) {
		if (objTabContainer.dhtml) {
			for (i = 0; i < objTabContainer.tabs.length; i++) {
				var tabObj = DotJ_getObj(objTabContainer.tabs[i]);
				if (objTabContainer.tabs[i] == tabName) {
					tabObj.style.display = '';
					DotJ_positionFieldValidators(tabName);
				} else {
					tabObj.style.display = 'none';
				}
			}
			objTabContainer.setClientState('select', tabName, '');
		} else {
			objTabContainer.submitFunc(objTabContainer.id, 'select', tabName, '');
		}
	}

	return false;
}

//******************************  IE SHIELD  ******************************

function DotJ_IEShield(shieldId, component) {
	this.id = shieldId;
	this.iframe = DotJ_getObj(this.id);
	this.div = component;
}

DotJ_IEShield.prototype.refresh = function() {
    if (this.iframe != null) {
		this.iframe.style.width=DotJ_getWidth(this.div);
		this.iframe.style.height=DotJ_getHeight(this.div);
	    DotJ_moveTo(this.iframe,DotJ_getX(this.div),DotJ_getY(this.div));
	    DotJ_displayElement(this.iframe);
    }
};

DotJ_IEShield.prototype.hide = function() {
    if (this.iframe != null) DotJ_hideElement(this.iframe);
};

//****************************   DIALOG  *****************************

DotJ_Dialog.onMove = function(type, args) {
	var dialog = args[0].obj;
    if (dialog != null) {
        //if (dialog.shadow != null) dialog.shadow.refresh();
        if (dialog.shield != null) dialog.shield.refresh();
    }
};

function DotJ_Dialog(id, collapsed, movable) {
	this.id = id;
	this.forceCollapse = false;
	this.collapsed = collapsed;
	this.movable = movable;
	this.originalHeight = -1;
	this.divElement = DotJ_getObj(this.id + '_div');
	this.dlgBodyElement = DotJ_getObj(this.id);
	this.shellElement = DotJ_getObj(this.id + '_shell');
	this.hdrElement = DotJ_getObj(this.id + '_hdr');
	this.slideTimer = null;
	this.shield = null;
	this.proxy = null;

	if (this.movable) {
		if (DotJ_is_ie4up && !DotJ_is_ie7up) {
			this.shield = new DotJ_IEShield(this.id + '_IEShield', this.divElement);
		}

        this.proxy = new DotJ_Proxy(this.id + '_div', this.id + '_hdr', this.movable, this,
                                    DotJ_Dialog.onMove, null);
	}

	this.computeOriginalHeight();
}

DotJ_Dialog.prototype.computeOriginalHeight = function () {
	if (this.originalHeight == -1) {
		var curHeight = parseInt(DotJ_getHeight(this.dlgBodyElement));
		this.originalHeight = curHeight;
		this.currentHeight = curHeight;
	}
};

DotJ_Dialog.prototype.expandCollapse = function () {
	if (DotJ_DIALOGBOX_SLIDE_ENABLED) {
		if (DotJ_is_ie) this.dlgBodyElement.style.overflowY="hidden";
		else this.dlgBodyElement.style.overflow="hidden";

		if (this.shellElement) {
			if (DotJ_is_ie) this.shellElement.style.overflowY="hidden";
			else this.shellElement.style.overflow="hidden";
		}
	}

	if (this.collapsed && !this.forceCollapse) {
		this.collapsed = false;
//		if (DotJ_is_ie4up) {
//            this.dlgBodyElement.style.filter="alpha(opacity=1)";
//        }

		this.dlgBodyElement.style.display = "";
		if (DotJ_DIALOGBOX_SLIDE_ENABLED) {
			this.slideTimer = setTimeout("DotJ_slideDown('" + this.id + "')", DotJ_DIALOGBOX_SLIDE_INTERVAL);
		} else {
			if (this.shellElement && this.hdrElement) {
				this.shellElement.style.width=DotJ_getWidth(this.hdrElement);
				this.shellElement.style.height=DotJ_getHeight(this.hdrElement) + DotJ_getHeight(this.dlgBodyElement);
			}
		}
	} else if (this.forceCollapse) {
		this.forceCollapse = false;
		this.collapsed = true;
	    this.currentHeight = parseInt(DotJ_getHeight(this.dlgBodyElement));
		this.opacity = 1;
		this.dlgBodyElement.style.display = "none";
		if (this.shellElement && this.hdrElement) {
			this.shellElement.style.width=DotJ_getWidth(this.hdrElement);
			this.shellElement.style.height=DotJ_getHeight(this.hdrElement);
        }
	} else {
		this.collapsed = true;
		if (DotJ_is_ie4up) {
            this.dlgBodyElement.style.filter="alpha(opacity=100)";
        }
	    this.currentHeight = parseInt(DotJ_getHeight(this.dlgBodyElement));
		this.opacity = 100;
		if (DotJ_DIALOGBOX_SLIDE_ENABLED) {
			this.slideTimer = setTimeout("DotJ_slideUp('" + this.id + "')", DotJ_DIALOGBOX_SLIDE_INTERVAL);
		} else {
			this.dlgBodyElement.style.display = "none";
			if (this.shellElement && this.hdrElement) {
				this.shellElement.style.width=DotJ_getWidth(this.hdrElement);
				this.shellElement.style.height=DotJ_getHeight(this.hdrElement);
            }
		}
	}
};

DotJ_Dialog.prototype.place = function () {
	if (this.shellElement) {
		this.shellElement.style.width = DotJ_getWidth(this.divElement);
		this.shellElement.style.height = DotJ_getHeight(this.divElement);
		var x = DotJ_getX(this.shellElement);
		var y = DotJ_getY(this.shellElement);
		DotJ_moveTo(this.divElement,x,y);
		DotJ_displayElement(this.divElement);
	}
};

//************************************************************************

function DotJ_slideDown(dlgId) {
    var dlgObj = DotJ_objectArray.get(dlgId);
	var increment = dlgObj.currentHeight / DotJ_DIALOGBOX_SLIDE_NUM_INTERVALS;
	var height = parseInt(DotJ_getHeight(dlgObj.dlgBodyElement));
	var newHeight = height + increment;
	dlgObj.opacity = dlgObj.opacity + (100 / DotJ_DIALOGBOX_SLIDE_NUM_INTERVALS);
	DotJ_setOpacity(dlgObj.dlgBodyElement, dlgObj.opacity);

	if (newHeight >= dlgObj.currentHeight) {
		dlgObj.dlgBodyElement.style.height = dlgObj.currentHeight;
		dlgObj.opacity = 100;
		DotJ_setOpacity(dlgObj.dlgBodyElement, -1);
		if (dlgObj.shellElement && dlgObj.hdrElement) {
			dlgObj.shellElement.style.width=DotJ_getWidth(dlgObj.hdrElement);
			dlgObj.shellElement.style.height=DotJ_getHeight(dlgObj.hdrElement) + DotJ_getHeight(dlgObj.dlgBodyElement);
        }
		clearTimeout(dlgObj.slideTimer);
		if (dlgObj.shield != null) dlgObj.shield.refresh();
	} else {
		dlgObj.dlgBodyElement.style.height = newHeight;
		if (dlgObj.shellElement && dlgObj.hdrElement) {
			dlgObj.shellElement.style.height=DotJ_getHeight(dlgObj.hdrElement) + DotJ_getHeight(dlgObj.dlgBodyElement);
        }
		dlgObj.slideTimer = setTimeout("DotJ_slideDown('" + dlgId + "')", DotJ_DIALOGBOX_SLIDE_INTERVAL);
	}
}

function DotJ_slideUp(dlgId) {
    var dlgObj = DotJ_objectArray.get(dlgId);
	var increment = dlgObj.currentHeight / DotJ_DIALOGBOX_SLIDE_NUM_INTERVALS;
	var height = parseInt(DotJ_getHeight(dlgObj.dlgBodyElement));
	var newHeight = height - increment;
	dlgObj.opacity = dlgObj.opacity - (100 / DotJ_DIALOGBOX_SLIDE_NUM_INTERVALS);
	DotJ_setOpacity(dlgObj.dlgBodyElement, dlgObj.opacity);

	if (height < 8 || newHeight < 8) {
		dlgObj.dlgBodyElement.style.display = "none";
		dlgObj.opacity = 1;
		if (dlgObj.shellElement && dlgObj.hdrElement) {
			dlgObj.shellElement.style.width=DotJ_getWidth(dlgObj.hdrElement);
			dlgObj.shellElement.style.height=DotJ_getHeight(dlgObj.hdrElement);
        }
		clearTimeout(dlgObj.slideTimer);
		if (dlgObj.shield != null) dlgObj.shield.refresh();
	} else {
		dlgObj.dlgBodyElement.style.height = newHeight;
		if (dlgObj.shellElement && dlgObj.hdrElement) {
			dlgObj.shellElement.style.height=DotJ_getHeight(dlgObj.hdrElement) + DotJ_getHeight(dlgObj.dlgBodyElement);
        }
		dlgObj.slideTimer = setTimeout("DotJ_slideUp('" + dlgId + "')", DotJ_DIALOGBOX_SLIDE_INTERVAL);
	}
}

//************************   AJAX FUNCTIONS   ************************

function DotJ_AjaxRequest() {
}

var DotJ_handleAjaxFailure = function(o) {
    if (typeof(o.responseText) != 'undefined') {
        alert('dotJ: The ajax operation could not complete successfully.\nError Message:\n' + o.statusText);
    }
};

DotJ_AjaxRequest.prototype.getXml = function(url, callback) {
    this.lastUrl = url;

    if (DotJ_is_ie) {
        var d = new Date();
        var sd = '' + d.getFullYear() + (d.getMonth()+1) + d.getDate() + d.getHours() + d.getMinutes() + d.getSeconds() + d.getMilliseconds();
        url = DotJ_makeNewURL(url, 'dotjax', sd, '');
    }

    YAHOO.util.Connect.asyncRequest('GET', url, callback, '');
};

DotJ_AjaxRequest.prototype.getXmlValue = function(xmlDom, tag) {
    var path = tag.split('/');

    var i, node = xmlDom;
    for (i=0; i < path.length; i++) {
        node = node.getElementsByTagName(path[i]).item(0);
    }

    return (node == null) ? null : node.firstChild.nodeValue;
};

//****************************   LOG/DEBUG FUNCTIONS  *****************************

function DotJ_logDebug(msg) {
    if (DotJ_LOG) {
        var log = DotJ_getObj('dotJ_log');
        if (log != null) {
            DotJ_setText('dotJ_log', log.innerHTML + "<br>" + msg);
        }
    }
}

function DotJ_clearLog() {
    if (DotJ_LOG) {
        var log = DotJ_getObj('dotJ_log');
        if (log != null) {
            DotJ_setText('dotJ_log', "<b><a href='javascript:DotJ_clearLog()'>Clear</a></b><br>");
        }
    }
}

//****************************   OBJECT ARRAY  *****************************
//* Supported thus far:
//*  - DotJ_DesktopAlert
//*  - DotJ_AutoFader
//*  - DotJ_TabContainer
//**************************************************************************

function DotJ_ObjectArray(){
	this.objects = new Array();
}

DotJ_ObjectArray.prototype.add = function (obj) {
    this.objects[this.objects.length] = obj;
};

DotJ_ObjectArray.prototype.get = function(id) {
	for (var i = 0; i < this.objects.length; i++) {
		if (this.objects[i].id == id) {
			return this.objects[i];
		}
	}

	return null;
};

var DotJ_objectArray;
if (typeof(DotJ_objectArray) == 'undefined'){
	DotJ_objectArray = null;
}
if (DotJ_objectArray == null){
	DotJ_objectArray = new DotJ_ObjectArray();
}

//***********************************************************************

// Instantiations
var DotJ_SCROLLBAR_WIDTH;
if (typeof(DotJ_SCROLLBAR_WIDTH) == 'undefined'){
	DotJ_SCROLLBAR_WIDTH = null;
}
if (DotJ_SCROLLBAR_WIDTH == null){
	DotJ_SCROLLBAR_WIDTH = DotJ_getScrollbarWidth();
}

var DotJ_validators;
if (typeof(DotJ_validators) == 'undefined'){
	DotJ_validators = null;
}
if (DotJ_validators == null){
	DotJ_validators = new Array();
}

var DotJ_validateForm;
if (typeof(DotJ_validateForm) == 'undefined'){
	DotJ_validateForm = null;
}

var DotJ_today = new Date();
var DotJ_daysInMonth = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
var DotJ_tipDiv = DotJ_getObj('dotJ_tip');
var DotJ_tipDiv_shield = null;

if (DotJ_is_ie4up && !DotJ_is_ie7up) {
	DotJ_tipDiv_shield = new DotJ_IEShield('dotJ_tip_IEShield', DotJ_tipDiv);
}

var DotJ_ajax = DotJ_makeObject(DotJ_ajax, 'DotJ_AjaxRequest');

//TODO:
// - BUG: forms field errors need an IE shield
// - consolidate onto DotJ_ObjectArray
