// standard form functions

// dropdown keypress matching routines
// onkeypress="listboxKeypress(this);" onblur="listboxBlur(this);"
var jsListboxBuffer = "";
var jsListboxTimeout = "";
var jsListboxCounter = 0;
var jsListboxCounterLimit = 3;
var jsPhoneRE = /^([0-9]{3}\.){2}[0-9]{4}$/;
var jsSSNRE = /^[0-9]{3}\-[0-9]{2}\-[0-9]{4}$/;
var jsEmailRE = /^\w+((\.|\-)\w+)*@\w+(\-\w+)*(\.\w+)+$/;
var jsTimeRE = /^[0-9]{2}:[0-9]{2}$/;

function listboxKeypress(theField){
	if (theField.name == null) theField = event.srcElement;
	window.clearInterval(jsListboxTimeout)
	var keycode = window.event.keyCode;
	if (keycode >= 32) {
		jsListboxBuffer += String.fromCharCode(keycode).toUpperCase(); 
		listboxFind(theField);
		jsListboxTimeout = window.setInterval("listboxIdle()", 325);  
	}
}

function listboxBlur(theField) {
	if (theField.name == null) theField = event.srcElement;
	window.clearInterval(jsListboxTimeout);
	jsListboxBuffer = "";
	//if (theField.onchange) theField.onchange();
}

function listboxIdle(){
	jsListboxCounter += 1
	if(jsListboxCounter > jsListboxCounterLimit) {
		jsListboxBuffer = "";
		jsListboxCounter = 0;
		window.clearInterval(jsListboxTimeout);
	}
}

function listboxFind(theField) {
	if (theField.name == null) theField = event.srcElement;
	var allOptions = theField.options;	
	for (i=0; i < allOptions.length; i++){
		nextOptionText = allOptions(i).text.toUpperCase();
		if(!isNaN(nextOptionText) && !isNaN(jsListboxBuffer) ){
			nextOptionText *= 1;
			jsListboxBuffer *= 1;
		}
		if(jsListboxBuffer == nextOptionText){
			theField.selectedIndex = i;
			window.event.returnValue = false;
			break;
		}
		if(i < allOptions.length-1) {
			lookAheadOptionText = allOptions(i+1).text.toUpperCase() ;
			if ( (jsListboxBuffer > nextOptionText) && (jsListboxBuffer < lookAheadOptionText) ) {
				theField.selectedIndex = i+1;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			}
		} else {
			if (jsListboxBuffer > nextOptionText) {
				theField.selectedIndex = allOptions.length-1;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			}
		}
	}
}

// TextBox tab capturing
// set the BODY tag's onMouseUp function to call tabClear();
// set the textarea onFocus to "window.self.tabFocus=this;" 
// set the textarea onKeydown to "tabCapture(this);"

function tabClear() {
	if (window.self.tabFocus) {
		window.self.tabFocus.onblur = null;
		window.self.tabFocus = null;
	} 
	
}

function tabCapture (obj) {
	if (!window.self.workingObj) window.self.workingObj  = new Object();
	if (!window.self.workingId) window.self.workingId  = new Object();
	if (!window.self.tabMode) window.self.tabMode = new Object();

	if (new String(tabMode[event.srcElement.id]) == 'undefined') tabMode[event.srcElement.id] = false;
	// status = event.srcElement.id + '.TabMode = ' + tabMode[event.srcElement.id] + ' ' + event.keyCode;
	status = "Press Ctrl-M to turn tab capturing " + ((tabMode[event.srcElement.id]) ? "off" : "on");
	window.self.theRange = document.selection.createRange();
	window.self.workingObj[obj.id] = obj;
	window.self.workingId[obj.id] = obj.id;
	
	if (event.keyCode == 9 && tabMode[event.srcElement.id]) {
		workingObj[event.srcElement.id].onblur = function anonymous () {
			this.focus();
			theRange.select();
		}
		theRange.text = "\t";
	}
	if (! tabMode[event.srcElement.id]) {
		if (workingObj[event.srcElement.id]) workingObj[event.srcElement.id].onblur = null;
	}
	if (event.keyCode == 77 && event.ctrlKey) {
		tabMode[event.srcElement.id] = !tabMode[event.srcElement.id];
		status = "Press Ctrl-M to turn tab capturing " + ((tabMode[event.srcElement.id]) ? "off" : "on");
//		status = 'TabMode = ' + tabMode[event.srcElement.id];
	}
}

// Dropdown redrawing functions
function EditTypes(dropdownList)
{
	if (dropdownList.options[dropdownList.selectedIndex].text == "<< Edit >>") 
	{
		dropdownList.selectedIndex = 0;
		editWindow = window.open(document.qbo.Application + "/Design/ObjectSelect.aspx?Object=" + dropdownList.ObjectType);
//				var results = document.qbo.textFromUrl("/Report/ExecuteProcedure.aspx?SP=pObjectTypeList&Object=" + dropdownList.ObjectType);
//				alert(results);
		dropdownList.attachEvent("onfocus", RefreshTypes);
	}
}
function RefreshTypes(dropdownList)
{
	dropdownList = event.srcElement;
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pObjectTypeList&Object=" + dropdownList.ObjectType);
	dropdownList.detachEvent("onfocus", RefreshTypes);
	DropdownRefresh(dropdownList, results, "//DataItem", "ObjectType", "ObjectType", "Select a Type >>");
	DropdownAppend(dropdownList, "<< Edit >>", "");	
}
function DropdownAppend(dropdownList, text, value)
{
	dropdownList.options.length++;
	dropdownList.options[dropdownList.options.length-1].text = text;
	if (value != null) dropdownList.options[dropdownList.options.length-1].value = value;
}
function DropdownRefresh(dropdownList, xml, xpathCollection, xpathValue, xpathText, firstItem)
{
	if (xpathText == null) xpathText = xpathValue;
	var nodeList = xml.selectNodes(xpathCollection);
	dropdownList.options.length = 0;
	if (firstItem != null) DropdownAppend(dropdownList, firstItem, "");
	for (var i=0; i<nodeList.length; i++)
	{
		DropdownAppend(dropdownList, nodeList[i].selectSingleNode(xpathText).text, nodeList[i].selectSingleNode(xpathValue).text);
	}
}

// Address lookup functions
function PostalCodeLookup(postalCode)
{
	with (postalCode.form) 
	{
		var results = document.qbo.xmlFromUrl("/Contact/PostalCodeLookup.aspx?PostalCode=" + postalCode.value.substring(0, 5));
		var firstNode = results.selectSingleNode("//DataItem");
		if (firstNode != null)
		{
			city = postalCode.name.replace("PostalCode", "City");
			state = postalCode.name.replace("PostalCode", "State");
			elements[city].value = firstNode.selectSingleNode("City").text;
			document.qbo.dropdownSetValue(elements[state], firstNode.selectSingleNode("State").text);
		}
	}
}
function PostalCodeAutoFill(postalCode)
{
	if (event.altKey) PostalCodeLookup(postalCode);
}


function progressBarAdjust() 
{
	progressImage.dotCount = parseInt(progressImage.dotCount) + 1;
	if (progressImage.dotCount > 20) progressImage.dotCount = 1;
	theDots = "";
	for (var i=0; i<progressImage.dotCount; i++) theDots += ". ";
	progressImage.innerHTML = "<h1><br/>  " + document.progressBarMessage + "  <br/>  " + theDots + "</h1>";
	window.status = progressImage.dotCount;
	setTimeout("progressBarAdjust()", 250);
}
function progressBar(theForm, theMessage) 
{
	if (theMessage == null) theMessage = "Saving. Please Wait";
	document.progressBarMessage = theMessage;
	with (theForm) {
		var progressElement = document.createElement("DIV");
		progressElement.id = "progressImage";
		progressElement.className = "progressBar";
		progressElement.style.position = "absolute";
//		alert(document.body.offsetHeight + ", " + document.body.clientHeight);
		progressElement.style.posLeft = document.body.clientWidth/2 - 150;
		progressElement.style.posTop = document.body.clientHeight - 300;
		progressElement.style.backgroundColor = "white";
		progressElement.style.border = "2px groove blue";
		progressElement.dotCount = 1;
		progressElement.innerHTML = "<h1><br/>" + document.progressBarMessage + "<br/></h1>";
		theForm.appendChild(progressElement);
		setTimeout("progressBarAdjust();", 10);
		for (var i=0; i<elements.length; i++) 
		{
			if ((elements[i].type == "button") || (elements[i].type == "submit"))
			{
//				elements[i].disabled = true;
			}
		}
	}
}
function progressBarDisplay()
{
	var args = "dialogHeight:100px;";
	args += "dialogWidth:350px;";
	args += "edge:sunken;";
	args += "unadorned:1;";
	args += "status:0;";
	args += "resizable:0;";
	result = showModelessDialog(document.qbo.Application + "/Library/ProgressDialog.html", document.progressBarMessage, args);
}
function progressBar(theForm, theMessage) 
{
	if (theMessage == null) theMessage = "Saving. Please Wait";
	document.progressBarMessage = theMessage;
//	setTimeout("progressBarDisplay();", 10);
}

function popupHelp(theUrl)
{
	alert(theUrl.indexOf("?"));
	if (theUrl.indexOf("?") >= 0) theUrl += "&ApplicationPage=" + document.location.pathname;
	else theUrl += "?ApplicationPage=" + document.location.pathname;
	return(popupWindow(theUrl));
}
function popupWindow(theUrl)
{
	document.qbo.WindowPopup = window.open(theUrl, "WindowPopup", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=450");
	document.qbo.WindowPopup.focus();
	//return(false);
}
function popupNew(theUrl)
{
	document.qbo.WindowPopup = window.open(theUrl, "WindowPopup", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=450");
}

function popupNew(theUrl, height, width)
{
	document.qbo.WindowPopup = window.open(theUrl, "WindowPopup", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
}

function isNull(value, theDefault) 
{
	return((value == null) ? theDefault : value);
}
function searchButtonClick(theSearchButton) 
{
	with (theSearchButton.form) 
	{
		var theValue = SearchString.value;
		if (theValue.substring(theValue.length-1, theValue.length) != "%") SearchString.value += "%";
	}
}
function formExecuteMethod(theMethod, theForm, theItem) 
{
   	if (theForm == null) theForm = document.forms[0];
   	if (theItem != null) 
   	{
		if (!isChecked(theItem)) 
		{
			alert("You must select at least one item to " + theMethod + ".");
			return;
		}
   	}
	theForm.action = document.qbo.urlAddParameter(theForm.action, "ExecuteMethod", theMethod);
	theForm.submit();
}
function formSearchSuggest(theForm) 
{
	with (theForm) 
	{
	    var searchElement = SearchString;
		var theValue = searchElement.value;
		if (theValue.substring(theValue.length-1, theValue.length) != "%") searchElement.value += "%";
	}
}
var ResetStartPosition = true;
function formSubmit(recordStart, theForm) 
{
	if (theForm == null) theForm = document.forms[0];
	with (theForm) 
	{
		RecordStart.value = recordStart;
		ResetStartPosition = false;
		try 
		{
			btnSearch.click();
		} 
		catch(e) 
		{
			submit();
		}
	}
}

function formSortBy(sortOrder, theForm) 
{
	if (theForm == null) theForm = document.forms[0];
	with (theForm) 
	{
		if (SortBy.value == sortOrder)
			SortBy.value = "-" + sortOrder;
		else if (SortBy.value == "-" + sortOrder)
			SortBy.value = sortOrder;
		else 
			SortBy.value = sortOrder;
		if ((elements["btnSearch"] != null) && (btnSearch.disabled == false))
			btnSearch.click();
		else if (elements["btnAdvanceSearch"] != null)
			btnAdvanceSearch.click();
		else
		{
			fireEvent("onsubmit");
			submit();
		}
	}
}

function SetPagination(element) 
{
	var displaySize = element.innerHTML;
	var form = getParentElement(element, "FORM");
	var buttons = form.all.tags("input");
	for (var submit=0; submit!=buttons.length; submit++)
	{
		if (buttons[submit].type == "submit")
			break;
	}
	var displayElement = form.elements["DisplaySize"];
	if (displayElement == null)
		return(window.status = "No 'DisplaySize' element found in form.");
	if (isNaN(displaySize))
	{
		alert("'" + displaySize  + "' is not a valid dislay size.");
		element.innerHTML = (displayElement.value == "") ? element.displaySize : displayElement.value;
		return;
	}
	displayElement.value = displaySize;
	if (parseInt(element.recordBegin) + parseInt(displaySize) > parseInt(element.recordCount))
		form.elements["RecordStart"].value = "0";
	if ((displaySize != element.displaySize) && (confirm("Redraw this page now?"))) 
	{
		if (submit != buttons.length)
			buttons[submit].click();
		else 
			form.submit();
	}
}

function SetPanelPagination(element) 
{
	var displaySize = element.innerHTML;
//	var recordStart = element.recordStart;
	var tag = getParentElement(element, "DIV");
	tag.ObjectPanel.SetParameter("//DisplaySize", displaySize);
//	tag.ObjectPanel.SetParameter("//RecordStart", recordStart);
	tag.ObjectPanel.List();
//	alert(tag.ObjectPanel);
	return;
	var buttons = form.all.tags("input");
	for (var submit=0; submit!=buttons.length; submit++)
	{
		if (buttons[submit].type == "submit")
			break;
	}
	var displayElement = form.elements["DisplaySize"];
	if (displayElement == null)
		return(window.status = "No 'DisplaySize' element found in form.");
	if (isNaN(displaySize))
	{
		alert("'" + displaySize  + "' is not a valid dislay size.");
		element.innerHTML = (displayElement.value == "") ? element.displaySize : displayElement.value;
		return;
	}
	displayElement.value = displaySize;
	if (parseInt(element.recordBegin) + parseInt(displaySize) > parseInt(element.recordCount))
		form.elements["RecordStart"].value = "0";
	if ((displaySize != element.displaySize) && (confirm("Redraw this page now?"))) 
	{
		if (submit != buttons.length)
			buttons[submit].click();
		else 
			form.submit();
	}
}

// DHTML functions
function getParentElement(theElement, theTagName) 
{
	if (theTagName == null) return(theElement.parentElement);
	if (theElement.tagName == theTagName) return(theElement);
	else if (theElement.parentElement != null) return(getParentElement(theElement.parentElement, theTagName));
	else return(null);
}

function getChildElement(theElement, theTagName) {
	for (var i=0; i<theElement.childNodes.length; i++) {
		currentElement = theElement.childNodes(i);
		if (currentElement.tagName == theTagName) return(currentElement);
		getChildElement(currentElement, theTagName);
	}
	return(null);
}

function getParentTable(theElement) {
	return(getParentElement(theElement, "TABLE"));
}

function toggleCheckbox(theElementName, theForm)
{
	if (theForm == null) theForm = document.forms[0];
	with (theForm) 
	{
		for (var i=0; i<theForm.elements.length; i++) 
		{
			if ((elements[i].name == theElementName) && (elements[i].disabled != true)) 
				elements[i].checked = !elements[i].checked;
		}
	}
}
function toggleCheckboxPattern(pattern, theForm)
{
	if (theForm == null) theForm = document.forms[0];
	with (theForm) 
	{
		for (var i=0; i<theForm.elements.length; i++) 
		{
			if (elements[i].name.indexOf(pattern)!= -1) elements[i].checked = !elements[i].checked;
		}
	}
}
function isChecked(theElementName, theForm) {
	if (theForm == null) theForm = document.forms[0];
	theElementList = theForm.elements;	//document.all[theElementName];
	for (var i=0; i<theElementList.length; i++) {
		if ((theElementList[i].name == theElementName) && (theElementList[i].checked)) return(true);
	}
	return(false);
}
function clearFormAction(theForm) {
	if (theForm == null) theForm = document.forms[0];
	theForm.action = document.location.pathname;
}
function toggleDisplay(theObject, theImage, theTagType) 
{
	theTagCollection = (theTagType != null) ? document.all.tags(theTagType) : document.all.tags("TR");
	for (i=0; i<theTagCollection.length; i++) {
		if (theTagCollection[i].id == theObject) {
			if (theTagCollection[i].style.display == "inline" || theTagCollection[i].style.display == "") {
				theTagCollection[i].style.display = "none";
				if (theImage != null) document.images[theImage].src = document.images[theImage].src.replace("Collapse", "Expand");
			} else {
				theTagCollection[i].style.display = "inline";
				if (theImage != null) document.images[theImage].src = document.images[theImage].src.replace("Expand", "Collapse");
			}
		}
	}
	
	FooterAlign();
}
function SwapAttachment(theObject)
{
	var uploadFile = document.all[theObject + "_UploadFile"];
	var serverFile = document.all[theObject + "_ServerFile"];
	if (uploadFile.style.display == "none") 
	{
		serverFile.style.display = "none";
		uploadFile.style.display = "inline";
	}
	else
	{
		uploadFile.style.display = "none";
		serverFile.style.display = "inline";
	}
}
function displayTags(theObject, theImage, theTagType) 
{
	theTagCollection = (theTagType != null) ? document.all.tags(theTagType) : document.all.tags("TR");
	for (i=0; i<theTagCollection.length; i++) {
		if (theTagCollection[i].id == theObject) {
			theTagCollection[i].style.display = "inline";
			if (theImage != null) document.images[theImage].src = document.images[theImage].src.replace("Expand", "Collapse");
		}
	}
}
function hideTags(theObject, theImage, theTagType) 
{
	theTagCollection = (theTagType != null) ? document.all.tags(theTagType) : document.all.tags("TR");
	for (i=0; i<theTagCollection.length; i++) {
		if (theTagCollection[i].id == theObject) {
			theTagCollection[i].style.display = "none";
			if (theImage != null) document.images[theImage].src = document.images[theImage].src.replace("Collapse", "Expand");
		}
	}
}
function showMenu(menuElement, tagName)
{
	if (menuElement == null)
		menuElement = getParentElement(event.srcElement, "TABLE");
	if (tagName == null)
		tagName = "TH";
	var menuItems = menuElement.all.tags(tagName);
	for (var i=0; i<menuItems.length; i++)
	{
	    if (menuItems[i].className.indexOf("elected") > 0)
	    {
	        if (menuItems[i] == event.srcElement)
	        {
		        if (menuItems[i].className.indexOf("Unselected") > 0)
			        menuItems[i].className = menuItems[i].className.replace("Unselected", "Selected");
	        }
	        else
	        {
		        if (menuItems[i].className.indexOf("Selected") > 0)
			        menuItems[i].className = menuItems[i].className.replace("Selected", "Unselected");
	        }
	    }
	}
}
function showPanel(thePanel, thePrefix, tagArray)
{
	if (thePrefix == null) thePrefix = "Panel"
	if (tagArray == null) tagArray = new Array("TABLE");
	for (var j=0; j<tagArray.length; j++)
	{
		theTagCollection = document.all.tags(tagArray[j]);
		for (i=0; i<theTagCollection.length; i++) {
			if (theTagCollection[i].id.substring(0, thePrefix.length) == thePrefix) 
			{
				theTagCollection[i].style.display = (theTagCollection[i].id == thePrefix + thePanel) ? "block" : "none";
			}
		}
	}
}
function toggleLoanDisplay(theObject, theImage, theTagType, theApplicationRoot) {
	theTagCollection = (theTagType != null) ? document.all.tags(theTagType) : document.all.tags("TR");
	for (i=0; i<theTagCollection.length; i++) {
		if (theTagCollection[i].id == theObject) {
			if (theTagCollection[i].style.display == "inline") {
				theTagCollection[i].style.display = "none";
				if (theImage != null) theImage.src = theImage.src.replace("Collapse", "Expand");
			} else {
				theTagCollection[i].style.display = "inline";
				if (theImage != null) theImage.src = theImage.src.replace("Expand", "Collapse");
			}
		}
	}
}
function toggleRowDisplay(theObject, theImage, theTagType, theApplicationRoot) {
	theTagCollection = (theTagType != null) ? document.all.tags(theTagType) : document.all.tags("TR");
	for (i=0; i<theTagCollection.length; i++) {
		if (theTagCollection[i].id == theObject) {
			if (theTagCollection[i].style.display == "inline") {
				theTagCollection[i].style.display = "none";
				if (theImage != null) theImage.src = theImage.src.replace("Collapse", "Expand");
			} else {
				theTagCollection[i].style.display = "inline";
				if (theImage != null) theImage.src = theImage.src.replace("Expand", "Collapse");
			}
		}
	}
}
function sizeToParent(theElement, theParent)
{
	if (theParent == null) theParent = getParentElement(theElement);
	theElement.style.height = theParent.clientHeight;
	theElement.style.width = theParent.clientWidth;
	theElement.style.display = "block";
}
function sizeToParentWidth(theElement, theParent)
{
	if (theParent == null) theParent = getParentElement(theElement);
	theElement.style.width = theParent.clientWidth;
	theElement.style.display = "block";
}
function sizeToSelf(theElement)
{
	var cache = theElement.style.display;
	theElement.style.display = "inline";
	// theElement.style.height = theElement.clientHeight;
	theElement.style.width = theElement.clientWidth;
	theElement.style.display = cache;
}
function qboWebService(soapMethod, soapNamespace, payload) {
	this.addElement = function(theName, theText, theParent) {
		if (theParent == null) theParent = this.method;
		if (this.needsCdata(theText)) {
			theNewNode = theParent.ownerDocument.createNode(1, theName, "");
			theCdataNode = theParent.ownerDocument.createNode(4, theName + "Cdata", "");
			theCdataNode.text = theText;
			if (theText != null) theNewNode.insertBefore(theCdataNode, null);
		} else {
			//theNewNode = theParent.ownerDocument.createNode(1, theName, "");
			theNewNode = this.message.createNode(1, theName, "");
			if (theText != null) theNewNode.text = theText;
		}
		return(theParent.insertBefore(theNewNode, null));
	}
	this.addNode = function(theNodeXml, theParent) {
		if (theParent == null) theParent = this.method;
			//theNewNode = theParent.ownerDocument.createNode(1, theName, "");
//		theNewNode = this.message.createNode(1, theName, "");
//		if (theNodeXml != null) theNewNode.xml = theNodeXml;
		return(theParent.insertBefore(theNodeXml, null));
	}
	
	this.needsCdata = function(theValue) {
		if (theValue == null) return(false);
		if (new String(theValue).indexOf("&") > 0) return(true);
		if (new String(theValue).indexOf("<") > 0) return(true);
		if (new String(theValue).indexOf(">") > 0) return(true);
		return(false);
	}
	this.execute = function(methodParameter) 
	{
		if (methodParameter != null)
		{
			// this.addElement(this.method, methodParameter.xml, 
		}
		theURL = "http://www.webservicex.net/CurrencyConvertor.asmx";
		if (this.SOAPAction == null)
			this.SOAPAction = this.SOAPNamespace + "/" + this.SOAPMethod;		
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.Open("POST", this.SOAPUrl, false);

		xmlhttp.setRequestHeader("Content-Type", "text/xml");

		// alert("Content length is " + this.message.xml.length);
		xmlhttp.setRequestHeader("Content-Length", this.message.xml.length);
		xmlhttp.setRequestHeader("SOAPAction", this.SOAPAction);
		xmlhttp.Send(this.message.xml);
		// xmlhttp.Send();
		try {
			var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = false;
			xmlDoc.loadXML(xmlhttp.responseText);
			return(xmlDoc);
		} catch(e) {
			alert(e.description + "\n\n" + xmlhttp.responseText);
		}	
	}
	

	theMessage = new ActiveXObject("Microsoft.XMLDOM");
	theMessage.loadXML("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body/></soap:Envelope>");
	theMessage.addNameSpace;
	this.message = theMessage;
	this.SOAPMethod = soapMethod;
	this.SOAPNamespace = soapNamespace;
	if (this.SOAPNamespace == null) this.SOAPNamespace = "http://tempuri.org/";
	this.body = this.message.selectSingleNode("//soap:Body");
	this.SOAPUrl = null;
	this.SOAPAction = null;
	this.addElement(this.SOAPMethod, null, this.body);
	this.method = this.message.selectSingleNode("//" + this.SOAPMethod);
	this.method.insertBefore(payload.documentElement, null);
	
	this.method.setAttribute("xmlns", this.SOAPNamespace);
//	this.addElement("soap:Body");
}
// file functions
function uploadFile(theElement, theFileControl) {
	theFile = new qboWebService(theFileControl);
	theMethod = theFile.addElement("imageInsert", null, theFile.body);
	theImage = theFile.addElement("theImageXML", null, theMethod);
	theFile.addElement("Description", "This is a test", theImage);
	theFile.addElement("AboImage", "New Document name", theImage); 
	alert(theFile.message.xml);
}
// validation functions
function validateAction(theName, theForm)
{
	if (theForm == null) theForm = document.forms[0];
	with (theForm)
	{
  		if (Action.selectedIndex == 0)
  		{
	   		alert("You must select an action before clicking Go!");
	   		return(false);
		}
		else 
		{
			theAction = Action.options[Action.selectedIndex].value;
		}
		isSelected = false;
		for (i=0; i<elements.length; i++)
		{
			if (elements[i].name == theName)
			{
				if (isSelected = elements[i].checked) break;
			}
		}
		if (!isSelected)
		{
			alert("You must check at least one checkbox before clicking Go!");
			return(false);
		}
	}
	return(confirm("Are you sure you want to " + theAction + " these items?"));
}

function submitAction(theParentElementName, theForm)
{
	if (theForm == null) theForm = document.forms[0];
	if (validateAction(theParentElementName, theForm))
	{
		theForm.submit();
	}
}

function validateRE(element, reText, message) {
	re = new RegExp(reText);
	if (message == null) message = "Please re-enter.";
	if ((element.value > "") && (!re.test(element.value)))
	{
		alert("'" + element.value + "' is not a valid value. " + message);
		element.value = element.defaultValue;
	}
}

function qboEnvironment() 
{
	this.dateFormat = "MM/DD/YYYY";
	this.today = new Date();
	this.integer = /^([0-9]||[-]||[+])*$/;
	this.decimal = /^([0-9]||[.]||[-]||[+])*$/;
	this.baseURL = document.location.protocol + "//" + document.location.hostname;
	this.debug = false;
	this.trustedSite = null;
	this.classXML = "Microsoft.XMLDOM";
	this.classXMLHTTP = "Microsoft.XMLHTTP";
	this.checkboxChecked = false;
	
	this.calendarLoaded = false;
	this.connectionString = null;
	
	this.LoginTimeout = 17; // Minutes before the Login prompt is displayed
	this.LogoutPrompt = 90; // Seconds the Logout prompt remains viaible
	this.WebServiceTag = null;
	this.WebServiceArray = new Array();
	window.attachEvent("onload", this.SetBehaviors);
	window.attachEvent("onload", this.SetDefaultLabels);
	window.attachEvent("onload", this.AddSmartWorklistOption);
//	window.attachEvent("onbeforeunload", this.SmartWorklistPopUp);
	window.attachEvent("onload", this.LoadMRU);
//	window.attachEvent("onbeforeunload", this.MaskUI);
}
qboEnvironment.prototype.SetLinkMRU = function(element)
{
	if (!this.MRUFlag) return;
	var links = ((element == null) || (element.all == undefined)) ? document.all.tags("a") : element.all.tags("a");
	for (var i=0; i<links.length; i++)
	{
		if (links[i].mru != null)
			links[i].attachEvent("onclick", function anon() {document.qbo.AddLinkMRU();});
	}
}
qboEnvironment.prototype.AddLinkMRU = function(link)
{
	if (!this.MRUFlag) return;
	if (link == null) link = event.srcElement;
	// this.setCookie(mru, link.href, null, "/");
	var mrulist = this.MRUXml.selectNodes("//MRUItem");
	for (var i=0; i<mrulist.length; i++)
	{
		if (mrulist[i].getAttribute("href") == link.href)
		{
			mrulist[i].text = (link.mru == null) ? link.innerHTML : link.mru;
			break;
		}
	}
	if (i == mrulist.length)
	{
		if (mrulist >= 5) 
		{
			this.MRUXml.documentElement.removeChild(this.MRUXml.documentElement.firstChild);
		}

		var item = this.MRUXml.createNode(1, "MRUItem", "");
		item.text = (link.mru == null) ? link.innerHTML : link.mru;
		item.setAttribute("href", link.href);
		this.MRUXml.documentElement.appendChild(item);
	}
	this.MRUDiv.setAttribute("sPersistValue", this.MRUXml.xml);
	this.MRUDiv.save("oXMLStore");
	
}
qboEnvironment.prototype.CreateMRU = function()
{
	if (this.MRUXml == null)
	{
		this.MRUXml = new ActiveXObject("Microsoft.XMLDOM");
		this.MRUXml.loadXML("<MURList/>");
	}
	if (this.MRUDiv == null)
	{
		this.MRUDiv = document.getElementById("MRUDiv");
		if (this.MRUDiv == null)
		{
			this.MRUFlag = false;
			window.status = "Most recently used list not supported by this skin.";
//			this.MRUDiv = document.createElement("<div id=\"MRUDiv\" style=\"behavior:url(#default#userdata)\"/>");
//			alert(this.MRUDiv);
//			// this.MRUDiv.id = "MRUDiv";
//			alert(this.MRUDiv.id);
//			//this.MRUDiv.style.behavior = "url(#default#userdata)";
//			alert(this.MRUDiv.style.behavior);
//			alert(this.MRUDiv.outerHTML);
		}
		else
			window.status = "Most recently used list loaded.";
	}
}
qboEnvironment.prototype.LoadMRU = function()
{
	if (this.today == null) return document.qbo.LoadMRU();
	this.MRUFlag = true;
	this.CreateMRU();
	if (!this.MRUFlag) return;
	this.SetLinkMRU();
	this.MRUDiv.load("oXMLStore");
	if (this.MRUDiv.getAttribute("sPersistValue") != null)
	{
		this.MRUXml.loadXML(this.MRUDiv.getAttribute("sPersistValue"));
		var mrulist = this.MRUXml.selectNodes("//MRUItem");
		this.AddCommand("---", "#");
		for (var i=0; i<mrulist.length; i++)
		{
			this.AddCommand(mrulist[i].text, mrulist[i].getAttribute("href"));
		}
	}
	else
		this.MRUXml.loadXML("<MRUList/>");
}

// Message Object Functions
function MessageObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "MessageObject";
	ob.SelectXslt = "/Templates/Message/MessageSelect.xslt";
	ob.ListXslt = "/Templates/Message/MessageList.Ajax.xslt";
	ob.WebServiceUrl = "/Message/MessageService.asmx";
	ob.SortBy = "Message";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.MessageID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.Edit = function()
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		if (this.WebService.ObjectBaseService)
		{
		    var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "Edit", this.ClassName, this.ReadXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
		}
	}
	ob.ReadXml = function()
	{
		var objectXml = "<MessageCollection>";
		objectXml += "<MessageItem>";
		
		if (this.MessageID != null) objectXml += "<MessageID>" + this.MessageID + "</MessageID>";
		if (this.Message != null) objectXml += "<Message>" + this.Message + "</Message>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "</Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "</ObjectID>";
		if (this.MessageType != null) objectXml += "<MessageType>" + this.MessageType + "</MessageType>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.Priority != null) objectXml += "<Priority>" + this.Priority + "</Priority>";
		if (this.SecureDelivery != null) objectXml += "<SecureDelivery>" + this.SecureDelivery + "</SecureDelivery>";
		if (this.FromAddress != null) objectXml += "<FromAddress>" + this.FromAddress + "</FromAddress>";
		if (this.FromName != null) objectXml += "<FromName>" + this.FromName + "</FromName>";
		if (this.FromContactID != null) objectXml += "<FromContactID>" + this.FromContactID + "</FromContactID>";
		if (this.DateAdded != null) objectXml += "<DateAdded>" + this.DateAdded + "</DateAdded>";
		if (this.BodyText != null) objectXml += "<BodyText>" + this.BodyText + "</BodyText>";
		if (this.BodyHTML != null) objectXml += "<BodyHTML>" + this.BodyHTML + "</BodyHTML>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		objectXml += "</MessageItem>";
		objectXml += "</MessageCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	this.Refresh = function(result)
	{
	alert("Response Result");
		if ((result != null) && (result.error))
		{
			alert(result.errorDetail.string);
			return false;
		}
		if (this.WebServiceUrl == null) 
		{
			window.status += " In Refresh";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				window.status = "ObjectBase.Refresh was called after a web service call completed, but the result.id (" + result.id + ") was not found in document.qbo.WebServiceArray (length is " + document.qbo.WebServiceArray.length + "). \nEnsure the object that called the web service binds itself to document.qbo.WebServiceArray as soon as the web service is called." + result.id;
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].Refresh(result);
		}
		if (this.RefreshMethod != null)
			this.RefreshMethod();
		else
			this.Trace("Refresh method is not defined");
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.ParentID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.ParentID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Message list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for MessageObject.ListXhtml");
		}
	}


	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
	if (xml == null) return;
	base.WriteXml(xml);
	
		if (xml.selectSingleNode("//MessageID") != null) this.MessageID = xml.selectSingleNode("//MessageID").text;
		if (xml.selectSingleNode("//Message") != null) this.Message = xml.selectSingleNode("//Message").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//MessageType") != null) this.MessageType = xml.selectSingleNode("//MessageType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//Priority") != null) this.Priority = xml.selectSingleNode("//Priority").text;
		if (xml.selectSingleNode("//SecureDelivery") != null) this.SecureDelivery = xml.selectSingleNode("//SecureDelivery").text;
		if (xml.selectSingleNode("//FromAddress") != null) this.FromAddress = xml.selectSingleNode("//FromAddress").text;
		if (xml.selectSingleNode("//FromName") != null) this.FromName = xml.selectSingleNode("//FromName").text;
		if (xml.selectSingleNode("//FromContactID") != null) this.FromContactID = xml.selectSingleNode("//FromContactID").text;
		if (xml.selectSingleNode("//DateAdded") != null) this.DateAdded = xml.selectSingleNode("//DateAdded").text;
		if (xml.selectSingleNode("//BodyText") != null) this.BodyText = xml.selectSingleNode("//BodyText").text;
		if (xml.selectSingleNode("//BodyHTML") != null) this.BodyHTML = xml.selectSingleNode("//BodyHTML").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "MessageID"] != null) 
		{
			this.MessageID = form.elements[prefix + "MessageID"].value;
		}
		if (form.elements[prefix + "Message"] != null) 
		{
			this.Message = form.elements[prefix + "Message"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "MessageType"] != null) 
		{
			this.MessageType = form.elements[prefix + "MessageType"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "Priority"] != null) 
		{
			this.Priority = form.elements[prefix + "Priority"].value;
		}
		if (form.elements[prefix + "SecureDelivery"] != null) 
		{
			this.SecureDelivery = form.elements[prefix + "SecureDelivery"].value;
		}
		if (form.elements[prefix + "FromAddress"] != null) 
		{
			this.FromAddress = form.elements[prefix + "FromAddress"].value;
		}
		if (form.elements[prefix + "FromName"] != null) 
		{
			this.FromName = form.elements[prefix + "FromName"].value;
		}
		if (form.elements[prefix + "FromContactID"] != null) 
		{
			this.FromContactID = form.elements[prefix + "FromContactID"].value;
		}
		if (form.elements[prefix + "DateAdded"] != null) 
		{
			this.DateAdded = form.elements[prefix + "DateAdded"].value;
		}
		if (form.elements[prefix + "BodyText"] != null) 
		{
			this.BodyText = form.elements[prefix + "BodyText"].value;
		}
		if (form.elements[prefix + "BodyHTML"] != null) 
		{
			this.BodyHTML = form.elements[prefix + "BodyHTML"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}

	return ob;
}
// Message Object End

// SmartWorklist Functions 
qboEnvironment.prototype.AddSmartWorklistOption = function()
{
	var cookieUrl = document.qbo.getCookie("qbo.SmartWorkListMember.UrlCookie");
	if (cookieUrl != null)
	{
		if (cookieUrl.indexOf("&ReferringPage=") > 0)
			cookieUrl = cookieUrl.substring(0, cookieUrl.indexOf("&ReferringPage="));
		var commandXml = document.getElementById('OptionXml_CommandBar');
		if(commandXml != null)
		{
            //Adds for all pages except Login page, if an smartWorklistmember is assigned
            var loginIndex = document.location.pathname.indexOf("Login.aspx");
            if((loginIndex == -1) && (cookieUrl != unescape(document.location)))
            {
                document.qbo.AddCommand("View Current Item","/Decision/SmartWorklistAssignByPerson.aspx?Action=Assign","Click to Navigate to the Current SmartWorklistMember Item");
            }
            var location = unescape(document.location);
			if (location.indexOf("&ReferringPage=") > 0)
				location = location.substring(0, location.indexOf("&ReferringPage="));
            
			if(cookieUrl == location)
			{
				alert(cookieUrl +"\n"+location);
				// We are on a SmartWorklistMember
				var swbar = document.getElementById("SmartWorklistBar");
				var pathName = document.location.pathname;
				var barInfo;
				if (pathName.indexOf("Edit") == -1)
				{
					if (swbar != null)
					{
						swbar.style.display = "inline";
//						// document.getElementById("SmartWorklistBarRow").style.display = "inline";
//						barInfo = "<table border='0'><tr><td align='right'></td>";
//						barInfo = "<td align='right'><input name='chkNext' type='checkbox' checked='checked' onclick=\"javascript:document.qbo.NextItemOption('chkNext','chkBatchAssign');\"/>Get Next Item";
//						var SmartWorklistBatchSizeCookie = document.qbo.getCookie("qbo.SmartWorkListMember.BatchSizeCookie");
//						if(SmartWorklistBatchSizeCookie!=null)
//							barInfo += "<input name='chkBatchAssign' type='checkbox' onclick=\"javascript:document.qbo.NextItemOption('chkBatchAssign','chkNext');\" />Get next "+((SmartWorklistBatchSizeCookie!=null)?SmartWorklistBatchSizeCookie:"X") +" items  ";
//						barInfo += "<input type=button class='button' value='Complete' onclick=\"javascript:SmartWorklistMemberCompleteOrSkip('complete','chkNext','chkBatchAssign');\"/>";
//						barInfo += "<input type=button class='button' value='Skip' onclick=\"javascript:SmartWorklistMemberCompleteOrSkip('skip','chkNext','chkBatchAssign');\"/></td></tr></table>";
//						swbar.innerHTML = barInfo;
					}
					else 
						window.status = "SmartWorklist Bar is not set in this skin";
					document.getElementById("CommandBarOptionMenu").style.color="red";
				}
			}
			else window.status = "This is not your current Smart Worklist item.";
		}
	}
}
qboEnvironment.prototype.NextItemOption = function(chk1,chk2)
{
        var chk1 = document.getElementById(chk1);
        var chk2 = document.getElementById(chk2);
        if(chk1.checked)
        (chk2!=null)?chk2.checked=false:null;
}

function SmartWorklistMemberCompleteOrSkip(action,chk1,ckk2)
{
	var chkNext = document.getElementById(chk1);
	var chkBatchAssign = document.getElementById(ckk2);
	var cookieUrl = document.qbo.getCookie("qbo.SmartWorkListMember.UrlCookie");
	if (cookieUrl.indexOf("&ReferringPage=") > 0)
		cookieUrl = cookieUrl.substring(0, cookieUrl.indexOf("&ReferringPage="));
	if (action == "skip")
	{
		var cookieDurationExist = document.qbo.getCookie("qbo.SmartWorkList.SkipPopup");
		if (cookieDurationExist!=null && cookieDurationExist=="popup")
		{
			document.qbo.setCookie( "qbo.SmartWorkListMember.SkipDateTime",null, null, "/");
			window.showModalDialog("/Decision/SmartWorklistSkipPlan.aspx?SmartWorklistMemberID="+document.qbo.getCookie("qbo.SmartWorklistMember.MemberIDCookie"), top, 'dialogHeight:250px;dialogWidth:500px');
		}
	}
	if(chkNext.checked)
	{
		action += "-assign";
	}
	if(chkBatchAssign!=null && chkBatchAssign.checked)
	{
		action += "-batchassign";
	}
    if(cookieUrl != null)
    {
        var location = unescape(document.location);
		if (location.indexOf("&ReferringPage=") > 0)
			location = location.substring(0, location.indexOf("&ReferringPage="));
        
		if(cookieUrl == location)
		{
			this.Action = "continue";
			var SkipDuration = document.qbo.getCookie("qbo.SmartWorkListMember.SkipDuration");
			var SkipDateTime = document.qbo.getCookie("qbo.SmartWorkListMember.SkipDateTime");
			if(action != null)this.Action = action;
			this.SmartWorklistMemberIDCookie = document.qbo.getCookie("qbo.SmartWorklistMember.MemberIDCookie");
			if(this.SmartWorklistMemberIDCookie != null)
			{
				var service = new document.qbo.WebService();
				this.WebServiceUrl1 = "/Decision/SmartWorklistMemberService.asmx";
				service.useService(document.qbo.baseURL + this.WebServiceUrl1 + "?WSDL", "SmartWorklistMemberService");
				if (service.SmartWorklistMemberService)
				{
					this.SmartWorklistMemberID = service.SmartWorklistMemberService.callService(SmartWorklistResult, "IsSmartWorklistComplete", this.SmartWorklistMemberIDCookie, this.Action, SkipDateTime);
				}
				else 
				{
					this.Error("Failed to launch web service call to Complete or Skip the item");
				}
}
	    }
	}
}

function Trace(message)
	{
		if (this.Tracing)
			alert(message);
	}
	
function SmartWorklistResult(result)
{
	if (result.error)
	{
		alert(result.errorDetail.string);
		return;
	}
	if (result.value != null)
	{
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		xmlDoc.loadXML(result.value.xml);
		if (xmlDoc.selectSingleNode("//BusinessRuleExceptionCollection/BusinessRuleFailureItem")!=null)
		{
			alert(xmlDoc.selectSingleNode("//BusinessRuleExceptionCollection/BusinessRuleFailureItem").text);
		}
		else
		{
			window.location.href = (xmlDoc.selectSingleNode("//URLItem").text=="")?"/Decision/SmartWorklistAssignByPerson.aspx?Action=Assign":xmlDoc.selectSingleNode("//URLItem").text;
		}
		return;
	}
}


function SmartWorklistMemberSkip()
{
    var SmartWorklistMemberIDCookie = document.qbo.getCookie("qbo.SmartWorklistMember.MemberIDCookie");
    this.WebServiceUrl = "/Decision/SmartWorklistMemberService.asmx";
    //alert(SmartWorklistMemberIDCookie);
    var service = new document.qbo.WebService();
    service.useService(document.qbo.baseURL + this.WebServiceUrl + "?WSDL", "SmartWorklistMemberService");
    //document.qbo.setCookie("qbo.SmartWorkListMember.SkipDateTime",null, null, "/");
    if (SmartWorklistMemberIDCookie != null)
    {
        if (service.SmartWorklistMemberService)
        {
            this.SmartworklistMemberID = service.SmartWorklistMemberService.callService(SmartWorklistSkipResult, "IsPopupRequired");
        }
    }
    else
        window.location.href ="/Decision/SmartWorklistAssignByPerson.aspx?Action=Skip";
}

function SmartWorklistSkipResult(result)
{

//alert(result.errorDetail.string);
	if (result.error)
	{
		return;
	}
if (result.value != null)
{
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.loadXML(result.value.xml);
       if (xmlDoc.selectSingleNode("//URLItem").text != "")
       {
            window.location.href = xmlDoc.selectSingleNode("//URLItem").text;
       }
       else
       {
            var cookieDurationExist = document.qbo.getCookie("qbo.SmartWorkList.SkipPopup");
            if (cookieDurationExist!=null && cookieDurationExist=="popup")
            {
              
                //document.qbo.setCookie("qbo.SmartWorkListMember.SkipDateTime",null, null, "/");
                window.showModalDialog("/Decision/SmartWorklistSkipPlan.aspx?SmartWorklistMemberID="+document.qbo.getCookie("qbo.SmartWorklistMember.MemberIDCookie"), top, 'dialogHeight:250px;dialogWidth:500px');
            }
            
              var SmartWorklistMemberIDCookie = document.qbo.getCookie("qbo.SmartWorklistMember.MemberIDCookie");
              var service = new document.qbo.WebService();
                this.SmartWorklistMemberId = service.SmartWorklistMemberService.callService(SmartWorklistResult, "IsSmartWorklistComplete", SmartWorklistMemberIDCookie, 'Skip', document.qbo.getCookie("qbo.SmartWorkListMember.SkipDateTime"));
//            else
//            {
//                 window.location.href ="/Decision/SmartWorklistAssignByPerson.aspx?Action=Skip";
//            }
                

        }
  
}
return;
}

function SmartWorklistSkipResult1(result)
{

//alert(result.errorDetail.string);
	if (result.error)
	{
		return;
	}
if (result.value != null)
{
    
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.loadXML(result.value.xml);
       if (xmlDoc.selectSingleNode("//URLItem").text != "")
       {
            window.location.href = xmlDoc.selectSingleNode("//URLItem").text;
       }
}
return;
}

/*****************************SmartWorklist Functions**************--END*/
qboEnvironment.prototype.SetBehaviors = function()
{
	if (this.today == null) return document.qbo.SetBehaviors();
	this.TableList = document.getElementsByTagName("TABLE");
	this.SetBehaviorContent();
	this.SetBehaviorForms();
}
qboEnvironment.prototype.SetBehaviorForms = function()
{
	for (var i=0; i<document.forms.length; i++)
		document.forms[i].attachEvent("onsubmit", function anon() {document.qbo.MaskUI(document.forms[i])});
}
qboEnvironment.prototype.SetBehaviorContent = function()
{
	for (var i=0; i<this.TableList.length; i++) 
	{
		if (this.TableList[i].className.substring(0, 7) == "content")
			this.SetBehaviorSortBy(this.TableList[i]);
		if (this.TableList[i].selectable)
			this.SetBehaviorHighlight(this.TableList[i]);
	}
}
qboEnvironment.prototype.SetBehaviorSortBy = function(table)
{
	var cells = table.getElementsByTagName("TH");
	for (var i=0; i<cells.length; i++) if (cells[i].sortBy)
	{
		cells[i].attachEvent("onmouseover", function anon() {event.srcElement.style.cursor='hand';});
		cells[i].attachEvent("onclick", function anon() {formSortBy(event.srcElement.sortBy);});
		if (cells[i].onFilter) cells[i].attachEvent("oncontextmenu", function anon() {eval(event.srcElement.onFilter); return false;});
		if (!cells[i].title) 
		{
			cells[i].title = "Click here to sort by " + cells[i].innerHTML;
			if (cells[i].onFilter) cells[i].title += "\nRight-click here to filter results by this column.";
		}
	} 
}
qboEnvironment.prototype.SetBehaviorHighlight = function(table)
{
	var rows = table.getElementsByTagName("TR");
	for (var i=0; i<rows.length; i++) 
	{
		rows[i].attachEvent("onmouseover", function anon() {e = getParentElement(event.srcElement, "TR"); if (e.className != "contentSelected") {e.classCache = e.className; e.className='contentHighlight';}});
		rows[i].attachEvent("onmouseout", function anon() {e = getParentElement(event.srcElement, "TR"); if (e.className != "contentSelected") e.className=e.classCache;});
/*
		rows[i].attachEvent("onclick", function anon() {
			e = getParentElement(event.srcElement, "TR"); 
			e.selected = (e.selected) ? !e.selected : true;
			e.className = (!e.selected) ? e.classCache : "contentSelected";

			if (!window.event.ctrlKey)
			{
				var table = getParentElement(event.srcElement, "TABLE");
				var rows = table.all.tags("TR");
				for(var l=0; l<rows.length; l++)
				{
					if (rows[l].className == "contentSelected" && rows[l] != e)
					{
						rows[l].selected = false;
						rows[l].className = rows[l].classCache;
					}
				}
			}
			
			r = e.all.tags("TD");
			if (r.length == 0) return;
			c = r[r.length-1].all.tags("INPUT");
			if ((c.length == 1) && (c[0].type == "checkbox"))
				c[0].checked = e.selected;
		});
*/
	} 
}
qboEnvironment.prototype.errorHandler = function(error, message) 
{
	theMessage = "";
	if (message != null) theMessage += message;
	if (error != null) theMessage += "\n\n" + error.descrption;
	throw(error);
	alert(theMessage);
}

qboEnvironment.prototype.MaskUI = function(element)
{
//	if ((event.srcElement.tagName == "a"))	// && (event.srcElement.href.indexOf("javascript") >= 0))
//		return;
	if (event && (event.cancelBubble)) return;
	if (element == null) element = event.srcElement;
	
	if (this.baseURL == null) return document.qbo.MaskUI(element);
	if (element.InMaskUI) return;
	element.InMaskUI = true;
	var overlay = document.createElement("div");
	overlay.className = "locked";
	document.body.appendChild(overlay);
	if (element == document.body)
	{
		overlay.style.pixelLeft = element.scrollLeft;
		overlay.style.pixelTop = element.scrollTop;
		overlay.style.height = element.clientHeight;
		overlay.style.width = element.clientWidth;
	}
	else
	{
		getElementPosition(element);
		if ((element.tagName == "FORM") && (t = element.all.tags("TABLE")[0]))
		{
			getElementPosition(t);
			element.PositionLeft = t.PositionLeft;
		}
		overlay.style.pixelLeft = element.PositionLeft;
		overlay.style.pixelTop = element.PositionTop;
		overlay.style.height = element.PositionBottom - element.PositionTop;
		var k = element.PositionRight - element.PositionLeft
		if (k < 0) k = 0;
		overlay.style.width = k + "px";
	}
	overlay.style.zIndex = 100;
	element.MaskUIoverlay = overlay;
}
qboEnvironment.prototype.UnMaskUI = function(element)
{
	if (this.baseURL == null) return document.qbo.UnMaskUI(element);
	if (element == null) element = document.body;
	if (!element.InMaskUI) return;
	element.InMaskUI = false;
	if (element.MaskUIoverlay) 
		document.body.removeChild(element.MaskUIoverlay);
}
qboEnvironment.prototype.Shim = function(element, shimID)
{
	if (!shimID) shimID = "__qboShim";
	var shim = document.getElementById(shimID);
	if (shim == null)
	{
		shim = document.createElement("iframe");
		document.body.appendChild(shim);
		shim.style.position = "absolute";
		shim.style.display = "none";
		shim.src = "about:blank";
		shim.id = shimID;
		shim.className = element.className;
	}
	shim.style.pixelTop = element.style.pixelTop;
	shim.style.pixelLeft = element.style.pixelLeft;
	shim.style.height = element.style.height;
	shim.style.width = element.style.width;
	shim.style.display = "block";
}
qboEnvironment.prototype.UnShim = function(shimID)
{
	if (!shimID) shimID = "__qboShim";
	var shim = document.getElementById(shim);
	if (shim) shim.style.display = "none";
}
// Database functions
qboEnvironment.prototype.AdoRecordSet = function(query, connectionString) 
{
	if (connectionString == null) connectionString = this.connectionString;
	var theConnection = new ActiveXObject("ADODB.connection");
	try 
	{
		theConnection.open(connectionString);
	} 
	catch(e) 
	{
		this.errorHandler(e, "Cannot connect to database.");
		return null;
	}
	try 
	{
		var theADO = new ActiveXObject("ADODB.recordset");
		theADO.open(query, theConnection, 3);
		return theADO;
	} 
	catch(e) 
	{
		this.errorHandler(e, "Error executing " + query);
		return null;
	}

}
qboEnvironment.prototype.AdoXml = function(query, connectionString) 
{
	if (connectionString == null) connectionString = this.connectionString;
	var theRecordSet = this.AdoRecordSet(query, connectionString);
	try {
		var theResponse = new ActiveXObject("Microsoft.XMLDOM");
		theRecordSet.save(theResponse, 1);
		return(theResponse);		
	} catch(e) {
		this.errorHandler(e, "AdoXml encountered an error");
		return(null);
	}	
}

function getADOFromXML(theXML) {
	var theRecordSet = new ActiveXObject("ADODB.Recordset");
	theXML.save(theRecordSet);
	return(theRecordSet);
}

qboEnvironment.prototype.initialize = function() 
{
	document.body.onMouseUp = "document.qbo.tabClear(this);";
	this.tables = document.all.tags("TABLE");
	this.rows = document.all.tags("TR");
}

qboEnvironment.prototype.getDateString = function(theDate) 
{
	if (theDate.getMonth() < 9) theMonth = "0" + (theDate.getMonth() + 1);
	else theMonth = (theDate.getMonth() + 1);
	if (theDate.getDate() < 10) theDay = "0" + theDate.getDate();
	else theDay = theDate.getDate();
	theYear = theDate.getFullYear();
	if (this.dateFormat == "DD/MM/YYYY") theString = theDay + "/" + theMonth + "/" + theYear;
	else theString = theMonth + "/" + theDay + "/" + theYear;
	return theString;
}

qboEnvironment.prototype.isDate = function(theValue) {
	var theDate;
	var theCentury = new Date("1/1/1900");
	if (theValue != "") {
		if ((theValue.length == 4) && (theValue.indexOf("/") == -1) && (theValue.indexOf("-") == -1)) {
			theValue = theValue + new Date().getFullYear().toString().substring(2, 4);
		}
		if ((theValue.length < 6) && ((theValue.indexOf("/") > 0) || (theValue.indexOf("-") > -1))) {
			theValue = theValue + "/" + new Date().getFullYear().toString().substring(2, 4);
		}
		if (theValue == ".") {
			theDate = new Date();
		} else if ((theValue.length == 6) && (theValue.indexOf("/") == -1) && (theValue.indexOf("-") == -1)) {
			theString = new String(theValue);
			if (this.dateFormat == "DD/MM/YYYY") {
				theDay = theString.substring(2, 4);
				theMonth = theString.substring(0, 2);
				theYear = new Number(theString.substring(4, 6));
			} else {
				theDay = theString.substring(0, 2);
				theMonth = theString.substring(2, 4);
				theYear = new Number(theString.substring(4, 6));
			}
			if (theYear <= 50) theYear += 2000;
			theDate = new Date(theDay + '/' + theMonth + '/' + theYear);
		} else if ( (theValue == "2/29/00") || (theValue == "02/29/00") || (theValue == "022900") ) {
			theDate = new Date("02/29/2000");
		} else if ( (theValue == "29/2/00") || (theValue == "29/02/00") || (theValue == "290200") ) {
			theDate = new Date("02/29/2000");
		} else {
			theString = theValue.replace(/-/g, "/");	//getSubstituteString(theValue, "-", "/")
			if (this.dateFormat == "DD/MM/YYYY") {
				theDay = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theMonth = theString.substring(0, theString.indexOf("/"));
			} else {
				theMonth = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theDay = theString.substring(0, theString.indexOf("/"));
			}
			theYear = new Number(theString.substring(theString.indexOf("/") + 1, theString.length));
			if (theYear <= 50) theYear += 2000;
			theYearTest = theYear + '';
			if (theYearTest.length > 4) theYear = theYearTest.substring(0,4);
			theDate = new Date(theMonth + "/" + theDay + "/" + theYear);
		}
		if ( isNaN(theDate.getMonth()) || (theDate.getTime() < theCentury.getTime()) ) {
			return(null);
		} else {
			return(this.getDateString(theDate, this.dateFormat));
		}
	}
	return("");
}

qboEnvironment.prototype.elementIsDate = function(theElement) 
{
	theValue = theElement.value;
	if (theValue.indexOf(" ") > 0) theValue = theValue.substring(0, theValue.indexOf(" "));
	theDateValue = this.isDate(theValue);
	if (theDateValue == null) {
		alert(theElement.value + " is an invalid date.");
		theElement.value = "";
		theElement.focus();
	} 
	else 
	{
		theElement.value = theDateValue;
		if ((theElement.DateMin != null) && (new Date(theDateValue) < new Date(theElement.DateMin)))
		{
			theElement.value = "";
			alert("You may not select a date before " + theElement.DateMin);
			theElement.focus();
		}
		if ((theElement.DateMax != null) && (new Date(theDateValue) > new Date(theElement.DateMax)))
		{
			theElement.value = "";
			alert("You may not select a date after " + theElement.DateMax);
			theElement.focus();
		}
		
	}
}

qboEnvironment.prototype.properName = function(theValue)
{
	var theResult = "";
	for (var i=0; i<theValue.length; i++)
	{
		var resultChar = theValue.substring(i, i+1);
		if ((resultChar >= "0") && (resultChar <= "9")) theResult += resultChar;
		else if ((resultChar >= "A") && (resultChar <= "z")) theResult += resultChar;
	}
	return(theResult);
}
qboEnvironment.prototype.isMoney = function(theValue) 
{
	var theResult = "";
	theValue = "" + theValue;
	if (theValue > "") {
		theValue = theValue.replace(/\$/g, "");
		theValue = theValue.replace(/,/g, "");
		theMoney = new Number(theValue);
		if (isNaN(theMoney)) return(null);
		theResult = '' + Math.round(theMoney*100)/100;
		for (i=0; i<theResult.length; i++) {
			if (theResult.charAt(i) == '.') break;
		}
		if (i == theResult.length) theResult += ".00";
		else if (i == (theResult.length-1)) theResult += "00";
		else if (i == (theResult.length-2)) theResult += "0";
	} 
	return theResult;
}
qboEnvironment.prototype.elementIsMoney = function(theElement) 
{
	if (theElement.value.substring(0,1) == "(") 
	{
//		alert("-" + theElement.value.substring(1, theElement.value.length-1));
		theMoneyValue = this.isMoney("-" + theElement.value.substring(1, theElement.value.length-1));
	}  
	else 
	{
		theMoneyValue = this.isMoney(theElement.value);
	}
//	alert(theMoneyValue);
	if (theMoneyValue == null) {
//		alert(theElement.value + " is an invalid amount of money.");
		theElement.value = "";
		theElement.focus();
	} else {
		theMoneyLeft = theMoneyValue.substring(0, theMoneyValue.indexOf("."));
		theCount = 0;
		theMoneyFormatted = "";
		for (var i=theMoneyLeft.length; i--; i==0) {
			theMoneyFormatted = theMoneyLeft.substring(i, i+1) + theMoneyFormatted;
			if ((++theCount == 3) && (i > 0) && (theMoneyLeft.substring(i-1, i) != "-")) {
				theMoneyFormatted = "," + theMoneyFormatted;
				theCount = 0;
			}
		}
		if (theMoneyFormatted.substring(0, 1) == "-")
		{
			theElement.value = "(" + theMoneyFormatted.substring(1, 255) + theMoneyValue.substring(theMoneyValue.indexOf("."), theMoneyValue.length) + ")";
		}
		else 
		{
			theElement.value = theMoneyFormatted + theMoneyValue.substring(theMoneyValue.indexOf("."), theMoneyValue.length);
		}
	}
}

qboEnvironment.prototype.elementIsTime = function(theElement) 
{
	function Pad(number)
	{
		result = "" + number;
		return((result.length == 1) ? "0" + result : result);
	}

	if (theElement.value == "") return;
	if ((theElement.getAttribute("ShowAmPm")) && (theElement.getAttribute("ShowAmPm") == "false"))
		showAmPm = false;
	else 
		showAmPm = true;
		
	showSeconds = !( (theElement.getAttribute("ShowSeconds")) && (theElement.getAttribute("ShowSeconds") == "false") );
	
	theResult = theElement.value.toLowerCase().replace(" ", "");
	isAm = theResult.indexOf("am") > 0;
	isPm = theResult.indexOf("pm") > 0;
	theResult = theResult.replace("am", "");
	theResult = theResult.replace("pm", "");
	var parts = theResult.split(":");
	for (var i=0; i<parts.length; i++)
	{
		if (isNaN(parts[i]) || (parts[i].length >2))
		{
			// alert("Invalid time '" + theElement.value + "'.  Format should be HH:MM:SSam, HH:MM:SSpm, or HH:MM:SS.");
			alert("Invalid time '" + parts[i] + "'.  Format should be HH:MM:SSam, HH:MM:SSpm, or HH:MM:SS.");
			theElement.value = theElement.defaultValue;
			return false;
		}
	}
	var hours = (isPm) ? parseInt(parts[0]) + 12 : parseInt(parts[0]);
	if ((hours == 12) && (isAm)) hours = 0;
//	if ((hours == 24) && (isPm)) hours = 12;
	var minutes = (parts.length > 1) ? parseInt(parts[1]) : 0;
	var seconds = (parts.length > 2) ? parseInt(parts[2]) : 0;
	if (showAmPm)
	{
		if (hours > 11) 
		{
			if (showSeconds)
				theElement.value = Pad(hours-12) + ":" + Pad(minutes) + ":" + Pad(seconds) + "pm";
			else
				theElement.value = Pad(hours-12) + ":" + Pad(minutes) + "pm";
		}
		else 
		{
			if (showSeconds)
				theElement.value = Pad(hours) + ":" + Pad(minutes) + ":" + Pad(seconds) + "am";
			else
				theElement.value = Pad(hours) + ":" + Pad(minutes) + "am";
		}
	} 
	else 
	{
		if (showSeconds)
			theElement.value = Pad(hours) + ":" + Pad(minutes) + ":" + Pad(seconds);
		else
			theElement.value = Pad(hours) + ":" + Pad(minutes) + "am";
	}
}

qboEnvironment.prototype.isInteger = function(theValue)
{
	return(this.integer.test(theValue))
}

qboEnvironment.prototype.dropdownSetValue = function(theElement, theValue) 
{
	if (theElement.options) for (i=0; i<theElement.options.length; i++) {
		if (theElement.options[i].value == theValue) {
			theElement.options[i].selected = true; 
			break;
		}
	} else trapError(theElement.type + " is not a select field.");
}

qboEnvironment.prototype.dropdownSetText = function(theElement, theText) 
{
	if (theElement.options) for (i=0; i<theElement.options.length; i++) {
		if (theElement.options[i].text == theText) {
			theElement.options[i].selected = true; 
			break;
		}
	} else trapError(theElement.type + " is not a select field.");
}


qboEnvironment.prototype.elementIsInteger = function(theElement)
{
	if (!this.isInteger(theElement.value))
	{
		alert(theElement.value + " is an invalid integer number.");
		theElement.value = "";
		theElement.focus();
	}
}

qboEnvironment.prototype.isDecimal = function(theValue)
{
	return(this.decimal.test(theValue));
}

qboEnvironment.prototype.elementIsDecimal = function(theElement)
{
	if (theElement.value == "") return;
	if (theElement.value.indexOf("-") > -1
	    &&  theElement.value.indexOf("-") != 0)
	{
		alert(theElement.value + " is an invalid decimal number.");
		theElement.value = "";
		theElement.focus();
	}
	else if (!this.isDecimal(theElement.value))
	{
		alert(theElement.value + " is an invalid decimal number.");
		theElement.value = "";
		theElement.focus();
	}
	else
	{
		if (theElement.value.indexOf(".") == 0)
			theElement.value = "0" + theElement.value;
		if (theElement.value.indexOf(".") == theElement.value.length-1)
			theElement.value += "0";
	}
}
qboEnvironment.prototype.elementIsPercentage = function(theElement, theFractionDigits)
{
	if (!this.isDecimal(theElement.value))
	{
		alert(theElement.value + " is an invalid percentage.");
		theElement.value = "";
		theElement.focus();
	}
	else
	{
		var thePercentage = new Number(theElement.value);
		theElement.value = thePercentage.toFixed(theFractionDigits);
	}
}

qboEnvironment.prototype.tabClear = function() {
	if (window.self.tabFocus) {
		window.self.tabFocus.onblur = null;
		window.self.tabFocus = null;
	}
}

qboEnvironment.prototype.tabCapture = function(obj) {
	if (!window.self.workingObj) window.self.workingObj  = new Object();
	if (!window.self.workingId) window.self.workingId  = new Object();
	if (!window.self.tabMode) window.self.tabMode = new Object();

	if (new String(tabMode[event.srcElement.id]) == 'undefined') tabMode[event.srcElement.id] = false;
	status = 'TabMode = ' + tabMode[event.srcElement.id]
	window.self.theRange = document.selection.createRange();
	window.self.workingObj[obj.id] = obj;
	window.self.workingId[obj.id] = obj.id;
	
	if (event.keyCode == 9 && tabMode[event.srcElement.id]) {
		workingObj[event.srcElement.id].onblur = function anonymous () {
			this.focus();
			theRange.select();
		}
		theRange.text = "\t";
	}
	if (! tabMode[event.srcElement.id]) {
		if (workingObj[event.srcElement.id]) workingObj[event.srcElement.id].onblur = null;
	}
	if (event.keyCode == 84 && event.ctrlKey) {
		tabMode[event.srcElement.id] = !tabMode[event.srcElement.id];
		status = 'TabMode = ' + tabMode[event.srcElement.id];
	}
}

qboEnvironment.prototype.getFolderLocal = function(theRootFolder) {
	if (!this.isTrustedSite()) {
		this.errorHandler(null, "This site is not trusted.  This page is attempting to access a folder on your local machine.");
		return(null);
	}
	try {
		osShell = new ActiveXObject("Shell.Application");
		if (theRootFolder != null) this.rootFolder = theRootFolder;
		var theFolder = osShell.BrowseForFolder(0, "Select folder", (32 | 64), this.rootFolder);
		return(theFolder);
	} catch(e) {
		alert(e.description);
		this.errorHandle("qbo.getFolderLocal: " + e.description);
	}
}

qboEnvironment.prototype.getFolderNameLocal = function(theRootFolder) {
	theFolder = this.getFolderLocal(theRootFolder);
	theResult = "";
	while (theFolder != null) {
		alert(theResult);
		theResult = theFolder + "\\" + theResult;
		theFolder = theFolder.ParentFolder;
	}
	alert(theResult);
	return(theResult);
}

qboEnvironment.prototype.fileFolderName = function(theFileSpec) {
	var theResult = new String(theFileSpec);
	theResult = theResult.replace(/\\/g, "/");
	var theResultArray = theResult.split("/");
	theResult = theResultArray[0];
	for (var i=1; i<theResultArray.length-1; i++) theResult += "/" + theResultArray[i];
	return(theResult);
	
}

qboEnvironment.prototype.isTrustedSite = function() 
{
	if (this.trustedSite == null) {
		try {
			var theFileSystem = new ActiveXObject("Scripting.FileSystemObject");
			this.trustedSite = true;
			var theFileSystem = null;
		} catch(e) {
			this.trustedSite = false;
		}	
	}
	return(this.trustedSite);
}

qboEnvironment.prototype.errorHandle = function(theError) 
{
	try {
		alert("qboError: " + theError.description);
	} catch(e) {
		alert("qboError: " + theError);
	}
}

qboEnvironment.prototype.displayTab = function(theTab) {
	if (this.tables == null) this.tables = document.all.tags("TABLE");
	for (i=0; i<this.tables.length; i++) {
		if (this.tables[i].id.indexOf("Tab") >= 0) {
			if (this.tables[i].id == "Tab" + theTab) this.tables[i].style.display = "block";
			else this.tables[i].style.display = "none";
		}
	}
}

qboEnvironment.prototype.urlAddParameter = function(theURL, theParameter, theValue) {
	var theResult = new String(theURL);
	if (theResult.indexOf(theParameter + "=") > 0)
	{
		splitPos = theResult.indexOf(theParameter + "=") + theParameter.length + 1;
		leftSide = theResult.substring(0, splitPos);
		rightSide = theResult.substring(splitPos);
		if (rightSide.indexOf("&") > 0)
			remainder = rightSide.substring(rightSide.indexOf("&"));
		else
			remainder = "";
		theResult = leftSide + theValue + remainder;
	} 
	else 
	{
		theResult += (theResult.indexOf("?") > 0) ? "&" : "?";
		theResult += theParameter + "=";
		if (theValue != null) theResult += theValue;
	}
	return(theResult);
}

qboEnvironment.prototype.xmlFromUrl = function(theURL, theConnectionString) {
	var xmlhttp = new ActiveXObject(this.classXMLHTTP);
	xmlhttp.Open("GET", this.urlAddParameter(theURL, "__DTS", new Date().getTime()), false);
	if (theConnectionString != null) xmlhttp.setRequestHeader("ActionConnectionString", theConnectionString);
	xmlhttp.Send();

	var xmlDoc = new ActiveXObject(this.classXML);
	xmlDoc.async = false;
	xmlDoc.loadXML(xmlhttp.responseText);
	return(xmlDoc);
}
qboEnvironment.prototype.textFromUrl = function(theURL, theConnectionString) {
	var xmlhttp = new ActiveXObject(this.classXMLHTTP);
	xmlhttp.Open("GET", this.urlAddParameter(theURL, "__DTS", new Date().getTime()), false);
	if (theConnectionString != null) xmlhttp.setRequestHeader("ActionConnectionString", theConnectionString);
	xmlhttp.Send();
	return(xmlhttp.responseText);
}
qboEnvironment.prototype.checkboxToggle = function(theName, theForm) {
	this.checkboxChecked = !this.checkboxChecked;
	if (theForm == null) theForm = document.forms[0];
	with (theForm) for (i=0; i<elements.length; i++) {
		if (theName == null) {
			if (elements[i].type == "checkbox") elements[i].checked = this.checkboxChecked;
		} else  {
			if (elements[i].name == theName) elements[i].checked = this.checkboxChecked;
		}
	}
}


qboEnvironment.prototype.xmlToHtml = function(theXML, theXSLURL) {
	try {
		if (!(theXSLURL instanceof ActiveXObject)) {
			var theXSL = new ActiveXObject(this.classXML);
			theXSL.async = false;
			theXSL.load(theXSLURL);
		} else {
			var theXSL = theXSLURL;
		}
		return(theXML.transformNode(theXSL));
	} catch(e) {
		throw(e);
	}
}

qboEnvironment.prototype.calendarChooser = function() {
	try {
		this.calendarImage = window.event.srcElement;
		this.calendarField = document.all(this.calendarImage.sourceField);
		this.calendarMinimum = (this.calendarField.DateMin == null) ? "1/1/1990" : this.calendarField.DateMin;
		this.calendarMaximum = (this.calendarField.DateMax == null) ? "12/31/2050" : this.calendarField.DateMax;
			ShowCalendar();
	} catch(e) {
		throw(e);
	}
}

qboEnvironment.prototype.fileUpload = function(theLink) {
	attachmentWindow = window.open(theLink.href, "attachmentWindow", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500");
	if (attachmentWindow != null) if (attachmentWindow.opener == null) attachmentWindow.opener = self;
	return(false);
}
qboEnvironment.prototype.attachmentAdd = function(theElement) {
	this.attachmentElement = theElement;
	attachmentWindow = window.open("/attachment/attachmentUpload.aspx", "attachmentWindow", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500");
	if (attachmentWindow != null) if (attachmentWindow.opener == null) attachmentWindow.opener = self;
	return(false);
}
qboEnvironment.prototype.attachmentProcess = function(theAttachment) {
	if (this.attachmentXML == null) {
		var attachmentXML = new ActiveXObject(this.classXML);
		attachmentXML.loadXML("<attachmentCollection/>");
		this.attachmentXML = attachmentXML;
	}
	this.attachmentXML.documentElement.appendChild(theAttachment.documentElement);
	this.attachmentRender();
}
qboEnvironment.prototype.attachmentRender = function(theElement) {
	if (theElement == null) theElement = this.attachmentElement;
	if (theElement != null) {
		theElement.innerHTML = this.xslRender(this.attachmentXML, "/attachment/attachmentList.xslt");
	}
}	
qboEnvironment.prototype.xslRender = function(theXML, theXSLURL) {
	try {
		var theXSL = new ActiveXObject(this.classXML);
		theXSL.async = false;
		theXSL.load(theXSLURL);
		return(theXML.transformNode(theXSL));
	} catch(e) {
		throw(e);
	}
}

qboEnvironment.prototype.clearSelection = function() {
	var theTextRange = document.body.createTextRange();
	theTextRange.moveToPoint(0, 0);
	theTextRange.select();
}
qboEnvironment.prototype.formElementChecked = function(theElementName, theForm) {
	if (theForm == null) theForm = document.forms[0];
	for (var i=0; i<theForm.elements.length; i++) {
		if ((theForm.elements[i].name == theElementName)
			&& (theForm.elements[i].type == "checkbox") 
			&& (theForm.elements[i].checked))
			return(true);
	}
	return(false);
}

qboEnvironment.prototype.getFileName = function(filePath) {
	filePath = filePath.replace(/\\/gi, "/");
	var fileArray = filePath.split("/");
	return(fileArray[fileArray.length-1]);
}

qboEnvironment.prototype.contactChooser = function(theElement) 
{
	theChooser = window.open("/contact/contactChooser.aspx", "ContactChooser", "toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=500");
	theChooser.document.contactField = theElement;
	return(false);
}

qboEnvironment.prototype.getCookie = function(name) {
	var cname = name + "=";
	if (document.cookie.length > 0) {              
		begin = document.cookie.indexOf(cname);       
		if (begin != -1) {
			begin += cname.length;       
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		} 
	}
	return(null);
}

qboEnvironment.prototype.setCookie = function(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) + 
		((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		((secure == null) ? "" : "; secure");
}

qboEnvironment.prototype.deleteCookie = function(name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

qboEnvironment.prototype.xmlReformat = function(xmlString)
{
	var xmlText = xmlString;
	var xmlResult = "";
	var indent = "";
	while (xmlText.indexOf("><") > 0)
	{
		fragment = xmlText.substring(0, xmlText.indexOf("><"));
		indent += "\t";
		if (fragment.substring(fragment.length-1) == "/") indent = indent.substring(0, indent.length-1);
		if (fragment.substring(0, 1) == "/") indent = indent.substring(0, indent.length-1);
		if (xmlText.substring(xmlText.indexOf("><") + 2).substring(0, 1) == "/") indent = indent.substring(0, indent.length-1);
		xmlResult += fragment + ">\n" + indent + "<";
		xmlText = xmlText.substring(xmlText.indexOf("><") + 2);
	}
	xmlResult += xmlText;
	return(xmlResult);
}
qboEnvironment.prototype.xmlFormat = function(xmlDocument, tabChar)
{
	function writeNode(xmlNode, tab) 
	{
		if (tab == null) tab = "";
		if (xmlNode.nodeName != "#text") 
		{
			result += "\n" + tab + "<" + xmlNode.nodeName;
			for (var i=0; i<xmlNode.attributes.length; i++)
			{
				result += " " + xmlNode.attributes[i].name + "=\"" + xmlNode.attributes[i].value + "\"";
			}
			result += ">";
		}
		if (xmlNode.childNodes.length == 0) {
			result += xmlNode.text;
		}
		else 
		{
			for (var i=0; i<xmlNode.childNodes.length; i++) writeNode(xmlNode.childNodes[i], tab + "	");
			//if (xmlNode.nodeName != "#text") 
			if (xmlNode.childNodes[0].nodeName != "#text") result += "\n" + tab;
		}
		if (xmlNode.nodeName != "#text") 
		{
			result += "</" + xmlNode.nodeName + ">";
		}
	}
	var result = "";
	writeNode(xmlDocument.documentElement);
	return result;
}

qboEnvironment.prototype.DropDownListAppend = function(selectObject)
{
	if (selectObject.selectedIndex == selectObject.length - 1)
	{
		var prefix = (selectObject.id == null) ? selectObject.name : selectObject.id;
		var spanObject = eval(prefix + "Span");
		selectObject.style.display = "none";
		spanObject.style.display = "inline";
		var appendElement = selectObject.form.elements[prefix + "Append"];
		appendElement.focus();
	}
}

qboEnvironment.prototype.DropDownListUnAppend = function(imageObject)
{
	var prefix = imageObject.name.substring(0, imageObject.name.length-8)
	var spanObject = eval(prefix + "Span");
	var selectObject = spanObject.previousSibling;
	spanObject.style.display = "none";
	selectObject.style.display = "inline";
	selectObject.selectedIndex = 0;
	selectObject.focus();
}

qboEnvironment.prototype.ClearDefaultLabels = function()
{
	theForm = event.srcElement;
	for (var i=0; i<theForm.elements.length; i++)
	{
		var element = theForm.elements[i]; 
		if (element.defaultLabel != null)
		{
			if (element.defaultLabel == element.value)
			{
				element.value = "";
				element.style.color = "Black";			
			}
		}
	}
}

qboEnvironment.prototype.SetDefaultLabels = function()
{
	for (var j=0; j<document.forms.length; j++)
	{
		theForm = document.forms[j];
		theForm.attachEvent("onsubmit", document.qbo.ClearDefaultLabels);	
		for (var i=0; i<theForm.elements.length; i++)
		{
			element = theForm.elements[i];
			if ((element.value == "") && (element.defaultLabel != null)) 
			{
				element.value = element.defaultLabel;
				element.style.color = "Gray";
				element.attachEvent("onfocus", function anon() 
				{
					var element = event.srcElement; 
					if (element.value == element.defaultLabel) element.value = '';
					element.style.color = "Black";
				});
				element.attachEvent("onblur", function anon() 
				{
					var element = event.srcElement; 
					if (element.value == '') 
					{
						element.value = element.defaultLabel;
						element.style.color = "Gray";
					}
				});
			}
		}
	}
}

qboEnvironment.prototype.LoginPrompt = function()
{
	if ((this.LoginTimeout == null) || (this.LoginTimeout == 0))
		return;
	if (document.location.pathname.indexOf("/Security/Login.aspx") >= 0)
		return;
	if (keepLoggedIn = window.showModalDialog(this.Application + "/Security/LogoutPrompt.html", this.LogoutPrompt))
	{
		var string = this.textFromUrl(this.Application + "/Security/LogoutPrompt.html");
		setTimeout("document.qbo.LoginPrompt()", (1000*60*this.LoginTimeout));
	}
	else
	{
		document.location = document.qbo.Application + "/Security/Login.aspx?Action=logout";
	}
}	

//--- Begin calendar function
var zz, zv, d, fTSR;
var gBF=false;
var g_MINY = 1601;
var g_MAXY = 4500;
var g_month = 0;
var g_day = 0;
var g_year = 0;
var g_yLow = 1990;
var g_eC=null;
var g_eCV="";
var g_dFmt=GetDateFmt();
var g_fnCB=null;

var rgMC = new Array(12);
rgMC[0] = 31;rgMC[1] = 28;rgMC[2] = 31;rgMC[3] = 30;rgMC[4] = 31;rgMC[5] = 30;rgMC[6] = 31;rgMC[7] = 31;rgMC[8] = 30;rgMC[9] = 31;rgMC[10] = 30;rgMC[11] = 31;

d = new Date();
fTSR=0;
zv = d.getTime();
zz = "&zz="+zv;

function GetDowStart() {return 0;}
function GetDateFmt() {return "mmddyy";}
function GetDateSep() {return "/";}

function GetInputDate(t,f){
  var l = t.length;
  if(0 == l) return false;
  var cSp = '\0';
  var sSp1 = "";
  var sSp2 = "";
  for(var i = 0; i < t.length; i++){
    var c = t.charAt(i);
    if(c == ' ' || isdigit(c)) continue;
    else if(cSp == '\0' && (c == '/' || c == '-' || c == '.')){
      cSp = c
      sSp1 = t.substring(i+1,l);
    }
    else if(c == cSp) sSp2 = t.substring(i+1,l);
    else if(c != cSp) return false;
  }
  if(0 == sSp1.length) return false;
  var m;
  var d;
  var y; 
  if(f=="mmddyy"){
    m = atoi(t);
    d = atoi(sSp1);
    if(0 != sSp2.length) y = atoi(sSp2);
    else y = DefYr(m,d);
  }
  else if(f=="ddmmyy"){
    m = atoi(sSp1);
    d = atoi(t);
    if(0 != sSp2.length) y = atoi(sSp2);
    else y = DefYr(m,d);
  }
  else{
    if(0 == sSp2.length) return false;
    m = atoi(sSp1);
    d = atoi(sSp2);
    y = atoi(t);
  }
  if(y < 100){
    y = 1900+y;
    while(y < g_yLow) y = y+100;
  }
  if(y < g_MINY || y > g_MAXY || m < 1 || m > 12) return false;
  if(d < 1 || d > GetMonthCount(m,y)) return false;
  g_month = m;
  g_day = d;
  g_year = y;
  return true;
}

function DefYr(m,d){
  var dt = new Date();
  var yCur = (dt.getYear() < 1000) ? 1900+dt.getYear() : dt.getYear();
  if(m-1 < dt.getMonth() || (m-1 == dt.getMonth() && d < dt.getDate())) return 1+yCur;
  else return yCur;
}

function atoi(s){
  var t = 0;
  for(var i = 0; i < s.length; i++){
    var c = s.charAt(i);
    if(!isdigit(c)) return t;
    else t = t*10 + (c-'0');
  }
  return t;
}

function isdigit(c) {return(c >= '0' && c <= '9');}
function GetMonthCount(m,y){
  var c = rgMC[m-1];
  if((2 == m) && IsLeapYear(y)) c++;
  return c;
}
function IsLeapYear(y){
  if(0 == y % 4 && ((y % 100 != 0) || (y % 400 == 0))) return true;
  else return false;
}

function ShowCalendar(eP, eD, eDP, dmin, dmax, fnCB)
{
	if (document.getElementsByTagName("body")[0].all(document.getElementsByTagName("body")[0].all.length - 1) != document.all.calendarControl)
	{
		var dF = document.all.calendarControl;
		if (dF.length > 0) dF = dF[0];
		
		var newDf = dF.cloneNode(true);
		document.getElementsByTagName("body")[0].appendChild(newDf);
		
		var dFParent = dF.parentElement;
		dFParent.removeChild(dF);
		
		dF = document.all.calendarControl;
		if (dF.length > 0) dF = dF[0];

		window.frames.calendarControl.document.location.reload();
	}
	RealShowCalendar(eP, eD, eDP, dmin, dmax, fnCB);
}

function RealShowCalendar(eP, eD, eDP, dmin, dmax, fnCB)
{
// check to see if calendar frame is loaded
	if (window.frames.calendarControl.document.readyState != "complete")
	{
		setTimeout(RealShowCalendar, 50);
	}
	else
	{
		eP = document.qbo.calendarImage;
		eD = document.qbo.calendarField;
		eDP = null;
		dmin = document.qbo.calendarMinimum;
		dmax = document.qbo.calendarMaximum;

	//	var dF = document.all.CalFrame;
		var dF = document.all.calendarControl;
		if (dF.length > 0) dF = dF[0];

	//	var wF = window.frames.CalFrame;
		var wF = window.frames.calendarControl;

		if(null == wF.g_fCalLoaded || false == wF.g_fCalLoaded)
		{
			alert("Unable to load popup calendar.\r\nPlease reload the page.");
			return;
		}

		wF.SetMinMax(new Date(dmin),new Date(dmax));
		g_fnCB=fnCB;

		if(eD == g_eC && "block" == dF.style.display)
		{
			if(g_eCV != eD.value && GetInputDate(eD.value,g_dFmt))
			{
				wF.SetInputDate(g_day,g_month,g_year);
				wF.SetDate(g_day,g_month,g_year);
				g_eCV = eD.value;
			}
			else
			{	
				dF.style.display = "none";
			}
		}
		else
		{
			if(GetInputDate(eD.value,g_dFmt))
			{
				wF.SetInputDate(g_day,g_month,g_year);
				wF.SetDate(g_day,g_month,g_year);
			}
			else if(null != eDP && GetInputDate(eDP.value,g_dFmt))
			{
				wF.SetInputDate(g_day,g_month,g_year);
				wF.SetDate(g_day,g_month,g_year);
			}
			else
			{
	//			var dt=new Date(dmin);
				var dt = new Date();
				wF.SetInputDate(-1,-1,-1);
				wF.SetDate(dt.getDate(),dt.getMonth()+1,dt.getFullYear());
			}
			var eL = 0;
			var eT = 0;
	//		try {
			for(var p = eP; p && p.tagName != 'BODY'; p = p.offsetParent)
			{
				if (p.tagName == 'DIV')
				{
					eL -= 115;
				}
				else
				{
					eL += p.offsetLeft-38;
					eT += p.offsetTop;
				}
			}
	//		} catch(e) {
				// do nothing
	//			setTimeout("ShowCalendar();", 10);
	//		}

			var eH = eP.offsetHeight;
			var dH = dF.style.pixelHeight;
			var sT = document.body.scrollTop;
			dF.style.left = eL;
			if(eT - dH >= sT && eT + eH + dH > document.body.clientHeight + sT)
			{
				dF.style.top = eT-dH;
			}
			else
			{
				dF.style.top = eT+eH;
			}
			if("none" == dF.style.display)
			{
				dF.style.display = "block";
			}
			g_eC = eD;
			g_eCV = eD.value;

		}
	}
}

function SetDate(d,m,y){
  var ds=GetDateSep();
  g_eC.focus();
  if("mmddyy"==g_dFmt) g_eC.value=m+ds+d+ds+y;
  else if("ddmmyy"==g_dFmt) g_eC.value=d+ds+m+ds+y;
  else g_eC.value=y+ds+m+ds+d;
  g_eC.fireEvent("onchange");
  g_eCV=g_eC.value;
  if(null != g_fnCB && "" != g_fnCB)
    eval(g_fnCB);
}

function GetDOW2(d,m,y){
  var dt=new Date(y,m-1,d);
  return(dt.getDay()+(7-GetDowStart()))%7;
}

function LoadMonths(n){
  var dt=new Date();
  var m=dt.getMonth()+1;
  var y=dt.getFullYear();
  var rg=new Array(n);
  for(i=0; i < n; i++){
    rg[i]=document.createElement("IMG");
    rg[i].src="/eta/months/w" + GetDOW2(1,m,y) + "d" + GetMonthCount(m,y) + ".gif";
    m++;
    if(12 < m){
      m=1;
      y++;
    }
  }
}

//LoadMonths(12);

//--- End calendar function


// Standard event handler for all qbo pages.  
// This can be overridden for any page; just make sure to call document.qbo.initialize();
function loadPage() 
{
	document.qbo.initialize();
}
function qboElementFocus()
{
	theElement = window.event.srcElement;
	theElement.className+=" qbofocus";
}
function qboElementBlur()
{
	theElement = window.event.srcElement;
	theElement.className = theElement.className.replace(new RegExp(" qbofocus\\b"), ""); 
}
function qboFocusEvent(tagName)
{
	var elements = document.getElementsByTagName(tagName); 
	for (var i=0; i<elements.length; i++) 
	{ 
		elements[i].attachEvent("onfocus", qboElementFocus);
		elements[i].attachEvent("onblur", qboElementBlur);
	} 
}
function loadFocus() 
{ 
	qboFocusEvent("INPUT");
	qboFocusEvent("SELECT");
	qboFocusEvent("TEXTAREA");
	document.body.attachEvent("onmouseup", tabClear);
} 
qboEnvironment.prototype.AddCommand = function(label, url, title, position, image)
{
	if (title == null) title = "";
	if (position == null) position = 3;
	if (document.getElementById("TabBar") != null)
	{
	    var command = document.getElementById("TabBar").insertRow(TabBar.rows.length-position);
	    var cell = command.insertCell();
	    cell.className = "commandBar";
    	
	    if (url != null)
		    cell.innerHTML = (image == true ? "<img src='/images/bullet.read.png'/>  " : "") + "<a href=\"" + url + "\" title=\"" + title + "\"/>" + label + "</a>";
	    else
		    cell.innerHTML = (image == true ? "<img src='/images/bullet.read.png'/>  " : "") + label;
	    return(cell);
	}
	else
	    return null;
}
 
if (window.attachEvent) 
{
	window.attachEvent("onload", loadFocus);
}
if (!window.self.tabMode) window.self.tabMode = new Object();

function ErrorWebService(errorDetail)
{
	var div = document.createElement("div");
	div.style.height = "100px";
	div.style.width = "400px";
	div.className = "Dialog";
	div.style.position = "absolute";
	div.style.posLeft = document.body.clientWidth/2 - 200;
	div.style.posTop = document.body.clientHeight/2 - 50;
	div.style.zIndex = 1;
			
	var table = div.appendChild(document.createElement("table"));
	table.className = "standalone";
	var tbody = table.appendChild(document.createElement("tbody"));
	var row = tbody.appendChild(document.createElement("tr"));
	var header = row.appendChild(document.createElement("th"));
	header.colSpan = 2;
	header.innerHTML = "Web Service Error";
	
	var row = tbody.appendChild(document.createElement("tr"));
	var label = row.appendChild(document.createElement("td"));
	label.innerHTML = "Error:";
	var value = row.appendChild(document.createElement("td"));
	value.innerHTML = errorDetail.string;

	var row = tbody.appendChild(document.createElement("tr"));
	var label = row.appendChild(document.createElement("td"));
	label.innerHTML = "Code:";
	var value = row.appendChild(document.createElement("td"));
	value.innerHTML = errorDetail.code;

	var row = tbody.appendChild(document.createElement("tr"));
	var label = row.appendChild(document.createElement("td"));
	label.innerHTML = "Raw:";
	var value = row.appendChild(document.createElement("td"));
	value.innerHTML = errorDetail.raw;

	var row = tbody.appendChild(document.createElement("tr"));
	var footer = row.appendChild(document.createElement("td"));
	footer.colSpan = 2;
	footer.align = "center";
	var button = footer.appendChild(document.createElement("button"));
	button.value = "OK";
	button.className = "button";
	button.onclick = function anonymous(){div.outerHTML = "";}

	document.body.appendChild(div);
}

function objectXml(objectName, theForm)
{
	if (theForm == null) theForm = document.forms[0];
	var objectXml = "<" + objectName + "Collection>";
	theElementList = theForm.elements;	
	for (var i=0; i<theElementList.length; i++) {
		if ((theElementList[i].name == objectName + "ID") && (theElementList[i].checked))
		{
			objectXml = objectXml + "<" + objectName + "Item>";
			objectXml = objectXml + "<" + objectName + "ID>";
			objectXml += theElementList[i].value;
			objectXml = objectXml + "</" + objectName + "ID>";
			objectXml = objectXml + "</" + objectName + "Item>";
		}
	}
	objectXml = objectXml + "</" + objectName + "Collection>";
	
	var result = new ActiveXObject("Microsoft.XMLDOM");
	result.loadXML(objectXml);
	return(result);	
}	

qboEnvironment.prototype.WebService = function()
{
	if (document.readyState == "complete" || document.readyState == "interactive")
	{
		if (this.WebServiceTag != null) return this.WebServiceTag;
		//if (document.readyState != "complete") return null;
		this.WebServiceTag = document.getElementById("WebService");
		if (this.WebServiceTag == null)
		{
			var serviceTag = document.createElement("<div id=\"WebService\" style=\"BEHAVIOR: url(/Library/WebService.htc)\"></div>");
			if (document.body.childNodes.length > 0)
				document.body.insertBefore(serviceTag, document.body.childNodes(0));
			else
				document.body.appendChild(serviceTag);
			this.WebServiceTag = serviceTag;
		}
		return this.WebServiceTag;
	}
	else
	{
		setTimeout(document.qbo.WebService, 25);
	}

}
qboEnvironment.prototype.WebServiceError = function(errorDetail)
{
	ErrorWebService(errorDetail);	
}
qboEnvironment.prototype.SetWebService = function()
{
	if (document.readyState == "complete") // wait for page to fully load so that a check to see if WebService is already on page can occur
	{  
		if (!document.getElementById("WebService")) {
			var serviceTag = document.createElement("<div id=\"WebService\" style=\"BEHAVIOR: url(/Library/WebService.htc)\"></div>");
			if (document.body.childNodes.length > 0) document.body.insertBefore(serviceTag, document.body.childNodes(0));
			else document.body.appendChild(serviceTag);
		}
	} 
	else 
	{
		setTimeout(document.qbo.SetWebService, 25);
	}
}
function LoadWebService()
{
	try 
	{
		ws = document.qbo.WebService();
	}
	catch(e)
	{
		// window.status = "Unable to load webservice node programatically.";
	}
	document.detachEvent("onactivate", LoadWebService);
}
document.attachEvent("onactivate", LoadWebService);

// Calls a web service to obtain the HTML representing a context-sensitive menu
function ContextMenu(sourceElement, useCursor)
{
	if (useCursor)
	{
		alert(event.clientX + "-" + event.clientY);
		this.ClientX = event.clientX;
		this.ClientY = event.clientY;
	}
	this.SourceElement = sourceElement;
	if (sourceElement.webServiceUrl != null)
		this.WebServiceUrl = document.qbo.baseURL + document.qbo.Application + sourceElement.webServiceUrl;
	this.MenuTag = document.createElement("div");
	this.MenuTag.innerHTML = "Loading ...";
	this.Title = sourceElement.title;
	this.SourceClass = sourceElement.className;
	this.MenuTag.style.position = "absolute";
	document.body.appendChild(this.MenuTag);
	this.MenuTag.ContextMenu = this;
	this.Toggle(true);
	
	this.WebService = document.qbo.WebService();
	this.WebService.useService(this.WebServiceUrl + "?WSDL", "ContextMenuMethod");
	var ContextMenuID;
	if (WebService.ContextMenuMethod)
	{
		// Make this context menu a property of the web service method call
		WebService.ContextMenuMethod.ContextMenu = this;
		
		var callOptions = this.WebService.createCallOptions();
		callOptions.funcName = sourceElement.webServiceMethod;
		callOptions.params = new Array();
		for (var i=0; i<sourceElement.attributes.length; i++)
		{
			var attribute = sourceElement.attributes[i];
			if (attribute.name.substring(0, 2) == "ws")
			{
				callOptions.params[attribute.name.substring(2)] = attribute.value;
			}
		}
		ContextMenuID = WebService.ContextMenuMethod.callService(this.WsResult, callOptions);
	}
}
ContextMenu.prototype.WsLoad = function()
{
	
}
ContextMenu.prototype.WsResult = function(result)
{
	if (this.MenuTag == null) 
		return WebService.ContextMenuMethod.ContextMenu.WsResult(result);
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}
	this.MenuTag.innerHTML = result.value;
	this.Toggle(true);
	for (var i=0; i<this.MenuTag.childNodes.length; i++)
	{	
		if (this.MenuTag.childNodes(i).className == "contextMenu")
		{
			contextElement = this.MenuTag.childNodes(i);
			this.MenuTag.childNodes(i).onmouseout = function anonymous()
			{
/*
				if (event.srcElement.className != "contextMenu")
				{
					event.cancelBubble;
					return false;
				}
*/

				var contextMenu = getParentElement(event.srcElement, "DIV").ContextMenu;
				if ((event.clientX - 1 <= contextMenu.Left)
					|| (event.clientX + 1 >= contextMenu.Left + contextMenu.MenuTag.clientWidth)
					|| (event.clientY - 1 <= contextMenu.Top)
					|| (event.clientY + 1 >= contextMenu.Top + contextMenu.MenuTag.clientHeight)
					)				
				{
					contextMenu.Toggle(false);
					// alert("Cancelled");
					event.cancelBubble = true;
				}
				else
				{
					window.status = event.srcElement.tagName;
					window.status += event.clientX + ":" + event.clientY;
					window.status += " - " + contextMenu.Left + ":" + contextMenu.Top;
					window.status += " - " + (contextMenu.Left + contextMenu.MenuTag.clientWidth) + ":" + (contextMenu.Top + contextMenu.MenuTag.clientHeight);
				}

			}
		}
	}
/*
	for (var i=0; i<this.MenuTag.childNodes.length; i++)
	{
		this.MenuTag.childNodes(i).onmouseout = function anonymous() {};
		alert(this.MenuTag.childNodes(i).tagName);
	}
*/
}
ContextMenu.prototype.Toggle = function(showMenu)
{
	if ((this.MenuTag.style.display == "none") || showMenu)
	{
		if (this.ClientX != null)
		{
			this.Left = this.ClientX;
			this.Top = this.ClientY;
		}
		else
		{
			this.Left = 0;
			this.Top = (isNaN(parseInt(this.SourceElement.height))) ? 0 : parseInt(this.SourceElement.height);
			ce = this.SourceElement;
			while (ce != null)
			{
				if (!isNaN(parseInt(ce.offsetLeft))) this.Left += parseInt(ce.offsetLeft);
				if (!isNaN(parseInt(ce.offsetTop))) this.Top += parseInt(ce.offsetTop);
				ce = ce.offsetParent;
			}
		}
				
		this.MenuTag.style.pixelLeft = this.Left;
		this.MenuTag.style.pixelTop = this.Top;

		if (this.MenuTag.clientWidth + this.Left > document.body.clientWidth)
		{
			this.MenuTag.style.pixelLeft = this.Left = document.body.clientWidth - this.MenuTag.clientWidth;
		}
		if (this.MenuTag.clientHeight + this.Top > document.body.clientHeight)
		{
			this.MenuTag.style.pixelTop = this.Top = document.body.clientHeight - this.MenuTag.clientHeight;
		}
		this.MenuTag.style.display = "inline";
		this.SourceElement.title = "";
		this.SourceElement.className = "contextMenu";
	}
	else 
	{
		this.MenuTag.style.display = "none";
		this.SourceElement.title = this.Title;
		this.SourceElement.className = this.SourceClass;
	}
}

function ContextMenuRender(element)
{
	if (element.ContextMenu == null)
	{
		// alert("Creating context menu");
		element.ContextMenu = new ContextMenu(element);
	}
	else
	{
		// alert("Context menu already here");
		element.ContextMenu.Toggle();
	}
}
function ContextMenuToggle(element, show)
{
	if (show == null) show = false;
	var currentElement = element;
	while ((currentElement != null) && (currentElement.ContextMenu == null))
		currentElement = currentElement.parentElement;
	if (currentElement != null)
		currentElement.ContextMenu.Toggle(show);
}
qboEnvironment.prototype.FireWebService = function(element)
{
	var WebService = this.WebService();
	WebService.SourceElement = element;
	if (element.webServiceUrl == null) 
		this.ErrorHandler(null, "FireWebService called from an element without a 'webServiceUrl' attribute: " + element.outerHTML);
	if (element.webServiceMethod == null) 
		this.ErrorHandler(null, "FireWebService called from an element without a 'webServiceMethod' attribute: " + element.outerHTML);
	if (element.webServiceResult == null) 
		this.ErrorHandler(null, "FireWebService called from an element without a 'webServiceResult' attribute: " + element.outerHTML);
	WebService.useService(this.baseURL + element.webServiceUrl + "?WSDL", element.webServiceMethod);
	var WSCallID;
	var WSMethod = eval("WebService." + element.webServiceMethod);	
	if (WSMethod)
	{
		var callOptions = WebService.createCallOptions();
		callOptions.funcName = element.webServiceMethod;
		callOptions.params = new Array();
		for (var i=0; i!=element.attributes.length; i++)
		{
			var attribute = element.attributes[i];
			if (attribute.name.substring(0, 2) == "ws")
			{
				callOptions.params[attribute.name.substring(2)] = attribute.value;
			}
		}
		WSCallID = WSMethod.callService(eval(element.webServiceResult), callOptions); 
		//WebService.SourceElement[WSCallID] = element;
	} 
	else 
		this.ErrorHandler(null, "FireWebService unable to create WebService." + element.webServiceMethod + " object.");
}

function DateChooserRender(element)
{
	if (element.DateChooser == null)
	{
		if (document.DateChooserElement != null)
		{
			document.DateChooserElement.style.display = "none";
			document.DateChooserElement = null;
		}
		element.DateChooser = new DateChooser(element);
	}
	else
	{
		if ((document.DateChooserElement != null) && (document.DateChooserElement != element.DateChooser.DateTag))
		{
			document.DateChooserElement.style.display = "none";
			document.DateChooserElement = null;
		}
		element.DateChooser.RenderMonth(new Date(element.value));
		// element.DateChooser.Render();
	}
}		
function DateChooserRemove(sourceElement)
{
//	if ((sourceElement != null) && (sourceElement.DateChooser != null))
//	{
//		sourceElement.DateChooser.DateTag.style.display="none";
//		document.DateChooserElement = null;
//		return;
//	}
	if (document.DateChooserElement != null)
	{
		// if (document.DateChooser.SourceElement.hasFocus()) return;
		var ex = event.x + document.body.scrollLeft;
		var ey = event.y + document.body.scrollTop;
		if (event.keyCode > 0) alert(event.keyCode);
		if ((ex < document.DateChooserElement.style.pixelLeft)
			|| (ey < document.DateChooserElement.style.pixelTop - document.DateChooserElement.DateChooser.SourceElement.clientHeight)
			|| (ex > document.DateChooserElement.style.pixelLeft + document.DateChooserElement.clientWidth)
			|| (ey > document.DateChooserElement.style.pixelTop + document.DateChooserElement.clientHeight)
			)
		{
			window.status = "Removing: " + event.clientX + "." + event.clientY + " - " + document.DateChooserElement.style.pixelTop + "." + document.DateChooserElement.style.pixelLeft;
			document.DateChooserElement.style.display = "none";
			document.DateChooserElement = null;
		}	
	}
}
function DateChooserJump(element)
{
	getParentElement(element, "DIV").DateChooser.RenderMonth(new Date(element.jumpDate));
}
function DateChooserSet(element)
{
	getParentElement(element, "DIV").DateChooser.SetDate(new Date(element.jumpDate));
}
function DateChooser(element)
{
	this.MonthArray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	this.LengthArray = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	this.SourceElement = (element.sourceField) ? document.all[element.sourceField] : element;
	this.DateTag = document.createElement("div");
	this.MinDate = (this.SourceElement.DateMin) ? new Date(this.SourceElement.DateMin) : null;
	this.MaxDate = (this.SourceElement.DateMax) ? new Date(this.SourceElement.DateMax) : null;
	this.RenderMonth(new Date(this.SourceElement.value));
	this.DateTag.style.position = "absolute";
	document.body.appendChild(this.DateTag);
	this.DateTag.DateChooser = this;
	this.SourceElement.DateChooser = this;
}
DateChooser.prototype.Position = function()
{
	this.Left = 0;
	this.Top = (isNaN(parseInt(this.SourceElement.offsetHeight))) ? 0 : parseInt(this.SourceElement.offsetHeight);
	ce = this.SourceElement;
	while (ce != null)
	{
		if (!isNaN(parseInt(ce.offsetLeft))) this.Left += parseInt(ce.offsetLeft);
		if (!isNaN(parseInt(ce.offsetTop))) this.Top += parseInt(ce.offsetTop);
		ce = ce.offsetParent;
	}
				
	this.DateTag.style.pixelLeft = this.Left; //+ document.body.scrollLeft;
	this.DateTag.style.pixelTop = this.Top;// + document.body.scrollTop;
	window.status = "Positioning: " + this.Left + "." + this.Top + " - " + this.DateTag.style.pixelLeft + "." + this.DateTag.style.pixelTop;

//	if (this.DateTag.clientWidth + this.Left > document.body.clientWidth)
//	{
//		this.DateTag.style.pixelLeft = this.Left = document.body.clientWidth - this.DateTag.clientWidth;
//	}
//	if (this.DateTag.clientHeight + this.Top > document.body.clientHeight)
//	{
//		this.DateTag.style.pixelTop = this.Top = document.body.clientHeight - this.DateTag.clientHeight;
//	}

}
DateChooser.prototype.SetDate = function(date)
{
	this.SourceElement.value = document.qbo.getDateString(date);
	this.SourceElement.fireEvent("onchange");
	this.DateTag.style.display = "none";
}
DateChooser.prototype.RenderMonth = function(renderDate)
{
	this.Position();
	document.DateChooserElement = this.DateTag;
	if ((renderDate == null) || ("" + renderDate == "NaN"))
		renderDate = new Date();
	if (this.DateTag.firstChild != null)
		this.DateTag.removeChild(this.DateTag.firstChild);
	this.DateTag.innerHTML = "";

	var table = this.DateTag.appendChild(document.createElement("table"));
	table.style.zIndex = 1;
	table.className = "contextMenu";
	this.DateTag.attachEvent("onmouseout", DateChooserRemove);	
	document.body.attachEvent("onclick", DateChooserRemove);
	
	var tbody = table.appendChild(document.createElement("tbody"));
	var row = tbody.appendChild(document.createElement("tr"));
	var cell = row.appendChild(document.createElement("td"));
	var jumpDate = new Date(renderDate);
	cell.innerHTML = "<a onmouseover=\"this.style.cursor='hand';\" jumpDate=\"" + new Date(jumpDate.setMonth(jumpDate.getMonth()-1)) + "\" onclick=\"DateChooserJump(this);\">&lt;</a>";
	
	cell = row.appendChild(document.createElement("td"));
	cell.colSpan = 5;
	cell.align="center";
	cell.innerHTML = this.MonthArray[renderDate.getMonth()] + " " + renderDate.getFullYear();

	var cell = row.appendChild(document.createElement("td"));
	var jumpDate = new Date(renderDate);
	cell.innerHTML = "<a onmouseover=\"this.style.cursor='hand';\" jumpDate=\"" + new Date(jumpDate.setMonth(jumpDate.getMonth()+1)) + "\" onclick=\"DateChooserJump(this);\">&gt;</a>";

	row = tbody.appendChild(document.createElement("tr"));
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "S";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "M";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "T";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "W";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "T";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "F";
	cell.align="center";
	cell = row.appendChild(document.createElement("td"));
	cell.innerHTML = "S";
	cell.align="center";

	var theDate = new Date(renderDate.setDate(1));
	var theDay = theDate.getDay();
	var theYear = (theDate.getFullYear() < 1000) ? theDate.getFullYear()+1900 : theDate.getFullYear();
	this.LengthArray[1] = ( ( ((theYear%4)==0) && ((theYear%100)!=0) ) || ((theYear%1000)==0)) ? 29 : 28;

	row = tbody.appendChild(document.createElement("tr"));
	for (i=0; i<theDay; i++) 
	{
		cell = row.appendChild(document.createElement("td"));
		cell.innerHTML = "&nbsp;";
	}
	for (i=1; i<=this.LengthArray[theDate.getMonth()]; i++) 
	{
		if (theDay++ == 7) {
			row = tbody.appendChild(document.createElement("tr"));
			theDay = 1;
		}	
		cell = row.appendChild(document.createElement("td"));
		// cell.innerHTML = i;
		cell.align="right";
		cell.innerHTML = this.RenderDay(new Date(theDate.setDate(i)));	//this.RenderDay(theDate);
	}
	for (i=theDay; i<7; i++) 
	{
		cell = row.appendChild(document.createElement("td"));
		cell.innerHTML = "&nbsp;";
	}
	this.DateTag.style.display = "inline";
}
DateChooser.prototype.RenderDay = function(theDay)
{
	//return new String(theDay.getDate());
if ( ((theDay >= this.MinDate) || (this.MinDate == null))
		&& (((this.MaxDate != null) && (theDay.getDate() <= this.MaxDate.getDate()) && theDay.getMonth() <= this.MaxDate.getMonth() && theDay.getYear() <= this.MaxDate.getYear()) || (this.MaxDate == null)) )
	{
		var result = "<a onmouseover=\"this.style.cursor='hand';\" jumpDate=\"" + theDay + "\" onclick=\"DateChooserSet(this);\">";
		result += "" + theDay.getDate();
		result += "</a>";
	}
	else
	{
		result = "<i>" + theDay.getDate() + "</i>";
	}
	return result;
}

function SetDefaultLabel(element)
{
	if ((element.value == "") && (element.defaultLabel != null)) 
	{
		element.value = element.defaultLabel;
		element.style.color = "Gray";
		element.attachEvent("onfocus", function anon() 
		{
			var element = event.srcElement; 
			if (element.value == element.defaultLabel) element.value = '';
			element.style.color = "Black";
		});
		element.attachEvent("onblur", function anon() 
		{
			var element = event.srcElement; 
			if (element.value == '') 
			{
				element.value = element.defaultLabel;
				element.style.color = "Gray";
			}
		});
	}
}


// Multi-Select AJAX control
function MultiSelectFetch(element)
{
	if (element == null) element = event.srcElement;
	element = getParentElement(element, "TABLE");
	if (element.MultiSelectControl == null)
		element.MultiSelectControl = new MultiSelectControl(element);
	return element.MultiSelectControl;
}
function MultiSelectGet(element)
{
	return MultiSelectFetch(element);
}
function MultiSelectToggle(element)
{
	MultiSelectGet(element).Toggle();
}		
function MultiSelectClick(element)
{
	MultiSelectGet(element).Selection(element);
}
function MultiSelectClear(element)
{
	MultiSelectGet(element).Clear(element);
}
function MultiSelectControl(element)
{
	this.Table = (element.tagName != "TABLE") ? getParentElement(element, "TABLE") : element;
	this.ID = this.Table.id.substring(0, this.Table.id.length-6);
	this.XmlElement = document.all[this.ID + "_Xml"];
	this.Procedure = document.getElementById(this.ID + "_Procedure");
	this.SearchElement = document.getElementById(this.ID + "_Search");
	this.NodeName = this.Table.nodeName;
	this.RecordCount = parseInt(this.Table.recordCount);
	this.RecordStart = 0;
	this.DisplaySize = (this.Table.displaySize == null) ? 15: parseInt(this.Table.displaySize);
	this.DataTextField = this.Table.dataTextField;
	this.DataValueField = this.Table.dataValueField;
	this.WebService = document.qbo.WebService();
	this.WebServiceUrl = "/Report/ReportService.asmx";
	this.SelectedNodes = new ActiveXObject(document.qbo.classXML);
	
	if (this.XmlElement.value != "")
	{
		this.SelectedNodes.loadXML(this.XmlElement.value);
	}
	else
		this.SelectedNodes.loadXML("<MLT/>");
	
	if (this.Table.style.position != "absolute")
	{
		this.ParentHeight = this.Table.parentElement.clientHeight;
		this.ParentWidth = this.Table.parentElement.clientWidth;
		this.Expanded = false;
		this.Table.style.position="absolute";
		this.Table.parentElement.height = this.ParentHeight;
		this.Table.parentElement.width = this.ParentWidth;
	}
}
MultiSelectControl.prototype.Selection = function(checkbox)
{
	var elements = this.Table.all.tags("INPUT");
	elements[0].checked = false;
	this.XmlElement.value = "";

	if (checkbox.checked)
	{
		window.status = "Adding node for " + checkbox.value;
		if (checkbox.XmlNode == null)
		{
			var node = this.SelectedNodes.createNode(1, this.NodeName, "");
			node.text = checkbox.value;
			if (checkbox.label != null)
				node.setAttribute("label", checkbox.label);
			this.SelectedNodes.documentElement.appendChild(node);
			checkbox.XmlNode = node;
		}
	}
	else
	{
		if (checkbox.XmlNode == null)
			checkbox.XmlNode = this.SelectedNodes.selectSingleNode("//" + this.NodeName + "[.='" + checkbox.value + "']");
		if (checkbox.XmlNode != null)
			this.SelectedNodes.documentElement.removeChild(checkbox.XmlNode);
	}
	
	if (this.SelectedNodes.selectNodes("//" + this.NodeName).length > 0)
		this.XmlElement.value = this.SelectedNodes.xml;
	// alert(this.SelectedNodes.xml);
}
MultiSelectControl.prototype.Clear = function()
{
	this.XmlElement.value = "";
	var elements = this.Table.all.tags("INPUT");
	for (var i=1; i<elements.length; i++) if (elements[i].type == "checkbox")
	{
		elements[i].checked = false;
		elements[i].XmlNode = null;
	}
	this.SelectedNodes.loadXML("<MLT/>");
}
MultiSelectControl.prototype.Toggle = function()
{
	this.Expanded = !this.Expanded;
	this.Table.style.zIndex = (this.Expanded) ? 1 : null;
	for (var i=1; i<this.Table.all.tags("TR").length; i++)
	{
		var tag = this.Table.all.tags("TR")[i];
		window.status = "Row " + i + " style is " + tag.style.display;
		tag.style.display = (tag.style.display == "inline") ? "none" : "inline";
	}
	// window.status = this.ID + " zindex is " + this.Table.style.zIndex;
}
MultiSelectControl.prototype.Default = function()
{
	if (this.XmlElement.value == "") return;
	
	var theXml = new ActiveXObject(document.qbo.classXML);
	theXml.loadXML(this.XmlElement.value);
	
	var elements = this.Table.all.tags("INPUT");
	elements[0].checked = false;

	var hasElement = false;	
	for (var i=1; i<elements.length; i++) if (elements[i].type == "checkbox")
	{
		var node = theXml.selectSingleNode("//" + this.NodeName + "[.='" + elements[i].value + "']");
		elements[i].checked = (node != null);
		
		hasElement = elements[i].checked || hasElement;
	}
	elements[0].checked = !hasElement;
	this.XmlElement.value = !hasElement ? "" : this.XmlElement.value;
}
MultiSelectControl.prototype.ToggleMatch = function()
{
	if (this.XmlElement.value == "") return;
	
	var elements = this.Table.all.tags("INPUT");
	elements[0].checked = false;
	for (var i=1; i<elements.length; i++) if (elements[i].type == "checkbox")
	{
		elements[i].XmlNode = this.SelectedNodes.selectSingleNode("//" + this.NodeName + "[.=" + elements[i].value + "]");
		elements[i].checked = (elements[i].XmlNode != null);
	}
}
MultiSelectControl.prototype.SetRecordStart = function(recordStart)
{
	if (recordStart != null)
		this.RecordStart = recordStart;
	var rs = this.Procedure.selectSingleNode("//RecordStart");
	if (rs == null)
	{
		var rs = this.Procedure.createNode(1, "RecordStart", "");
		this.Procedure.selectSingleNode("//StoredProcedure").appendChild(rs);
	}
	rs.text = this.RecordStart;
	var ds = this.Procedure.selectSingleNode("//DisplaySize");
	if (ds == null)
	{
		var ds = this.Procedure.createNode(1, "DisplaySize", "");
		this.Procedure.selectSingleNode("//StoredProcedure").appendChild(ds);
	}
	ds.text = this.DisplaySize;
}
MultiSelectControl.prototype.PreviousPage = function()
{
	this.RecordStart -= this.DisplaySize;
	this.SetRecordStart();
	this.Redraw();	
}
MultiSelectControl.prototype.NextPage = function()
{
	this.RecordStart += this.DisplaySize;
	this.SetRecordStart();
	this.Redraw();	
}
MultiSelectControl.prototype.Search = function(searchString)
{
	var ssNode = this.Procedure.selectSingleNode("//SearchString");
	ssNode.text = searchString + "%";
	this.RecordStart = 0;
	this.SetRecordStart();
	this.Redraw();
}
MultiSelectControl.prototype.Redraw = function()
{
	this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ReportService");
	this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
	if (this.WebService.ReportService)
	{
		this.ReportResultID = this.WebService.ReportService.callService(this.Render, "ExecuteProcedure", this.Procedure);
		document.qbo.WebServiceArray[this.ReportResultID] = this;
		this.Trace("ObjectBaseResultID is  " + this.ReportResultID);
		window.status = "Launched " + this.ReportResultID + " " + document.qbo.WebServiceArray[this.ReportResultID];
	}
	else 
	{
		this.Error("Failed to launch web service call to MultiSelectControl.Redraw");
	}
}
MultiSelectControl.prototype.Render = function(result)
{
	if (this.WebServiceUrl == null) 
	{
		window.status = "Getting object from WebServiceArray";
		if (document.qbo.WebServiceArray[result.id] == null) 
		{
			alert("Could not find MultiSelectList " + result.id);
			return;
		}
		else 
			return document.qbo.WebServiceArray[result.id].Render(result);
	}
	if (result.id < this.ReportResultID) 
	{
		window.status = "Newer request pending; bailing on this one.";
		return;
	}
	this.Trace("Okay so far");
	if (result.error)
	{
		alert(result.errorDetail.string);
		return;
	}
	this.Trace("MultiSelect.Render Success!" + result.value);

	if (result.value == null)
	{
		window.status = "No results returned.";
	}
	else
	{
		var tbody = this.Table.firstChild;
		var startIndex = (this.SearchElement == null) ? 1 : 2;
		for (var i=tbody.childNodes.length; i > startIndex; i--)
		{
			tbody.removeChild(tbody.childNodes[i-1]);
		}
		var rc = result.value.selectSingleNode("//RecordCount");
		if (rc != null)
			this.RecordCount = parseInt(rc.text);
		optionList = result.value.selectNodes("//" + this.DataTextField);
		valueList = result.value.selectNodes("//" + this.DataValueField);
		for (var i=0; i<optionList.length; i++)
		{
			// var optionRow = tbody.appendChild(document.createElement("<tr id=\"option\" style=\"display:inline\""));
			var optionRow = tbody.appendChild(document.createElement("tr"));
			optionRow.id = "option";
			optionRow.style.display = "inline";

			var optionCell = optionRow.appendChild(document.createElement("td"));
			optionCell.innerHTML = optionList[i].text;
			
			var checkCell = optionRow.appendChild(document.createElement("td"));
			var checkboxInput = checkCell.appendChild(document.createElement("<input type='checkbox' onclick=\"MultiSelectFetch().Selection(this);\"/>"));
			checkboxInput.value = (valueList.length > i) ? valueList[i].text : optionList[i].text;
			checkboxInput.label = optionList[i].text;
			checkboxInput.XmlNode = this.SelectedNodes.selectSingleNode("//" + this.NodeName + "[.=" + checkboxInput.value + "]");
			checkboxInput.checked = (checkboxInput.XmlNode != null);
		}
		// Next
		if ((this.RecordStart > 0) || ((this.RecordStart + this.DisplaySize) < this.RecordCount))
		{
			var optionRow = tbody.appendChild(document.createElement("tr"));
			optionRow.id = "option";
			optionRow.style.display = "inline";
			var optionCell = optionRow.appendChild(document.createElement("td"));
			optionCell.colSpan = 2;			
			optionCell.innerHTML = "";
			if (this.RecordStart > 0)
			{
				optionCell.innerHTML += "<a href=\"#\" onclick=\"MultiSelectFetch().PreviousPage()\"><< Back</a>";
			}
			if ((this.RecordStart + this.DisplaySize) < this.RecordCount)
			{
				if (this.RecordStart > 0)
					optionCell.innerHTML += " | ";
				optionCell.innerHTML += "<a href=\"#\" onclick=\"MultiSelectFetch().NextPage()\">Next >></a>";
			}
		}
	}
}

MultiSelectControl.prototype.Trace = function(message)
{
	if (this.Tracing == true)
		alert(message);
}


// Object Panel methods
function ObjectPanel(element)
{
	if (element == null) element = event.srcElement;
	element = getParentElement(element, "DIV");
	if (element == null) 
	{	
		window.status = "ObjectPanel: no div tag";
		return;
	}
	
	this.Tag = element;
	element.ObjectPanel = this;
	if (this.Tag.ObjectName == null)
		alert("No ObjectName attribute for panel '" + this.Tag.id + "'");
	this.ObjectName = this.Tag.ObjectName;
	if (this.Tag.WebServiceUrl == null)
		alert("No WebServiceUrl attribute for panel '" + this.Tag.id + "'");
	this.WebServiceUrl = this.Tag.WebServiceUrl;
	if (this.Tag.ParentObject == null)
		alert("No ParentObject attribute for panel '" + this.Tag.id + "'");
	this.ParentObject = this.Tag.ParentObject;
	if (this.Tag.ParentObjectID == null)
		alert("No ParentObjectID attribute for panel '" + this.Tag.id + "'");
	this.ParentObjectID = this.Tag.ParentObjectID;	
	this.wsCount = 0;

	this.SortBy = this.ObjectName;
	this.RecordStart = 0;
	this.DisplaySize = 25;
	this.Parameters = document.getElementById(this.Tag.id + "Parameters");

	//setTimeout("document.all['" + this.Tag.id + "'].ObjectPanel.SetWebService();", 25);
}
ObjectPanel.prototype.ExecuteMethod = function(method)
{
	var payload = objectXml(this.ObjectName);
	this.Tag.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectPanelMethod");
	if (this.Tag.ObjectPanelMethod)
	{
		var ObjectPanelResultID = this.Tag.ObjectPanelMethod.callService(this.ExecuteMethodResult, method, payload);
		document.qbo.WebServiceArray[ObjectPanelResultID] = this;
		window.status = "Launched " + ObjectPanelResultID + " " + document.qbo.WebServiceArray[ObjectPanelResultID];
		document.qbo.MaskUI(this.Tag);
	}
	else 
	{
		window.status = "Failed to launch";
	}
}
ObjectPanel.prototype.ExecuteMethodResult = function(result)
{
	if (this.Tag == null) 
	{
		if (document.qbo.WebServiceArray[result.id] == null) 
			alert("But could not find it! " + result.id);
		else 
			return document.qbo.WebServiceArray[result.id].ExecuteMethodResult(result);
	}
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}
//	alert("About to List " + this.Tag.id);
	this.List();
}
ObjectPanel.prototype.BuildStatement = function(stmt, method)
{
	var params = this.Parameters.selectSingleNode("/ParameterCollection/" + method)
	for (var i=0; i<params.childNodes.length; i++)
	{
		stmt += ", \"" + params.childNodes[i].text + "\"";
	}
	return stmt;
}
ObjectPanel.prototype.SetParameter = function(xpath, value)
{ 
	var nodes = this.Parameters.selectNodes(xpath);
	for (var i=0; i<nodes.length; i++)
		nodes[i].text = value;
}
ObjectPanel.prototype.GetParameter = function(xpath)
{
	var node = this.Parameters.selectSingleNode(xpath);
	return (node) ? node.text : null;
}
ObjectPanel.prototype.List = function(sortBy)
{
	var currentSort = this.Parameters.selectSingleNode("/ParameterCollection/PanelList/SortBy");
	if (sortBy) 
		currentSort.text = (currentSort.text == sortBy) ? "-" + sortBy : sortBy;
	this.Tag.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectPanelList");
	var listMethod = (this.Tag.ListMethod) ? this.Tag.ListMethod : "PanelList";
	if (this.Tag.ObjectPanelList)
	{
		var stmt = this.BuildStatement("this.Tag.ObjectPanelList.callService(this.ListResult, \"" + listMethod + "\"", "PanelList") + ")";
		var ObjectPanelResultID = eval(stmt);
		document.qbo.WebServiceArray[ObjectPanelResultID] = this;
		document.qbo.MaskUI(this.Tag);
	}
	else
	{
		window.status = "Failed";
	}
}
ObjectPanel.prototype.ListXslt = function(listMethod, sortBy)
{
	var currentSort = this.Parameters.selectSingleNode("/ParameterCollection/PanelList/SortBy");
	if (sortBy) 
		currentSort.text = (currentSort.text == sortBy) ? "-" + sortBy : sortBy;
	this.Tag.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectPanelList");
	//var listMethod = (this.Tag.ListMethod) ? this.Tag.ListMethod : "PanelList";
	if (this.Tag.ObjectPanelList)
	{
		var stmt = this.BuildStatement("this.Tag.ObjectPanelList.callService(this.ListResult, \"" + listMethod + "\"", "PanelList") + ")";
		var ObjectPanelResultID = eval(stmt);
		document.qbo.WebServiceArray[ObjectPanelResultID] = this;
		document.qbo.MaskUI(this.Tag);
	}
	else
	{
		window.status = "Failed";
	}
}
ObjectPanel.prototype.ListXslt = function(listMethod, sortBy)
{
	var currentSort = this.Parameters.selectSingleNode("/ParameterCollection/PanelList/SortBy");
	if (sortBy) 
		currentSort.text = (currentSort.text == sortBy) ? "-" + sortBy : sortBy;
	this.Tag.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectPanelList");
	//var listMethod = (this.Tag.ListMethod) ? this.Tag.ListMethod : "PanelList";
	if (this.Tag.ObjectPanelList)
	{
		var stmt = this.BuildStatement("this.Tag.ObjectPanelList.callService(this.ListResult, \"" + listMethod + "\"", "PanelList") + ")";
		var ObjectPanelResultID = eval(stmt);
		document.qbo.WebServiceArray[ObjectPanelResultID] = this;
		document.qbo.MaskUI(this.Tag);
	}
	else
	{
		window.status = "Failed";
	}
}
ObjectPanel.prototype.ListResult = function(result)
{
	if (this.Tag == null) 
		return document.qbo.WebServiceArray[result.id].ListResult(result);
	document.qbo.UnMaskUI(this.Tag);
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}
	this.Tag.outerHTML = result.value;
	if (result.value > "")
		new ObjectPanel(document.all[this.Tag.id]);

	document.qbo.SetBehaviorContent();
	FooterAlign();
}
ObjectPanel.prototype.SetPage = function(recordStart) 
{
	var rs = this.Parameters.selectSingleNode("/ParameterCollection/PanelList/RecordStart");
	rs.text = recordStart;
	this.List();
	return;
}
ObjectPanel.prototype.SetDisplaySize = function(element)
{
	var ds = this.Parameters.selectSingleNode("/ParameterCollection/PanelList/DisplaySize");
	var displaySize = element.innerHTML;
	if (isNaN(displaySize))
	{
		alert("'" + displaySize  + "' is not a valid dislay size.");
		element.innerHTML = (ds.text == "") ? 25 : ds.text;
		return;
	}
	ds.text = displaySize;
	if (parseInt(element.recordBegin) + parseInt(displaySize) > parseInt(element.recordCount))
		this.Parameters.selectSingleNode("/ParameterCollection/PanelList/RecordStart").text = 0;
	this.List();
}
//Suggestion Object - Start
function SuggestionQueue(element)
{
	if (element != null)
	{
		var suggestion = (element.Suggestion) ? element.Suggestion : new Suggestion(element);
		suggestion.SetKeyCode(event.keyCode);
		document.SuggestionObject = suggestion;
		if (suggestion.ArrowKey)
			suggestion.Suggest();
		else
			setTimeout(SuggestionQueue, 1000);
	}
	else
		document.SuggestionObject.Suggest();
}

function Suggestion(element)
{
	this.SourceElement = element;
	this.MinCharCount = element.MinCharCount;
	this.DisplaySize = element.DisplaySize;
	this.DataTextField = element.DataTextField;
	this.DataValueField = element.DataValueField;
	this.ValueParameter = element.ValueParameter;
	this.ProcedureXml = eval(element.id + "_Parameters");
	this.Display = eval(element.id + "_Display");
	this.DisplayClass = this.Display.className;
	this.SelectedClass = this.DisplayClass + "Selected";
	this.CanInsert = (element.CanInsert == "True");
	this.ValueField = element.form.elements[element.id + "_Value"];
	//this.ValueField.value = 
	this.ValueNode = this.ProcedureXml.selectSingleNode("//" + this.ValueParameter);
	this.WebService = document.qbo.WebService();
	this.HasService = false;
	this.Display.Suggestion = this;
	this.KeyCode = event.keyCode;
	this.LastValue = "";
	this.SelectedIndex = null;
	this.ResultXml = null;
	this.Iteration = 0;
	this.Debug = false;
	this.SourceElement.Suggestion = this;
	this.SelectedValue = null;
	this.Format = element.Format;
	this.SourceElement.attachEvent("onblur", this.ClearDisplay);
	this.SourceElement.attachEvent("onchange", this.Change);

	this.Position();
}
Suggestion.prototype.SetKeyCode = function(keyCode)
{
	this.KeyCode = keyCode;
	this.ArrowKey = ((this.KeyCode == 38) || (this.KeyCode == 39) || (this.KeyCode == 40) || (this.KeyCode == 13));
}
Suggestion.prototype.Change = function()
{
	if (this.SourceElement == null)
	{
		event.srcElement.Suggestion.Change();
		return;
	}
	this.SelectedIndex = null;
}
Suggestion.prototype.Position = function()
{
	this.Display.style.position = "absolute";
	this.Left = 0;
	this.Top = (isNaN(parseInt(this.SourceElement.offsetHeight))) ? 0 : parseInt(this.SourceElement.offsetHeight);
	ce = this.SourceElement;
	while (ce != null)
	{
		if (!isNaN(parseInt(ce.offsetLeft))) this.Left += parseInt(ce.offsetLeft);
		if (!isNaN(parseInt(ce.offsetTop))) this.Top += parseInt(ce.offsetTop);
		ce = ce.offsetParent;
	}
				
	this.Display.style.pixelLeft = this.Left;
	this.Display.style.pixelTop = this.Top;
	
	if (this.Display.clientWidth + this.Left > document.body.clientWidth)
		this.Display.style.pixelLeft = this.Left = document.body.clientWidth - this.Display.clientWidth;
	if (this.Display.clientHeight + this.Top > document.body.clientHeight)
		this.Display.style.pixelTop = this.Top = document.body.clientHeight - this.Display.clientHeight;
}
Suggestion.prototype.Suggest = function()
{
	this.Iteration++;
	//if (this.Debug) test.innerHTML += "<br/>Suggest start: " + this.ArrowKey + "; " + this.Iteration + "; " + this.SourceElement.value.length + "; " + this.MinCharCount;

	if (this.SourceElement.value.length < this.MinCharCount) return;
	
	if (this.ValueNode != null)
	{
		if (this.Format == "Email")
		{
			this.SourceElement.value = this.SourceElement.value.replace(/,/g, ";");	//replaceIt(this.SourceElement.value, ",", ";");
		
			if (this.SourceElement.value.lastIndexOf(";") > -1)
			{
				this.ValueNode.text = this.SourceElement.value.substr(this.SourceElement.value.lastIndexOf(";")+1, this.SourceElement.value.length)
				this.ValueNode.text = this.ValueNode.text.replace(/ /g, "") + "%";	//replaceIt(this.ValueNode.text, " ", "") + "%";
			}
			else
				this.ValueNode.text = this.SourceElement.value + "%";

			if (this.ValueNode.text.length < (this.MinCharCount)) return
		}
		else
			this.ValueNode.text = this.SourceElement.value + "%";
	}

	if (!this.HasService)
	{
		//if (this.Debug) test.innerHTML += "<br/>Suggest ws creation: " + this.ArrowKey + "; " + this.Iteration;
		this.WebService.useService(document.qbo.baseURL  + document.qbo.Application + "/Report/ReportService.asmx?WSDL", "ReportService");
		this.HasService = this.WebService.ReportService;
	}
	
	if ((this.HasService) && (!this.ArrowKey) && (this.LastValue != this.SourceElement.value))
	{
		//if (this.Debug) test.innerHTML += "<br/>Suggest query: " + this.LastValue + "; " + this.SourceElement.value;
		this.LastValue = this.SourceElement.value;
		this.SourceElement.ReportCallID = this.WebService.ReportService.callService(this.Render, "ExecuteProcedure", this.ProcedureXml);
		//if (this.Debug) test.innerHTML += "<br/>" + this.SourceElement.ReportCallID;
		document.qbo.WebServiceArray[this.SourceElement.ReportCallID] = this.SourceElement;
	}
	else if ((this.ArrowKey) && (this.ResultXml != null)) 
	{
		//if (this.Debug) test.innerHTML += "<br/>Arrow Suggest SelectItem: " + this.ArrowKey + "; " + this.Iteration;
		this.SelectItem();
	}
	else if ((this.ResultXml != null))
	{
		this.Display.style.display = "inline";
		this.SelectedIndex = null;
	}
	else 
	{
		// if (this.Debug) test.innerHTML += "<br/>Suggest nothing: " + this.ArrowKey + "; " + this.Iteration;
	}

}
Suggestion.prototype.SetValue = function(cell, clear)
{
	//if (this.Debug) test.innerHTML += "<br/>SetValue: " + this.ArrowKey + "; " + this.Iteration + "; " + cell.innerHTML;
	if (this.Format == "Email")
	{
		this.SourceElement.value = this.SourceElement.value.replace(/,/g, ";");	//replaceIt(this.SourceElement.value, ",", ";");
	
		if (this.SourceElement.value.lastIndexOf(";") > -1)
			this.SourceElement.value = this.SourceElement.value.substr(0, this.SourceElement.value.lastIndexOf(";")+1) + " " + cell.innerHTML;
		else
			this.SourceElement.value = cell.innerHTML;
	}
	else
		this.SourceElement.value = cell.innerHTML.replace(/\&amp\;/g, "&");

	this.ValueField.value = cell.Value;
	this.SelectedValue = cell.innerHTML;
	
	if (this.SourceElement.onselect) 
	{
		document.SuggestionObject = this;
		this.SourceElement.onselect();
	}
	
	cell.className = "";
	//while(document.getElementById("iShim")) document.body.removeChild(document.getElementById("iShim"));
	this.Display.style.display = "none";
	this.SelectedIndex = null;

	if (clear)
		this.ClearDisplay(true);
}
Suggestion.prototype.ClearDisplay = function(fromMethod)
{
	if (this.SourceElement == null)
		return event.srcElement.Suggestion.ClearDisplay(fromMethod);
		
	//if (this.Debug) test.innerHTML += "<br/>ClearDisplay: " + (fromMethod == false) + "; " + this.KeyCode;

	if ((this.KeyCode == null) && (!fromMethod)) return;

	cellIndex = -1;
	//Trapping the tab character
	if (this.Cells != null)
		for (i=0; i<this.Cells.length; i++)
		{
			if (this.Cells[i].className == this.SelectedClass)
			{
				this.SelectedIndex = i;
				this.SetValue(this.Cells[this.SelectedIndex], false);
				cellIndex = this.SelectedIndex;
			}
		}
		
	if (cellIndex < 0
		&&	this.SourceElement.value != this.SelectedValue)
	{
		if (!this.CanInsert)
		{
			this.SourceElement.value = "";
		}
		else
		{
			this.ValueField.value = "";
			
			if (this.SourceElement.onselect) 
			{
				document.SuggestionObject = this;
				this.SourceElement.onselect();
			}
		}
	}

	if (!this.CanInsert)
	{
		if (this.ValueField.value == "")
			this.SourceElement.value = "";
		else 
			window.status = "Clearing: " + this.ValueField.value;
	}
	
	this.KeyCode = null;
	this.Display.style.display = "none";
	while(document.getElementById("iShim")) document.body.removeChild(document.getElementById("iShim"));
}
Suggestion.prototype.SelectItem = function(cell)
{
	//if (this.Debug) test.innerHTML += "<br/>kc SelectItem: " + this.SelectedIndex + "; ";
	if (cell) this.KeyCode = null;
	if (this.SelectedIndex == null)
		this.SelectedIndex = (cell) ? cell.Index : 0;
	else
	{
		this.Cells[this.SelectedIndex].className = "";
		if (this.KeyCode == 40) this.SelectedIndex++;
		else if (this.KeyCode == 38)
		{
			if (this.SelectedIndex != null)
			{
				if (this.SelectedIndex < 1)
				{
					this.Cells[this.SelectedIndex].className = "";
					this.SelectedIndex = null;
				}
				else
					this.SelectedIndex--;
			}
		}
		else if ((this.KeyCode == 39) || (this.KeyCode == 13))
		{
			this.SetValue(this.Cells[this.SelectedIndex], true);
			return;
		}
		else if (cell)
		{
			this.SelectedIndex = cell.Index;
			this.KeyCode = null;
		}
	}
	
	if (this.SelectedIndex != null)
	{
		if (this.SelectedIndex >= this.Cells.length) this.SelectedIndex = this.Cells.length-1;
		this.Cells[this.SelectedIndex].className = this.SelectedClass;
		//if (this.Debug) test.innerHTML += this.SelectedIndex + "; ";
	}
}
Suggestion.prototype.ClearItem = function()
{
	if (this.SelectedIndex != null)
	{
		cells[this.SelectedIndex].className = "";
		this.SelectedIndex = null;
	}
}
Suggestion.prototype.Render = function(result)
{
	//if (this.Debug) test.innerHTML += "<br/>Render: " + this.ArrowKey + "; " + this.Iteration;
	if (this.SourceElement == null)
	{
		document.qbo.WebServiceArray[result.id].Suggestion.Render(result);
		return;
	}
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}
	function onover()
	{
		getParentElement(event.srcElement, "DIV").Suggestion.SelectItem(event.srcElement);
	}
	function onout()
	{
		var cell = event.srcElement;
		cell.className = "";
	}
	function doclick()
	{
		var cell = event.srcElement;
		getParentElement(cell, "DIV").Suggestion.SetValue(cell, true);
	}
	if (result.value)
	{
		this.ResultXml = result.value;
		var resultList = result.value.selectNodes("//DataItem");
		this.Display.innerHTML = "";
		this.Display.className = "contextMenuAbsolute";

		var iShim = document.createElement("iframe");
		iShim.src = "javascript:;";
		iShim.scrolling = "no";
		iShim.frameborder = "0";
		iShim.className = "suggestion";
		//iShim = this.Display.appendChild(iShim);
		iShim.id = "iShim";
		iShim = document.body.appendChild(iShim);

		var table = this.Display.appendChild(document.createElement("table"));
		table.width = this.SourceElement.offsetWidth;
		var tbody = table.appendChild(document.createElement("tbody"));
		table.className = "contextMenuAbsolute";

		for (var i=0; i<resultList.length; i++)
		{
			var row = tbody.appendChild(document.createElement("tr"));
			var cell = row.appendChild(document.createElement("td"));

			cell.innerHTML = resultList[i].selectSingleNode(this.DataTextField).text;

			cell.DataNode = resultList[i];
			cell.Index = i;
			cell.Value = resultList[i].selectSingleNode(this.DataValueField).text;
			cell.style.cursor="hand";
			
			cell.attachEvent("onmouseover", onover);
			cell.attachEvent("onmouseleave", onout);
			cell.attachEvent("onclick", doclick);
		}

		this.Display.style.display = "inline";
		
		iShim.style.posLeft = this.Display.style.posLeft;
		iShim.style.posTop = this.Display.style.posTop;
		iShim.style.width = this.Display.offsetWidth+"px";
		iShim.style.height = this.Display.offsetHeight+"px";

		/*
		var ieMat = this.Display.firstChild;
		ieMat.style.width = this.Display.offsetWidth+"px";
		ieMat.style.height = this.Display.offsetHeight+"px";
		*/

		this.SelectedIndex = null;
		this.Cells = this.Display.all.tags("TD");
		if (this.KeyCode == 40) this.SelectItem();
	}
	else
	{
		this.Display.innerHTML = "";
		this.Cells = null;
		this.SelectedIndex = null;
	}
}
Suggestion.prototype.RenderMethods = function(result)
{
	if (this.SourceElement == null)
	{
		document.qbo.WebServiceArray[result.id].Suggestion.RenderMethods(result);
		return;
	}
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}

	var sourceElementName = new String(this.SourceElement.id);
	var arySourceElement = sourceElementName.split(/\_/g);
	sourceElementName = arySourceElement[arySourceElement.length - 2] + "_" + arySourceElement[arySourceElement.length - 1];
	var ctlName = "";
	for (var i = 0; i < arySourceElement.length - 2; i++)
	{
		if (ctlName.length > 0) ctlName += "_";
		ctlName += arySourceElement[i];
	}
	var attorneyMethods = eval("document." + ctlName + "_Methods");
	if (result.value)
	{
		xml = result.value.xml;
		xml = xml.replace(/DataItem/g, "ContactMethodItem");
		xml = xml.replace("<Report xmlns=\"\">", "");
		xml = xml.replace("</Report>", "");
		xml = xml.replace(/ExecuteProcedureResult/g, "ContactMethodCollection");

		attorneyMethods.MethodXml.loadXML(xml);
		attorneyMethods.RenderHtml();
	}
	else
	{
		attorneyMethods.MethodXml.loadXML("<ContactMethodCollection/>");
		attorneyMethods.RenderHtml();
	}
}
Suggestion.prototype.GetDateString = function(xmlDateString)
{
	if (xmlDateString == null || xmlDateString.length <= 0)
	{
		return null;
	}
	else
	{
		var aryDateString = xmlDateString.split("T");
		var aryDateParts = aryDateString[0].split("-");
		var theDate = new Date(aryDateParts[1] + "/" + aryDateParts[2] + "/" + aryDateParts[0]);
		return document.qbo.getDateString(theDate);
	}
}
Suggestion.prototype.GetCheckboxBitValue = function(xmlBitValue)
{
	if (xmlBitValue == null || xmlBitValue.length <= "")
	{
		return false;
	}
	else
	{
		return (xmlBitValue == "true");
	}
}
Suggestion.prototype.SetFormValue = function(theNode, controlPrefix)
{
	if (controlPrefix == null) controlPrefix = "";
	if (document.getElementById(controlPrefix + "ddl" + theNode.tagName))
	{
		document.getElementById(controlPrefix + "ddl" + theNode.tagName).value = theNode.text;
	}
	if (document.getElementById(controlPrefix + "tbx" + theNode.tagName))
	{
		if (theNode.tagName.indexOf("Date") > -1)
		{
			document.getElementById(controlPrefix + "tbx" + theNode.tagName).value = this.GetDateString(theNode.text);
		}
		else
		{
			document.getElementById(controlPrefix + "tbx" + theNode.tagName).value = theNode.text;
		}
	}
	if (document.getElementById(controlPrefix + "cbx" + theNode.tagName))
	{
		document.getElementById(controlPrefix + "cbx" + theNode.tagName).checked = this.GetCheckboxBitValue(theNode.text);
	}
	if (theNode.tagName == "Address" || theNode.tagName == "City" || theNode.tagName == "State" || theNode.tagName == "PostalCode")
	{
		if (document.getElementById(controlPrefix + theNode.tagName))
		{
			document.getElementById(controlPrefix + theNode.tagName).value = theNode.text;
		}
	}
}
Suggestion.prototype.RenderObject = function(result)
{
	if (this.SourceElement == null)
	{
		document.qbo.WebServiceArray[result.id].Suggestion.RenderObject(result);
		return;
	}
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}

	if (result.value)
	{
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.loadXML(result.value.xml);
		var theNode = xmlDoc.selectSingleNode("//ExecuteProcedureResult/Report/DataItem");

		var sourceElementName = new String(this.SourceElement.name);
		var arySourceElement = sourceElementName.split(/\:/g);
		sourceElementName = arySourceElement[0];

		var childNodes = new Enumerator(theNode.childNodes);
		for (; !childNodes.atEnd(); childNodes.moveNext())
		{
			if (childNodes.item().tagName == "Address" || childNodes.item().tagName == "City" || childNodes.item().tagName == "State" || childNodes.item().tagName == "PostalCode")
			{
				this.SetFormValue(childNodes.item(), sourceElementName + ":conAddress:");
			}
			else
			{
				this.SetFormValue(childNodes.item(), sourceElementName + ":");
			}
		}
	}
	else
	{
		/*
		*/
	}
}
//Suggestion Object - End

// Rounded corners from Nifty Rounded Corners
function Rounded(selector,wich,bk,color,opt)
{
	var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

	if(color=="transparent"){
		cn=cn+"x";
		ecolor=bk;
		bk="transparent";
		}
	else if(opt && opt.indexOf("border")>=0){
		var optar=opt.split(" ");
		for(i=0;i<optar.length;i++)
			if(optar[i].indexOf("#")>=0) ecolor=optar[i];
		if(ecolor=="") ecolor="#666";
		cn+="e";
		edges=true;
		}
	else if(opt && opt.indexOf("smooth")>=0){
		cn+="a";
		ecolor=Mix(bk,color);
		}
	if(opt && opt.indexOf("small")>=0) cn+="s";
	prefixt=cn;
	prefixb=cn;
	if(wich.indexOf("all")>=0){t=true;b=true}
	else if(wich.indexOf("top")>=0) t="true";
	else if(wich.indexOf("tl")>=0){
		t="true";
		if(wich.indexOf("tr")<0) prefixt+="l";
		}
	else if(wich.indexOf("tr")>=0){
		t="true";
		prefixt+="r";
		}
	if(wich.indexOf("bottom")>=0) b=true;
	else if(wich.indexOf("bl")>=0){
		b="true";
		if(wich.indexOf("br")<0) prefixb+="l";
		}
	else if(wich.indexOf("br")>=0){
		b="true";
		prefixb+="r";
		}
	var v=getElementsBySelector(selector);
	var l=v.length;
	for(i=0;i<l;i++){
		if(edges) AddBorder(v[i],ecolor);
		if(t) AddTop(v[i],bk,color,ecolor,prefixt);
		if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
		}
}

function AddBorder(el,bc)
{
	var i;
	if(!el.passed){
		if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
			var t=el.firstChild.nodeValue;
			el.removeChild(el.lastChild);
			var d=CreateEl("span");
			d.style.display="block";
			d.appendChild(document.createTextNode(t));
			el.appendChild(d);
			}
		for(i=0;i<el.childNodes.length;i++){
			if(el.childNodes[i].nodeType==1){
				el.childNodes[i].style.borderLeft="1px solid "+bc;
				el.childNodes[i].style.borderRight="1px solid "+bc;
				}
			}
		}
	el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn)
{
	var i,lim=4,d=CreateEl("b");

	if(cn.indexOf("s")>=0) lim=2;
	if(bc) d.className="artop";
	else d.className="rtop";
	d.style.backgroundColor=bk;
	for(i=1;i<=lim;i++){
		var x=CreateEl("b");
		x.className=cn + i;
		x.style.backgroundColor=color;
		if(bc) x.style.borderColor=bc;
		d.appendChild(x);
		}
	el.style.paddingTop=0;
	el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn)
{
	var i,lim=4,d=CreateEl("b");

	if(cn.indexOf("s")>=0) lim=2;
	if(bc) d.className="artop";
	else d.className="rtop";
	d.style.backgroundColor=bk;
	for(i=lim;i>0;i--){
		var x=CreateEl("b");
		x.className=cn + i;
		x.style.backgroundColor=color;
		if(bc) x.style.borderColor=bc;
		d.appendChild(x);
		}
	el.style.paddingBottom=0;
	el.appendChild(d);
}

function CreateEl(x)
{
	isXHTML = false;
	if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
	else return(document.createElement(x));
}

function getElementsBySelector(selector)
{
	var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

	if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
		s=selector.split(" ");
		var fs=s[0].split("#");
		if(fs.length==1) return(objlist);
		f=document.getElementById(fs[1]);
		if(f) return(f.getElementsByTagName(s[1]));
		return(objlist);
		}
	if(selector.indexOf("#")>0){ //id selector like "tag#id"
		s=selector.split("#");
		tag=s[0];
		selid=s[1];
		}
	if(selid!=""){
		f=document.getElementById(selid);
		if(f) objlist.push(f);
		return(objlist);
		}
	if(selector.indexOf(".")>0){  //class selector like "tag.class"
		s=selector.split(".");
		tag=s[0];
		selclass=s[1];
		}
	var v=document.getElementsByTagName(tag);  // tag selector like "tag"
	if(selclass=="")
		return(v);
	for(i=0;i<v.length;i++){
		if(v[i].className.indexOf(selclass)>=0){
			objlist.push(v[i]);
			}
		}
	return(objlist);
}

function Mix(c1,c2)
{
	var i,step1,step2,x,y,r=new Array(3);
	if(c1.length==4)step1=1;
	else step1=2;
	if(c2.length==4) step2=1;
	else step2=2;
	for(i=0;i<3;i++){
		x=parseInt(c1.substr(1+step1*i,step1),16);
		if(step1==1) x=16*x+x;
		y=parseInt(c2.substr(1+step2*i,step2),16);
		if(step2==1) y=16*y+y;
		r[i]=Math.floor((x*50+y*50)/100);
		}
	return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
}
// End Rounded corners

function getElementPosition(element, recalc)
{
	if ((element.PositionLeft) && (recalc != true)) return;
	element.PositionLeft = 0;
	element.PositionTop = 0;
	ce = element;
	while (ce != null)
	{
		if (!isNaN(parseInt(ce.offsetLeft))) element.PositionLeft += parseInt(ce.offsetLeft);
		if (!isNaN(parseInt(ce.offsetTop))) element.PositionTop += parseInt(ce.offsetTop);
		ce = ce.offsetParent;
	}
	element.PositionRight = element.PositionLeft + ((element.clientWidth == 0) ? element.offsetWidth : element.clientWidth);
	element.PositionBottom = element.PositionTop + ((element.clientHeight == 0) ? element.offsetHeight : element.clientHeight);
	return;
}
function getElementOverlap(element1, element2)
{
	getElementPosition(element1);
	getElementPosition(element2);
	return ( (element1.PositionLeft <= element2.PositionRight) 
		&& (element2.PositionLeft <= element1.PositionRight)
		&& (element1.PositionTop <= element2.PositionBottom) 
		&& (element2.PositionTop <= element1.PositionBottom)
	)
}

//Balloon function for DashBoard Graphics
function DashBoardBalloon(name,height,width)
{
	this.StartX = event.clientX + 100;
	//this.StartX = 75;
	this.StartY = event.clientY;
	//this.StartY = 500;
	this.DivTag = document.createElement("div");
	this.ImageTag = document.createElement("img");
	//with (this.ImageTag)
	//{
	//	style.display = "none";
	//	style.position = "relative";
	//	style.zIndex = 100;
	//}
	this.Rounded = false;
	this.Url = null;
	with (this.DivTag) 
	{
		balloon = this;
		id = name;
		style.display = "none";
		//className = "balloon";
		style.zIndex = 100;
		style.height = height;
		style.width = width;
		style.position = "absolute";
	}

	if (document.getElementById("iShim") == null)
	{
		iShim = document.createElement("iframe");
		iShim.src = "javascript:;";
		document.body.appendChild(iShim);
		iShim.style.position = "absolute";
		iShim.style.display = "none";
		iShim.id = "iShim";
	}

	document.body.appendChild(this.DivTag);
	document.body.appendChild(this.ImageTag);
}

DashBoardBalloon.prototype.Render = function()
{
	if (this.Url != null)
		this.GetUrl(this.Url);
	this.StartX = event.clientX;
	this.StartY = event.clientY;
	this.ImageTag.style.display = "none";

	this.ImagePosition = (this.StartY < document.body.clientHeight/2) ? "B" : "T";
	this.ImagePosition += (this.StartX < document.body.clientWidth/2) ? "R" : "L";
	this.ImageTag.src = "/Images/qbo/balloon." + this.ImagePosition + ".png";

	this.DivTag.style.display = "inline";
	switch (this.ImagePosition)
	{
		case "BR":
			this.ImageTag.style.pixelLeft = this.StartX;
			this.ImageTag.style.pixelTop = this.StartY;
			this.DivTag.style.pixelLeft = this.StartX + this.ImageTag.clientWidth-1;
			this.DivTag.style.pixelTop = (this.StartY + 60) - (this.DivTag.clientHeight/2);
			break;
		case "BL":
			this.ImageTag.style.pixelLeft = this.StartX - this.ImageTag.clientWidth;
			this.ImageTag.style.pixelTop = this.StartY;
			this.DivTag.style.pixelLeft = this.StartX - this.DivTag.clientWidth - this.ImageTag.clientWidth +1;
			this.DivTag.style.pixelTop = (this.StartY + 60) - (this.DivTag.clientHeight/2);
			break;
		case "TR":
			this.ImageTag.style.pixelLeft = this.StartX;
			this.ImageTag.style.pixelTop = this.StartY - this.ImageTag.clientHeight;
			this.DivTag.style.pixelLeft = this.StartX + this.ImageTag.clientWidth-1;
			this.DivTag.style.pixelTop = (this.StartY -this.ImageTag.clientHeight + 20) - (this.DivTag.clientHeight/2);
			break;
		case "TL":
			this.ImageTag.style.pixelLeft = this.StartX - this.ImageTag.clientWidth;
			this.ImageTag.style.pixelTop = this.StartY - this.ImageTag.clientHeight;
			this.DivTag.style.pixelLeft = this.StartX - this.DivTag.clientWidth - this.ImageTag.clientWidth +1;
			this.DivTag.style.pixelTop = (this.StartY - this.ImageTag.clientHeight + 20) - (this.DivTag.clientHeight/2);
			break;
	}
	this.ImageTag.style.pixelLeft += document.body.scrollLeft;
	this.ImageTag.style.pixelTop += document.body.scrollTop;
	//this.DivTag.style.pixelLeft += document.body.scrollLeft;
	this.DivTag.style.pixelLeft = 100;
	this.DivTag.style.pixelTop += document.body.scrollTop + 100;
	getElementPosition(this.DivTag, true);
	//this.Round();
	this.SelectPush();
	document.BalloonCurrent = this;
	document.body.attachEvent("onmousedown", this.MouseDown);
	document.body.attachEvent("onkeypress", this.Escape);
	document.body.attachEvent("onmouseout", this.MouseDown);
	if (this.onRender) this.onRender(this);
	window.status = document.body.scrollTop;
}
DashBoardBalloon.prototype.Round = function()
{
	if (!this.Rounded) 
	{
		// alert(this.DivTag.outerHTML);
		this.DivTag.passed = false;
		Rounded("div#" + this.DivTag.id, "all", "#FFF","White", "border");
		// Rounded("div#" + this.DivTag.id, "bottom", "#FFF","#EFEFE7", "border");
		this.Rounded = true;
	}
}
DashBoardBalloon.prototype.SelectPush = function()
{
	return;
	shim = document.getElementById("iShim");
	shim.style.pixelTop = this.DivTag.style.pixelTop;
	shim.style.pixelLeft = this.DivTag.style.pixelLeft;
	shim.style.height = this.DivTag.style.height;
	shim.style.width = this.DivTag.style.width;
	shim.style.display = "solid";
}
DashBoardBalloon.prototype.SelectPop = function()
{
	return;
	document.getElementById("iShim").style.display = "none";
}
DashBoardBalloon.prototype.MouseDown = function(balloon)
{
	if (this.DivTag == null) 
		return document.BalloonCurrent.MouseDown();
	if ((event.clientX < this.DivTag.PositionLeft - document.body.scrollLeft)
		|| (event.clientX > this.DivTag.PositionRight - document.body.scrollLeft)
		|| (event.clientY < this.DivTag.PositionTop - document.body.scrollTop)
		|| (event.clientY > this.DivTag.PositionBottom - document.body.scrollTop)
	)
	{
		this.Hide();
	}
}

DashBoardBalloon.prototype.Escape = function()
{
	if (event.keyCode != 27) return;
	if (this.DivTag == null) return document.BalloonCurrent.Escape();
	this.Hide();
	
}
DashBoardBalloon.prototype.Hide = function()
{
	this.SelectPop();
	this.DivTag.style.display = "none";
	this.ImageTag.style.display = "none";
	document.body.detachEvent("onmousedown", this.MouseDown);
	document.body.detachEvent("onkeypress", this.Escape);
	document.body.detachEvent("onmouseout", this.Escape);
}

DashBoardBalloon.prototype.GetUrl = function(url)
{
	this.DivTag.innerHTML = document.qbo.textFromUrl(url);
	this.Rounded = false;
}
DashBoardBalloon.prototype.Resize = function()
{
//	this.Rounded = false;
//	this.Round();
	getElementPosition(this.DivTag, true);
	
}
// End DashBoardBalloon functions
// Balloon functions

function Balloon(name)
{
	if (event)
	{
		this.StartX = event.clientX;
		this.StartY = event.clientY;
	}
	this.DivTag = document.createElement("div");
	this.ImageTag = document.createElement("img");
	with (this.ImageTag)
	{
		style.display = "none";
		style.position = "absolute";
		style.zIndex = 100;
	}
	this.Rounded = false;
	this.Url = null;
	with (this.DivTag) 
	{
		balloon = this;
		id = name;
		style.display = "none";
		className = "balloon";
		style.zIndex = 100;
	}

	if (document.getElementById("iShim") == null)
	{
		iShim = document.createElement("iframe");
		iShim.src = "javascript:;";
		document.body.appendChild(iShim);
		iShim.style.position = "absolute";
		iShim.style.display = "none";
		iShim.id = "iShim";
	}

	document.body.appendChild(this.DivTag);
	document.body.appendChild(this.ImageTag);
}
Balloon.prototype.Render = function()
{
	if (this.Url != null)
		this.GetUrl(this.Url);
		
	//document.getElementById("DebtStatus"));	

	if (event) 
	{	
		this.StartX = event.clientX;
		this.StartY = event.clientY;
	}
	this.ImageTag.style.display = "inline";

	this.ImagePosition = (this.StartY < document.body.clientHeight/2) ? "B" : "T";
	this.ImagePosition += (this.StartX < document.body.clientWidth/2) ? "R" : "L";
	this.ImageTag.src = "/Images/qbo/balloon." + this.ImagePosition + ".png";

	this.DivTag.style.display = "inline";	
	switch (this.ImagePosition)
	{
		case "BR":
			this.ImageTag.style.pixelLeft = this.StartX;
			this.ImageTag.style.pixelTop = this.StartY;
			this.DivTag.style.pixelLeft = this.StartX + this.ImageTag.clientWidth-1;
			this.DivTag.style.pixelTop = (this.StartY + 60) - (this.DivTag.clientHeight/2);
			break;
		case "BL":
			this.ImageTag.style.pixelLeft = this.StartX - this.ImageTag.clientWidth;
			this.ImageTag.style.pixelTop = this.StartY;
			this.DivTag.style.pixelLeft = this.StartX - this.DivTag.clientWidth - this.ImageTag.clientWidth +1;
			this.DivTag.style.pixelTop = (this.StartY + 60) - (this.DivTag.clientHeight/2);
			break;
		case "TR":
			this.ImageTag.style.pixelLeft = this.StartX;
			this.ImageTag.style.pixelTop = this.StartY - this.ImageTag.clientHeight;
			this.DivTag.style.pixelLeft = this.StartX + this.ImageTag.clientWidth-1;
			this.DivTag.style.pixelTop = (this.StartY -this.ImageTag.clientHeight + 20) - (this.DivTag.clientHeight/2);
			break;
		case "TL":
			this.ImageTag.style.pixelLeft = this.StartX - this.ImageTag.clientWidth;
			this.ImageTag.style.pixelTop = this.StartY - this.ImageTag.clientHeight;
			this.DivTag.style.pixelLeft = this.StartX - this.DivTag.clientWidth - this.ImageTag.clientWidth +1;
			this.DivTag.style.pixelTop = (this.StartY - this.ImageTag.clientHeight + 20) - (this.DivTag.clientHeight/2);
			break;
	}
	this.ImageTag.style.pixelLeft += document.body.scrollLeft;
	this.ImageTag.style.pixelTop += document.body.scrollTop;
	this.DivTag.style.pixelLeft += document.body.scrollLeft;
	this.DivTag.style.pixelTop += document.body.scrollTop;
	getElementPosition(this.DivTag, true);
	this.Round();
	this.SelectPush();
	document.BalloonCurrent = this;
	document.body.attachEvent("onmousedown", this.MouseDown);
	document.body.attachEvent("onkeypress", this.Escape);
	if (this.onRender) this.onRender(this);
	window.status = document.body.scrollTop;
}
Balloon.prototype.Round = function()
{
	if (!this.Rounded) 
	{
		// alert(this.DivTag.outerHTML);
		this.DivTag.passed = false;
		Rounded("div#" + this.DivTag.id, "all", "#FFF","White", "border");
		// Rounded("div#" + this.DivTag.id, "bottom", "#FFF","#EFEFE7", "border");
		this.Rounded = true;
	}
}
Balloon.prototype.SelectPush = function()
{
	return;
	shim = document.getElementById("iShim");
	shim.style.pixelTop = this.DivTag.style.pixelTop;
	shim.style.pixelLeft = this.DivTag.style.pixelLeft;
	shim.style.height = this.DivTag.style.height;
	shim.style.width = this.DivTag.style.width;
	shim.style.display = "block";
	
	
}
Balloon.prototype.SelectPop = function()
{
	return;
	document.getElementById("iShim").style.display = "none";
}
Balloon.prototype.MouseDown = function(balloon)
{
	if (this.DivTag == null) 
		return document.BalloonCurrent.MouseDown();
	if ((event.clientX < this.DivTag.PositionLeft - document.body.scrollLeft)
		|| (event.clientX > this.DivTag.PositionRight - document.body.scrollLeft)
		|| (event.clientY < this.DivTag.PositionTop - document.body.scrollTop)
		|| (event.clientY > this.DivTag.PositionBottom - document.body.scrollTop)
	)
	{
		this.Hide();
	}
}
Balloon.prototype.Escape = function()
{
	if (event.keyCode != 27) return;
	if (this.DivTag == null) return document.BalloonCurrent.Escape();
	this.Hide();
	
}
Balloon.prototype.Hide = function()
{
	this.SelectPop();
	this.DivTag.style.display = "none";
	this.ImageTag.style.display = "none";
	document.body.detachEvent("onmousedown", this.MouseDown);
	document.body.detachEvent("onkeypress", this.Escape);
}
Balloon.prototype.GetUrl = function(url)
{
	this.DivTag.innerHTML = document.qbo.textFromUrl(url);
	this.Rounded = false;
}
Balloon.prototype.Resize = function()
{
//	this.Rounded = false;
//	this.Round();
	getElementPosition(this.DivTag, true);
	
}

function LinkBalloon(link, ajaxClass, xsltUrl)
{
	if (link.Balloon == null)
	{
		var balloon = new Balloon(link.id + "Balloon");
		if (ajaxClass == null)
		{
			balloon.Url = link.href;
			if (balloon.Url.indexOf("RenderSkin=false") <= 0)
				balloon.Url += "&RenderSkin=false";
		} 
		else
		{
			if (link.AjaxControl == null)
			{
				try
				{
					var ajax = new ajaxClass(link.id + "Ajax", balloon.DivTag.id);
					ajax.Tracing = false;
					// if (xsltUrl != null)
					//	ajax.SelectXslt = xsltUrl;
					link.AjaxControl = ajax;
					
					var url = link.href.substring(0, link.href.indexOf("?"));
					var qs = link.href.substring(url.length + 1);
					urlA = url.split("/");
					qsA = qs.split("&");
					if (ajaxClass == ObjectBase)
					{
						ajax.ClassName = urlA[urlA.length-1].replace("Select.aspx", "Object");
					}
					for (var i=0; i<qsA.length; i++)
					{
						var param = qsA[i].substring(0, qsA[i].indexOf("="));
						var value = qsA[i].substring(qsA[i].indexOf("=")+1);
						if (param == ajax.ClassName.replace("Object", "ID"))
						{
							ajax.SetIdentity(parseInt(value));
							break;
						}
					}
					ajax.SelectXhtml(value);
				}
				catch(e)
				{
					alert(e.description);
				}
			}
		}
		link.Balloon = balloon;
	}
	link.Balloon.Render();
	return link.Balloon;
}
// End Balloon functions

function FormXml(theForm, theNodeName)
{
	if (theNodeName == null) theNodeName = "Form";
	var xmlString = "<" + theNodeName + ">";
	for (var i=0; i<theForm.elements.length; i++)
	{
		if ((theForm.elements[i].name > "") && (theForm.elements[i].name.substring(0, 2) != "__"))
		{
			xmlString += "<" + theForm.elements[i].name + ">";
			xmlString += theForm.elements[i].value;
			xmlString += "</" + theForm.elements[i].name + ">";
		}
	}
	xmlString += "</" + theNodeName + ">";
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.loadXML(xmlString);
	return xmlDoc;
}
function FireServiceList(Object, Event, Async)
{
	window.status = '';
	var checkedObjectXml = objectXml(Object, null);
	var WarningMessage = '';
	var CheckedObjects = checkedObjectXml.selectNodes("//" + Object + "ID");
	if(CheckedObjects.length == 0)
	{
		alert('You must select at least one ' + Object + ' before executing');
	}
	else
	{
		var payloadXml = "<EventCollection xmlns=''>";
		payloadXml += "<EventItem>"
		payloadXml += "<Event>" + Event + "</Event>";
		payloadXml += "<Async>" + Async + "</Async>";
		payloadXml += "<ObjectCollection>";
		for (var i=0; i<CheckedObjects.length; i++)
		{
			if(document.qbo.WebServiceArray[Event + CheckedObjects[i].text] == null)
			{
				payloadXml += "<ObjectItem>"
				payloadXml += "<Object>" + Object + "</Object>";
				payloadXml += "<ObjectID>" + CheckedObjects[i].text + "</ObjectID>";
				payloadXml += "</ObjectItem>"
			}
			else
			{
				WarningMessage += Event + ' has already been executed for ' + Object + ' ID: ' + CheckedObjects[i].text + "\n";
			}
		}
		
		if(WarningMessage != '')
		{
			WarningMessage = 'Warning:\n\n' + WarningMessage;
			WarningMessage += '\nPlease make sure duplicate commands have not been executed. The ' + Event + ' will be executed for any remaining selected ' + Object;
			WarningMessage += '(s). In order to re-execute the ' + Event + ' command for the selected ' + Object + '(s) that have already been executed, the page must be refreshed.';
			alert(WarningMessage);
		}
		
		
		payloadXml += "</ObjectCollection>";
		payloadXml += "</EventItem>"
		payloadXml += "</EventCollection>"
		var payload = new ActiveXObject("Microsoft.XMLDOM");
		payload.loadXML(payloadXml);
		
		var service = document.qbo.WebService();
		try
		{
			//we only want to make WS call if there are objects
			var OrderedObjects = payload.selectNodes("//ObjectItem")
			if(OrderedObjects.length > 0)
			{
				var accept = confirm("You are about to execute the " + Event + " event for " + OrderedObjects.length + " " + Object + "(s). Do you want to continue?");
				if(accept)
				{
					service.useService(document.qbo.baseURL + document.qbo.Application + "/Event/EventActionService.asmx?WSDL", "EventActionService");
					if (service.EventActionService)
					{
						//add items ordered to track
						var OrderedServices = payload.selectNodes("//ObjectItem");
						for (var j=0; j < OrderedServices.length; j++)
						{
							var ObjectID = OrderedServices[j].selectSingleNode("ObjectID").text;
							document.qbo.WebServiceArray[Event + ObjectID] = Event + ObjectID;
						}
						//make WS Call to Event Action Service
						//var theResultCall = new Function("result", "EventResult(result);");
						window.status = 'Executing command: ' + Event + ' for selected ' + Object + '(s)...';
						var callID = service.EventActionService.callService(EventResult, "ProcessEvent", payload);
					}
				}
			}
		}
		catch(e)
		{
			window.status = 'Error executing command ' + Event + ': ' + e.description;
		}
	}

}
function EventResult(result)
{
	if(result.raw)
	{
		var Message;
		try
		{
			var theSuccess = result.raw.selectSingleNode("//Success").text;
			if(theSuccess == "true")
			{
				Message = "Success: " + result.raw.selectSingleNode("//Message").text;
			}
			else
			{
				Message = "Error: " + result.raw.selectSingleNode("//Message").text;
			}
		}
		catch(e)
		{
			Message = "Exception: " + e.description;
		}
		finally
		{
			window.status = Message;
		}
	}
}

// DropDownMenu functions
function DropDownMenu()
{
	this.DivTag = document.createElement("div");
	with (this.DivTag) 
	{
		menu = this;
		style.display = "none";
		style.position = "absolute";
		style.zIndex = 100;
	}
	document.body.appendChild(this.DivTag);
	document.onmousemove = setMouse;
}
DropDownMenu.prototype.Render = function()
{
	this.isRendering = true;
	if (this.module == "Panel")
		this.DivTag.innerHTML = getPanelUrl(this.skin, this.id);
	else
		this.DivTag.innerHTML = getSkinUrl(this.skin, this.module);

	srcElement = this.element;
	if (srcElement)
	{
		this.sourceElement = srcElement;
		this.DivTag.style.pixelLeft = 0;
		this.DivTag.style.pixelTop = srcElement.offsetHeight;
		
		status = srcElement.tagName + ", " + srcElement.offsetHeight +", " + srcElement.offsetTop;
	}

	while (srcElement)
	{
		this.DivTag.style.pixelLeft += srcElement.offsetLeft;
		this.DivTag.style.pixelTop += srcElement.offsetTop;
		srcElement = srcElement.offsetParent;
	}

	getElementPosition(this.element, true);
	this.DivTag.style.display = "inline";
	getElementPosition(this.DivTag, true);
	if (this.module == "Panel")
	{
		this.DivTag.style.pixelLeft = (this.element.PositionLeft - (this.DivTag.PositionRight - this.element.PositionRight));
		getElementPosition(this.DivTag, true);
	}
		
	document.MenuCurrent = this;
	this.isRendering = false;
}
DropDownMenu.prototype.MouseOut = function(menu)
{
	if (this.DivTag == null) return document.MenuCurrent.MouseOut();
	this.DivTag.innerHTML = "";
	this.DivTag.style.display = "none";
}

function getSkinUrl(skin, module)
{
	var theTable = "";
	var theLabel = "";
	var theUrl = "";
	
	var nodeList = skin.selectNodes("//qboSiteStructure/mainMenu/*[@label='" + module+ "']/*[@ui='folder']/*[@ui='tab']");
	if (nodeList.length == 0) return "";
	
	var menuNodeList = skin.selectNodes("//qboSiteStructure/mainMenu/*[@label='" + module+ "']");
	
	for (var i=0; i<nodeList.length; i++)
	{
		theLabel = "";
		theUrl = "";
		for (var j=0; j<nodeList[i].attributes.length; j++)
		{
			var attribute = nodeList[i].attributes[j];
			if (attribute.name == "label")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theLabel = attribute.value;
			}
			if (attribute.name == "url")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theUrl = attribute.value;
			}
		}
		if (theLabel != "" && theUrl != "")
			theTable += "<tr><td><a href='" + theUrl + "'>" + theLabel + "</a></td></tr>";
	}
	if (theTable != "") theTable += "</table>";
	return theTable;
}

function getPanelUrl(skin, id)
{
	var theTable = "";
	var theLabel = "";
	var theUrl = "";
	var theTitle = "";
	var theRel = "";
	var theImg = "";

	var nodeList = skin.selectNodes("//qboSiteStructure/mainMenu/Panel/action");
	if (nodeList.length == 0) return "";
	
	for (var i=0; i<nodeList.length; i++)
	{
		theLabel = "";
		theUrl = "";
		theRel = "";
		theImg = "";
		theWidth = "800";
		theHeight = "600";

		for (var j=0; j<nodeList[i].attributes.length; j++)
		{
			var attribute = nodeList[i].attributes[j];
			if (attribute.name == "label")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theLabel = attribute.value;
			}
			if (attribute.name == "url")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theUrl = attribute.value;
			}
			if (attribute.name == "rel")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theRel = attribute.value;
			}
			if (attribute.name == "img")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theImg = attribute.value;
			}
			if (attribute.name == "height")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theHeight = attribute.value;
			}
			if (attribute.name == "width")
			{
				if (theTable == "") theTable = "<table class='contextMenu'>";
				theWidth = attribute.value;
			}
		}
		if (theLabel != "" && theUrl != "") theTable += "<tr><td nowrap='true'><a href='#' ";
		theTable += " onclick=\"return GB_showPage('" + theLabel + "', '" + theUrl + id + "')\">";
		if (theImg != "") theTable += "<img src='" + theImg + "' border='0'/> ";
		theTable += theLabel + "</a></td></tr>";
	}
	if (theTable != "") theTable += "</table>";
	return theTable;
}

function MenuDropDown(skin, module, id, isLoaded)
{
	if (document.readyState == "complete")
	{
		if (document.MainMenuDropDown1 == null) document.MainMenuDropDown1 = new DropDownMenu(skin);
		document.MainMenuDropDown1.skin = new ActiveXObject(document.qbo.classXML);
		
		if (module == "Panel")
			document.MainMenuDropDown1.skin.loadXML(document.qbo.textFromUrl(skin));
		else
		{
			if (!document.MainMenuDropDown1.skinMenu)
			{
				document.MainMenuDropDown1.skinMenu = new ActiveXObject(document.qbo.classXML);
				document.MainMenuDropDown1.skinMenu.loadXML(document.qbo.textFromUrl(skin));
			}
			document.MainMenuDropDown1.skin = document.MainMenuDropDown1.skinMenu;
		}
		
		if (module)
		{
			if (event)
			{
				if ((event.srcElement.tagName == "TD") || (module == "Panel"))
					document.MainMenuDropDown1.element = event.srcElement;
				else
					document.MainMenuDropDown1.element = getParentElement(event.srcElement, "TD");
			}
			document.MainMenuDropDown1.id = id;
			document.MainMenuDropDown1.module = module;
			document.MainMenuDropDown1.Render();

			this.curElemLeft = document.MainMenuDropDown1.DivTag.PositionLeft;
			this.curElemTop = document.MainMenuDropDown1.sourceElement.PositionTop;
			this.curElemRight = document.MainMenuDropDown1.DivTag.PositionRight;
			this.curElemBottom = document.MainMenuDropDown1.DivTag.PositionBottom;

			setTimeout("ClearDropDown()", 500);
		}
	}
}

function LocalMenuDropDown(skin, module, id, isLoaded)
{	
	if (document.readyState == "complete")
	{
		if (document.MainMenuDropDown1 == null) document.MainMenuDropDown1 = new DropDownMenu(skin);
		document.MainMenuDropDown1.skin = skin;
		
		if (module != "Panel")
		{
			if (!document.MainMenuDropDown1.skinMenu)
			{
				document.MainMenuDropDown1.skinMenu = skin; //new ActiveXObject(document.qbo.classXML);
				// document.MainMenuDropDown1.skinMenu.loadXML(document.qbo.textFromUrl(skin));
			}
			document.MainMenuDropDown1.skin = document.MainMenuDropDown1.skinMenu;
		}
		
		if (module)
		{
			if (event)
			{
				if ((event.srcElement.tagName == "TD") || (module == "Panel"))
					document.MainMenuDropDown1.element = event.srcElement;
				else
					document.MainMenuDropDown1.element = getParentElement(event.srcElement, "TD");
			}
			document.MainMenuDropDown1.id = id;
			document.MainMenuDropDown1.module = module;
			document.MainMenuDropDown1.Render();

			this.curElemLeft = document.MainMenuDropDown1.DivTag.PositionLeft;
			this.curElemTop = document.MainMenuDropDown1.sourceElement.PositionTop;
			this.curElemRight = document.MainMenuDropDown1.DivTag.PositionRight;
			this.curElemBottom = document.MainMenuDropDown1.DivTag.PositionBottom;

			setTimeout("ClearDropDown()", 500);
		}
	}
}


function ClearDropDown()
{
	if ((document.curX < this.curElemLeft)
		||	(document.curX > this.curElemRight)
		||	(document.curY > this.curElemBottom)
		||	(document.curY < this.curElemTop))
	{
		document.MainMenuDropDown1.MouseOut();
		document.MainMenuDropDown1.module = "";
	}
	else
		setTimeout("ClearDropDown()", 500);
}

function getAbsPos(elt,which)
{
	iPos = 0; 
	while (elt != null)
	{ 
		iPos += elt["offset" + which]; 
		elt = elt.offsetParent; 
	} 
	return iPos; 
} 

function setMouse()
{
	if (document.body.scrollTop)
		offsetY = document.body.scrollTop;
	else
		offsetY = 0;
	
	document.curX = event.clientX;
	document.curY = event.clientY+offsetY;
}
// End DropDownMenu functions

function doFilter(elementID)
{
	element = document.getElementById(elementID);
	if (element == null)
		return alert("doFilter: no element with an id of " + elementID + " found in document.");
	if (element.Filter == null)
		element.Filter = new Filter(element);
	else 
		element.Filter.Render();
}
function Filter(element)
{
	this.Element = element;
	this.Name = (element.name == null) ? element.id : element.name;
	this.ProcedureXml = document.getElementById("xmlFilter" + this.Name);
	if (this.ProcedureXml == null)
		return alert("Filter: no xml element named 'xmlFilter" + this.Name + "' found in document.");
	this.ResultXslt = document.getElementById("xslFilter" + this.Name);
	this.FilterXml = new ActiveXObject(document.qbo.classXML);
	this.FilterXml.loadXML((this.Element.value == "") ? "<" + this.Name + "Collection/>" : this.Element.value);
	this.CreateBalloon();
	this.WebService = document.qbo.WebService();
	this.Render();
}
Filter.prototype.CreateBalloon = function()
{
	this.Balloon = new Balloon("balloon" + this.Name);
	this.DivTag = this.Balloon.DivTag;
	this.DivTag.Filter = this;
	var table = document.createElement("table");
	table.className = element.className;
	this.DivTag.appendChild(table);
	var tbody = document.createElement("tbody");
	table.appendChild(tbody);
	
	var row = document.createElement("tr");
	tbody.appendChild(row);
	
	var cell = document.createElement("th");
	cell.innerHTML = "<a href=\"#\" onclick=\"javascript:getParentElement(this, 'DIV').Filter.ShowFilter();\">Filter</a>";
	cell.width = "50%";
	row.appendChild(cell);
	
	var cell = document.createElement("th");
	cell.innerHTML = "<a href=\"#\" onclick=\"javascript:getParentElement(this, 'DIV').Filter.ShowSearch();\">More Items</a>";
	cell.width = "50%";
	row.appendChild(cell);
	
	var span = document.createElement("<div align=\"center\"/>");
	this.DivTag.appendChild(span);
	
	this.Suggest = document.createElement("<input type=\"text\"></input>");
	span.appendChild(this.Suggest);

	this.Go = document.createElement("<input type=\"button\" value=\"Go\" onclick=\"this.Filter.Search()\"/>");
	this.Go.Filter = this;
	span.appendChild(this.Go);
	
	this.FilterData = document.createElement("<div/>");
	this.FilterData.Filter = this;
	this.DivTag.appendChild(this.FilterData);

	this.SearchData = document.createElement("<div/>");
	this.SearchData.Filter = this;
	this.DivTag.appendChild(this.SearchData);
}
Filter.prototype.Render = function()
{
	//alert(this.ProcedureXml);
	this.Balloon.Render();
}
Filter.prototype.Search = function()
{
	if (!this.HasService)
	{
		//if (this.Debug) test.innerHTML += "<br/>Suggest ws creation: " + this.ArrowKey + "; " + this.Iteration;
		this.WebService.useService(document.qbo.baseURL  + document.qbo.Application + "/Report/ReportService.asmx?WSDL", "ReportService");
		this.HasService = this.WebService.ReportService;
	}
	
	if (this.HasService) 
	{
		var filter = this.ProcedureXml.selectSingleNode("//*[@filter='true']");
		if (filter != null)
			filter.text = this.Suggest.value + '%';
		this.Element.ReportCallID = this.WebService.ReportService.callService(this.RenderSearch, "ExecuteProcedure", this.ProcedureXml);
		//if (this.Debug) test.innerHTML += "<br/>" + this.SourceElement.ReportCallID;
		document.qbo.WebServiceArray[this.Element.ReportCallID] = this;
	}
	else return alert("No webservice established.");


}
Filter.prototype.RenderSearch = function(result)
{
	if (this.Element == null)
	{
		document.qbo.WebServiceArray[result.id].RenderSearch(result);
		return;
	}
	if (result.error)
	{
		ErrorWebService(result.errorDetail);
		return;
	}
	document.CurrentFilter = this;
	if (result.value.xml)
	{
		if (this.ResultXslt != null) 
		{
			this.SearchData.innerHTML = result.value.transformNode(this.ResultXslt);
			this.CheckboxList = this.SearchData.all.tags("input");
			this.SetCheckboxes();
		}
		this.Balloon.Resize();
	}
}
Filter.prototype.SetCheckboxes = function()
{
	alert(this.FilterXml.xml);
	for (var i=0; i<this.CheckboxList.length; i++)
	{
		this.CheckboxList[i].checked = (this.FilterXml.selectSingleNode("//" + this.Element.nodeName + "[. = '" + this.CheckboxList[i].value + "']") != null)
	}
}
Filter.prototype.ToggleItem = function(element)
{
	if (element.checked)
		this.AddItem(element);
	else 
		this.RemoveItem(element);
	
}
Filter.prototype.AddItem = function(element)
{
	var theNewNode = this.FilterXml.createNode(1, this.Element.nodeName, "");
	theNewNode.setAttribute("label", element.label);
	theNewNode.text = element.value;
	this.FilterXml.documentElement.appendChild(theNewNode);
	this.Element.value = this.FilterXml.xml;
}
Filter.prototype.RemoveItem = function(element) 
{
	var node = this.FilterXml.selectSingleNode("//" + this.Element.nodeName + "[. = '" + element.value + "']");
	if (node != null)
		this.FilterXml.documentElement.removeChild(node);
	this.Element.value = this.FilterXml.xml;
}
Filter.prototype.ShowFilter = function()
{
	this.FilterData.style.display = "inline";
	this.SearchData.style.display = "none";
}
Filter.prototype.ShowSearch = function()
{
	this.SearchData.style.display = "inline";
	this.FilterData.style.display = "none";
}
// Generic AJAX Control
function AjaxControl(id, xpath, xmlTag, autoInit) 
{
	if (autoInit == null) autoInit = true;
	this.ID = id;
	this.SourceElement = document.getElementById(id);
	this.AttributeCentric = (this.SourceElement.attributeCentric == "true");
	this.SourceElement.AjaxControl = this;
	this.RepeaterXPath = xpath;
	this.XmlTag = (xmlTag == null) ? id + "_Xml" : xmlTag;
	if (autoInit) 
		this.Initialize();
}	
AjaxControl.prototype.Initialize = function()
{
    if ((document.readyState != "complete")) // && (document.readyState != "interactive"))
    {
	    setTimeout("document.getElementById('" + this.ID + "').AjaxControl.Initialize();", 25);
	    return;
	}
	var nodes = this.RepeaterXPath.split("/");
	this.RepeaterNodeName = nodes[nodes.length-1];
	for (var i=0; i<this.SourceElement.all.length; i++)
	{
		this.SourceElement.all[i].AjaxControl = this;
		if (this.SourceElement.all[i].id == this.SourceElement.id + "Repeater")
			this.RepeaterElement = this.SourceElement.all[i];
		if (this.SourceElement.all[i].id == this.SourceElement.id + "InsertBefore")
			this.InsertBeforeElement = this.SourceElement.all[i];
	}
	if (this.RepeaterElement == null)
		return alert("No repeater element defined for ajax control '" + this.ID + "'.");
	this.RepeaterParent = this.RepeaterElement.parentElement;
	if (this.RepeaterParent == null)
		return alert("The repeater element ('" + this.RepeaterElement.id + "') for ajax control '" + this.ID + "' has no parent element.");
	this.SourceXml = document.getElementById(this.XmlTag);
	this.SourceNode = this.RepeaterElement.cloneNode(true);
	this.SetEventHandlers(this.SourceNode);
	var firstNode = this.SourceXml.selectSingleNode(this.RepeaterXPath);
	this.RepeaterXPathParent = this.SourceElement.RepeaterXPathParent;
	if (this.RepeaterXPathParent)
		this.RepeaterXmlParent = this.SourceXml.selectSingleNode(this.RepeaterXPathParent);
	else
		this.RepeaterXmlParent = (firstNode) ? firstNode.parentNode : this.SourceXml.documentElement;
	// this.RepeaterXmlParent = (firstNode) ? firstNode.parentNode : this.SourceXml.documentElement;
	this.HiddenXml = document.getElementById(this.ID + "_Hidden");
	if (this.HiddenXml != null)
		this.HiddenXml.value = this.SourceXml.xml;
	this.RenderXml();
}
AjaxControl.prototype.RenderXml = function()
{
	this.ClearControl();
	var nodeList = this.SourceXml.selectNodes(this.RepeaterXPath);
	for (var i=0; i<nodeList.length; i++)
		this.InsertItem(nodeList[i]);
		var thennode =  this.SourceXml.selectSingleNode("//Then");
		if(document.getElementById("PanelIfThenStatement_IsTrue")!=null)
		{
            document.getElementById("PanelIfThenStatement_IsTrue").value=thennode.text; 
      }


}
AjaxControl.prototype.RenderItem = function()
{
}
AjaxControl.prototype.ClearControl = function()
{
	var repeaters = this.RepeaterParent.all(this.ID + "Repeater");
	if (repeaters.length)
	{
		for (var i=0; i<repeaters; i++)
		{
			this.RepeaterParent.removeChild(repeaters[i]);
		}
	} 
	else
		this.RepeaterParent.removeChild(repeaters);
}
AjaxControl.prototype.GetRepeater = function(element)
{
	var repeater = element;
	while ((repeater) && (repeater.id != this.ID + "Repeater"))
		repeater = repeater.parentElement;
	if (repeater == null)
		alert("PropertyToggle could not find a repeater parent for this element: " + element.outerHTML);
	else 
		return repeater;
	return null;
}

AjaxControl.prototype.InsertItem = function(xmlNode)
{
	if (this.InsertBeforeElement != null)
		var item = this.RepeaterParent.insertBefore(this.SourceNode.cloneNode(true), this.InsertBeforeElement);
	else
		var item = this.RepeaterParent.appendChild(this.SourceNode.cloneNode(true));
	item.SourceXml = xmlNode;
	this.SetItemFromXml(item, xmlNode);
}
// Creates a new XmlNode in SourceXml, and calls InsertItem.
// Have an insert icon or command call this method.
AjaxControl.prototype.CreateItem = function()
{
	var node = this.SourceXml.createNode(1, this.RepeaterNodeName, "");
	this.RepeaterXmlParent.appendChild(node);
	for (var i=0; i<this.SourceNode.all.length; i++)
	{
		element = this.SourceNode.all[i];
		if ((element.id) && (element.id.indexOf(this.ID + "_") == 0) && (!element.ajaxIgnore))
		{
			if (this.AttributeCentric)
			{
				node.setAttribute(element.id.substring(this.ID.length+1), element.value);
			}
			else 
			{
				var childNode = this.SourceXml.createNode(1, element.id.substring(this.ID.length+1), "");
				childNode.text = element.value;
				node.appendChild(childNode);
			}
		}
	}	
	this.InsertItem(node);
	this.HiddenXml.value = this.SourceXml.xml;
}
AjaxControl.prototype.SetEventHandlers = function(element)
{
	for (var i=0; i<this.SourceNode.all.length; i++)
	{
		element = this.SourceNode.all[i];
		if ((element.id) && (element.id.indexOf(this.ID + "_") == 0) && (!element.ajaxIgnore))
		{
			element.attachEvent("onchange", this.EditItem);
			element.AjaxControl = this;
		}
	}	
}
// Sets the value of HTML elements in a repeater node from xmlNode values.
// element = a repeater element
// xmlNode = the value to set input elements to, from AjaxControl.SourceXml
AjaxControl.prototype.SetItemFromXml = function(element, xmlNode)
{
	var xmlElements = (this.AttributeCentric) ? xmlNode.attributes : xmlNode.childNodes;
	// for (var i=0; i<xmlNode.childNodes.length; i++)
	for (var i=0; i<xmlElements.length; i++)
	{
		
		var input = element.all(this.ID + "_" + xmlElements[i].nodeName);
		var toggle = element.all(this.ID + "_" +"imgtoggle");
		var selectedvalue = element.all(this.ID + "_" +"SelectedValue");
		if (input == null) input = element.all(xmlElements[i].nodeName);
		if (input) input.AjaxControl = this;
		// else alert("Could not find a matching element for " + xmlElements[i].nodeName);
		if ((input) && (input.type) && (!input.ajaxIgnore))
		{
			input.SourceXml = xmlElements[i];
			// var value = (xmlNode.childNodes[i].firstChild) ? xmlNode.childNodes[i].firstChild.xml : xmlNode.childNodes[i].text;
			var value = xmlElements[i].text;
			// alert("Setting " + input.name + " to " + value + " instead of " + xmlNode.childNodes[i].text);
			
			if(xmlElements[i].nodeName == "RightValue")
			{ 
			       if(xmlElements[i].text != "")
			       {
			            if(toggle !=null)
			            {
			            toggle.onclick();
			            }
			       }
			}
			
			if(xmlElements[i].nodeName == "RightStatus")
			{ 
			       if(xmlElements[i].text != "" && xmlElements[i].text.indexOf("Select a") !=0 )
			       {      
			       
			                   if(toggle !=null)
			                    { 
			                      selectedvalue.value  = xmlElements[i].text;
			                      toggle.src = document.qbo.Application + "/Images/qbo/icon.TextBox.png";
			                      toggle.onclick();
			                      }
			       }
			}
			
			switch (input.type)
			{
				case "text":
					input.value = value;
					break;
				case "textarea":
					input.value = value;
					break;
				case "hidden":
					input.value = value;
					break;
				case "select-one":
					document.qbo.dropdownSetValue(input, value);
					break;
				case "span":
					input.innerHTML = value;
					break;
				default:
					alert("AjaxControl.SetItemFromXml not coded to handle " + input.type);
					break;
			}
			if (input.onblur != null)
			{
				s = "(" + input.onblur + ")";
				if (s.indexOf("document.qbo.elementIsPercentage") > -1)
					document.qbo.elementIsDecimal(input);
				else if (s.indexOf("document.qbo.elementIsDecimal") > -1)
					document.qbo.elementIsDecimal(input);
				else if (s.indexOf("document.qbo.elementIsMoney") > -1)
					document.qbo.elementIsMoney(input);
				else if (s.indexOf("document.qbo.elementIsDate") > -1)
				{
					if (xmlNode.selectSingleNode(xmlElements[i].nodeName + "Format"))
						input.value = xmlNode.selectSingleNode(xmlElements[i].nodeName + "Format").text;
					document.qbo.elementIsDate(input);
				}
			}
			// Allow custom event handler to be fired from here
			// The event handler is restricted to calling methods of the Ajax control.
			// Custom Ajax control methods can be created on the local page.
			// Ex: <input name="MyField" onSetFromXml="DoSomething(this);"/>
			// and, in javascript:
			//		AjaxControl.prototype.DoSomething = function(element) { ... }
			if (input.onSetFromXml != null) 
			{
				document.ajaxInputOnSet = input.AjaxControl;
				try 
				{
					eval("document.ajaxInputOnSet." + input.onSetFromXml); // + input.id + ".AjaxControl." + input.onSetFromXml);
				} 
				catch(e) 
				{
					alert("Error in onSetFromXml event handler of " + input.id + ":\n\n" + e.message);
				}
			}
		} 
	}
}

AjaxControl.prototype.DeleteItem = function(element)
{
	if (this.SourceElement == null) return element.AjaxControl.DeleteItem(element);
	var repeater = element;
	while ((repeater) && (repeater.id != this.ID + "Repeater"))
		repeater = repeater.parentElement;
	if (repeater == null)
		alert("Could not find a repeater parent for this element: " + element.outerHTML);
	repeater.SourceXml.parentNode.removeChild(repeater.SourceXml);
	this.RepeaterParent.removeChild(repeater);
	this.HiddenXml.value = this.SourceXml.xml;
}
AjaxControl.prototype.EditItem = function(element)
{
	element = (element.outerHTML) ? element : event.srcElement;
	if (this.SourceElement == null) return element.AjaxControl.EditItem(element);
	if (!element.SourceXml) 
	{
		parentElement = element;
		while ((parentElement != null) && (parentElement.SourceXml == null))
			parentElement = parentElement.parentElement;
		if (parentElement != null)
		{
			var childNode = this.SourceXml.createNode(1, element.id.substring(this.ID.length+1), "");
			childNode.text = element.value;
			parentElement.SourceXml.appendChild(childNode);
			element.SourceXml = childNode;
		}
		else
			return alert("Element.SourceXml is null; this should have been set by the SetItemFromXml method.");
	}
	switch (element.type)
	{
		case "text":
			element.SourceXml.text = element.value;
			break;
		case "hidden":
			element.SourceXml.text = element.value;
			break;
		case "select-one":
			element.SourceXml.text = element.options[element.selectedIndex].value;
			break;
		case "textarea":
			element.SourceXml.text = element.value;
			break;
	
		default:
			alert("AjaxControl.EditItem not coded to handle " + element.type);
			break;
	}
	this.HiddenXml.value = this.SourceXml.xml;
}

// End Generic AJAX Control

// Standard ObjectTransfer method
function ObjectTransfer(xsltUrl, theForm) 
{
    if (theForm == null) theForm = document.forms[0];
    theForm.action = "/Application/ObjectTransfer.aspx?Object=Organization&XsltUrl=" + xsltUrl;
    if (theForm.elements["__VIEWSTATE"] != null)
        theForm.elements["__VIEWSTATE"].value = "";
    theForm.submit();
}
// Standard Form redirection
function FormTransfer(theUrl, theForm) 
{
    if (theForm == null) theForm = document.forms[0];
    theForm.action = theUrl;
    for (var i=0; i<theForm.elements.length; i++)
    {
        if (theForm.elements[i].name.substring(0, 2) == "__")
            theForm.elements[i].value = "";
    }
    theForm.submit();
}

// Start QBO 2.0 AJAX controls
function EventHandler(eventName, eventSource) //structure to hold 
{
	this.Name = eventName;
	this.Source = eventSource; //function pointer
}

function PopupEdit(a, height, width, callback)
{
		if (height == null)
			height = document.body.clientHeight * 0.8;
		if (width == null)
			width = document.body.clientWidth * 0.8;
		if ((callback != null) && (callback != undefined))
			GB_showCenter(a.title, a.href, height, width, callback);
		else
			GB_showCenter(a.title, a.href, height, width);
		return false;
}

function ObjectBaseFetch(className, sourceElement)
{
    if ((sourceElement == null) && (event != null))
	sourceElement = event.srcElement;
	while (sourceElement != null)
	{
		if (sourceElement.AjaxControl != null)
		{
			if ((className == null) || (className == sourceElement.AjaxControl.ClassName)) 
			{
				return sourceElement.AjaxControl;
			}
		}
		sourceElement = sourceElement.parentElement;
	}
	alert("Failed to find an AjaxControl in the parent elements of " + event.srcElement.outerHTML);
}
function ObjectBase(prefixName, elementName)
{
	if (prefixName == null)
	{
		if (event.srcElement != null)
		{
			if (event.srcElement.AjaxControl != null)
				return event.srcElement.AjaxControl;
			if (event.srcElement.id == null)
			{
				window.status="Cannot create an AjaxControl based on an object without an id.";
				return;
			}
			elementName = event.srcElement.id;
		}
		prefixName = "Dynamic__";
	}
	this.ClassName = "ObjectBase";
	
	this.Initialize = function(prefixName, elementName)
	{
		this.PrefixName = prefixName;
		this.ElementName = elementName;
		if (elementName != null)
		this.Element = document.getElementById(elementName);
		if (this.Element != null) 
		this.Element.AjaxControl = this;
		if (elementName != null)
		this.Xml = document.getElementById(elementName + "Xml");
		this.Tracing = false;
		this.WebService = document.qbo.WebService();
		this.WebServiceUrl = "/Application/ObjectBaseService.asmx";
		
		this.RecordStart = 0;
		this.DisplaySize = 25;
		this.PanelMenu = document.getElementById("ajax_" + this.PrefixName + "Menu");
		this.LoadMessage = document.getElementById("ajax_" + this.PrefixName + "LoadMessage");
		this.EventHandlers = new Array();
		if (this.Xml != null) 
			this.WriteXml(this.Xml);
	}
	this.WriteXml = function(xml, object)
	{
		if (object == null)
			object = this;
		if (xml == null) return;
		if (((object.ClassName == "ObjectBase") || (object.ClassName == "undefined")) && (xml.documentElement != null))
		{
			object.ClassName = xml.documentElement.nodeName;
			object.ClassName = object.ClassName.substring(0, object.ClassName.length-4) + "Object";
		}
		if ((object.ClassName != null) && (xml.selectSingleNode("//" + object.ClassName.substring(0, object.ClassName.length-6) + "ID") != null))
			object.IdentityID = xml.selectSingleNode("//" + object.ClassName.substring(0, object.ClassName.length-6) + "ID").text;
		if (xml.selectSingleNode("//ListXslt") != null)
			object.ListXslt = xml.selectSingleNode("//ListXslt").text;
		if (xml.selectSingleNode("//SelectXslt") != null)
			object.SelectXslt = xml.selectSingleNode("//SelectXslt").text;
		if (xml.selectSingleNode("//RecordStart") != null)
			object.RecordStart = parseInt(xml.selectSingleNode("//RecordStart").text);
		if (xml.selectSingleNode("//DisplaySize") != null)
			object.DisplaySize = parseInt(xml.selectSingleNode("//DisplaySize").text);
		if (xml.selectSingleNode("//SortBy") != null)
			object.SortBy = xml.selectSingleNode("//SortBy").text;
		if (xml.selectSingleNode("//WebServiceUrl") != null)
			object.WebServiceUrl = xml.selectSingleNode("//WebServiceUrl").text;
		if (xml.selectSingleNode("//ServiceType") != null)
			object.ServiceType = xml.selectSingleNode("//ServiceType").text;
		if ((object.ClassName != null) && (object.ClassName.length > 6))
			object.ClassPrefix = object.ClassName.substring(0, object.ClassName.length-6);
	}
	this.SetIdentity = function(id)
	{
		this.IdentityID = id;
	}
	this.SelectXhtml = function(id, selectXslt, className)
	{
		if (className != null) this.ClassName = className;
		if (selectXslt == null) selectXslt = this.SelectXslt;
		if (id != null) this.SetIdentity(id);
		if (this.ClassName == null)
		{
			this.Error("ObjectBase.SelectXhtml was called without setting a ClassName.");
			return;
		}
		if (this.IdentityID == null)
		{
			this.Error("ObjectBase.SelectXhtml was called without setting an IdentityID.");
//			return;
		}
		if (this.SelectXslt == null)
		{
			this.Error("ObjectBase.SelectXhtml was called without setting a SelectXslt.");
			return;
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + ", SelectXslt=" + this.SelectXslt);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "SelectXhtml", this.ClassName, this.IdentityID, selectXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			this.RefreshMethod = this.SelectXhtml;
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	this.SummaryXhtml = function(id, selectXslt, className)
	{
		if (className != null) this.ClassName = className;
		if (selectXslt == null) selectXslt = this.SelectXslt;
		if (id != null) this.SetIdentity(id);
		if (this.ClassName == null)
		{
			this.Error("ObjectBase.SummaryXhtml was called without setting a ClassName.");
			return;
		}
		if (this.IdentityID == null)
		{
			this.Error("ObjectBase.SummaryXhtml was called without setting an IdentityID.");
//			return;
		}
		if (this.SelectXslt == null)
		{
			this.Error("ObjectBase.SummaryXhtml was called without setting a SelectXslt.");
			return;
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + ", SelectXslt=" + this.SelectXslt);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "SummaryXhtml", this.ClassName, this.IdentityID, selectXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			this.RefreshMethod = this.SummaryXhtml;
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	this.Edit = function(selectXslt)
	{
		if (selectXslt == null) selectXslt = this.SelectXslt;
		if (this.ClassName == null)
		{
			this.Error("ObjectBase.Edit was called without setting a ClassName.");
			return;
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "Edit", this.ClassName, this.ReadXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			// this.RefreshMethod = this.SelectXhtml;
			window.status = "ObjectBase.Edit Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Edit");
		}
	}
	this.ReadXml = function()
	{
		var objectXml = "<" + this.ClassPrefix + "Collection>";
		objectXml += "<" + this.ClassPrefix + "Item>";
		if (this.IdentityID != null) objectXml += "<" + this.ClassPrefix + "ID>" + this.IdentityID + "</" + this.ClassPrefix + "ID>";
		// if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		for (key in this)
		{
			switch (typeof this[key])
			{
				case "function":
					break;
				case "object":
					break;
				default:
					switch (key)
					{
						case "IdentityID": break;
						case "ClassName": break;
						case "ClassPrefix": break;
						case "PrefixName": break;
						case "ElementName": break;
						case "Tracing": break;
						case "WebServiceUrl": break;
						case "RecordStart": break;
						case "DisplaySize": break;
						case "SortBy": break;
						default:
							if ((key.length > 4) && (key.substring(key.length-4).toLowerCase() != "xslt"))
							{
								objectXml += "<" + key + ">";
								objectXml += this[key];
								objectXml += "</" + key + ">";
							}
					}
			}
			// xmlString += "<" + key + ">" + this.Parameters[key] + "</" + key + ">";
		}
		objectXml += "</" + this.ClassPrefix + "Item>";
		objectXml += "</" + this.ClassPrefix + "Collection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		alert(result.xml);
		return result;
	}
	this.ListXhtml = function(parentID) 
	{
		alert("OB Private List");
	}
	this.AccessListXhtml = function(id)
	{
		if (id != null) this.SetIdentity(id);
		if (this.ClassName == null)
		{
			this.Error("ObjectBase.AccessListXhtml was called without setting a ClassName.");
			return;
		}
		if (this.IdentityID == null)
		{
			this.Error("ObjectBase.AccessListXhtml was called without setting an IdentityID.");
			return;
		}
		var length = this.ClassName.length;
		if(length > 6)
		{
		    if(this.ClassName.substring(length - 6, length) == "Object")
		    {
		        this.ClassName = this.ClassName.substring(0,length - 6);
		    }
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "AccessListXhtml", this.ClassName, this.IdentityID);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			this.RefreshMethod = this.AccessListXhtml;
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	this.RevokeAccess = function(element, className)
	{
		if (className != null) this.ClassName = className;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			document.qbo.WebServiceArray[this.WebService.ObjectBaseService.callService(this.Refresh, "RevokeAccessList", this.ObjectIDXml("ObjectAccessID", "ObjectAccess"))] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	this.DeleteList = function(element, className)
	{
		if (className != null) this.ClassName = element;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			document.qbo.WebServiceArray[this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ClassName, this.ObjectIDXml())] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	this.Refresh = function(result)
	{
//		if (this.ResultError(result)) return;
		if ((result != null) && (result.error))
		{
			alert(result.errorDetail.string);
			return false;
		}
		if (this.WebServiceUrl == null) 
		{
			window.status += " In Refresh";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				// alert("ObjectBase.Refresh was called after a web service call completed, but the result.id (" + result.id + ") was not found in document.qbo.WebServiceArray (length is " + document.qbo.WebServiceArray.length + "). \nEnsure the object that called the web service binds itself to document.qbo.WebServiceArray as soon as the web service is called." + result.id);
				window.status = "ObjectBase.Refresh was called after a web service call completed, but the result.id (" + result.id + ") was not found in document.qbo.WebServiceArray (length is " + document.qbo.WebServiceArray.length + "). \nEnsure the object that called the web service binds itself to document.qbo.WebServiceArray as soon as the web service is called." + result.id;
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].Refresh(result);
		}
		if (this.RefreshMethod != null)
			this.RefreshMethod();
		else
			this.Trace("Refresh method is not defined");
	}
	this.DisplayXhtml = function(result)
	{
		if (this.LoadMessage != null)
			this.LoadMessage.style.display = "none";
			
			
		if (this.WebServiceUrl == null) 
		{
			window.status = "Getting object from WebServiceArray";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				alert("Could not find ObjectBase! " + result.id);
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].DisplayXhtml(result);
		}
		this.Trace("Okay so far");
		if (result.error)
		{
			// alert("Have an error " + typeof(result.errorDetail));
			// alert(result.errorDetail.string);
			this.Element.innerHTML = "<p align=\"center\">Oops. There was an error loading this panel. Please try again later.</p>";
			this.Error(result.errorDetail);
			return;
		}
		this.Trace("Success!");
		this.Trace("ObjectBase.DisplayXhtml Success!" + result.value.xml);
		if (this.DisplayElement == null)
			this.DisplayElement = this.Element;
		this.DisplayElement.innerHTML = result.value.xml;
		document.qbo.UnMaskUI(this.DisplayElement);
		
		jscriptNodes = this.Element.all.tags("SCRIPT");	//result.value.selectNodes("//script[@language='javascript' or @language='jscript']");
		for (var i=0; i<jscriptNodes.length; i++)
		{
			eval(jscriptNodes[i].innerHTML);
		}
		this.DisplayTimeStamp = new Date();
		FooterAlign();
	}
	this.Error = function(message)
	{
		var errorMessage = (message.string) ? message.string : message;
		this.Element.innerHTML = "<p align=\"center\" title=\"Click to see error details.\" onclick=\"document.getElementById('" + this.ElementName + "_ErrorMessage').style.display = 'inline';\">Oops!  There was an error loading this panel.  Please try again later.</p>";
		this.Element.innerHTML += "<pre align=\"left\" title=\"Click to hide error details.\" style=\"display:none\" onclick=\"this.style.display='none'\" id=\"" + this.ElementName + "_ErrorMessage\">" + errorMessage + "</pre>";
		this.Element.innerHTML += "<!-- ObjectBase web service error: ";
/*
		if (message.string)
			alert(message.string);
		else
			alert(message);
*/
	}
	this.Trace = function(message)
	{
		if (this.Tracing)
			alert(message);
	}
	this.HideAll = function()
	{
		this.DivCollection = document.all.tags("DIV");
		for (i=0; i<this.DivCollection.length; i++) 
		{
			if (this.DivCollection[i].id.substring(0, this.PrefixName.length + 1) == this.PrefixName + "_") 
			{
				this.DivCollection[i].style.display = "none";
			}
		}
	}
	this.DisplayMessage = function(message)
	{
		if (this.LoadMessage != null)
			this.LoadMessage.style.display = "none";
		this.Element.innerHTML = "<p align=\"center\">" + message + "</blockquote>";
	}
	this.Focus = function(method)
	{
		document.qbo.setCookie(
			this.PrefixName + "_Focus", 
			this.ElementName.substring(this.PrefixName.length + 1), 
			null, 
			document.location.pathname);

		if (method == null) method = "ListXhtml";
		if (this.TagArray == null) this.TagArray = new Array("DIV");
		this.DivCollection = document.all.tags("DIV");
		for (i=0; i<this.DivCollection.length; i++) {
			if (this.DivCollection[i].id.substring(0, this.PrefixName.length + 1) == this.PrefixName + "_") 
			{
				if (this.DivCollection[i].id == this.ElementName)
				{
					if ((this.DivCollection[i].style.display == "none") || (this.DivCollection[i].style.display == ""))
					{
						this.DivCollection[i].style.display = "block";
					}
					else
					{
						this.DivCollection[i].style.display = "none";
					}
					if (this.DisplayTimeStamp == null)
					{
						if (this.LoadMessage != null)
						{
							this.LoadMessage.style.display = "block";
						}
						eval("this." + method + "();")
					}
				} 
				else
				{
					this.DivCollection[i].style.display = "none";
				}
			}
		}
		if (this.PanelMenu == null) 
			this.PanelMenu = document.getElementById("ajax_" + this.PrefixName + "Menu");
		if (this.PanelMenu.Items == null)
			this.PanelMenu.Items = this.PanelMenu.all.tags("TH");
		for (var i=0; i<this.PanelMenu.Items.length; i++)
		{
			var menu = this.PanelMenu.Items[i];
			var div = getChildElement(menu, "DIV");
			if (div)
			{
			    var tag = getChildElement(div, "B");
			    if (tag) div.removeChild(tag);
			}
			if (menu.innerHTML.indexOf(this.ElementName) > 0) 
			{
    			var span = menu.all.tags("SPAN"); // getChildElement(menu, "SPAN");
        		for (var p=0; p<span.length; p++)
				{
				    span[p].className = span[p].className.replace("off", "on");
				}

				menu.className = menu.className.replace("Unselected", "Selected");
				
//				Rounded("Div#" + getChildElement(menu, "DIV").id,'top','black','Orange','');
//   				FooterAlign();
			} 
			else
			{
    			var span = menu.all.tags("SPAN"); // getChildElement(menu, "SPAN");
        		for (var p=0; p<span.length; p++)
				{
				    span[p].className = span[p].className.replace("on", "off");
				}
				
				menu.className = menu.className.replace("Selected", "Unselected");
//				Rounded("Div#" + getChildElement(menu, "DIV").id,'top','black','Silver','');
//   				FooterAlign();
			}
		}
	}
	this.ObjectIDArray = function(elementName)
	{
		if (elementName == null)
			elementName = (this.ClassName.substring(this.ClassName.length-6) == "Object") ? this.ClassName.substring(0, this.ClassName.length-6) + "ID" : this.ClassName + "ID"; 
		var identityArray = new Array();
		var checkboxes = this.Element.all(elementName);
		if (checkboxes == null)
		{
			window.status = "No element matching " + elementName + " found in " + this.Element.tagName;
		}
		else if (checkboxes.outerHTML)
		{
			if (checkboxes.checked)
				identityArray[0] = checkboxes.value;
		}
		else for (var i=0; i<checkboxes.length; i++)
		{
			if (checkboxes[i].checked)
				identityArray[identityArray.length] = checkboxes[i].value;
		}	
		return identityArray;
	}
	this.ObjectIDXml = function(elementName, objectName)
	{
		var identityArray = this.ObjectIDArray(elementName);
		if (objectName == null)
			objectName = (this.ClassName.substring(this.ClassName.length-6) == "Object") ? this.ClassName.substring(0, this.ClassName.length-6) : this.ClassName;
		var objectXml = "<" + objectName + "Collection>";
		for (var i=0; i<identityArray.length; i++) {
			objectXml = objectXml + "<" + objectName + "Item>";
			objectXml = objectXml + "<" + objectName + "ID>";
			objectXml += identityArray[i];
			objectXml = objectXml + "</" + objectName + "ID>";
			objectXml = objectXml + "</" + objectName + "Item>";
		}
		objectXml = objectXml + "</" + objectName + "Collection>";
		
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return(result);	
		
	}
	this.SetSortBy = function(sortBy)
	{
		this.SortBy = (this.SortBy == sortBy) ? "-" + sortBy : sortBy;
		if (this.RefreshMethod != null)
			this.RefreshMethod();
	}
	this.SetDisplaySize = function(displaySize)
	{
		if (typeof(displaySize) == "object")
		{
			var ds = displaySize.innerHTML;
			if (isNaN(ds))
			{
				alert("'" + ds + "' is not a valid dislay size.");
				displaySize.innerHTML = this.DisplaySize;
				return;
			}
			displaySize = ds;
		}
		if (this.DisplaySize != displaySize)
		{
			this.DisplaySize = displaySize;
			if (this.RefreshMethod != null)
				this.RefreshMethod();
		}
	}
	this.SetPage = function(recordStart)
	{
		// alert("Setting page rs to " + recordStart);
		if (this.RecordStart != recordStart)
		{
			this.RecordStart = recordStart;
			if (this.RefreshMethod != null)
				this.RefreshMethod();
		}
	}
	this.PopupXhtml = function()
	{
		window.status=("time to render" + new Date() + ", " + this.PopupTime);
		this.PopupID = null;
		if (this.PopupBalloon == null)
		{
			this.PopupBalloon = new Balloon(this.ClassName + "_" + this.IdentityID, this.PopupEvent);
			this.PopupBalloon.StartX = this.PopupEventX;
			this.PopupBalloon.StartY = this.PopupEventY;
			this.PopupBalloon.DivTag.innerHTML = "<p align=\"center\"><img src=\"" + document.qbo.Application + "/Images/qbo/qbo.ico\"/> Loading data ... </p>";
			this.PopupBalloon.Render();
			this.DisplayElement = this.PopupBalloon.DivTag;
			this.SelectXhtml();
		} 
		else
		{
			this.PopupBalloon.Render();
		}
	}
	this.PopupQueue = function(id)
	{
		if (id != null)
			this.SetIdentity(id);
		this.PopupX = event.clientX;
		this.PopupY = event.clientY;
		this.PopupTime = new Date();
		this.PopupEventX = event.clientX;
		this.PopupEventY = event.clientY;
		document.PopupQueueControl = this;
		window.status = ("Popup time. " + this.PopupTime);
		this.PopupID = setTimeout("document.getElementById('" + this.Element.id + "').AjaxControl.PopupXhtml()", 2000);
		this.Element.attachEvent("onmouseout", function anon() {
			if (document.PopupQueueControl)
				document.PopupQueueControl.PopupClear();
		});
	}
	this.PopupClear = function()
	{
		if (this.PopupID != null)
			clearTimeout(this.PopupID);
	}
	// Uses GreyBox to launch a popup window, and calls ObjectBase.Refresh() when the window is closed.
	this.PopupEdit = function(a, height, width)
	{
		if (height == null)
			height = document.body.clientHeight * 0.8;
		if (width == null)
			width = document.body.clientWidth * 0.8;
		window.ObjectBase = this;
		GB_showCenter(a.title, a.href, height, width, function anon() {
			top.window.ObjectBase.Refresh(); 
		}); 
		return false;
	}	
	this.AttachEvent = function(eventName, eventSource)
	{
		this.EventHandlers[this.EventHandlers.length] = new EventHandler(eventName, eventSource);
	}
	this.DetachEvent = function(eventName)
	{
		for (var i = 0; i < this.EventHandlers.length; i++)
		{
			if (this.EventHandlers[i].Name == eventName)
			{
				this.EventHandlers.splice(i, 1);
			}
		}
	}
	this.FireEvent = function(eventName)
	{
		var args = new Array();
		var result = true;
		for (var i = 1; i < arguments.length; i++) //starting at 1 because argument[0] should be the eventName
		{
			args[args.length] = arguments[i];
		}
		for (var i = 0; i < this.EventHandlers.length; i++)
		{
			if (this.EventHandlers[i].Name == eventName)
			{
				switch (args.length)
				{
					case 0:
						result = result && this.EventHandlers[i].Source();
						break;
					case 1:
						result = result && this.EventHandlers[i].Source(args[0]);
						break;
					default:
						result = result && this.EventHandlers[i].Source(args);
						break;
				}
				// this.EventHandlers[i].Source(args.slice());
			}
		}
		return result;
	}
	this.FireEventsByCollection = function(eventID, collectionID, activeOnly)
	{
		if (eventID != null) this.EventID = eventID;
		if (collectionID != null) this.CollectionID = collectionID;
		if (activeOnly != null) this.ActiveOnly = activeOnly;
		
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + "/Event/EventWebService.asmx" + "?WSDL", "CreateEventByCollection");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + "/Event/EventWebService.asmx");
		if (this.WebService.CreateEventByCollection)
		{
			var ObjectBaseResultID = this.WebService.CreateEventByCollection.callService(this.Refresh, "CreateEventByCollection", this.EventID, this.CollectionID, this.ActiveOnly);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to EventWeb.CreateEventByCollection");
		}
	}
	this.Initialize(prefixName, elementName);
}
function ObjectGeneric(prefixName, elementName)
{
	var ob = new ObjectBase(prefixName, elementName);
	ob.WriteXml(ob.Xml);
	ob.ClassName = "ObjectGeneric";

//	var base = new Object();
//	base.WriteXml = ob.WriteXml;
//	ob.objectBaseWriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		if (xml.documentElement == null) return;
		if (this.Tracing) 
			alert("In og.WriteXml: objectBaseWriteXml = \n\n" + this.objectBaseWriteXml);
//		if (this.objectBaseWriteXml)
//			this.objectBaseWriteXml(xml);
		if (xml.documentElement.nodeName.indexOf("Item") == xml.documentElement.nodeName.length-4)
			this.ClassName = xml.documentElement.nodeName.substring(0, xml.documentElement.nodeName.length-4) + "Object";
		if (xml.selectSingleNode("//Object") != null)
			this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null)
			this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//ReportID") != null)
			this.ReportID = xml.selectSingleNode("//ReportID").text;
		if (xml.selectSingleNode("//WarningMessage") != null)
			this.WarningMessage = xml.selectSingleNode("//WarningMessage").text;
	}
	ob.ListXhtml = function(element, className, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (className != null) this.ClassName = className;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		
		if(this.Object == "")
		{
		this.Element.innerHTML=this.WarningMessage
		
		document.getElementById("ajax_CommentsLoadMessage").style.display ="none";		
		return;
		}
		else
		{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectGenericService");
		this.Trace("ObjectGeneric: WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + ", ListXslt=" + this.ListXslt);
		if (this.WebService.ObjectGenericService)
		{
			this.Trace("ObjectGeneric.ListXhtml is calling ListXhtml with " + this.ClassName + ", " + this.Object + ", " + this.ObjectID);
			var ObjectGenericResultID = this.WebService.ObjectGenericService.callService(this.DisplayXhtml, "ListXhtml", this.ClassName, this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectGenericResultID] = this;
			this.Trace("ObjectGenericResultID is  " + ObjectGenericResultID);
			this.RefreshMethod = this.ListXhtml;
			window.status = "Launched " + ObjectGenericResultID + " " + document.qbo.WebServiceArray[ObjectGenericResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
		}
	}
	ob.ListDeepXhtml = function(element, className, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (className != null) this.ClassName = className;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectGenericService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + ", ListXslt=" + this.ListXslt);
		if (this.WebService.ObjectGenericService)
		{
			var ObjectGenericResultID = this.WebService.ObjectGenericService.callService(this.DisplayXhtml, "ListDeelXhtml", this.ClassName, this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectGenericResultID] = this;
			this.Trace("ObjectGenericResultID is  " + ObjectGenericResultID);
			this.RefreshMethod = this.ListDeepXhtml;
			window.status = "Launched " + ObjectGenericResultID + " " + document.qbo.WebServiceArray[ObjectGenericResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}

	ob.ObjectSummaryXhtml = function(id, selectXslt, className)
	{
		if (className != null) this.ClassName = className;
		if (selectXslt == null) selectXslt = this.SelectXslt;
		if (id != null) this.SetIdentity(id);
		if (this.ClassName == null)
		{
			this.Error("ObjectGeneric.ObjectSummaryXhtml was called without setting a ClassName.");
			return;
		}
		if (this.IdentityID == null)
		{
			this.Error("ObjectGeneric.ObjectSummaryXhtml was called without setting an IdentityID.");
//			return;
		}
		if (this.SelectXslt == null)
		{
			this.Error("ObjectGeneric.ObjectSummaryXhtml was called without setting a SelectXslt.");
			return;
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + ", SelectXslt=" + this.SelectXslt);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ObjectSummaryXhtml", this.Object + "Object", this.ObjectID, selectXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("ObjectBaseResultID is  " + ObjectBaseResultID);
			this.RefreshMethod = this.SelectXhtml;
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}

	ob.WebServiceUrl = "/Application/ObjectGenericService.asmx";
	ob.WriteXml(ob.Xml);
	return ob;
}
function MilestoneObject(prefixName, elementName)
{
	var og = new ObjectGeneric(prefixName, elementName);
	//og.Load(arguments)
	og.ClassName = "MilestoneObject";
	og.WebServiceUrl = "/Milestone/MilestoneService.asmx";
	og.WebMethod = "ListXhtml";
	og.ListXslt = "/Templates/Milestone/MilestoneList.Ajax.xslt";
	og.SortBy = "Date";
	og.ShowType = "All";
	
//	og.WriteXml = function(xml)
//	{

//	}
	og.ListXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, showType, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (showType != null) this.ShowType = showType;
		if (listXslt != null) this.ListXslt = listXslt;
		if (isNaN(parseInt(this.ObjectID)))
		{ 
			this.DisplayMessage("There is no parent record for this panel");
			return;
		}
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ShowType, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	og.Cancel = function(element)
	{
		if (this.WebService.ObjectBaseService == null)
		{
			this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
			this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		}
		if (this.WebService.ObjectBaseService)
		{
			this.RefreshMethod = this.ListXhtml;
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "Cancel", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	og.Enable = function(element)
	{
		if (this.WebService.ObjectBaseService == null)
		{
			this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
			this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		}
		if (this.WebService.ObjectBaseService)
		{
			this.RefreshMethod = this.ListXhtml;
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "Enable", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	og.QuickAdd = function()
	{
		// DIV tag like calendar, call the MilestoneService, add the milestone, and redraw the list by calling this.ListXhtml();
	}
	og.SetShowType = function(showType)
	{
		if (this.ShowType != showType) 
		{
			this.ShowType = showType;
			if (this.RefreshMethod != null)
				this.RefreshMethod();
		}
	}

//	var base = new Object();
//	base.WriteXml = og.WriteXml;
	og.objectGenericWriteXml = og.WriteXml;
	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		// base.WriteXml(xml);
		this.objectGenericWriteXml(xml);
		if (xml.selectSingleNode("//ShowType") != null)
			og.ShowType = xml.selectSingleNode("//ShowType").text;
		
	}
	og.WriteXml(og.Xml)
	return og;
	
}
function ReportObject(prefixName, elementName)
{
	var og = new ObjectGeneric(prefixName, elementName);
	//og.Load(arguments)
	og.ClassName = "ReportObject";
	og.WebServiceUrl = "/Report/ReportService.asmx";
	og.WebMethod = "ListXhtml";
	og.ListXslt = "/Templates/Report/ReportList.Ajax.xslt";
	og.SortBy = "Date";
	
	og.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ReportID = this.IdentityID;
	}

	og.SetMimeType = function(MimeType)
	{
		if (this.MimeType != MimeType) 
		{
			this.MimeType = (MimeType == "") ? null : MimeType;
			if (this.RefreshMethod != null)
				this.RefreshMethod();
		}
	}

	og.ListXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, mimeType, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (mimeType != null) this.MimeType = mimeType;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.MimeType, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
	og.ExecuteXhtml = function(element, parentObject, parentObjectID, reportID, subscriberID)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (reportID != null) this.ReportID = reportID;
		if (subscriberID != null) this.SubscriberID = subscriberID;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ReportService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ReportService)
		{
			this.RefreshMethod = this.ExecuteXhtml;
			if ((this.ReportID == null) && (this.SubscriberID != null))
			{
				var ObjectBaseResultID = this.WebService.ReportService.callService(this.DisplayXhtml, "ExecuteBySubscriberIDXhtml", this.Object, this.ObjectID, this.SubscriberID, this.ResultXslt);
			}
			else
				var ObjectBaseResultID = this.WebService.ReportService.callService(this.DisplayXhtml, "ExecuteXhtml", this.Object, this.ObjectID, this.ReportID, this.ResultXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
	var base = new Object();
	base.WriteXml = og.WriteXml;

	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
	
		if (xml.selectSingleNode("//ReportID") != null) this.ReportID = xml.selectSingleNode("//ReportID").text;
		if (xml.selectSingleNode("//Report") != null) this.Report = xml.selectSingleNode("//Report").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//ReportType") != null) this.ReportType = xml.selectSingleNode("//ReportType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//MimeType") != null) this.MimeType = xml.selectSingleNode("//MimeType").text;
		if (xml.selectSingleNode("//Description") != null) this.Description = xml.selectSingleNode("//Description").text;
		if (xml.selectSingleNode("//Instructions") != null) this.Instructions = xml.selectSingleNode("//Instructions").text;
		if (xml.selectSingleNode("//HelpURL") != null) this.HelpURL = xml.selectSingleNode("//HelpURL").text;
		if (xml.selectSingleNode("//PromptUrl") != null) this.PromptUrl = xml.selectSingleNode("//PromptUrl").text;
		if (xml.selectSingleNode("//PromptXslt") != null) this.PromptXslt = xml.selectSingleNode("//PromptXslt").text;
		if (xml.selectSingleNode("//ResultUrl") != null) this.ResultUrl = xml.selectSingleNode("//ResultUrl").text;
		if (xml.selectSingleNode("//ResultXslt") != null) this.ResultXslt = xml.selectSingleNode("//ResultXslt").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//CacheDuration") != null) this.CacheDuration = xml.selectSingleNode("//CacheDuration").text;
	}
	
	og.WriteXml(og.Xml)
	return og;
}
function OrganizationObject(prefixName, elementName)
{
	var ob = new ObjectBase(prefixName, elementName);
	// write some overrides here
	ob.ClassName = "OrganizationObject";
	ob.SelectXslt = "/Templates/Contact/OrganizationSelect.xslt";
	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.OrganizationID = this.IdentityID;
	}
	return ob;
}
function ProcessTemplateObject(prefixName, elementName)
{
	var ob = new ObjectBase(prefixName, elementName);
	// write some overrides here
	ob.ClassName = "ProcessTemplateObject";
	ob.SelectXslt = "/Templates/Process/ProcessTemplateSelect.xslt";
	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ProcessTemplateID = this.IdentityID;
	}
	return ob;
}
function ContactObject(prefixName, elementName)
{
	var ob = new ObjectGeneric(prefixName, elementName);
			
	ob.ClassName = "ContactObject";
	ob.SelectXslt = "/Templates/Contact/ContactSelect.xslt";
	ob.WebServiceUrl = "/Contact/ContactService.asmx";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ContactID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<ContactCollection>";
		objectXml += "<ContactItem>";
		
		if (this.ContactID != null) objectXml += "<ContactID>" + this.ContactID + "<ContactID>";
		if (this.Contact != null) objectXml += "<Contact>" + this.Contact + "<Contact>";
		if (this.ParentContactID != null) objectXml += "<ParentContactID>" + this.ParentContactID + "<ParentContactID>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "<Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "<ObjectID>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "<SubscriberID>";
		if (this.ContactType != null) objectXml += "<ContactType>" + this.ContactType + "<ContactType>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "<Status>";
		if (this.Company != null) objectXml += "<Company>" + this.Company + "<Company>";
		if (this.Title != null) objectXml += "<Title>" + this.Title + "<Title>";
		if (this.Prefix != null) objectXml += "<Prefix>" + this.Prefix + "<Prefix>";
		if (this.FirstName != null) objectXml += "<FirstName>" + this.FirstName + "<FirstName>";
		if (this.MiddleName != null) objectXml += "<MiddleName>" + this.MiddleName + "<MiddleName>";
		if (this.LastName != null) objectXml += "<LastName>" + this.LastName + "<LastName>";
		if (this.Suffix != null) objectXml += "<Suffix>" + this.Suffix + "<Suffix>";
		if (this.Address != null) objectXml += "<Address>" + this.Address + "<Address>";
		if (this.City != null) objectXml += "<City>" + this.City + "<City>";
		if (this.State != null) objectXml += "<State>" + this.State + "<State>";
		if (this.PostalCode != null) objectXml += "<PostalCode>" + this.PostalCode + "<PostalCode>";
		if (this.Country != null) objectXml += "<Country>" + this.Country + "<Country>";
		if (this.USSSN != null) objectXml += "<USSSN>" + this.USSSN + "<USSSN>";
		if (this.BirthDate != null) objectXml += "<BirthDate>" + this.BirthDate + "<BirthDate>";
		if (this.DeathDate != null) objectXml += "<DeathDate>" + this.DeathDate + "<DeathDate>";
		if (this.Nationality != null) objectXml += "<Nationality>" + this.Nationality + "<Nationality>";
		if (this.SpokenLanguage != null) objectXml += "<SpokenLanguage>" + this.SpokenLanguage + "<SpokenLanguage>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "<CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "<CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "<UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "<UpdatedDate>";
		if (this.ValidStart != null) objectXml += "<ValidStart>" + this.ValidStart + "<ValidStart>";
		if (this.ValidEnd != null) objectXml += "<ValidEnd>" + this.ValidEnd + "<ValidEnd>";
		objectXml += "</ContactItem>";
		objectXml += "</ContactCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}

	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
		
		if (xml.selectSingleNode("//ContactID") != null) this.ContactID = xml.selectSingleNode("//ContactID").text;
		if (xml.selectSingleNode("//Contact") != null) this.Contact = xml.selectSingleNode("//Contact").text;
		if (xml.selectSingleNode("//ParentContactID") != null) this.ParentContactID = xml.selectSingleNode("//ParentContactID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//ContactType") != null) this.ContactType = xml.selectSingleNode("//ContactType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//Company") != null) this.Company = xml.selectSingleNode("//Company").text;
		if (xml.selectSingleNode("//Title") != null) this.Title = xml.selectSingleNode("//Title").text;
		if (xml.selectSingleNode("//Prefix") != null) this.Prefix = xml.selectSingleNode("//Prefix").text;
		if (xml.selectSingleNode("//FirstName") != null) this.FirstName = xml.selectSingleNode("//FirstName").text;
		if (xml.selectSingleNode("//MiddleName") != null) this.MiddleName = xml.selectSingleNode("//MiddleName").text;
		if (xml.selectSingleNode("//LastName") != null) this.LastName = xml.selectSingleNode("//LastName").text;
		if (xml.selectSingleNode("//Suffix") != null) this.Suffix = xml.selectSingleNode("//Suffix").text;
		if (xml.selectSingleNode("//Address") != null) this.Address = xml.selectSingleNode("//Address").text;
		if (xml.selectSingleNode("//City") != null) this.City = xml.selectSingleNode("//City").text;
		if (xml.selectSingleNode("//State") != null) this.State = xml.selectSingleNode("//State").text;
		if (xml.selectSingleNode("//PostalCode") != null) this.PostalCode = xml.selectSingleNode("//PostalCode").text;
		if (xml.selectSingleNode("//Country") != null) this.Country = xml.selectSingleNode("//Country").text;
		if (xml.selectSingleNode("//USSSN") != null) this.USSSN = xml.selectSingleNode("//USSSN").text;
		if (xml.selectSingleNode("//BirthDate") != null) this.BirthDate = xml.selectSingleNode("//BirthDate").text;
		if (xml.selectSingleNode("//DeathDate") != null) this.DeathDate = xml.selectSingleNode("//DeathDate").text;
		if (xml.selectSingleNode("//Nationality") != null) this.Nationality = xml.selectSingleNode("//Nationality").text;
		if (xml.selectSingleNode("//SpokenLanguage") != null) this.SpokenLanguage = xml.selectSingleNode("//SpokenLanguage").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//ValidStart") != null) this.ValidStart = xml.selectSingleNode("//ValidStart").text;
		if (xml.selectSingleNode("//ValidEnd") != null) this.ValidEnd = xml.selectSingleNode("//ValidEnd").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "ContactID"] != null) 
		{
			this.ContactID = form.elements[prefix + "ContactID"].value;
		}
		if (form.elements[prefix + "Contact"] != null) 
		{
			this.Contact = form.elements[prefix + "Contact"].value;
		}
		if (form.elements[prefix + "ParentContactID"] != null) 
		{
			this.ParentContactID = form.elements[prefix + "ParentContactID"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "ContactType"] != null) 
		{
			this.ContactType = form.elements[prefix + "ContactType"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "Company"] != null) 
		{
			this.Company = form.elements[prefix + "Company"].value;
		}
		if (form.elements[prefix + "Title"] != null) 
		{
			this.Title = form.elements[prefix + "Title"].value;
		}
		if (form.elements[prefix + "Prefix"] != null) 
		{
			this.Prefix = form.elements[prefix + "Prefix"].value;
		}
		if (form.elements[prefix + "FirstName"] != null) 
		{
			this.FirstName = form.elements[prefix + "FirstName"].value;
		}
		if (form.elements[prefix + "MiddleName"] != null) 
		{
			this.MiddleName = form.elements[prefix + "MiddleName"].value;
		}
		if (form.elements[prefix + "LastName"] != null) 
		{
			this.LastName = form.elements[prefix + "LastName"].value;
		}
		if (form.elements[prefix + "Suffix"] != null) 
		{
			this.Suffix = form.elements[prefix + "Suffix"].value;
		}
		if (form.elements[prefix + "Address"] != null) 
		{
			this.Address = form.elements[prefix + "Address"].value;
		}
		if (form.elements[prefix + "City"] != null) 
		{
			this.City = form.elements[prefix + "City"].value;
		}
		if (form.elements[prefix + "State"] != null) 
		{
			this.State = form.elements[prefix + "State"].value;
		}
		if (form.elements[prefix + "PostalCode"] != null) 
		{
			this.PostalCode = form.elements[prefix + "PostalCode"].value;
		}
		if (form.elements[prefix + "Country"] != null) 
		{
			this.Country = form.elements[prefix + "Country"].value;
		}
		if (form.elements[prefix + "USSSN"] != null) 
		{
			this.USSSN = form.elements[prefix + "USSSN"].value;
		}
		if (form.elements[prefix + "BirthDate"] != null) 
		{
			this.BirthDate = form.elements[prefix + "BirthDate"].value;
		}
		if (form.elements[prefix + "DeathDate"] != null) 
		{
			this.DeathDate = form.elements[prefix + "DeathDate"].value;
		}
		if (form.elements[prefix + "Nationality"] != null) 
		{
			this.Nationality = form.elements[prefix + "Nationality"].value;
		}
		if (form.elements[prefix + "SpokenLanguage"] != null) 
		{
			this.SpokenLanguage = form.elements[prefix + "SpokenLanguage"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
		if (form.elements[prefix + "ValidStart"] != null) 
		{
			this.ValidStart = form.elements[prefix + "ValidStart"].value;
		}
		if (form.elements[prefix + "ValidEnd"] != null) 
		{
			this.ValidEnd = form.elements[prefix + "ValidEnd"].value;
		}
	}
	ob.ListByParentXhtml = function(element, parentContactID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentContactID != null) this.ParentContactID = parentContactID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ContactService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ContactService)
		{
			var ObjectBaseResultID = this.WebService.ContactService.callService(this.DisplayXhtml, "ListByParentXhtml", this.ParentContactID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByParentXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListChildrenXhtml = function(element, parentContactID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentContactID != null) this.ParentContactID = parentContactID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ContactService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ContactService)
		{
			var ObjectBaseResultID = this.WebService.ContactService.callService(this.DisplayXhtml, "ListChildrenXhtml", this.ParentContactID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListChildrenXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListByService = function(element, parentContactID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentContactID != null) this.ParentContactID = parentContactID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ContactService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ContactService)
		{
			var ObjectBaseResultID = this.WebService.ContactService.callService(this.DisplayXhtml, "ListByService", this.ParentContactID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByService;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListWithMethodXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ContactService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ContactService)
		{
			var ObjectBaseResultID = this.WebService.ContactService.callService(this.DisplayXhtml, "ListWithMethodXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			//this.RefreshMethod = this.ListWithMethodXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
	ob.EditXhtml = function(element, contactID, editXslt)
	{
        // call ContactService.asmx's new EditXhtml function
        // overwrite element.outerHTML with what is returned bythe web service
        // what is returned should include a save button, which does the following:
        //  - set ObjectBaseFetch() properties 
        //  - calls ObjectBaseFetch().Refresh();
        /*
        var theContact = ObjectBaseFetch();
        tehContact.Status = ddlContactStatus.selectedIdnex;
        theContact.ContactType = "Property Address";
        theContact.ReadXml(); -- should call CotnactService.Save()
        */
	}
	ob.Save = function()
	{
	    // this will submit this.ReadXml() to CotnactService.asmx's Save() method
	}
	ob.RenderContact = function()
	{
		// alert("Rendering " + this.Xml.outerHTML);
		var contactAjax = new AjaxControl(this.ElementName + "Contact", "//ContactItem", this.ElementName + "Xml", false);
		contactAjax.Initialize();
		contactAjax.HiddenXml = document.getElementById(this.ElementName + "_Hidden");
		alert(contactAjax.SourceXml.xml);

		
		var methodAjax = new AjaxControl(this.ElementName + "Methods", "//ContactMethodItem", this.ElementName + "Xml", false);
		methodAjax.Initialize();
		methodAjax.HiddenXml = document.getElementById(this.ElementName + "_Hidden");
		alert(methodAjax.SourceXml.xml);
	}
	return ob;
}

function CollectionMemberObject(prefixName, elementName)
{
	var og = new ObjectGeneric(prefixName, elementName);
	//og.Load(arguments)
	og.ClassName = "CollectionMemberObject";
	// og.WebServiceUrl = "/Contact/CollectionMemberService.asmx";
	og.ListXslt = "/Templates/Contact/CollectionMemberList.Ajax.xslt";
	og.CollectionMemberServiceUrl = "/Contact/CollectionMemberService.asmx";
	
//	og.WriteXml = function(xml)
//	{

//	}
    og.ListXhtml = function(element, collectionID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		//if (parentObject != null) this.Object = parentObject;
		if (collectionID != null) this.CollectionID = collectionID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.CollectionMemberServiceUrl + "?WSDL", "CollectionMemberService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.CollectionMemberService)
		{
			var ObjectBaseResultID = this.WebService.CollectionMemberService.callService(this.DisplayXhtml, "ListXhtml", this.CollectionID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	og.ListByObjectXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.CollectionMemberServiceUrl + "?WSDL", "CollectionMemberService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.CollectionMemberService)
		{
			var ObjectBaseResultID = this.WebService.CollectionMemberService.callService(this.DisplayXhtml, "ListByObjectXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByObjectXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	og.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.CollectionMemberID = this.IdentityID;
	}
	og.ReadXml = function()
	{
		var objectXml = "<CollectionMemberCollection>";
		objectXml += "<CollectionMemberItem>";
		
		if (this.CollectionMemberID != null) objectXml += "<CollectionMemberID>" + this.CollectionMemberID + "</CollectionMemberID>";
		if (this.CollectionMember != null) objectXml += "<CollectionMember>" + this.CollectionMember + "</CollectionMember>";
		if (this.CollectionID != null) objectXml += "<CollectionID>" + this.CollectionID + "</CollectionID>";
		if (this.SourceObjectID != null) objectXml += "<SourceObjectID>" + this.SourceObjectID + "</SourceObjectID>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.MemberType != null) objectXml += "<MemberType>" + this.MemberType + "</MemberType>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.EffectiveDate != null) objectXml += "<EffectiveDate>" + this.EffectiveDate + "</EffectiveDate>";
		if (this.ExpiresDate != null) objectXml += "<ExpiresDate>" + this.ExpiresDate + "</ExpiresDate>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		objectXml += "</CollectionMemberItem>";
		objectXml += "</CollectionMemberCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	og.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "CollectionMemberID"] != null) 
		{
			this.CollectionMemberID = form.elements[prefix + "CollectionMemberID"].value;
		}
		if (form.elements[prefix + "CollectionMember"] != null) 
		{
			this.CollectionMember = form.elements[prefix + "CollectionMember"].value;
		}
		if (form.elements[prefix + "CollectionID"] != null) 
		{
			this.CollectionID = form.elements[prefix + "CollectionID"].value;
		}
		if (form.elements[prefix + "SourceObjectID"] != null) 
		{
			this.SourceObjectID = form.elements[prefix + "SourceObjectID"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "MemberType"] != null) 
		{
			this.MemberType = form.elements[prefix + "MemberType"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "EffectiveDate"] != null) 
		{
			this.EffectiveDate = form.elements[prefix + "EffectiveDate"].value;
		}
		if (form.elements[prefix + "ExpiresDate"] != null) 
		{
			this.ExpiresDate = form.elements[prefix + "ExpiresDate"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}
//	var base = new Object();
//	base.WriteXml = og.WriteXml;
//	og.WriteXml = function(xml)
//	{
//		if (xml == null) return;
//		base.WriteXml(xml);
//		if (xml.selectSingleNode("//CollectionID") != null)
//			og.CollectionID = xml.selectSingleNode("//CollectionID").text;
//		
//	}
//	
	var base = new Object();
	base.WriteXml = og.WriteXml;
	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
	
		if (xml.selectSingleNode("//CollectionMemberID") != null) this.CollectionMemberID = xml.selectSingleNode("//CollectionMemberID").text;
		if (xml.selectSingleNode("//CollectionMember") != null) this.CollectionMember = xml.selectSingleNode("//CollectionMember").text;
		if (xml.selectSingleNode("//CollectionID") != null) this.CollectionID = xml.selectSingleNode("//CollectionID").text;
		if (xml.selectSingleNode("//SourceObjectID") != null) this.SourceObjectID = xml.selectSingleNode("//SourceObjectID").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//MemberType") != null) this.MemberType = xml.selectSingleNode("//MemberType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//EffectiveDate") != null) this.EffectiveDate = xml.selectSingleNode("//EffectiveDate").text;
		if (xml.selectSingleNode("//ExpiresDate") != null) this.ExpiresDate = xml.selectSingleNode("//ExpiresDate").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
	}

	og.WriteXml(og.Xml)
	return og;
}

function CollectionObject(prefixName, elementName)
{
	var og = new ObjectGeneric(prefixName, elementName);
	//og.Load(arguments)
	og.ClassName = "CollectionMemberObject";
	og.ListXslt = "/Skins/Faslo/Templates/Contact/CollectionList.Ajax.xslt";
	og.CollectionServiceUrl = "/Faslo/Contact/CollectionService.asmx";
	
//	og.WriteXml = function(xml)
//	{

//	}
	og.ListByObjectXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.CollectionServiceUrl + "?WSDL", "CollectionService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.CollectionService)
		{
			var ObjectBaseResultID = this.WebService.CollectionService.callService(this.DisplayXhtml, "ListByObjectXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByObjectXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	var base = new Object();
	base.WriteXml = og.WriteXml;
	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
		if (xml.selectSingleNode("//CollectionID") != null)
			og.CollectionID = xml.selectSingleNode("//CollectionID").text;
		
	}
	og.WriteXml(og.Xml)
	return og;
}

function ImportFormObject(prefixName, elementName)
{
	var og = new ObjectGeneric(prefixName, elementName);
	og.ClassName = "ImportFormObject";
	og.WebServiceUrl = "/Decision/ImportFormService.asmx";
	og.WebMethod = "RefreshReportData";
	og.ListXslt = "/Templates/Decision/ImportFormList.Ajax.xslt";
	og.SortBy = "Date";

	og.GetImportXml = function()
	{
		var form = getParentElement(this.Element, "FORM");
		var importForm = "<ImportFormXml>";
		importForm += "<ImportFormPrefix>" + this.PrefixName + "</ImportFormPrefix>";
		for (var i=0; i!=form.elements.length; i++)
		{
			if ((form.elements[i].name.substring(0, this.PrefixName.length) == this.PrefixName)
				&& (form.elements[i].name.substring(this.PrefixName.length) != "ImportFormXml")
				&& (form.elements[i].name.indexOf("$") == -1))
			{
				if (form.elements[i].type == "radio")
				{
				    if (form.elements[i].checked)
				    {
				        importForm += "<" + form.elements[i].name.substring(this.PrefixName.length) + ">";
				        importForm += form.elements[i].value;
				        importForm += "</" + form.elements[i].name.substring(this.PrefixName.length) + ">";
				    }
				}
				else
				{
				    importForm += "<" + form.elements[i].name.substring(this.PrefixName.length) + ">";
				    importForm += form.elements[i].value;
				    importForm += "</" + form.elements[i].name.substring(this.PrefixName.length) + ">";
				}
			}
		}
		importForm += "</ImportFormXml>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(importForm);
		this.Trace(importForm);
		return result;
	}
	og.RefreshReportData = function()
	{
		if (this.ImportFormID == null)
			return this.TemplateReportXmlFromData();
		else 
			return this.ReportXmlFromData();
	}
	og.ReportXmlFromData = function()
	{
		var importFormXml = this.GetImportXml();
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ImportFormService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ImportFormService)
		{
			var ObjectBaseResultID = this.WebService.ImportFormService.callService(this.DisplayXhtml, "ReportXmlFromData", this.ImportFormID, importFormXml, this.PrefixName);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ReportXmlFromData;
			document.qbo.MaskUI(this.Element);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
		
	}
	og.TemplateReportXmlFromData = function()
	{
		var importFormXml = this.GetImportXml();
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ImportFormService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ImportFormService)
		{
			var ObjectBaseResultID = this.WebService.ImportFormService.callService(this.DisplayXhtml, "TemplateReportXmlFromData", this.ImportFormTemplateID, this.Object, this.ObjectID, importFormXml, this.PrefixName);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.TemplateReportXmlFromData;
			document.qbo.MaskUI(this.Element);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
		
	}
	og.SetImportXml = function(importXml)
	{
		importElement = document.getElementById(this.PrefixName + "ImportFormXml");
		if (importElement != null)
		{
			importElement.value = importXml.xml;
			window.status = "ImportFormXml value set.";
		}
		else
			window.status = "No ImportFormXml element found.";
	}
	var base = new Object();
	base.WriteXml = og.WriteXml;
	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
		if (xml.selectSingleNode("//ImportFormID") != null)
			og.ImportFormID = xml.selectSingleNode("//ImportFormID").text;
		if (xml.selectSingleNode("//ImportFormTemplateID") != null)
			og.ImportFormTemplateID = xml.selectSingleNode("//ImportFormTemplateID").text;
		
	}
	og.WriteXml(og.Xml)
	return og;
}

function SystemPermissionObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
	ob.WriteXml(ob.Xml);
	ob.ClassName = "SystemPermissionObject";
	ob.SelectXslt = "/Templates/Security/SystemPermissionSelect.xslt";
	ob.ListXslt = (ob.ListXslt) ? ob.ListXslt : "/Templates/Security/SystemPermissionList.Ajax.xslt";
	ob.WebServiceUrl = "/Security/SystemPermissionService.asmx";
	ob.SortBy = "SystemPermission";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.SystemPermissionID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<SystemPermissionCollection>";
		objectXml += "<SystemPermissionItem>";
		
		if (this.SystemPermissionID != null) objectXml += "<SystemPermissionID>" + this.SystemPermissionID + "</SystemPermissionID>";
		if (this.SystemRoleID != null) objectXml += "<SystemRoleID>" + this.SystemRoleID + "</SystemRoleID>";
		if (this.PersonID != null) objectXml += "<PersonID>" + this.PersonID + "</PersonID>";
		if (this.SystemFunctionID != null) objectXml += "<SystemFunctionID>" + this.SystemFunctionID + "</SystemFunctionID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		objectXml += "</SystemPermissionItem>";
		objectXml += "</SystemPermissionCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.ParentID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.ParentID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading SystemPermission list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for SystemPermissionObject.ListXhtml");
		}
	}

	ob.ListByRoleXhtml = function(element, systemRoleID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (systemRoleID != null) this.SystemRoleID = systemRoleID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListByRoleXhtml", this.SystemRoleID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByRoleXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		if (xml.selectSingleNode("//SystemPermissionID") != null) this.SystemPermissionID = xml.selectSingleNode("//SystemPermissionID").text;
		if (xml.selectSingleNode("//SystemRoleID") != null) this.SystemRoleID = xml.selectSingleNode("//SystemRoleID").text;
		if (xml.selectSingleNode("//PersonID") != null) this.PersonID = xml.selectSingleNode("//PersonID").text;
		if (xml.selectSingleNode("//SystemFunctionID") != null) this.SystemFunctionID = xml.selectSingleNode("//SystemFunctionID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "SystemPermissionID"] != null) 
		{
			this.SystemPermissionID = form.elements[prefix + "SystemPermissionID"].value;
		}
		if (form.elements[prefix + "SystemRoleID"] != null) 
		{
			this.SystemRoleID = form.elements[prefix + "SystemRoleID"].value;
		}
		if (form.elements[prefix + "PersonID"] != null) 
		{
			this.PersonID = form.elements[prefix + "PersonID"].value;
		}
		if (form.elements[prefix + "SystemFunctionID"] != null) 
		{
			this.SystemFunctionID = form.elements[prefix + "SystemFunctionID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
	}

	return ob;
}


function SystemMemberObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
	ob.ListByPersonXhtml = function(element, personID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (personID != null) this.PersonID = personID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListByPersonXhtml", this.PersonID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByPersonXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListByRoleXhtml = function(element, systemRoleID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (systemRoleID != null) this.SystemRoleID = systemRoleID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListByRoleXhtml", this.SystemRoleID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByRoleXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
			
	ob.ClassName = "SystemMemberObject";
	ob.SelectXslt = "/Templates/Security/SystemMemberSelect.xslt";
	ob.ListXslt = "/Templates/Security/SystemMemberList.Ajax.xslt";
	ob.WebServiceUrl = "/Security/SystemMemberService.asmx";
	ob.SortBy = "SystemMember";


	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.SystemMemberID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<SystemMemberCollection>";
		objectXml += "<SystemMemberItem>";
		
		if (this.SystemMemberID != null) objectXml += "<SystemMemberID>" + this.SystemMemberID + "<SystemMemberID>";
		if (this.PersonID != null) objectXml += "<PersonID>" + this.PersonID + "<PersonID>";
		if (this.SystemRoleID != null) objectXml += "<SystemRoleID>" + this.SystemRoleID + "<SystemRoleID>";
		if (this.IsDefault != null) objectXml += "<IsDefault>" + this.IsDefault + "<IsDefault>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "<CreatedDate>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "<CreatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "<UpdatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "<UpdatedPersonID>";
		objectXml += "</SystemMemberItem>";
		objectXml += "</SystemMemberCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}

	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml, this);
		
		if (xml.selectSingleNode("//SystemMemberID") != null) this.SystemMemberID = xml.selectSingleNode("//SystemMemberID").text;
		if (xml.selectSingleNode("//PersonID") != null) this.PersonID = xml.selectSingleNode("//PersonID").text;
		if (xml.selectSingleNode("//SystemRoleID") != null) this.SystemRoleID = xml.selectSingleNode("//SystemRoleID").text;
		if (xml.selectSingleNode("//IsDefault") != null) this.IsDefault = xml.selectSingleNode("//IsDefault").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "SystemMemberID"] != null) 
		{
			this.SystemMemberID = form.elements[prefix + "SystemMemberID"].value;
		}
		if (form.elements[prefix + "PersonID"] != null) 
		{
			this.PersonID = form.elements[prefix + "PersonID"].value;
		}
		if (form.elements[prefix + "SystemRoleID"] != null) 
		{
			this.SystemRoleID = form.elements[prefix + "SystemRoleID"].value;
		}
		if (form.elements[prefix + "IsDefault"] != null) 
		{
			this.IsDefault = form.elements[prefix + "IsDefault"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
	}
	return ob;
}

function PersonDefaultObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "PersonDefaultObject";
	ob.SelectXslt = "/Templates/Security/PersonDefaultSelect.xslt";
	ob.ListXslt = "/Templates/Security/PersonDefaultList.Ajax.xslt";
	ob.WebServiceUrl = "/Security/PersonDefaultService.asmx";
	ob.SortBy = "PersonDefault";

	ob.ListXhtml = function(element, personID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (personID != null) this.PersonID = personID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.PersonID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.PersonDefaultID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<PersonDefaultCollection>";
		objectXml += "<PersonDefaultItem>";
		
		if (this.PersonID != null) objectXml += "<PersonID>" + this.PersonID + "<PersonID>";
		if (this.SystemRoleID != null) objectXml += "<SystemRoleID>" + this.SystemRoleID + "<SystemRoleID>";
		if (this.SystemDefaultID != null) objectXml += "<SystemDefaultID>" + this.SystemDefaultID + "<SystemDefaultID>";
		if (this.PersonDefaultID != null) objectXml += "<PersonDefaultID>" + this.PersonDefaultID + "<PersonDefaultID>";
		if (this.Value != null) objectXml += "<Value>" + this.Value + "<Value>";
		objectXml += "</PersonDefaultItem>";
		objectXml += "</PersonDefaultCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}

	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml);
		
		if (xml.selectSingleNode("//PersonID") != null) this.PersonID = xml.selectSingleNode("//PersonID").text;
		if (xml.selectSingleNode("//SystemRoleID") != null) this.SystemRoleID = xml.selectSingleNode("//SystemRoleID").text;
		if (xml.selectSingleNode("//SystemDefaultID") != null) this.SystemDefaultID = xml.selectSingleNode("//SystemDefaultID").text;
		if (xml.selectSingleNode("//PersonDefaultID") != null) this.PersonDefaultID = xml.selectSingleNode("//PersonDefaultID").text;
		if (xml.selectSingleNode("//Value") != null) this.Value = xml.selectSingleNode("//Value").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "PersonID"] != null) 
		{
			this.PersonID = form.elements[prefix + "PersonID"].value;
		}
		if (form.elements[prefix + "SystemRoleID"] != null) 
		{
			this.SystemRoleID = form.elements[prefix + "SystemRoleID"].value;
		}
		if (form.elements[prefix + "SystemDefaultID"] != null) 
		{
			this.SystemDefaultID = form.elements[prefix + "SystemDefaultID"].value;
		}
		if (form.elements[prefix + "PersonDefaultID"] != null) 
		{
			this.PersonDefaultID = form.elements[prefix + "PersonDefaultID"].value;
		}
		if (form.elements[prefix + "Value"] != null) 
		{
			this.Value = form.elements[prefix + "Value"].value;
		}
	}

	return ob;
}

function LoanTransactionObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "LoanTransactionObject";
	ob.SelectXslt = "/Templates/Mortgage/LoanTransactionSelect.xslt";
	ob.ListXslt = "/Templates/Mortgage/LoanTransactionList.Ajax.xslt";
	ob.WebServiceUrl = "/Mortgage/LoanTransactionService.asmx";
	ob.SortBy = "LoanTransaction";

	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.ParentID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.ParentID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading LoanTransaction list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for LoanTransactionObject.ListXhtml");
		}
	}
	
	return ob;
}

function OptionMenu(xmlElement, menuElement, className)
{
	if (typeof(xmlElement) == "string")
		this.XmlElement = document.getElementById(xmlElement);
	else
		this.XmlElement = xmlElement;
	this.ClassName = className;
	if (menuElement == null)
	{
		var optionMenu = this.XmlElement.parentElement.insertBefore(document.createElement("span"), this.XmlElement);
		var rootNode = this.XmlElement.selectSingleNode("//OptionCollection");
		if ((rootNode != null) && (rootNode.getAttribute("title") != null))
			optionMenu.innerHTML = rootNode.getAttribute("title");
		else
			optionMenu.innerHTML = "Options";
		optionMenu.className = "OptionMenu";
		optionMenu.OptionMenu = this;
		optionMenu.title = "Click here to view this menu.";
		// optionMenu.style.cursor = "hand";
		//optionMenu.attachEvent("onclick", this.Toggle);
		this.Menu = optionMenu;
	}
	else
	{
		if (typeof(menuElement) == "string")
			menuElement = document.getElementById(menuElement);
		menuElement.OptionMenu = this;
		this.Menu = menuElement;
	}
	if (this.ClassName != null)
		this.Menu.className = this.ClassName;
	this.Menu.attachEvent("onclick", this.Toggle);
	// this.Menu.className = "OptionMenu";
	this.Menu.style.cursor = "hand";
	this.Menu.attachEvent("onmouseover", function anon() {event.srcElement.className+='Active'; window.status=event.srcElement.className;});
	this.Menu.attachEvent("onmouseout", function anon() {event.srcElement.className=event.srcElement.className.substring(0, event.srcElement.className.length-6); window.status=event.srcElement.className;});
	if (this.Menu.title == null)
		this.Menu.title = "Click here to view this menu.";
	

	this.Visible = false;
	// var optionList = this.XmlElement.parentElement.insertBefore(document.createElement("div"), this.Menu);
	var optionList = this.Menu.appendChild(document.createElement("div"));
	optionList.style.display = "none";
	optionList.style.position = "absolute";
	optionList.style.zIndex = 100;
	optionList.OptionMenu = this;
	optionList.attachEvent("onclick", this.Hide);
	optionList.className = "contextMenu";
	optionList.style.border = "solid 1 black"; //Change your contextMenu css class for the bordering.
	// optionList.attachEvent("onmouseout", this.Hide);
	this.List = optionList;
	
	var optionTable = this.List.appendChild(document.createElement("table"));
	optionTable.className = "contextMenu";
	optionTable.cellSpacing = "0"; //Keeps the options menu flicker from happening
	var optionBody = optionTable.appendChild(document.createElement("tbody"));
	
	var options = this.XmlElement.selectNodes("//Option");
	obPrefix = "";
	for (var i=0; i<options.length; i++)
	{
		var optionRow = optionBody.appendChild(document.createElement("tr"));
		var optionCell = optionRow.appendChild(document.createElement("td"));
		optionCell.nowrap = "true";
		// optionCell.attachEvent("onmouseup", this.OptionList.Hide()
		optionCell.innerHTML = options[i].xml.replace("_Focus", obPrefix + "_Focus");
	}
	//this.ListWidth = this.List.clientWidth;
	//optionList.style.display = "none";
}
OptionMenu.prototype.SetClassName = function(className)
{
	this.ClassName = className;
	this.Menu.className = className;
}
OptionMenu.prototype.Toggle = function()
{
	if (this.XmlElement == null)
	{
		if (event.srcElement.OptionMenu == null) return;
		return event.srcElement.OptionMenu.Toggle();
	}
	if (this.Visible)
		this.Hide();
	else
		this.Render();
}

OptionMenu.prototype.Render = function()
{
	if (this.XmlElement == null)
		return event.srcElement.OptionMenu.Render();
	this.Visible = true;
	if ((document.OptionMenuCurrent) && (document.OptionMenuCurrent != this))
		document.OptionMenuCurrent.Hide();
	document.OptionMenuCurrent = this;
	srcElement = this.Menu;
	if (srcElement)
	{
		this.List.style.pixelLeft = 0;
		// this.List.style.pixelRight = this.Menu.clientWidth;
		this.List.style.pixelTop = srcElement.offsetHeight + 1;
	}
	while (srcElement)
	{
		this.List.style.pixelLeft += srcElement.offsetLeft;
		// this.List.style.pixelRight += srcElement.offsetLeft;
		this.List.style.pixelTop += srcElement.offsetTop;
		srcElement = srcElement.offsetParent;
	}
	this.List.style.display = "block";
	// this.List.firstChild.width = this.ListWidth;
	// owidth = this.List.offsetWidth;
	// alert(this.Menu.clientWidth + " : " + this.List.style.pixelLeft + " : " + this.List.offsetWidth);
	if ((this.Menu.clientWidth < this.List.clientWidth) && (this.List.style.pixelLeft > document.body.clientWidth/2))
		this.List.style.pixelLeft -= (this.List.clientWidth - this.Menu.clientWidth);
	// this.List.firstChild.width = this.ListWidth;
	// alert(this.Menu.clientWidth + " : " + this.List.style.pixelLeft + " : " + this.List.offsetWidth);
	// window.status = new Date();
	// alert(this.List.outerHTML);
	event.cancelBubble = true;
	document.body.attachEvent("onkeypress", this.Escape);
	document.body.attachEvent("onclick", this.CheckClick);
	HideOrUnhideObjects("hide");
}
OptionMenu.prototype.Hide = function()
{
	if (this.XmlElement == null)
		return getParentElement(event.srcElement, "DIV").OptionMenu.Hide();
	this.Visible = false;
	document.OptionMenuCurrent = null;
	document.body.detachEvent("onkeypress", this.Escape);
	document.body.detachEvent("onclick", this.CheckClick);
	if (this.Tolerance == null) 
		this.Tolerance = 0;
	var ex = event.x + document.body.scrollLeft;
	var ey = event.y + document.body.scrollTop;
	if ((ex < this.List.style.pixelLeft - this.Tolerance)
		|| (ex > this.List.style.pixelLeft + this.List.clientWidth + this.Tolerance)
		|| (ey < this.List.style.pixelTop - this.Tolerance)
		|| (ey > this.List.style.pixelTop + this.List.clientHeight + this.Tolerance)) 
	{
		this.List.style.display = "none";
	}
	HideOrUnhideObjects("show");
	// window.status = event.x + "." + event.y + ", " + this.List.style.pixelLeft + "." + this.List.style.pixelTop + "x" + (this.List.style.pixelLeft + this.List.clientWidth) + "." + (this.List.style.pixelTop + this.List.clientHeight) + " -- " + document.body.scrollTop;
}
OptionMenu.prototype.Escape = function()
{
	if (this.XmlElement == null) 
	{
		if (document.OptionMenuCurrent) 
			return document.OptionMenuCurrent.Escape();
		else
			return;
	}
	// window.status += event.keyCode;
	if (event.keyCode == 27) this.Hide();
}
OptionMenu.prototype.CheckClick = function()
{
	window.status = "In checkclick: ";
	if (this.XmlElement == null) 
	{
		if (document.OptionMenuCurrent) 
			return document.OptionMenuCurrent.CheckClick();
		else
			return;
	}
	if (this.Tolerance == null) 
		this.Tolerance = 0;
	var ex = event.x + document.body.scrollLeft;
	var ey = event.y + document.body.scrollTop;
	if ((ex < this.List.style.pixelLeft - this.Tolerance)
		|| (ex > this.List.style.pixelLeft + this.List.clientWidth + this.Tolerance)
		|| (ey < this.List.style.pixelTop - this.Tolerance)
		|| (ey > this.List.style.pixelTop + this.List.clientHeight + this.Tolerance)) 
	{
		this.Hide();
	}


	window.status += event.x + ", " + event.y;
}

function DropdownList(element, table, procedure)
{
	this.Element = (typeof(element) == "string") ? document.getElementById(element) : element;
	this.TableName = (table == null) ? "Data" : table;
	this.Procedure = procedure;
	this.Parameters = new Array();
	this.DataTextField = null;
	this.DataValueField = null;
	this.DataSource = null;
	this.WebService = document.qbo.WebService();
	this.WebServiceUrl = "/Report/ReportService.asmx";
	this.AddParameter = function(parameter, value) 
	{
		this.Parameters[parameter] = (value == null) ? "" : value;
		
//		alert("Added " + parameter + " as " + this.Parameters[parameter] + ", length is now " + this.Parameters.length);
	}
	this.Trace = function(message)
	{
		if (this.Tracing == true)
			alert(message);
	}
	this.Redraw = function()
	{
		var xmlString = "<StoredProcedureCollection>";
		xmlString += "<StoredProcedure name=\"" + this.Procedure + "\" object=\"" + this.TableName + "\">";
		for (key in this.Parameters)
		{
			xmlString += "<" + key + ">" + this.Parameters[key] + "</" + key + ">";
		}
		xmlString += "</StoredProcedure>";
		xmlString += "</StoredProcedureCollection>";
		var procedure = new ActiveXObject("Microsoft.XMLDOM");
		procedure.loadXML(xmlString);
		
		this.Element.disabled = "true";
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ReportService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ReportService)
		{
			if (this.DataSource == null)
				this.ReportResultID = this.WebService.ReportService.callService(this.Render, "ExecuteProcedure", procedure);
			else
				this.ReportResultID = this.WebService.ReportService.callService(this.Render, "ExecuteExternalProcedure", this.DataSource, procedure);
			document.qbo.WebServiceArray[this.ReportResultID] = this;
			this.Trace("ObjectBaseResultID is  " + this.ReportResultID);
			window.status = "Launched " + this.ReportResultID + " " + document.qbo.WebServiceArray[this.ReportResultID];
		}
		else 
		{
			this.Error("Failed to launch web service call to DropdownList.Redraw");
		}

	}
	this.Render = function(result)
	{
		if (this.WebServiceUrl == null) 
		{
			window.status = "Getting object from WebServiceArray";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				alert("Could not find DropdownList " + result.id);
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].Render(result);
		}
		this.Element.disabled = null;
		if (result.id < this.ReportResultID) 
		{
			window.status = "Newer request pending; bailing on this one.";
			return;
		}
		this.Trace("Okay so far");
		if (result.error)
		{
			alert(result.errorDetail.string);
			return;
		}
		this.Trace("DropdownList.Render Success!" + result.value);
		if (result.value == null)
		{
			var startIndex = (this.Element.options[0].value == "") ? 1: 0;
			this.Element.options.length = startIndex;
		}
		else
		{
			var startIndex = (this.Element.options[0].value == "") ? 1: 0;
			this.Element.options.length = startIndex;
			optionList = result.value.selectNodes("//" + this.DataTextField);
			valueList = result.value.selectNodes("//" + this.DataValueField);
			for (var i=0; i<optionList.length; i++)
			{
				this.Element.options.length++;
				this.Element.options[this.Element.options.length-1].text = optionList[i].text;
				if (valueList.length > i)
					this.Element.options[this.Element.options.length-1].value = valueList[i].text;
			}
		}
	}
}		

function ContactPopup(id)
{
	if (document.BalloonContactSelect == null)
	{
		document.BalloonContactSelect = new Balloon("ContactSelect");
	}
	document.BalloonContactSelect.Url = "/Contact/ContactPopup.aspx?ContactID=" + id;
	document.BalloonContactSelect.Render();
}

function OrganizationPopup(id)
{
	if (document.BalloonOrganizationSelect == null)
	{
		document.BalloonOrganizationSelect = new Balloon("OrganizationSelect");
	}
	document.BalloonOrganizationSelect.Url = "/Contact/OrganizationPopup.aspx?OrganizationID=" + id;
	document.BalloonOrganizationSelect.Render();
}
//start-------------For Debt Status Dropdown----------------------//
function StatusPopup(object, id, userid)
{	
	
	if (document.getElementById("dropdownStatus") == null)
	{
		var innerText = event.srcElement.innerHTML;
		event.srcElement.innerHTML = "";
		var dropdown = event.srcElement.appendChild(document.createElement("select"));
		dropdown.id = "dropdownStatus";
		dropdown.ObjectStatus = "Debt";
		dropdown.ObjectID = id;
		dropdown.defaultValue = innerText;
		dropdown.userid=userid;
		RefreshStatuses(dropdown);
		
		for (var i=0; i<dropdown.options.length; i++)
		{
			if (dropdown.options[i].value == dropdown.defaultValue)
				dropdown.options[i].selected = true;
		}
		
		dropdown.attachEvent("onchange",UpdateObjectStatus);
		dropdown.attachEvent("onblur", ClearObjectStatus);
		dropdown.focus();
	}
}

function RefreshStatuses(dropdownList)
{
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pObjectStatusList&Object=" + dropdownList.ObjectStatus);
	DropdownRefresh(dropdownList, results, "//DataItem", "ObjectStatus", "ObjectStatus", "Select a Status >>");
}

function UpdateObjectStatus()
{
	
	document.qbo.MaskUI(document.forms[0])
	var dropdownlist = document.getElementById("dropdownStatus");
	var service = document.qbo.WebService();
	service.useService(document.qbo.baseURL + "/Design/ObjectService.asmx?WSDL", "UpdateObjectStatus");
	var returnID;
	if (service.UpdateObjectStatus)
	{
		var callOptions = service.createCallOptions();
		callOptions.funcName = "UpdateObjectStatus";
		callOptions.params = new Array();
		callOptions.params["status"] = dropdownlist.value; //dropdownlist.options[dropdownlist.selectedIndex].value;
		callOptions.params["table"] = dropdownlist.ObjectStatus;
		callOptions.params["id"] = dropdownlist.ObjectID;
		callOptions.params["userid"] = dropdownlist.userid;
		returnID = service.UpdateObjectStatus.callService(ObjectStatusResult, callOptions);
		//alert(document.qbo.baseURL + "/Design/ObjectService.asmx?WSDL");
	}
}

ObjectStatusResult = function(result)
{
    var dropdownlist = document.getElementById("dropdownStatus");
	var td = getParentElement(dropdownlist, "TD");
	
	if (dropdownlist.options[dropdownlist.selectedIndex].value == "Valid")
	{
	    td.innerHTML = "<font color='green'>" + dropdownlist.options[dropdownlist.selectedIndex].value + "<font>";
	}
	else if (dropdownlist.options[dropdownlist.selectedIndex].value == "Invalid")
	{
	    td.innerHTML = "<font color='red'>" + dropdownlist.options[dropdownlist.selectedIndex].value + "<font>";
	}
	else
	{
	    td.innerHTML = dropdownlist.options[dropdownlist.selectedIndex].value;
	   }
	
		
	dropdownlist=null;
	document.qbo.UnMaskUI(document.forms[0])
	return;
}

function ClearObjectStatus()
{
	var dropdownlist = document.getElementById("dropdownStatus");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.defaultValue;
	dropdownlist=null;
}
//end-------------For Debt Status Dropdown----------------------//

//start-------------For Debt Lien Position Dropdown----------------------//
function LienPopup(object, id, userid)
{
	if (document.getElementById("dropdownLien") == null)
	{
		var innerText = event.srcElement.innerHTML;
		event.srcElement.innerHTML = "";
		var dropdown = event.srcElement.appendChild(document.createElement("select"));
		dropdown.id = "dropdownLien";
		dropdown.Object = "Debt";
		dropdown.ObjectType = "Debt.LienPosition";
		dropdown.ObjectID = id;
		dropdown.defaultValue = innerText;
		dropdown.userid=userid;
		RefreshLien(dropdown);
		
		for (var i=0; i<dropdown.options.length; i++)
		{
			if (dropdown.options[i].value == dropdown.defaultValue)
				dropdown.options[i].selected = true;
		}
		
		dropdown.attachEvent("onchange", UpdateLien);
		dropdown.attachEvent("onblur", ClearLien);
		dropdown.focus();
	}
}

function RefreshLien(dropdownList)
{
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pObjectTypeList&Object=" + dropdownList.ObjectType);
	DropdownRefresh(dropdownList, results, "//DataItem", "ObjectType", "ObjectType", "Select a Type >>");
}

function UpdateLien()
{
	
	document.qbo.MaskUI(document.forms[0])
	var dropdownlist = document.getElementById("dropdownLien");
	var td = getParentElement(dropdownlist, "TD");
	var service = document.qbo.WebService();
	service.useService(document.qbo.baseURL + document.qbo.Application + "/Design/ObjectService.asmx?WSDL", "UpdateObject");
	var returnID;
	if (service.UpdateObject)
	{	
		var callOptions = service.createCallOptions();
		callOptions.funcName = "UpdateObject";
		callOptions.params = new Array();
		callOptions.params["thefield"] = "LienPosition";
		callOptions.params["thevalue"] = dropdownlist.value; //dropdownlist.options[dropdownlist.selectedIndex].value;
		callOptions.params["table"] = dropdownlist.Object;
		callOptions.params["id"] = dropdownlist.ObjectID;
		callOptions.params["userid"] = dropdownlist.userid;
		returnID = service.UpdateObject.callService(LienResult, callOptions);
	}
}

LienResult = function(result)
{
	var dropdownlist = document.getElementById("dropdownLien");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.options[dropdownlist.selectedIndex].value;
	dropdownlist=null;
	document.qbo.UnMaskUI(document.forms[0])
	return;
}

function ClearLien()
{
	var dropdownlist = document.getElementById("dropdownLien");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.defaultValue;
	dropdownlist=null;
}
//end-------------For Debt Lien Position Dropdown----------------------//
//start-------------For ProcessStop Dropdown----------------------//
function ProcessStopPopup(object, id)
{
	if (document.getElementById("dropdownProcessStop") == null)
	{
		var innerText = event.srcElement.innerHTML;
		event.srcElement.innerHTML = "";
		var dropdown = event.srcElement.appendChild(document.createElement("select"));
		dropdown.id = "dropdownProcessStop";
		dropdown.Object = "Debt";
		dropdown.ObjectType = "Debt.ProcessStop";
		dropdown.ObjectID = id;
		dropdown.defaultValue = innerText;
		RefreshProcessStop(dropdown);
		
		for (var i=0; i<dropdown.options.length; i++)
		{
			if (dropdown.options[i].value == dropdown.defaultValue)
				dropdown.options[i].selected = true;
		}
		
		dropdown.attachEvent("onchange", UpdateProcessStop);
		dropdown.attachEvent("onblur", ClearProcessStop);
		dropdown.focus();
	}
}

function RefreshProcessStop(dropdownList)
{
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pObjectTypeList&Object=" + dropdownList.ObjectType);
	DropdownRefresh(dropdownList, results, "//DataItem", "ObjectType", "ObjectType", "Select a Type >>");
}

function UpdateProcessStop()
{
	
	document.qbo.MaskUI(document.forms[0])
	var dropdownlist = document.getElementById("dropdownProcessStop");
	var td = getParentElement(dropdownlist, "TD");
	var service = document.qbo.WebService();
	service.useService(document.qbo.baseURL + document.qbo.Application + "/Design/ObjectService.asmx?WSDL", "UpdateObject");
	var returnID;
	if (service.UpdateObject)
	{	
		var callOptions = service.createCallOptions();
		callOptions.funcName = "UpdateObject";
		callOptions.params = new Array();
		callOptions.params["thefield"] = "ProcessStop";
		callOptions.params["thevalue"] = dropdownlist.options[dropdownlist.selectedIndex].value;
		callOptions.params["table"] = dropdownlist.Object;
		callOptions.params["id"] = dropdownlist.ObjectID;
		returnID = service.UpdateObject.callService(ProcessStopResult, callOptions);
	}
}

ProcessStopResult = function(result)
{
	var dropdownlist = document.getElementById("dropdownProcessStop");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.options[dropdownlist.selectedIndex].value;
	dropdownlist=null;
	document.qbo.UnMaskUI(document.forms[0])
	return;
}

function ClearProcessStop()
{
	var dropdownlist = document.getElementById("dropdownProcessStop");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.defaultValue;
	dropdownlist=null;
}
//end-------------For Debt Lien Position Dropdown----------------------//

function ContactPopup(id)
{
	if (document.BalloonContactSelect == null)
	{
		document.BalloonContactSelect = new Balloon("ContactSelect");
	}
	document.BalloonContactSelect.Url = "/Contact/ContactPopup.aspx?ContactID=" + id;
	document.BalloonContactSelect.Render();
}

function OrganizationPopup(id)
{
	if (document.BalloonOrganizationSelect == null)
	{
		document.BalloonOrganizationSelect = new Balloon("OrganizationSelect");
	}
	document.BalloonOrganizationSelect.Url = "/Contact/OrganizationPopup.aspx?OrganizationID=" + id;
	document.BalloonOrganizationSelect.Render();
}

//start-------------For Milestone Sequence Dropdown----------------------//
function MilestoneSequencePopup(objectid, id)
{
	if (document.getElementById("dropdownMilestoneSequence") == null)
	{
		var innerText = event.srcElement.innerHTML;
		event.srcElement.innerHTML = "";
		var dropdown = event.srcElement.appendChild(document.createElement("select"));
		dropdown.id = "dropdownMilestoneSequence";
		dropdown.ObjectID = objectid;
		dropdown.defaultValue = id;
		RefreshMilestoneSequence(dropdown);
		
		for (var i=0; i<dropdown.options.length; i++)
		{
			if (dropdown.options[i].value == dropdown.defaultValue)
				dropdown.options[i].selected = true;
		}
		
		dropdown.attachEvent("onchange", UpdateMilestoneSequence);
		dropdown.attachEvent("onblur", ClearMilestoneSequence);
		dropdown.focus();
	}
}

function RefreshMilestoneSequence(dropdownList)
{
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pMilestoneSequence&MilestoneID=" + dropdownList.ObjectID);
	DropdownRefresh(dropdownList, results, "//DataItem", "Sequence", "Sequence");
}

function UpdateMilestoneSequence()
{
	var dropdownList = document.getElementById("dropdownMilestoneSequence");
	//alert("/Report/ExecuteProcedure.aspx?SP=pMilestoneUpdateSequence&MilestoneID=" + dropdownList.ObjectID + "&Sequence=" + dropdownList.value);
	var results = document.qbo.xmlFromUrl("/Report/ExecuteProcedure.aspx?SP=pMilestoneUpdateSequence&MilestoneID=" + dropdownList.ObjectID + "&Sequence=" + dropdownList.value);
	document.forms[0].submit();
}

function ClearMilestoneSequence()
{
	var dropdownlist = document.getElementById("dropdownMilestoneSequence");
	var td = getParentElement(dropdownlist, "TD");
	td.innerHTML = dropdownlist.defaultValue;
	dropdownlist=null;
}
//end-------------For Milestone Sequence Dropdown----------------------//

//start-------------For SkipTrace (by object) Status Dropdown----------------------//
function StatusPopupByObject(object, id, userid)
{	

    if (document.getElementById("dropdownStatus") == null)
	{
	
		var innerText = event.srcElement.innerHTML;
		event.srcElement.innerHTML = "";
		var dropdown = event.srcElement.appendChild(document.createElement("select"));
		dropdown.id = "dropdownStatus";
		dropdown.ObjectStatus = object;
		dropdown.ObjectID = id;
		dropdown.defaultValue = innerText;
		dropdown.userid=userid;
		RefreshStatuses(dropdown);
		
		for (var i=0; i<dropdown.options.length; i++)
		{
			if (dropdown.options[i].value == dropdown.defaultValue)
				dropdown.options[i].selected = true;
		}
		
		dropdown.attachEvent("onchange",UpdateObjectStatus);
		dropdown.attachEvent("onblur", ClearObjectStatus);
		dropdown.focus();
	}
}	


//end------------- For SkipTrace Status Dropdown----------------------//

//start------------- SkipTrace Object ----------------------//
function SkipTraceObject(prefixName, elementName)
{
	var ob = new ObjectGeneric(prefixName, elementName);
    
	ob.ClassName = "SkipTraceObject";
	ob.SelectXslt = "/Templates/SkipTrace/SkipTraceSelect.xslt";
	ob.WebServiceUrl = "/SkipTrace/SkipService.asmx";
    
	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.SkipTraceID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
		
	ob.ListByParentXhtml = function(element, parentSkipTraceID, sortBy, recordStart, displaySize, listXslt)
	{

	    if (element != null) this.Element = element;
		if (parentSkipTraceID != null) this.ParentSkipTraceID = parentSkipTraceID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "SkipService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.SkipService)
		{
			var ObjectBaseResultID = this.WebService.SkipService.callService(this.DisplayXhtml, "ListByParentXhtml", this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByParentXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
	ob.ListByService = function(element, parentSkipTraceID, serviceType, sortBy, recordStart, displaySize, listXslt)
	{
	    
	    if (element != null) this.Element = element;
		if (parentSkipTraceID != null) this.ParentSkipTraceID = parentSkipTraceID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "SkipService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.SkipService)
		{
		    
		    
			var ObjectBaseResultID = this.WebService.SkipService.callService(this.DisplayXhtml, "ListBySkipService", this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt, this.ServiceType);
			
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByService;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	return ob;

}
//end--------------- SkipTrace Object ----------------------//

function ObjectStatusObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "ObjectStatusObject";
	ob.SelectXslt = "/Templates/Application/ObjectStatusSelect.xslt";
	ob.ListXslt = "/Templates/Application/ObjectStatusList.Ajax.xslt";
	ob.WebServiceUrl = "/Application/ObjectStatusService.asmx";
	ob.SortBy = "ObjectStatus";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ObjectStatusID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<ObjectStatusCollection>";
		objectXml += "<ObjectStatusItem>";
		
		if (this.ObjectStatusID != null) objectXml += "<ObjectStatusID>" + this.ObjectStatusID + "<ObjectStatusID>";
		if (this.ObjectStatus != null) objectXml += "<ObjectStatus>" + this.ObjectStatus + "<ObjectStatus>";
		if (this.ObjectLabel != null) objectXml += "<ObjectLabel>" + this.ObjectLabel + "<ObjectLabel>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "<Object>";
		if (this.ObjectType != null) objectXml += "<ObjectType>" + this.ObjectType + "<ObjectType>";
		if (this.Sequence != null) objectXml += "<Sequence>" + this.Sequence + "<Sequence>";
		if (this.Description != null) objectXml += "<Description>" + this.Description + "<Description>";
		if (this.Instructions != null) objectXml += "<Instructions>" + this.Instructions + "<Instructions>";
		if (this.InitialState != null) objectXml += "<InitialState>" + this.InitialState + "<InitialState>";
		if (this.FinalState != null) objectXml += "<FinalState>" + this.FinalState + "<FinalState>";
		if (this.DefaultSort != null) objectXml += "<DefaultSort>" + this.DefaultSort + "<DefaultSort>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "<CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "<CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "<UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "<UpdatedDate>";
		objectXml += "</ObjectStatusItem>";
		objectXml += "</ObjectStatusCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.ListXhtml = function(element, object, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (object != null) this.Object = object;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.Object, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading ObjectStatus list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for ObjectStatusObject.ListXhtml");
		}
	}


	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
	if (xml == null) return;
	base.WriteXml(xml);
	
		if (xml.selectSingleNode("//ObjectStatusID") != null) this.ObjectStatusID = xml.selectSingleNode("//ObjectStatusID").text;
		if (xml.selectSingleNode("//ObjectStatus") != null) this.ObjectStatus = xml.selectSingleNode("//ObjectStatus").text;
		if (xml.selectSingleNode("//ObjectLabel") != null) this.ObjectLabel = xml.selectSingleNode("//ObjectLabel").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectType") != null) this.ObjectType = xml.selectSingleNode("//ObjectType").text;
		if (xml.selectSingleNode("//Sequence") != null) this.Sequence = xml.selectSingleNode("//Sequence").text;
		if (xml.selectSingleNode("//Description") != null) this.Description = xml.selectSingleNode("//Description").text;
		if (xml.selectSingleNode("//Instructions") != null) this.Instructions = xml.selectSingleNode("//Instructions").text;
		if (xml.selectSingleNode("//InitialState") != null) this.InitialState = xml.selectSingleNode("//InitialState").text;
		if (xml.selectSingleNode("//FinalState") != null) this.FinalState = xml.selectSingleNode("//FinalState").text;
		if (xml.selectSingleNode("//DefaultSort") != null) this.DefaultSort = xml.selectSingleNode("//DefaultSort").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "ObjectStatusID"] != null) 
		{
			this.ObjectStatusID = form.elements[prefix + "ObjectStatusID"].value;
		}
		if (form.elements[prefix + "ObjectStatus"] != null) 
		{
			this.ObjectStatus = form.elements[prefix + "ObjectStatus"].value;
		}
		if (form.elements[prefix + "ObjectLabel"] != null) 
		{
			this.ObjectLabel = form.elements[prefix + "ObjectLabel"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectType"] != null) 
		{
			this.ObjectType = form.elements[prefix + "ObjectType"].value;
		}
		if (form.elements[prefix + "Sequence"] != null) 
		{
			this.Sequence = form.elements[prefix + "Sequence"].value;
		}
		if (form.elements[prefix + "Description"] != null) 
		{
			this.Description = form.elements[prefix + "Description"].value;
		}
		if (form.elements[prefix + "Instructions"] != null) 
		{
			this.Instructions = form.elements[prefix + "Instructions"].value;
		}
		if (form.elements[prefix + "InitialState"] != null) 
		{
			this.InitialState = form.elements[prefix + "InitialState"].value;
		}
		if (form.elements[prefix + "FinalState"] != null) 
		{
			this.FinalState = form.elements[prefix + "FinalState"].value;
		}
		if (form.elements[prefix + "DefaultSort"] != null) 
		{
			this.DefaultSort = form.elements[prefix + "DefaultSort"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}

	return ob;
}

function ObjectTypeObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "ObjectTypeObject";
	ob.SelectXslt = "/Templates/Application/ObjectTypeSelect.xslt";
	ob.ListXslt = "/Templates/Application/ObjectTypeList.Ajax.xslt";
	ob.WebServiceUrl = "/Application/ObjectTypeService.asmx";
	ob.SortBy = "ObjectType";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ObjectTypeID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<ObjectTypeCollection>";
		objectXml += "<ObjectTypeItem>";
		
		if (this.ObjectTypeID != null) objectXml += "<ObjectTypeID>" + this.ObjectTypeID + "<ObjectTypeID>";
		if (this.ObjectType != null) objectXml += "<ObjectType>" + this.ObjectType + "<ObjectType>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "<Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "<ObjectID>";
		if (this.Sequence != null) objectXml += "<Sequence>" + this.Sequence + "<Sequence>";
		if (this.Description != null) objectXml += "<Description>" + this.Description + "<Description>";
		if (this.Instructions != null) objectXml += "<Instructions>" + this.Instructions + "<Instructions>";
		if (this.HelpURL != null) objectXml += "<HelpURL>" + this.HelpURL + "<HelpURL>";
		if (this.Label != null) objectXml += "<Label>" + this.Label + "<Label>";
		objectXml += "</ObjectTypeItem>";
		objectXml += "</ObjectTypeCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.ListXhtml = function(element, object, objectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (object != null) this.Object = object;
		if (objectID != null) this.ObjectID = objectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading ObjectType list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for ObjectTypeObject.ListXhtml");
		}
	}


	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
	if (xml == null) return;
	base.WriteXml(xml);
	
		if (xml.selectSingleNode("//ObjectTypeID") != null) this.ObjectTypeID = xml.selectSingleNode("//ObjectTypeID").text;
		if (xml.selectSingleNode("//ObjectType") != null) this.ObjectType = xml.selectSingleNode("//ObjectType").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//Sequence") != null) this.Sequence = xml.selectSingleNode("//Sequence").text;
		if (xml.selectSingleNode("//Description") != null) this.Description = xml.selectSingleNode("//Description").text;
		if (xml.selectSingleNode("//Instructions") != null) this.Instructions = xml.selectSingleNode("//Instructions").text;
		if (xml.selectSingleNode("//HelpURL") != null) this.HelpURL = xml.selectSingleNode("//HelpURL").text;
		if (xml.selectSingleNode("//Label") != null) this.Label = xml.selectSingleNode("//Label").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "ObjectTypeID"] != null) 
		{
			this.ObjectTypeID = form.elements[prefix + "ObjectTypeID"].value;
		}
		if (form.elements[prefix + "ObjectType"] != null) 
		{
			this.ObjectType = form.elements[prefix + "ObjectType"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "Sequence"] != null) 
		{
			this.Sequence = form.elements[prefix + "Sequence"].value;
		}
		if (form.elements[prefix + "Description"] != null) 
		{
			this.Description = form.elements[prefix + "Description"].value;
		}
		if (form.elements[prefix + "Instructions"] != null) 
		{
			this.Instructions = form.elements[prefix + "Instructions"].value;
		}
		if (form.elements[prefix + "HelpURL"] != null) 
		{
			this.HelpURL = form.elements[prefix + "HelpURL"].value;
		}
		if (form.elements[prefix + "Label"] != null) 
		{
			this.Label = form.elements[prefix + "Label"].value;
		}
	}

	return ob;
}

function AttachmentObject(prefixName, elementName)
{
	var ob = new ObjectBase(prefixName, elementName);
	ob.ClassName = "AttachmentObject";
	ob.SelectXslt = "/Templates/Attachment/AttachmentSelect.xslt";
	ob.ListXslt = "/Templates/Attachment/AttachmentList.Ajax.xslt";
	ob.WebServiceUrl = "/Attachment/AttachmentService.asmx";
	ob.SortBy = "Attachment";
	ob.LabelElement = document.getElementById(elementName + "Label");
	ob.AttachmentUploadPrompt = true;
	if (ob.LabelElement != null)
		ob.LabelElement.AjaxControl = this;

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.AttachmentID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<AttachmentCollection>";
		objectXml += "<AttachmentItem>";
		
		if (this.AttachmentID != null) objectXml += "<AttachmentID>" + this.AttachmentID + "</AttachmentID>";
		if (this.Attachment != null) objectXml += "<Attachment>" + this.Attachment + "</Attachment>";
		if (this.AttachmentType != null) objectXml += "<AttachmentType>" + this.AttachmentType + "</AttachmentType>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "</Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "</ObjectID>";
		if (this.AttachmentTemplateID != null) objectXml += "<AttachmentTemplateID>" + this.AttachmentTemplateID + "</AttachmentTemplateID>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.OwnerID != null) objectXml += "<OwnerID>" + this.OwnerID + "</OwnerID>";
		if (this.PathURL != null) objectXml += "<PathURL>" + this.PathURL + "</PathURL>";
		if (this.Description != null) objectXml += "<Description>" + this.Description + "</Description>";
		if (this.CheckOutDate != null) objectXml += "<CheckOutDate>" + this.CheckOutDate + "</CheckOutDate>";
		if (this.CheckOutPersonID != null) objectXml += "<CheckOutPersonID>" + this.CheckOutPersonID + "</CheckOutPersonID>";
		if (this.CheckOutExpiration != null) objectXml += "<CheckOutExpiration>" + this.CheckOutExpiration + "</CheckOutExpiration>";
		if (this.CheckInDate != null) objectXml += "<CheckInDate>" + this.CheckInDate + "</CheckInDate>";
		if (this.CheckInComment != null) objectXml += "<CheckInComment>" + this.CheckInComment + "</CheckInComment>";
		if (this.ExpirationDate != null) objectXml += "<ExpirationDate>" + this.ExpirationDate + "</ExpirationDate>";
		if (this.OutboundService != null) objectXml += "<OutboundService>" + this.OutboundService + "</OutboundService>";
		if (this.OutboundTrackingID != null) objectXml += "<OutboundTrackingID>" + this.OutboundTrackingID + "</OutboundTrackingID>";
		if (this.OutboundDue != null) objectXml += "<OutboundDue>" + this.OutboundDue + "</OutboundDue>";
		if (this.OutboundReceived != null) objectXml += "<OutboundReceived>" + this.OutboundReceived + "</OutboundReceived>";
		if (this.ReturnService != null) objectXml += "<ReturnService>" + this.ReturnService + "</ReturnService>";
		if (this.ReturnTrackingID != null) objectXml += "<ReturnTrackingID>" + this.ReturnTrackingID + "</ReturnTrackingID>";
		if (this.ReturnDue != null) objectXml += "<ReturnDue>" + this.ReturnDue + "</ReturnDue>";
		if (this.ReturnReceived != null) objectXml += "<ReturnReceived>" + this.ReturnReceived + "</ReturnReceived>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		if (this.MetaXSD != null) objectXml += "<MetaXSD>" + this.MetaXSD + "</MetaXSD>";
		if (this.MetaXML != null) objectXml += "<MetaXML>" + this.MetaXML + "</MetaXML>";
		if (this.FileContent != null) objectXml += "<FileContent>" + this.FileContent + "</FileContent>";
		objectXml += "</AttachmentItem>";
		objectXml += "</AttachmentCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.ParentID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.ParentID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Attachment list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for AttachmentObject.ListXhtml");
		}
	}


	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
	if (xml == null) return;
	base.WriteXml(xml);
	
		if (xml.selectSingleNode("//AttachmentID") != null) this.AttachmentID = xml.selectSingleNode("//AttachmentID").text;
		if (xml.selectSingleNode("//Attachment") != null) this.Attachment = xml.selectSingleNode("//Attachment").text;
		if (xml.selectSingleNode("//AttachmentType") != null) this.AttachmentType = xml.selectSingleNode("//AttachmentType").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//AttachmentTemplateID") != null) this.AttachmentTemplateID = xml.selectSingleNode("//AttachmentTemplateID").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//OwnerID") != null) this.OwnerID = xml.selectSingleNode("//OwnerID").text;
		if (xml.selectSingleNode("//PathURL") != null) this.PathURL = xml.selectSingleNode("//PathURL").text;
		if (xml.selectSingleNode("//Description") != null) this.Description = xml.selectSingleNode("//Description").text;
		if (xml.selectSingleNode("//CheckOutDate") != null) this.CheckOutDate = xml.selectSingleNode("//CheckOutDate").text;
		if (xml.selectSingleNode("//CheckOutPersonID") != null) this.CheckOutPersonID = xml.selectSingleNode("//CheckOutPersonID").text;
		if (xml.selectSingleNode("//CheckOutExpiration") != null) this.CheckOutExpiration = xml.selectSingleNode("//CheckOutExpiration").text;
		if (xml.selectSingleNode("//CheckInDate") != null) this.CheckInDate = xml.selectSingleNode("//CheckInDate").text;
		if (xml.selectSingleNode("//CheckInComment") != null) this.CheckInComment = xml.selectSingleNode("//CheckInComment").text;
		if (xml.selectSingleNode("//ExpirationDate") != null) this.ExpirationDate = xml.selectSingleNode("//ExpirationDate").text;
		if (xml.selectSingleNode("//OutboundService") != null) this.OutboundService = xml.selectSingleNode("//OutboundService").text;
		if (xml.selectSingleNode("//OutboundTrackingID") != null) this.OutboundTrackingID = xml.selectSingleNode("//OutboundTrackingID").text;
		if (xml.selectSingleNode("//OutboundDue") != null) this.OutboundDue = xml.selectSingleNode("//OutboundDue").text;
		if (xml.selectSingleNode("//OutboundReceived") != null) this.OutboundReceived = xml.selectSingleNode("//OutboundReceived").text;
		if (xml.selectSingleNode("//ReturnService") != null) this.ReturnService = xml.selectSingleNode("//ReturnService").text;
		if (xml.selectSingleNode("//ReturnTrackingID") != null) this.ReturnTrackingID = xml.selectSingleNode("//ReturnTrackingID").text;
		if (xml.selectSingleNode("//ReturnDue") != null) this.ReturnDue = xml.selectSingleNode("//ReturnDue").text;
		if (xml.selectSingleNode("//ReturnReceived") != null) this.ReturnReceived = xml.selectSingleNode("//ReturnReceived").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//MetaXSD") != null) this.MetaXSD = xml.selectSingleNode("//MetaXSD").text;
		if (xml.selectSingleNode("//MetaXML") != null) this.MetaXML = xml.selectSingleNode("//MetaXML").text;
		if (xml.selectSingleNode("//FileContent") != null) this.FileContent = xml.selectSingleNode("//FileContent").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "AttachmentID"] != null) 
		{
			this.AttachmentID = form.elements[prefix + "AttachmentID"].value;
		}
		if (form.elements[prefix + "Attachment"] != null) 
		{
			this.Attachment = form.elements[prefix + "Attachment"].value;
		}
		if (form.elements[prefix + "AttachmentType"] != null) 
		{
			this.AttachmentType = form.elements[prefix + "AttachmentType"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "AttachmentTemplateID"] != null) 
		{
			this.AttachmentTemplateID = form.elements[prefix + "AttachmentTemplateID"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "OwnerID"] != null) 
		{
			this.OwnerID = form.elements[prefix + "OwnerID"].value;
		}
		if (form.elements[prefix + "PathURL"] != null) 
		{
			this.PathURL = form.elements[prefix + "PathURL"].value;
		}
		if (form.elements[prefix + "Description"] != null) 
		{
			this.Description = form.elements[prefix + "Description"].value;
		}
		if (form.elements[prefix + "CheckOutDate"] != null) 
		{
			this.CheckOutDate = form.elements[prefix + "CheckOutDate"].value;
		}
		if (form.elements[prefix + "CheckOutPersonID"] != null) 
		{
			this.CheckOutPersonID = form.elements[prefix + "CheckOutPersonID"].value;
		}
		if (form.elements[prefix + "CheckOutExpiration"] != null) 
		{
			this.CheckOutExpiration = form.elements[prefix + "CheckOutExpiration"].value;
		}
		if (form.elements[prefix + "CheckInDate"] != null) 
		{
			this.CheckInDate = form.elements[prefix + "CheckInDate"].value;
		}
		if (form.elements[prefix + "CheckInComment"] != null) 
		{
			this.CheckInComment = form.elements[prefix + "CheckInComment"].value;
		}
		if (form.elements[prefix + "ExpirationDate"] != null) 
		{
			this.ExpirationDate = form.elements[prefix + "ExpirationDate"].value;
		}
		if (form.elements[prefix + "OutboundService"] != null) 
		{
			this.OutboundService = form.elements[prefix + "OutboundService"].value;
		}
		if (form.elements[prefix + "OutboundTrackingID"] != null) 
		{
			this.OutboundTrackingID = form.elements[prefix + "OutboundTrackingID"].value;
		}
		if (form.elements[prefix + "OutboundDue"] != null) 
		{
			this.OutboundDue = form.elements[prefix + "OutboundDue"].value;
		}
		if (form.elements[prefix + "OutboundReceived"] != null) 
		{
			this.OutboundReceived = form.elements[prefix + "OutboundReceived"].value;
		}
		if (form.elements[prefix + "ReturnService"] != null) 
		{
			this.ReturnService = form.elements[prefix + "ReturnService"].value;
		}
		if (form.elements[prefix + "ReturnTrackingID"] != null) 
		{
			this.ReturnTrackingID = form.elements[prefix + "ReturnTrackingID"].value;
		}
		if (form.elements[prefix + "ReturnDue"] != null) 
		{
			this.ReturnDue = form.elements[prefix + "ReturnDue"].value;
		}
		if (form.elements[prefix + "ReturnReceived"] != null) 
		{
			this.ReturnReceived = form.elements[prefix + "ReturnReceived"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
		if (form.elements[prefix + "MetaXSD"] != null) 
		{
			this.MetaXSD = form.elements[prefix + "MetaXSD"].value;
		}
		if (form.elements[prefix + "MetaXML"] != null) 
		{
			this.MetaXML = form.elements[prefix + "MetaXML"].value;
		}
		if (form.elements[prefix + "FileContent"] != null) 
		{
			this.FileContent = form.elements[prefix + "FileContent"].value;
		}
	}

	ob.Upload = function() 
	{
		this.Frame = document.getElementById(this.ElementName + "Frame");
		this.Frame.AttachmentObject = this;
		this.Frame.src = document.qbo.Application + "/Attachment/AttachmentUpload.aspx";
		this.UploadPrompt();
	}
	ob.UploadPrompt = function()
	{
		if (this.Frame.readyState != "complete")
		{
			setTimeout("document.getElementById('" + this.ElementName + "Frame').AttachmentObject.UploadPrompt()", 250);
			return;
		}
		var attachmentForm = this.Frame.contentWindow.document.forms[0];
		// var inputButton = this.Frame.contentWindow.document.createElement("<input id=\"UploadFile\" type=\"file\" value=\"Test\" onchange=\"window.frameElement.AttachmentObject.UploadSubmit(); //document.forms[0].submit();\"/>");
		this.InputButton = this.Frame.contentWindow.document.getElementById("UploadFile");
		var hidAttachmentID = this.Frame.contentWindow.document.getElementById("hidAttachmentID");
		if ((this.AttachmentID != undefined) && (this.AttachmentID != null))
			hidAttachmentID.value = this.AttachmentID;
		var hidObject = this.Frame.contentWindow.document.getElementById("hidObject");
		if (this.Object != undefined)
			hidObject.value = this.Object;
		var hidObjectID = this.Frame.contentWindow.document.getElementById("hidObjectID");
		if (this.ObjectID != undefined)
			hidObjectID.value = this.ObjectID;
		this.InputButton.click();
	}
	ob.UploadSubmit = function()
	{
		if (this.LabelElement == null)
			this.LabelElement = document.getElementById(this.ElementName + "Label");
		this.PromptHtml = this.LabelElement.innerHTML;
		this.LabelElement.innerHTML = "<img src=\"" + document.qbo.Application + "/Images/qbo/qbo.ico\"/> Uploading document ...";

		var filePath = this.InputButton.value.split("\\");
		if (this.AttachmentUploadPrompt)
		{
			this.Label = this.Attachment;
			this.Attachment = prompt("Enter a name for this attachment:", filePath[filePath.length-1]);
		}
		var hidAttachment = this.Frame.contentWindow.document.getElementById("hidAttachment");
		if ((this.Attachment != undefined) && (this.Attachment != null))
			hidAttachment.value = this.Attachment;
		if (this.Form == null)
			this.Form = getParentElement(this.Element, "FORM");
		if (this.Form.AttachmentUploadCount == null)
		{
			this.Form.AttachmentUploadCount = 1;
			this.Form.attachEvent("onsubmit", function anon() {
				if ((!document.IsCanceling) && (event.srcElement) && (event.srcElement.AttachmentUploadCount > 0))
				{
					alert("Still uploading " + event.srcElement.AttachmentUploadCount + " document(s); please wait until this has completed before saving.");
					return false;
				}
			});
		}
		else
			this.Form.AttachmentUploadCount++;
		this.Frame.contentWindow.document.forms[0].submit();
	}
	
	ob.UploadComplete = function(attachmentXml)
	{
		ob.WriteXml(attachmentXml);
		this.LabelElement.innerHTML = this.PromptHtml.replace(this.Label, this.Attachment);
		this.AttachmentValue = document.getElementById(this.ElementName + "AttachmentID");
		if (this.AttachmentValue != null)
			this.AttachmentValue.value = this.AttachmentID;
		else
			this.Error("No element named " + this.ElementName + "AttachmentID found to populate.");
		this.Form.AttachmentUploadCount--;
	}
	ob.Remove = function()
	{
		this.AttachmentValue = document.getElementById(this.ElementName + "AttachmentID");
		if (confirm("Are you sure you want to remove this attachment?"))
		{
			this.AttachmentValue.value = "";
			if (this.LabelElement == null)
				this.LabelElement = document.getElementById(this.ElementName + "Label");
			this.LabelElement.innerHTML = this.Label;
		}
	}
	return ob;
}

function AttachmentCollection(prefixName, elementName)
{
	var ao = new AttachmentObject(prefixName, elementName);
	ao.Prompt = "Upload a new Attachment.";
	ao.PromptHtml = ao.Element.innerHTML;
	ao.AttachmentID = null;
	ao.AttachmentValue = document.getElementById(elementName + "Value");

	ao.RenderAttachmentLink = function(xml, target)
	{
		if (target == null) target = "_blank";
		var html = "<a href=\"" + document.qbo.Application + "/Attachment/AttachmentView.aspx?AttachmentID=" + xml.selectSingleNode("AttachmentID").text + "\" title=\"Click here to view this attachment.\">";
		html += xml.selectSingleNode("Attachment").text;
		html += "</a>";
		return html;
	}
	ao.RenderAttachmentDelete = function(xml)
	{
		var attachmentID = parseInt(xml.selectSingleNode("AttachmentID").text);
		var icon = document.createElement("<img class=\"icon\" src=\"" + document.qbo.Application + "/Images/qbo/icon.Delete.png\" onclick=\"ObjectBaseFetch().Remove(" + attachmentID + ");\"/>");
		return icon;
	}
	ao.RenderList = function()
	{
		var attachments = this.Xml.selectNodes("//AttachmentItem");
		this.LabelElement.AjaxControl = this;
		this.LabelElement.innerHTML = "";
		for (var i=0; i<attachments.length; i++)
		{
			this.LabelElement.innerHTML += this.RenderAttachmentLink(attachments[i]);
			this.LabelElement.appendChild(this.RenderAttachmentDelete(attachments[i]));
			this.LabelElement.innerHTML += "<br/>";
		}
	}
	ao.UploadSubmit = function()
	{
		this.PromptHtml = this.Element.innerHTML;
		this.Element.innerHTML = "<img src=\"" + document.qbo.Application + "/Images/qbo/qbo.ico\"/> Uploading document ...";
		// this.Frame.style.display = "inline";

		var filePath = this.InputButton.value.split("\\");
		if (this.AttachmentUploadPrompt)
		{
			this.Label = this.Attachment;
			this.Attachment = prompt("Enter a name for this attachment:", filePath[filePath.length-1]);
		}
		var hidAttachment = this.Frame.contentWindow.document.getElementById("hidAttachment");
		if ((this.Attachment != undefined) && (this.Attachment != null))
			hidAttachment.value = this.Attachment;
		if (this.Form == null)
			this.Form = getParentElement(this.Element, "FORM");
		if (this.Form.AttachmentUploadCount == null)
		{
			this.Form.AttachmentUploadCount = 1;
			this.Form.attachEvent("onsubmit", function anon() {
				if ((!document.IsCanceling) && (event.srcElement) && (event.srcElement.AttachmentUploadCount > 0))
				{
					alert("Still uploading " + event.srcElement.AttachmentUploadCount + " document(s); please wait until this has completed before saving.");
					return false;
				}
			});
		}
		else
			this.Form.AttachmentUploadCount++;

		this.Frame.contentWindow.document.forms[0].submit();
	}
	ao.UploadComplete = function(attachmentXml)
	{
		this.Xml.documentElement.appendChild(attachmentXml.selectSingleNode("//AttachmentItem"));
		this.AttachmentValue.value = this.Xml.xml;
		this.Element.innerHTML = this.PromptHtml;	//.replace(this.Label, this.Attachment);
		this.Form.AttachmentUploadCount--;
		this.RenderList();
	}
	ao.Remove = function(attachmentID)
	{
		var node = this.Xml.selectSingleNode("//AttachmentItem[AttachmentID=" + attachmentID + "]");
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			document.qbo.WebServiceArray[this.WebService.ObjectBaseService.callService(this.RemoveComplete, "Delete", this.ClassName, attachmentID)] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ao.RemoveComplete = function(result)
	{
		if (this.WebServiceUrl == null) 
		{
			window.status = "Getting object from WebServiceArray";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				alert("Could not find ObjectBase! " + result.id);
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].RemoveComplete(result);
		}
		if (result.error)
		{
			// this.Element.innerHTML = "<p align=\"center\">Oops. There was an error loading this panel. Please try again later.</p>";
			this.Error(result.errorDetail);
			return;
		}
		var node = this.Xml.selectSingleNode("//AttachmentItem[AttachmentID=" + result.value + "]");
		node.parentNode.removeChild(node);
		this.AttachmentValue.value = this.Xml.xml;
		this.RenderList();
	}

	return ao;
}

function PhotoCollection(prefixName, elementName)
{
	var ac = new AttachmentCollection(prefixName, elementName);
	ac.Prompt = "";

	ac.RenderAttachmentLink = function(index, xml, target)
	{
		if (target == null) target = "_blank";
		var html = "<a onclick=\"ao = ObjectBaseFetch(); ao.PreviewIndex=" + index + "; ao.Preview.src = this.href; return false;\" href=\"" + document.qbo.Application + "/Attachment/ImageView.aspx?AttachmentID=" + xml.selectSingleNode("AttachmentID").text + "\" title=\"Click here to preview this image.\nRight-click to save or open in a new window/tab.\">";
		// html += xml.selectSingleNode("Attachment").text;
		html += (index + 1);
		html += "</a> ";
		return html;
	}
	ac.RenderAttachmentDelete = function()
	{
		var icon = document.createElement("<img class=\"icon\" src=\"" + document.qbo.Application + "/Images/qbo/icon.Delete.png\" onclick=\"ObjectBaseFetch().Remove();\"/>");
		this.DeleteIcon = icon;
		return icon;
	}
	ac.RenderList = function(index)
	{
		var attachments = this.Xml.selectNodes("//AttachmentItem");
		if (this.PreviewHeight == null)
			this.PreviewHeight = 150;
		if (this.PreviewWidth == null)
			this.PreviewWidth = 240;
		this.PreviewIndex = (index == null) ? 0: index;
		this.LabelElement.AjaxControl = this;
		this.LabelElement.innerHTML = "";
		for (var i=0; i<attachments.length; i++)
		{
			this.LabelElement.innerHTML += this.RenderAttachmentLink(i, attachments[i]);
			// this.LabelElement.appendChild(this.RenderAttachmentDelete(attachments[i]));
		}
		this.LabelElement.appendChild(this.RenderAttachmentDelete());
		this.LabelElement.innerHTML += "<br/>";
		var preview = document.createElement("<img height=\"" + this.PreviewHeight + "\" width=\"" + this.PreviewWidth + "\"/>");
		this.LabelElement.appendChild(preview);
		if (this.PreviewIndex < attachments.length)
		{
			preview.style.display = "inline";
			this.DeleteIcon.style.display = "inline";
			preview.src = document.qbo.Application + "/Attachment/ImageView.aspx?AttachmentID=" + attachments[this.PreviewIndex].selectSingleNode("AttachmentID").text;
		}
		else
		{
			preview.style.display = "none";
			this.DeleteIcon.style.display = "none";
		}
		this.Preview = preview;
	}
	ac.UploadSubmit = function()
	{
		this.PromptHtml = this.Element.innerHTML;
		this.Element.innerHTML = "<img src=\"" + document.qbo.Application + "/Images/qbo/qbo.ico\"/> Uploading document ...";
		// this.Frame.style.display = "inline";

		var filePath = this.InputButton.value.split("\\");
		if (this.AttachmentUploadPrompt)
		{
			this.Label = this.Attachment;
			this.Attachment = prompt("Enter a name for this attachment:", filePath[filePath.length-1]);
		}
		var hidAttachment = this.Frame.contentWindow.document.getElementById("hidAttachment");
		if ((this.Attachment != undefined) && (this.Attachment != null))
			hidAttachment.value = this.Attachment;
		if (this.Form == null)
			this.Form = getParentElement(this.Element, "FORM");
		if (this.Form.AttachmentUploadCount == null)
		{
			this.Form.AttachmentUploadCount = 1;
			this.Form.attachEvent("onsubmit", function anon() {
				if ((!document.IsCanceling) && (event.srcElement) && (event.srcElement.AttachmentUploadCount > 0))
				{
					alert("Still uploading " + event.srcElement.AttachmentUploadCount + " document(s); please wait until this has completed before saving.");
					return false;
				}
			});
		}
		else
			this.Form.AttachmentUploadCount++;


		this.Frame.contentWindow.document.forms[0].submit();
	}
	ac.UploadComplete = function(attachmentXml)
	{
		this.Xml.documentElement.appendChild(attachmentXml.selectSingleNode("//AttachmentItem"));
		this.AttachmentValue.value = this.Xml.xml;
		this.Element.innerHTML = this.PromptHtml;	//.replace(this.Label, this.Attachment);
		this.Form.AttachmentUploadCount--;
		this.RenderList(this.Xml.selectNodes("//AttachmentItem").length-1);
	}
	ac.Remove = function()
	{
		var attachments = this.Xml.selectNodes("//AttachmentItem");
		if ((this.PreviewIndex == null) || (this.PreviewIndex == undefined) || (attachments[this.PreviewIndex] == null))
		{
			alert("You must preview an image before trying to delete it.");
			return;
		}
		if (!confirm("Are you sure you want to delete the photo being displayed (" + (this.PreviewIndex + 1) + ") ?"))
			return;
		var attachmentID = attachments[this.PreviewIndex].selectSingleNode("AttachmentID").text;	//this.Xml.selectSingleNode("//AttachmentItem[position()=" + this.PreviewIndex + "]");
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			document.qbo.WebServiceArray[this.WebService.ObjectBaseService.callService(this.RemoveComplete, "Delete", this.ClassName, attachmentID)] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ac.RemoveComplete = function(result)
	{
		if (this.WebServiceUrl == null) 
		{
			window.status = "Getting object from WebServiceArray";
			if (document.qbo.WebServiceArray[result.id] == null) 
			{
				alert("Could not find ObjectBase! " + result.id);
				return;
			}
			else 
				return document.qbo.WebServiceArray[result.id].RemoveComplete(result);
		}
		if (result.error)
		{
			// this.Element.innerHTML = "<p align=\"center\">Oops. There was an error loading this panel. Please try again later.</p>";
			this.Error(result.errorDetail);
			return;
		}
		var node = this.Xml.selectSingleNode("//AttachmentItem[AttachmentID=" + result.value + "]");
		node.parentNode.removeChild(node);
		this.AttachmentValue.value = this.Xml.xml;
		this.RenderList();
	}

	return ac;
}

function DecisionStepTemplateObject(prefixName, elementName)
{
		
	var ob = new ObjectBase(prefixName, elementName);
			
	ob.ClassName = "DecisionStepTemplateObject";
	ob.SelectXslt = "/Templates/Decision/DecisionStepTemplateSelect.xslt";
	ob.ListXslt = "/Templates/Decision/DecisionStepTemplateList.Ajax.xslt";
	ob.WebServiceUrl = "/Decision/DecisionStepTemplateService.asmx";
	ob.SortBy = "DecisionStepTemplate";

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.DecisionStepTemplateID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<DecisionStepTemplateCollection>";
		objectXml += "<DecisionStepTemplateItem>";
		
		if (this.DecisionStepTemplateID != null) objectXml += "<DecisionStepTemplateID>" + this.DecisionStepTemplateID + "</DecisionStepTemplateID>";
		if (this.DecisionStepTemplate != null) objectXml += "<DecisionStepTemplate>" + this.DecisionStepTemplate + "</DecisionStepTemplate>";
		if (this.DecisionTemplateID != null) objectXml += "<DecisionTemplateID>" + this.DecisionTemplateID + "</DecisionTemplateID>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "</Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "</ObjectID>";
		if (this.Sequence != null) objectXml += "<Sequence>" + this.Sequence + "</Sequence>";
		if (this.DecisionStepType != null) objectXml += "<DecisionStepType>" + this.DecisionStepType + "</DecisionStepType>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.DurationScale != null) objectXml += "<DurationScale>" + this.DurationScale + "</DurationScale>";
		if (this.EstimatedDuration != null) objectXml += "<EstimatedDuration>" + this.EstimatedDuration + "</EstimatedDuration>";
		if (this.MinDuration != null) objectXml += "<MinDuration>" + this.MinDuration + "</MinDuration>";
		if (this.MaxDuration != null) objectXml += "<MaxDuration>" + this.MaxDuration + "</MaxDuration>";
		if (this.OrganizationCollectionID != null) objectXml += "<OrganizationCollectionID>" + this.OrganizationCollectionID + "</OrganizationCollectionID>";
		if (this.GroupCollectionID != null) objectXml += "<GroupCollectionID>" + this.GroupCollectionID + "</GroupCollectionID>";
		if (this.PersonCollectionID != null) objectXml += "<PersonCollectionID>" + this.PersonCollectionID + "</PersonCollectionID>";
		if (this.StepXml != null) objectXml += "<StepXml>" + this.StepXml + "</StepXml>";
		if (this.StepXslt != null) objectXml += "<StepXslt>" + this.StepXslt + "</StepXslt>";
		if (this.OnStartParentStatus != null) objectXml += "<OnStartParentStatus>" + this.OnStartParentStatus + "</OnStartParentStatus>";
		if (this.OnStartDecisionStatus != null) objectXml += "<OnStartDecisionStatus>" + this.OnStartDecisionStatus + "</OnStartDecisionStatus>";
		if (this.OnCompleteParentStatus != null) objectXml += "<OnCompleteParentStatus>" + this.OnCompleteParentStatus + "</OnCompleteParentStatus>";
		if (this.OnCompleteDecisionStatus != null) objectXml += "<OnCompleteDecisionStatus>" + this.OnCompleteDecisionStatus + "</OnCompleteDecisionStatus>";
		if (this.ReferenceDate != null) objectXml += "<ReferenceDate>" + this.ReferenceDate + "</ReferenceDate>";
		if (this.ReportID != null) objectXml += "<ReportID>" + this.ReportID + "</ReportID>";
		if (this.MonitorScheduleID != null) objectXml += "<MonitorScheduleID>" + this.MonitorScheduleID + "</MonitorScheduleID>";
		if (this.ReuseAge != null) objectXml += "<ReuseAge>" + this.ReuseAge + "</ReuseAge>";
		if (this.ReuseAgeScale != null) objectXml += "<ReuseAgeScale>" + this.ReuseAgeScale + "</ReuseAgeScale>";
		if (this.ReuseCondition != null) objectXml += "<ReuseCondition>" + this.ReuseCondition + "</ReuseCondition>";
		if (this.ParentObject != null) objectXml += "<ParentObject>" + this.ParentObject + "</ParentObject>";
		if (this.ParentObjectID != null) objectXml += "<ParentObjectID>" + this.ParentObjectID + "</ParentObjectID>";
		if (this.CreateOnCompletion != null) objectXml += "<CreateOnCompletion>" + this.CreateOnCompletion + "</CreateOnCompletion>";
		if (this.CopySiblingStatus != null) objectXml += "<CopySiblingStatus>" + this.CopySiblingStatus + "</CopySiblingStatus>";
		if (this.ShapeType != null) objectXml += "<ShapeType>" + this.ShapeType + "</ShapeType>";
		if (this.ShapeX != null) objectXml += "<ShapeX>" + this.ShapeX + "</ShapeX>";
		if (this.ShapeY != null) objectXml += "<ShapeY>" + this.ShapeY + "</ShapeY>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		objectXml += "</DecisionStepTemplateItem>";
		objectXml += "</DecisionStepTemplateCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteStepList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.DecisionTemplateID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.DecisionTemplateID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading DecisionStepTemplate list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for DecisionStepTemplateObject.ListXhtml");
		}
	}


	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		base.WriteXml(xml, this);
		if (xml.selectSingleNode("//SortBy") != null) this.SortBy = xml.selectSingleNode("//SortBy").text;
		if (xml.selectSingleNode("//DecisionStepTemplateID") != null) this.DecisionStepTemplateID = xml.selectSingleNode("//DecisionStepTemplateID").text;
		if (xml.selectSingleNode("//DecisionStepTemplate") != null) this.DecisionStepTemplate = xml.selectSingleNode("//DecisionStepTemplate").text;
		if (xml.selectSingleNode("//DecisionTemplateID") != null) this.DecisionTemplateID = xml.selectSingleNode("//DecisionTemplateID").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//Sequence") != null) this.Sequence = xml.selectSingleNode("//Sequence").text;
		if (xml.selectSingleNode("//DecisionStepType") != null) this.DecisionStepType = xml.selectSingleNode("//DecisionStepType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//DurationScale") != null) this.DurationScale = xml.selectSingleNode("//DurationScale").text;
		if (xml.selectSingleNode("//EstimatedDuration") != null) this.EstimatedDuration = xml.selectSingleNode("//EstimatedDuration").text;
		if (xml.selectSingleNode("//MinDuration") != null) this.MinDuration = xml.selectSingleNode("//MinDuration").text;
		if (xml.selectSingleNode("//MaxDuration") != null) this.MaxDuration = xml.selectSingleNode("//MaxDuration").text;
		if (xml.selectSingleNode("//OrganizationCollectionID") != null) this.OrganizationCollectionID = xml.selectSingleNode("//OrganizationCollectionID").text;
		if (xml.selectSingleNode("//GroupCollectionID") != null) this.GroupCollectionID = xml.selectSingleNode("//GroupCollectionID").text;
		if (xml.selectSingleNode("//PersonCollectionID") != null) this.PersonCollectionID = xml.selectSingleNode("//PersonCollectionID").text;
		if (xml.selectSingleNode("//StepXml") != null) this.StepXml = xml.selectSingleNode("//StepXml").text;
		if (xml.selectSingleNode("//StepXslt") != null) this.StepXslt = xml.selectSingleNode("//StepXslt").text;
		if (xml.selectSingleNode("//OnStartParentStatus") != null) this.OnStartParentStatus = xml.selectSingleNode("//OnStartParentStatus").text;
		if (xml.selectSingleNode("//OnStartDecisionStatus") != null) this.OnStartDecisionStatus = xml.selectSingleNode("//OnStartDecisionStatus").text;
		if (xml.selectSingleNode("//OnCompleteParentStatus") != null) this.OnCompleteParentStatus = xml.selectSingleNode("//OnCompleteParentStatus").text;
		if (xml.selectSingleNode("//OnCompleteDecisionStatus") != null) this.OnCompleteDecisionStatus = xml.selectSingleNode("//OnCompleteDecisionStatus").text;
		if (xml.selectSingleNode("//ReferenceDate") != null) this.ReferenceDate = xml.selectSingleNode("//ReferenceDate").text;
		if (xml.selectSingleNode("//ReportID") != null) this.ReportID = xml.selectSingleNode("//ReportID").text;
		if (xml.selectSingleNode("//MonitorScheduleID") != null) this.MonitorScheduleID = xml.selectSingleNode("//MonitorScheduleID").text;
		if (xml.selectSingleNode("//ReuseAge") != null) this.ReuseAge = xml.selectSingleNode("//ReuseAge").text;
		if (xml.selectSingleNode("//ReuseAgeScale") != null) this.ReuseAgeScale = xml.selectSingleNode("//ReuseAgeScale").text;
		if (xml.selectSingleNode("//ReuseCondition") != null) this.ReuseCondition = xml.selectSingleNode("//ReuseCondition").text;
		if (xml.selectSingleNode("//ParentObject") != null) this.ParentObject = xml.selectSingleNode("//ParentObject").text;
		if (xml.selectSingleNode("//ParentObjectID") != null) this.ParentObjectID = xml.selectSingleNode("//ParentObjectID").text;
		if (xml.selectSingleNode("//CreateOnCompletion") != null) this.CreateOnCompletion = xml.selectSingleNode("//CreateOnCompletion").text;
		if (xml.selectSingleNode("//CopySiblingStatus") != null) this.CopySiblingStatus = xml.selectSingleNode("//CopySiblingStatus").text;
		if (xml.selectSingleNode("//ShapeType") != null) this.ShapeType = xml.selectSingleNode("//ShapeType").text;
		if (xml.selectSingleNode("//ShapeX") != null) this.ShapeX = xml.selectSingleNode("//ShapeX").text;
		if (xml.selectSingleNode("//ShapeY") != null) this.ShapeY = xml.selectSingleNode("//ShapeY").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "DecisionStepTemplateID"] != null) 
		{
			this.DecisionStepTemplateID = form.elements[prefix + "DecisionStepTemplateID"].value;
		}
		if (form.elements[prefix + "DecisionStepTemplate"] != null) 
		{
			this.DecisionStepTemplate = form.elements[prefix + "DecisionStepTemplate"].value;
		}
		if (form.elements[prefix + "DecisionTemplateID"] != null) 
		{
			this.DecisionTemplateID = form.elements[prefix + "DecisionTemplateID"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "Sequence"] != null) 
		{
			this.Sequence = form.elements[prefix + "Sequence"].value;
		}
		if (form.elements[prefix + "DecisionStepType"] != null) 
		{
			this.DecisionStepType = form.elements[prefix + "DecisionStepType"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "DurationScale"] != null) 
		{
			this.DurationScale = form.elements[prefix + "DurationScale"].value;
		}
		if (form.elements[prefix + "EstimatedDuration"] != null) 
		{
			this.EstimatedDuration = form.elements[prefix + "EstimatedDuration"].value;
		}
		if (form.elements[prefix + "MinDuration"] != null) 
		{
			this.MinDuration = form.elements[prefix + "MinDuration"].value;
		}
		if (form.elements[prefix + "MaxDuration"] != null) 
		{
			this.MaxDuration = form.elements[prefix + "MaxDuration"].value;
		}
		if (form.elements[prefix + "OrganizationCollectionID"] != null) 
		{
			this.OrganizationCollectionID = form.elements[prefix + "OrganizationCollectionID"].value;
		}
		if (form.elements[prefix + "GroupCollectionID"] != null) 
		{
			this.GroupCollectionID = form.elements[prefix + "GroupCollectionID"].value;
		}
		if (form.elements[prefix + "PersonCollectionID"] != null) 
		{
			this.PersonCollectionID = form.elements[prefix + "PersonCollectionID"].value;
		}
		if (form.elements[prefix + "StepXml"] != null) 
		{
			this.StepXml = form.elements[prefix + "StepXml"].value;
		}
		if (form.elements[prefix + "StepXslt"] != null) 
		{
			this.StepXslt = form.elements[prefix + "StepXslt"].value;
		}
		if (form.elements[prefix + "OnStartParentStatus"] != null) 
		{
			this.OnStartParentStatus = form.elements[prefix + "OnStartParentStatus"].value;
		}
		if (form.elements[prefix + "OnStartDecisionStatus"] != null) 
		{
			this.OnStartDecisionStatus = form.elements[prefix + "OnStartDecisionStatus"].value;
		}
		if (form.elements[prefix + "OnCompleteParentStatus"] != null) 
		{
			this.OnCompleteParentStatus = form.elements[prefix + "OnCompleteParentStatus"].value;
		}
		if (form.elements[prefix + "OnCompleteDecisionStatus"] != null) 
		{
			this.OnCompleteDecisionStatus = form.elements[prefix + "OnCompleteDecisionStatus"].value;
		}
		if (form.elements[prefix + "ReferenceDate"] != null) 
		{
			this.ReferenceDate = form.elements[prefix + "ReferenceDate"].value;
		}
		if (form.elements[prefix + "ReportID"] != null) 
		{
			this.ReportID = form.elements[prefix + "ReportID"].value;
		}
		if (form.elements[prefix + "MonitorScheduleID"] != null) 
		{
			this.MonitorScheduleID = form.elements[prefix + "MonitorScheduleID"].value;
		}
		if (form.elements[prefix + "ReuseAge"] != null) 
		{
			this.ReuseAge = form.elements[prefix + "ReuseAge"].value;
		}
		if (form.elements[prefix + "ReuseAgeScale"] != null) 
		{
			this.ReuseAgeScale = form.elements[prefix + "ReuseAgeScale"].value;
		}
		if (form.elements[prefix + "ReuseCondition"] != null) 
		{
			this.ReuseCondition = form.elements[prefix + "ReuseCondition"].value;
		}
		if (form.elements[prefix + "ParentObject"] != null) 
		{
			this.ParentObject = form.elements[prefix + "ParentObject"].value;
		}
		if (form.elements[prefix + "ParentObjectID"] != null) 
		{
			this.ParentObjectID = form.elements[prefix + "ParentObjectID"].value;
		}
		if (form.elements[prefix + "CreateOnCompletion"] != null) 
		{
			this.CreateOnCompletion = form.elements[prefix + "CreateOnCompletion"].value;
		}
		if (form.elements[prefix + "CopySiblingStatus"] != null) 
		{
			this.CopySiblingStatus = form.elements[prefix + "CopySiblingStatus"].value;
		}
		if (form.elements[prefix + "ShapeType"] != null) 
		{
			this.ShapeType = form.elements[prefix + "ShapeType"].value;
		}
		if (form.elements[prefix + "ShapeX"] != null) 
		{
			this.ShapeX = form.elements[prefix + "ShapeX"].value;
		}
		if (form.elements[prefix + "ShapeY"] != null) 
		{
			this.ShapeY = form.elements[prefix + "ShapeY"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}

	return ob;
}

function ScoreObject(prefixName, elementName)
{
		
	var og = new ObjectGeneric(prefixName, elementName);
			
	og.ClassName = "ScoreObject";
	og.SelectXslt = "/Templates/Score/ScoreSelect.xslt";
	
	og.ListXslt = (og.ListXslt) ? og.ListXslt : "/Templates/Score/ScoreList.Ajax.xslt";
	og.ListByTemplateXslt = "/Templates/Score/ScoreListByTemplate.Ajax.xslt";
	og.WebServiceUrl = "/Score/ScoreService.asmx";
	og.SortBy = "Score";
	og.WriteXml(og.Xml);

	og.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ScoreID = this.IdentityID;
	}
	og.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	og.ReadXml = function()
	{
		var objectXml = "<ScoreCollection>";
		objectXml += "<ScoreItem>";
		
		if (this.ScoreID != null) objectXml += "<ScoreID>" + this.ScoreID + "</ScoreID>";
		if (this.Score != null) objectXml += "<Score>" + this.Score + "</Score>";
		if (this.ScoreTemplateID != null) objectXml += "<ScoreTemplateID>" + this.ScoreTemplateID + "</ScoreTemplateID>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "</Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "</ObjectID>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.ScoreType != null) objectXml += "<ScoreType>" + this.ScoreType + "</ScoreType>";
		if (this.SourceXML != null) objectXml += "<SourceXML>" + this.SourceXML + "</SourceXML>";
		if (this.ScoreMoney != null) objectXml += "<ScoreMoney>" + this.ScoreMoney + "</ScoreMoney>";
		if (this.ScoreInt != null) objectXml += "<ScoreInt>" + this.ScoreInt + "</ScoreInt>";
		if (this.ScoreFloat != null) objectXml += "<ScoreFloat>" + this.ScoreFloat + "</ScoreFloat>";
		if (this.ScoreBoolean != null) objectXml += "<ScoreBoolean>" + this.ScoreBoolean + "</ScoreBoolean>";
		if (this.ScoreChar != null) objectXml += "<ScoreChar>" + this.ScoreChar + "</ScoreChar>";
		if (this.ScoreDate != null) objectXml += "<ScoreDate>" + this.ScoreDate + "</ScoreDate>";
		if (this.Confidence != null) objectXml += "<Confidence>" + this.Confidence + "</Confidence>";
		if (this.CalculatedDate != null) objectXml += "<CalculatedDate>" + this.CalculatedDate + "</CalculatedDate>";
		if (this.ExpirationDate != null) objectXml += "<ExpirationDate>" + this.ExpirationDate + "</ExpirationDate>";
		if (this.SpreadsheetXml != null) objectXml += "<SpreadsheetXml>" + this.SpreadsheetXml + "</SpreadsheetXml>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		objectXml += "</ScoreItem>";
		objectXml += "</ScoreCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	og.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
//	og.baseWriteXml = og.WriteXml;
	og.WriteXml = function(xml)
	{
		if (xml == null) return;
		// this.baseWriteXml(xml);
		if ((xml.selectSingleNode("//ScoreID") != null) && (!isNaN(parseInt(xml.selectSingleNode("//ScoreID").text))))
			this.ScoreID = parseInt(xml.selectSingleNode("//ScoreID").text);
		if (xml.selectSingleNode("//Score") != null) this.Score = xml.selectSingleNode("//Score").text;
		if (xml.selectSingleNode("//ScoreTemplateID") != null) this.ScoreTemplateID = xml.selectSingleNode("//ScoreTemplateID").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//ScoreType") != null) this.ScoreType = xml.selectSingleNode("//ScoreType").text;
		if (xml.selectSingleNode("//SourceXML") != null) this.SourceXML = xml.selectSingleNode("//SourceXML").text;
		if (xml.selectSingleNode("//ScoreMoney") != null) this.ScoreMoney = xml.selectSingleNode("//ScoreMoney").text;
		if (xml.selectSingleNode("//ScoreInt") != null) this.ScoreInt = xml.selectSingleNode("//ScoreInt").text;
		if (xml.selectSingleNode("//ScoreFloat") != null) this.ScoreFloat = xml.selectSingleNode("//ScoreFloat").text;
		if (xml.selectSingleNode("//ScoreBoolean") != null) this.ScoreBoolean = xml.selectSingleNode("//ScoreBoolean").text;
		if (xml.selectSingleNode("//ScoreChar") != null) this.ScoreChar = xml.selectSingleNode("//ScoreChar").text;
		if (xml.selectSingleNode("//ScoreDate") != null) this.ScoreDate = xml.selectSingleNode("//ScoreDate").text;
		if (xml.selectSingleNode("//Confidence") != null) this.Confidence = xml.selectSingleNode("//Confidence").text;
		if (xml.selectSingleNode("//CalculatedDate") != null) this.CalculatedDate = xml.selectSingleNode("//CalculatedDate").text;
		if (xml.selectSingleNode("//ExpirationDate") != null) this.ExpirationDate = xml.selectSingleNode("//ExpirationDate").text;
		if (xml.selectSingleNode("//SpreadsheetXml") != null) this.SpreadsheetXml = xml.selectSingleNode("//SpreadsheetXml").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//CollectionID") != null) this.CollectionID = xml.selectSingleNode("//CollectionID").text;
	}
	og.WriteXml(og.Xml);

	og.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "ScoreID"] != null) 
		{
			this.ScoreID = form.elements[prefix + "ScoreID"].value;
		}
		if (form.elements[prefix + "Score"] != null) 
		{
			this.Score = form.elements[prefix + "Score"].value;
		}
		if (form.elements[prefix + "ScoreTemplateID"] != null) 
		{
			this.ScoreTemplateID = form.elements[prefix + "ScoreTemplateID"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "ScoreType"] != null) 
		{
			this.ScoreType = form.elements[prefix + "ScoreType"].value;
		}
		if (form.elements[prefix + "SourceXML"] != null) 
		{
			this.SourceXML = form.elements[prefix + "SourceXML"].value;
		}
		if (form.elements[prefix + "ScoreMoney"] != null) 
		{
			this.ScoreMoney = form.elements[prefix + "ScoreMoney"].value;
		}
		if (form.elements[prefix + "ScoreInt"] != null) 
		{
			this.ScoreInt = form.elements[prefix + "ScoreInt"].value;
		}
		if (form.elements[prefix + "ScoreFloat"] != null) 
		{
			this.ScoreFloat = form.elements[prefix + "ScoreFloat"].value;
		}
		if (form.elements[prefix + "ScoreBoolean"] != null) 
		{
			this.ScoreBoolean = form.elements[prefix + "ScoreBoolean"].value;
		}
		if (form.elements[prefix + "ScoreChar"] != null) 
		{
			this.ScoreChar = form.elements[prefix + "ScoreChar"].value;
		}
		if (form.elements[prefix + "ScoreDate"] != null) 
		{
			this.ScoreDate = form.elements[prefix + "ScoreDate"].value;
		}
		if (form.elements[prefix + "Confidence"] != null) 
		{
			this.Confidence = form.elements[prefix + "Confidence"].value;
		}
		if (form.elements[prefix + "CalculatedDate"] != null) 
		{
			this.CalculatedDate = form.elements[prefix + "CalculatedDate"].value;
		}
		if (form.elements[prefix + "ExpirationDate"] != null) 
		{
			this.ExpirationDate = form.elements[prefix + "ExpirationDate"].value;
		}
		if (form.elements[prefix + "SpreadsheetXml"] != null) 
		{
			this.SpreadsheetXml = form.elements[prefix + "SpreadsheetXml"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
	}
	
	og.baseSelectXhtml = og.SelectXhtml;
	og.SelectXhtml = function(id, selectXslt, className)
	{
		if ((this.ScoreID != null) || (this.ScoreID == "undefined"))
		{
			this.baseSelectXhtml(id, selectXslt, className);
		}
		else
		{
			this.ListByTemplateXhtml();
		}
	}
	og.ListByTemplateXhtml = function(element, parentObject, parentObjectID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ParentObjectID = parentObjectID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListByTemplateXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListByTemplateXhtml", this.Object, this.ObjectID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListByTemplateXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Score list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListByTemplateXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for ScoreObject.ListXhtml");
		}
	}

	og.DetailByCollectionXhtml = function(element, collectionID, scoreTemplateID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (collectionID != null) this.CollectionID = collectionID;
		if (scoreTemplateID != null) this.ScoreTemplateID = scoreTemplateID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "DetailByCollectionXhtml", this.CollectionID, this.ScoreTemplateID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Score list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.DetailByCollectionXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for ScoreObject.DetailByCollectionXhtml");
		}
	}
	og.Calculate = function()
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		if (this.WebService.ObjectBaseService)
		{
		    var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "Calculate", this.ReadXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
		}
	}


	return og;
}

	
//ObjectLink

function ObjectLinkObject(prefixName, elementName)
{
	
	var ob = new ObjectGeneric(prefixName, elementName);
	//og.Load(arguments)
	ob.ClassName = "ObjectLinkObject";
	if (ob.ListXslt == null)
	ob.ListXslt = "/Skins/Faslo/Templates/Application/ObjectLinkList.Ajax.xslt";
	ob.ObjectLinkServiceUrl = "/Faslo/Application/ObjectLinkService.asmx";
	
	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.ObjectLinkID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<ObjectLinkCollection>";
		objectXml += "<ObjectLinkItem>";
		
		if (this.ObjectLinkID != null) objectXml += "<ObjectLinkID>" + this.ObjectLinkID + "</ObjectLinkID>";
		if (this.ObjectLink != null) objectXml += "<ObjectLink>" + this.ObjectLink + "</ObjectLink>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.ObjectLinkType != null) objectXml += "<ObjectLinkType>" + this.ObjectLinkType + "</ObjectLinkType>";
		if (this.PrimaryObject != null) objectXml += "<PrimaryObject>" + this.PrimaryObject + "</PrimaryObject>";
		if (this.PrimaryObjectID != null) objectXml += "<PrimaryObjectID>" + this.PrimaryObjectID + "</PrimaryObjectID>";
		if (this.PrimaryObjectSubscriberID != null) objectXml += "<PrimaryObjectSubscriberID>" + this.PrimaryObjectSubscriberID + "</PrimaryObjectSubscriberID>";
		if (this.LinkedObject != null) objectXml += "<LinkedObject>" + this.LinkedObject + "</LinkedObject>";
		if (this.LinkedObjectID != null) objectXml += "<LinkedObjectID>" + this.LinkedObjectID + "</LinkedObjectID>";
		if (this.LinkedObjectSubscriberID != null) objectXml += "<LinkedObjectSubscriberID>" + this.LinkedObjectSubscriberID + "</LinkedObjectSubscriberID>";
		if (this.Master != null) objectXml += "<Master>" + this.Master + "</Master>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		objectXml += "</ObjectLinkItem>";
		objectXml += "</ObjectLinkCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.ObjectLinkServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteObjectLinkList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListByObjectXhtml = function(element, parentObject, parentObjectID, ObjectLink, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (ObjectLink != null) this.ObjectLink = ObjectLink;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.ObjectLinkServiceUrl + "?WSDL", "ObjectLinkService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectLinkService)
		{
			var ObjectBaseResultID = this.WebService.ObjectLinkService.callService(this.DisplayXhtml, "ListByObjectXhtml", this.Object, this.ObjectID, this.ObjectLink, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByObjectXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
			//For Bankruptcy related records 
	ob.ListByBankruptcyXhtml = function(element, parentObject, parentObjectID, ObjectLink, sortBy, recordStart, displaySize, listXslt)
	{
	    if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (ObjectLink != null) this.ObjectLink = ObjectLink;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.ObjectLinkServiceUrl + "?WSDL", "ObjectLinkService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		
		if (this.WebService.ObjectLinkService)
		{
			var ObjectBaseResultID = this.WebService.ObjectLinkService.callService(this.DisplayXhtml, "ListByBankruptcyXhtml", this.Object, this.ObjectID, this.ObjectLink, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByObjectXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	
			//For CreditReport related records 
	ob.ListByCreditReportXhtml = function(element, parentObject, parentObjectID, ObjectLink, sortBy, recordStart, displaySize, listXslt)
	{
	    if (element != null) this.Element = element;
		if (parentObject != null) this.Object = parentObject;
		if (parentObjectID != null) this.ObjectID = parentObjectID;
		if (ObjectLink != null) this.ObjectLink = ObjectLink;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.ObjectLinkServiceUrl + "?WSDL", "ObjectLinkService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		
		if (this.WebService.ObjectLinkService)
		{
			var ObjectBaseResultID = this.WebService.ObjectLinkService.callService(this.DisplayXhtml, "ListByCreditReportXhtml", this.Object, this.ObjectID, this.ObjectLink, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Launched " + ObjectBaseResultID + " " + document.qbo.WebServiceArray[ObjectBaseResultID];
			this.RefreshMethod = this.ListByObjectXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
		
	var base = new Object();
	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
	if (xml == null) return;
	base.WriteXml(xml);
	
		if (xml.selectSingleNode("//ObjectLinkID") != null) this.ObjectLinkID = xml.selectSingleNode("//ObjectLinkID").text;
		if (xml.selectSingleNode("//ObjectLink") != null) this.ObjectLink = xml.selectSingleNode("//ObjectLink").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//ObjectLinkType") != null) this.ObjectLinkType = xml.selectSingleNode("//ObjectLinkType").text;
		if (xml.selectSingleNode("//PrimaryObject") != null) this.PrimaryObject = xml.selectSingleNode("//PrimaryObject").text;
		if (xml.selectSingleNode("//PrimaryObjectID") != null) this.PrimaryObjectID = xml.selectSingleNode("//PrimaryObjectID").text;
		if (xml.selectSingleNode("//PrimaryObjectSubscriberID") != null) this.PrimaryObjectSubscriberID = xml.selectSingleNode("//PrimaryObjectSubscriberID").text;
		if (xml.selectSingleNode("//LinkedObject") != null) this.LinkedObject = xml.selectSingleNode("//LinkedObject").text;
		if (xml.selectSingleNode("//LinkedObjectID") != null) this.LinkedObjectID = xml.selectSingleNode("//LinkedObjectID").text;
		if (xml.selectSingleNode("//LinkedObjectSubscriberID") != null) this.LinkedObjectSubscriberID = xml.selectSingleNode("//LinkedObjectSubscriberID").text;
		if (xml.selectSingleNode("//Master") != null) this.Master = xml.selectSingleNode("//Master").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;
	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "ObjectLinkID"] != null) 
		{
			this.ObjectLinkID = form.elements[prefix + "ObjectLinkID"].value;
		}
		if (form.elements[prefix + "ObjectLink"] != null) 
		{
			this.ObjectLink = form.elements[prefix + "ObjectLink"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "ObjectLinkType"] != null) 
		{
			this.ObjectLinkType = form.elements[prefix + "ObjectLinkType"].value;
		}
		if (form.elements[prefix + "PrimaryObject"] != null) 
		{
			this.PrimaryObject = form.elements[prefix + "PrimaryObject"].value;
		}
		if (form.elements[prefix + "PrimaryObjectID"] != null) 
		{
			this.PrimaryObjectID = form.elements[prefix + "PrimaryObjectID"].value;
		}
		if (form.elements[prefix + "PrimaryObjectSubscriberID"] != null) 
		{
			this.PrimaryObjectSubscriberID = form.elements[prefix + "PrimaryObjectSubscriberID"].value;
		}
		if (form.elements[prefix + "LinkedObject"] != null) 
		{
			this.LinkedObject = form.elements[prefix + "LinkedObject"].value;
		}
		if (form.elements[prefix + "LinkedObjectID"] != null) 
		{
			this.LinkedObjectID = form.elements[prefix + "LinkedObjectID"].value;
		}
		if (form.elements[prefix + "LinkedObjectSubscriberID"] != null) 
		{
			this.LinkedObjectSubscriberID = form.elements[prefix + "LinkedObjectSubscriberID"].value;
		}
		if (form.elements[prefix + "Master"] != null) 
		{
			this.Master = form.elements[prefix + "Master"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}
	return ob;
}
	
var tiedtoObject="";	
function ObjectLink()
	{
	    var PrimaryObject = document.qbo.getCookie("qbo.Application.ObjectLink.PrimaryObject");
   	    var PrimaryObjectID = document.qbo.getCookie("qbo.Application.ObjectLink.PrimaryObjectID");
    	var PrimaryLabel = document.qbo.getCookie("qbo.Application.ObjectLink.ObjectLink");
    	
    	var Object;
        var ObjectID ;
        var ObjectLink;
    this.SetObject = function(object, objectID, ObjectLink)
    {  
       
        var commandXml = document.getElementById('OptionXml_CommandBar');
	        if(commandXml != null)
	        {
	      if(tiedtoObject!=objectID)
	         {
	           tiedtoObject=objectID;
                document.qbo.AddCommand("Tie as Primary Object","###","Click here to Set this loan as Primary Object", null, null,"\"javascript:obj = new ObjectLink(); obj.SetPrimaryObject('" + object + "', " + objectID + ", '" + ObjectLink + "');\"");
              
               if ((PrimaryObjectID != objectID) && (PrimaryObject != null))
                {
                   document.qbo.AddCommand("Tie this record to " + PrimaryLabel, "###", "Tie to Primary Object " + PrimaryLabel, null, null, "\"javascript:var obj = new ObjectLink(); obj.SetRelatedObject('" + object + "', " + objectID + ", '" + ObjectLink + "');\""); 
                }
             }
            }
    }
    
    this.SetPrimaryObject = function(object, objectID, objectLink)
    {
    
        // sets the cookies referred to above
          document.qbo.setCookie("qbo.Application.ObjectLink.PrimaryObject",object, null, "/");
          document.qbo.setCookie("qbo.Application.ObjectLink.PrimaryObjectID",objectID, null, "/");
          document.qbo.setCookie( "qbo.Application.ObjectLink.ObjectLink",objectLink, null, "/");
		  var height = document.body.clientHeight * 0.8;
		  var width = document.body.clientWidth * 0.8;
		  GB_showCenter("RelatedRecords", "/Faslo/Application/LinksUserInterface.aspx?PrimaryObject="+object+"&PrimaryObjectID="+objectID+"&RenderSkin=false&AutoClose=false", height, width, function anon() {
			window.location.reload(true); });
    }
    //this.SetRelatedObject = function(object, objectID, objectLink)
    this.SetRelatedObject = function(object, objectID)
    {
        Object = object;
        ObjectID = objectID;
        //ObjectLink = objectLink;
        var service = document.qbo.WebService();
        this.WebServiceUrl1 = "/Faslo/Application/ObjectLinkService.asmx";
        service.useService(document.qbo.baseURL + this.WebServiceUrl1 + "?WSDL", "ObjectLinkService");
            if (service.ObjectLinkService)
	        {
		        this.ObjectBaseResultID = service.ObjectLinkService.callService(this.CheckResult, "ObjectLinkSelectByObject", PrimaryObject, PrimaryObjectID, object, objectID);
            }
	        else 
	        {
		        this.Error("Failed to launch web service call");
            }
	}
	this.CheckResult = function(result)
	{
	    var res;
	    res= result.value;
	    if (result.error)
		{
		    //this.Error(result.errorDetail);
			return;
		}
		if (res>0)
		{
		    //alert(result.value);
		   // alert(res);
		    alert("This record is already tied to '" + PrimaryLabel + "'");
		}
		else
		{
		    //window.open("/Faslo/Application/ObjectLinkType.aspx?PrimaryObject="+PrimaryObject+"&PrimaryObjectID="+PrimaryObjectID +"&PrimaryLabel="+PrimaryLabel+"&Object="+ Object + "&ObjectID=" + ObjectID, "WindowPopup", "toolbar=no,menubar=no,scrollbars=no,resizable=no,width=100,height=100");
		    window.showModalDialog("/Faslo/Application/ObjectLinkType.aspx?PrimaryObject="+PrimaryObject+"&PrimaryObjectID="+PrimaryObjectID +"&PrimaryLabel="+PrimaryLabel+"&Object="+ Object + "&ObjectID=" + ObjectID,top,'dialogHeight:85px;dialogWidth:500px');
		    window.location.reload(true);
		}
	}
}



/*objectlink related functions*/

function ShowObjectLinkSubMenu(item)
{


    if (item == 'All')
	{
		document.getElementById("tblListByLoanDetails").style.display = "inline";
		document.getElementById("tblListByBankruptcyDetails").style.display = "inline";
		document.getElementById("tblListByDebt").style.display = "inline";
		document.getElementById("tblListByBorrower").style.display = "inline";
	  	document.getElementById("tblListByForeclosureDetails").style.display = "inline";
	   
	   
	       //set the cssclass
	        document.getElementById("All").className="ajaxPanelMenuselected";
	        document.getElementById("Loans").className="ajaxPanelMenuUnselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuUnselected";
	        document.getElementById("Debt").className="ajaxPanelMenuUnselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuUnselected";
	   
	}
	if (item == 'Loan')
	{
	   
		    document.getElementById("tblListByLoanDetails").style.display = "inline";
		    document.getElementById("tblListByBankruptcyDetails").style.display = "none";
	
	       document.getElementById("tblListByDebt").style.display = "none";
	       document.getElementById("tblListByBorrower").style.display = "none";
	       document.getElementById("tblListByForeclosureDetails").style.display = "none";
    	   
	         //set the cssclass
	         document.getElementById("All").className="ajaxPanelMenuUnselected";
	        document.getElementById("Loans").className="ajaxPanelMenuselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuUnselected";
	          document.getElementById("Debt").className="ajaxPanelMenuUnselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuUnselected";
	        
	      
	   
	}
	if (item == 'Bankruptcy')
	{
		document.getElementById("tblListByLoanDetails").style.display = "none";
		document.getElementById("tblListByBankruptcyDetails").style.display = "inline";			
	    document.getElementById("tblListByDebt").style.display = "none";
	     document.getElementById("tblListByBorrower").style.display = "none";
	    document.getElementById("tblListByForeclosureDetails").style.display = "none";
	    
	    
	      //set the cssclass
	       document.getElementById("All").className="ajaxPanelMenuUnselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuselected";
	        document.getElementById("Loans").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuUnselected";
	        document.getElementById("Debt").className="ajaxPanelMenuUnselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuUnselected";
	   
	}
	if (item == 'Contact')
	{
		document.getElementById("tblListByLoanDetails").style.display = "none";
		document.getElementById("tblListByBankruptcyDetails").style.display = "none";	
		document.getElementById("tblListByDebt").style.display = "none";
		document.getElementById("tblListByBorrower").style.display = "none";
		document.getElementById("tblListByForeclosureDetails").style.display = "none";
		
	}
	if (item == 'Foreclosure')
	{
	  //  document.getElementById("Loans").style.class="ajaxPanelMenuUnselected";
	  //document.getElementById("Loans").SetAttribute("class","ajaxPanelMenuUnselected");
	
		document.getElementById("tblListByLoanDetails").style.display = "none";
		document.getElementById("tblListByBankruptcyDetails").style.display = "none";	
		document.getElementById("tblListByForeclosureDetails").style.display = "inline";
		document.getElementById("tblListByDebt").style.display = "none";
		document.getElementById("tblListByBorrower").style.display = "none";
		
		//set the cssclass
		     document.getElementById("All").className="ajaxPanelMenuUnselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuUnselected";
	        document.getElementById("Loans").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuselected";	       
	        document.getElementById("Debt").className="ajaxPanelMenuUnselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuUnselected";
	}
	
	if (item == 'Debt')
	{
	  //  document.getElementById("Loans").style.class="ajaxPanelMenuUnselected";
	  //document.getElementById("Loans").SetAttribute("class","ajaxPanelMenuUnselected");
	
		document.getElementById("tblListByLoanDetails").style.display = "none";
		document.getElementById("tblListByBankruptcyDetails").style.display = "none";
		
		document.getElementById("tblListByDebt").style.display = "inline";
		document.getElementById("tblListByBorrower").style.display = "none";
		document.getElementById("tblListByForeclosureDetails").style.display = "none";
		
		//set the cssclass
		    document.getElementById("All").className="ajaxPanelMenuUnselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuUnselected";
	        document.getElementById("Loans").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuUnselected";
	        document.getElementById("Debt").className="ajaxPanelMenuselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuUnselected";
	}
	if (item == 'Borrower')
	{
	  //  document.getElementById("Loans").style.class="ajaxPanelMenuUnselected";
	  //document.getElementById("Loans").SetAttribute("class","ajaxPanelMenuUnselected");
	
		document.getElementById("tblListByLoanDetails").style.display = "none";
		document.getElementById("tblListByBankruptcyDetails").style.display = "none";
		
		document.getElementById("tblListByDebt").style.display = "none";
		document.getElementById("tblListByBorrower").style.display = "inline";
		document.getElementById("tblListByForeclosureDetails").style.display = "none";
		
		
		//set the cssclass
		     document.getElementById("All").className="ajaxPanelMenuUnselected";
	        document.getElementById("Bankruptcy").className="ajaxPanelMenuUnselected";
	        document.getElementById("Loans").className="ajaxPanelMenuUnselected";
	        document.getElementById("Foreclosure").className="ajaxPanelMenuUnselected";
	       document.getElementById("Debt").className="ajaxPanelMenuUnselected";
	        document.getElementById("Borrower").className="ajaxPanelMenuselected";
	}
}
/* USSN (Social security number) functions */
qboEnvironment.prototype.PopuLateLabel = function(ClientID)
{
    this.clientID = ClientID;
    var displayElement = document.getElementById(this.clientID+"_lblUSSSN");

   if(displayElement.innerHTML != "")
    {
        var service = document.qbo.WebService();
        var contactID = document.getElementById(this.clientID+"ContactID").value;
        var WebServiceUrl = "/Contact/ContactService.asmx";
        service.useService(document.qbo.baseURL + WebServiceUrl + "?WSDL", "ContactWebService");
        if(service.ContactWebService)
        {
            serviceID = service.ContactWebService.callService(this.CaptureResult, "UserCredentialForSSN", contactID);
        }
        else 
        {
            this.Error("Failed to launch web service call");
        }
    }
}

qboEnvironment.prototype.ShowPopUp = function(clientID)
{
    var displayElementID = clientID+"_lblUSSSN";
    var hiddenElementID = clientID+"_USSSN";
    window.showModalDialog("/Contact/USSNModalDialog.aspx?DisplayElementID="+ displayElementID +"&HiddenControlID="+ hiddenElementID,self,'dialogHeight:85px;dialogWidth:320px');
}

qboEnvironment.prototype.CaptureResult=function(result)
{
    if(result.error)
    {
        return;
    }
    if(result.value != "")
    {
        if(result.value.indexOf("No") == -1)
        {   
          var val = result.value.substring(result.value.indexOf("-")+1, result.value.length);
          document.getElementById(document.qbo.clientID+"_lblUSSSN").innerHTML = val.substring(0, 3)+ "-"+val.substring(3, 5)+"-"+val.substring(5, 9);
        }
        else
        {
            alert("You dont have permission to UnMask SSN");
        }
    }
}
//Function used to hide and unhide the object tags when clicked on the menu
function HideOrUnhideObjects(theAction)
{
    if(theAction == null)theAction = "show";
    var objects = document.getElementsByTagName("object");
    var object = null;
    for(var i=0; i < objects.length; i++)
    {
        object = objects[i];
        if(theAction == "show")
           object.style.display="inline";
        else
            object.style.display="none";
    }
}

function DecisionObject(prefixName, elementName)
{
		
	var ob = new ObjectGeneric(prefixName, elementName);
	ob.ClassName = "DecisionObject";
	if (ob.SelectXslt == null)
		ob.SelectXslt = "/Templates/Decision/DecisionSelect.xslt";
	if (ob.ListXslt == null)
		ob.ListXslt = "/Templates/Decision/DecisionList.Ajax.xslt";
	ob.WebServiceUrl = "/Decision/DecisionService.asmx";
	if (ob.SortBy == null)
		ob.SortBy = "Decision";
	ob.WriteXml(ob.Xml);

	ob.SetIdentity = function(id)
	{
		this.IdentityID = id;
		this.DecisionID = this.IdentityID;
	}
	ob.Update = function(xml)
	{
		if (xml == null)
			xml = this.ReadXml()
		alert("Updating " + this.ClassName + " with " + xml.xml);
	}
	ob.ReadXml = function()
	{
		var objectXml = "<DecisionCollection>";
		objectXml += "<DecisionItem>";
		
		if (this.DecisionID != null) objectXml += "<DecisionID>" + this.DecisionID + "</DecisionID>";
		if (this.Decision != null) objectXml += "<Decision>" + this.Decision + "</Decision>";
		if (this.SubscriberID != null) objectXml += "<SubscriberID>" + this.SubscriberID + "</SubscriberID>";
		if (this.Object != null) objectXml += "<Object>" + this.Object + "</Object>";
		if (this.ObjectID != null) objectXml += "<ObjectID>" + this.ObjectID + "</ObjectID>";
		if (this.DecisionTemplateID != null) objectXml += "<DecisionTemplateID>" + this.DecisionTemplateID + "</DecisionTemplateID>";
		if (this.ParentDecisionStepID != null) objectXml += "<ParentDecisionStepID>" + this.ParentDecisionStepID + "</ParentDecisionStepID>";
		if (this.ChildDecisionID != null) objectXml += "<ChildDecisionID>" + this.ChildDecisionID + "</ChildDecisionID>";
		if (this.ParentDecisionID != null) objectXml += "<ParentDecisionID>" + this.ParentDecisionID + "</ParentDecisionID>";
		if (this.DecisionType != null) objectXml += "<DecisionType>" + this.DecisionType + "</DecisionType>";
		if (this.Status != null) objectXml += "<Status>" + this.Status + "</Status>";
		if (this.CurrentStep != null) objectXml += "<CurrentStep>" + this.CurrentStep + "</CurrentStep>";
		if (this.EstimatedStart != null) objectXml += "<EstimatedStart>" + this.EstimatedStart + "</EstimatedStart>";
		if (this.ProjectedStart != null) objectXml += "<ProjectedStart>" + this.ProjectedStart + "</ProjectedStart>";
		if (this.ActualStart != null) objectXml += "<ActualStart>" + this.ActualStart + "</ActualStart>";
		if (this.EstimatedCompletion != null) objectXml += "<EstimatedCompletion>" + this.EstimatedCompletion + "</EstimatedCompletion>";
		if (this.ProjectedCompletion != null) objectXml += "<ProjectedCompletion>" + this.ProjectedCompletion + "</ProjectedCompletion>";
		if (this.ActualCompletion != null) objectXml += "<ActualCompletion>" + this.ActualCompletion + "</ActualCompletion>";
		if (this.CanceledDate != null) objectXml += "<CanceledDate>" + this.CanceledDate + "</CanceledDate>";
		if (this.Delayed != null) objectXml += "<Delayed>" + this.Delayed + "</Delayed>";
		if (this.DelayCount != null) objectXml += "<DelayCount>" + this.DelayCount + "</DelayCount>";
		if (this.DelayDuration != null) objectXml += "<DelayDuration>" + this.DelayDuration + "</DelayDuration>";
		if (this.AssignedOrganizationID != null) objectXml += "<AssignedOrganizationID>" + this.AssignedOrganizationID + "</AssignedOrganizationID>";
		if (this.AssignedPersonID != null) objectXml += "<AssignedPersonID>" + this.AssignedPersonID + "</AssignedPersonID>";
		if (this.OwnerID != null) objectXml += "<OwnerID>" + this.OwnerID + "</OwnerID>";
		if (this.CreatedPersonID != null) objectXml += "<CreatedPersonID>" + this.CreatedPersonID + "</CreatedPersonID>";
		if (this.CreatedDate != null) objectXml += "<CreatedDate>" + this.CreatedDate + "</CreatedDate>";
		if (this.UpdatedPersonID != null) objectXml += "<UpdatedPersonID>" + this.UpdatedPersonID + "</UpdatedPersonID>";
		if (this.UpdatedDate != null) objectXml += "<UpdatedDate>" + this.UpdatedDate + "</UpdatedDate>";
		objectXml += "</DecisionItem>";
		objectXml += "</DecisionCollection>";
		var result = new ActiveXObject("Microsoft.XMLDOM");
		result.loadXML(objectXml);
		return result;
	}
	ob.DeleteList = function(element)
	{
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.Refresh, "DeleteList", this.ObjectIDXml());
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray length " + document.qbo.WebServiceArray.length + " set from " + this.ClassName);
		}
		else 
		{
			this.Error("Failed to launch web service call to ObjectBase.Select");
		}
	}
	ob.ListXhtml = function(element, parentID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (parentID != null) this.ParentID = parentID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "ListXhtml", this.ParentID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Decision list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.ListXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for DecisionObject.ListXhtml");
		}
	}

	ob.DetailByCollectionXhtml = function(element, collectionID, decisionTemplateID, sortBy, recordStart, displaySize, listXslt)
	{
		if (element != null) this.Element = element;
		if (collectionID != null) this.CollectionID = collectionID;
		if (decisionTemplateID != null) this.DecisionTemplateID = decisionTemplateID;
		if (sortBy != null) this.SortBy = sortBy;
		if (recordStart != null) this.RecordStart = recordStart;
		if (displaySize != null) this.DisplaySize = displaySize;
		if (listXslt != null) this.ListXslt = listXslt;
		this.WebService.useService(document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl + "?WSDL", "ObjectBaseService");
		this.Trace("WebService.useService was called with " + document.qbo.baseURL + document.qbo.Application + this.WebServiceUrl);
		if (this.WebService.ObjectBaseService)
		{
			var ObjectBaseResultID = this.WebService.ObjectBaseService.callService(this.DisplayXhtml, "DetailByCollectionXhtml", this.CollectionID, this.DecisionTemplateID, this.SortBy, this.RecordStart, this.DisplaySize, this.ListXslt);
			document.qbo.WebServiceArray[ObjectBaseResultID] = this;
			this.Trace("WebServiceArray index " + ObjectBaseResultID + " is a " + this.ClassName);
			window.status = "Downloading Decision list data; request id " + ObjectBaseResultID + " (" + document.qbo.WebServiceArray[ObjectBaseResultID] + ")";
			this.RefreshMethod = this.DetailByCollectionXhtml;
		}
		else 
		{
			this.Error("Failed to launch web service call to download list data for DecisionObject.DetailByCollectionXhtml");
		}
	}


//	var base = new Object();
//	base.WriteXml = ob.WriteXml;
	ob.WriteXml = function(xml)
	{
		if (xml == null) return;
		// base.WriteXml(xml);
		if (xml.selectSingleNode("//DecisionID") != null) this.DecisionID = xml.selectSingleNode("//DecisionID").text;
		if (xml.selectSingleNode("//Decision") != null) this.Decision = xml.selectSingleNode("//Decision").text;
		if (xml.selectSingleNode("//SubscriberID") != null) this.SubscriberID = xml.selectSingleNode("//SubscriberID").text;
		if (xml.selectSingleNode("//Object") != null) this.Object = xml.selectSingleNode("//Object").text;
		if (xml.selectSingleNode("//ObjectID") != null) this.ObjectID = xml.selectSingleNode("//ObjectID").text;
		if (xml.selectSingleNode("//DecisionTemplateID") != null) this.DecisionTemplateID = xml.selectSingleNode("//DecisionTemplateID").text;
		if (xml.selectSingleNode("//ParentDecisionStepID") != null) this.ParentDecisionStepID = xml.selectSingleNode("//ParentDecisionStepID").text;
		if (xml.selectSingleNode("//ChildDecisionID") != null) this.ChildDecisionID = xml.selectSingleNode("//ChildDecisionID").text;
		if (xml.selectSingleNode("//ParentDecisionID") != null) this.ParentDecisionID = xml.selectSingleNode("//ParentDecisionID").text;
		if (xml.selectSingleNode("//DecisionType") != null) this.DecisionType = xml.selectSingleNode("//DecisionType").text;
		if (xml.selectSingleNode("//Status") != null) this.Status = xml.selectSingleNode("//Status").text;
		if (xml.selectSingleNode("//CurrentStep") != null) this.CurrentStep = xml.selectSingleNode("//CurrentStep").text;
		if (xml.selectSingleNode("//EstimatedStart") != null) this.EstimatedStart = xml.selectSingleNode("//EstimatedStart").text;
		if (xml.selectSingleNode("//ProjectedStart") != null) this.ProjectedStart = xml.selectSingleNode("//ProjectedStart").text;
		if (xml.selectSingleNode("//ActualStart") != null) this.ActualStart = xml.selectSingleNode("//ActualStart").text;
		if (xml.selectSingleNode("//EstimatedCompletion") != null) this.EstimatedCompletion = xml.selectSingleNode("//EstimatedCompletion").text;
		if (xml.selectSingleNode("//ProjectedCompletion") != null) this.ProjectedCompletion = xml.selectSingleNode("//ProjectedCompletion").text;
		if (xml.selectSingleNode("//ActualCompletion") != null) this.ActualCompletion = xml.selectSingleNode("//ActualCompletion").text;
		if (xml.selectSingleNode("//CanceledDate") != null) this.CanceledDate = xml.selectSingleNode("//CanceledDate").text;
		if (xml.selectSingleNode("//Delayed") != null) this.Delayed = xml.selectSingleNode("//Delayed").text;
		if (xml.selectSingleNode("//DelayCount") != null) this.DelayCount = xml.selectSingleNode("//DelayCount").text;
		if (xml.selectSingleNode("//DelayDuration") != null) this.DelayDuration = xml.selectSingleNode("//DelayDuration").text;
		if (xml.selectSingleNode("//AssignedOrganizationID") != null) this.AssignedOrganizationID = xml.selectSingleNode("//AssignedOrganizationID").text;
		if (xml.selectSingleNode("//AssignedPersonID") != null) this.AssignedPersonID = xml.selectSingleNode("//AssignedPersonID").text;
		if (xml.selectSingleNode("//OwnerID") != null) this.OwnerID = xml.selectSingleNode("//OwnerID").text;
		if (xml.selectSingleNode("//CreatedPersonID") != null) this.CreatedPersonID = xml.selectSingleNode("//CreatedPersonID").text;
		if (xml.selectSingleNode("//CreatedDate") != null) this.CreatedDate = xml.selectSingleNode("//CreatedDate").text;
		if (xml.selectSingleNode("//UpdatedPersonID") != null) this.UpdatedPersonID = xml.selectSingleNode("//UpdatedPersonID").text;
		if (xml.selectSingleNode("//UpdatedDate") != null) this.UpdatedDate = xml.selectSingleNode("//UpdatedDate").text;

		if (xml.selectSingleNode("//CollectionID") != null) this.CollectionID = xml.selectSingleNode("//CollectionID").text;

	}
	ob.WriteXml(ob.Xml);

	ob.WriteForm = function(prefix, form)
	{
		if (prefix == null) prefix = (this.PrefixName == null) ? "" : this.PrefixName;
		if ((form == null) && (this.Element != null)) form = getParentElement(this.Element, "FORM");
		
		if (form.elements[prefix + "DecisionID"] != null) 
		{
			this.DecisionID = form.elements[prefix + "DecisionID"].value;
		}
		if (form.elements[prefix + "Decision"] != null) 
		{
			this.Decision = form.elements[prefix + "Decision"].value;
		}
		if (form.elements[prefix + "SubscriberID"] != null) 
		{
			this.SubscriberID = form.elements[prefix + "SubscriberID"].value;
		}
		if (form.elements[prefix + "Object"] != null) 
		{
			this.Object = form.elements[prefix + "Object"].value;
		}
		if (form.elements[prefix + "ObjectID"] != null) 
		{
			this.ObjectID = form.elements[prefix + "ObjectID"].value;
		}
		if (form.elements[prefix + "DecisionTemplateID"] != null) 
		{
			this.DecisionTemplateID = form.elements[prefix + "DecisionTemplateID"].value;
		}
		if (form.elements[prefix + "ParentDecisionStepID"] != null) 
		{
			this.ParentDecisionStepID = form.elements[prefix + "ParentDecisionStepID"].value;
		}
		if (form.elements[prefix + "ChildDecisionID"] != null) 
		{
			this.ChildDecisionID = form.elements[prefix + "ChildDecisionID"].value;
		}
		if (form.elements[prefix + "ParentDecisionID"] != null) 
		{
			this.ParentDecisionID = form.elements[prefix + "ParentDecisionID"].value;
		}
		if (form.elements[prefix + "DecisionType"] != null) 
		{
			this.DecisionType = form.elements[prefix + "DecisionType"].value;
		}
		if (form.elements[prefix + "Status"] != null) 
		{
			this.Status = form.elements[prefix + "Status"].value;
		}
		if (form.elements[prefix + "CurrentStep"] != null) 
		{
			this.CurrentStep = form.elements[prefix + "CurrentStep"].value;
		}
		if (form.elements[prefix + "EstimatedStart"] != null) 
		{
			this.EstimatedStart = form.elements[prefix + "EstimatedStart"].value;
		}
		if (form.elements[prefix + "ProjectedStart"] != null) 
		{
			this.ProjectedStart = form.elements[prefix + "ProjectedStart"].value;
		}
		if (form.elements[prefix + "ActualStart"] != null) 
		{
			this.ActualStart = form.elements[prefix + "ActualStart"].value;
		}
		if (form.elements[prefix + "EstimatedCompletion"] != null) 
		{
			this.EstimatedCompletion = form.elements[prefix + "EstimatedCompletion"].value;
		}
		if (form.elements[prefix + "ProjectedCompletion"] != null) 
		{
			this.ProjectedCompletion = form.elements[prefix + "ProjectedCompletion"].value;
		}
		if (form.elements[prefix + "ActualCompletion"] != null) 
		{
			this.ActualCompletion = form.elements[prefix + "ActualCompletion"].value;
		}
		if (form.elements[prefix + "CanceledDate"] != null) 
		{
			this.CanceledDate = form.elements[prefix + "CanceledDate"].value;
		}
		if (form.elements[prefix + "Delayed"] != null) 
		{
			this.Delayed = form.elements[prefix + "Delayed"].value;
		}
		if (form.elements[prefix + "DelayCount"] != null) 
		{
			this.DelayCount = form.elements[prefix + "DelayCount"].value;
		}
		if (form.elements[prefix + "DelayDuration"] != null) 
		{
			this.DelayDuration = form.elements[prefix + "DelayDuration"].value;
		}
		if (form.elements[prefix + "AssignedOrganizationID"] != null) 
		{
			this.AssignedOrganizationID = form.elements[prefix + "AssignedOrganizationID"].value;
		}
		if (form.elements[prefix + "AssignedPersonID"] != null) 
		{
			this.AssignedPersonID = form.elements[prefix + "AssignedPersonID"].value;
		}
		if (form.elements[prefix + "OwnerID"] != null) 
		{
			this.OwnerID = form.elements[prefix + "OwnerID"].value;
		}
		if (form.elements[prefix + "CreatedPersonID"] != null) 
		{
			this.CreatedPersonID = form.elements[prefix + "CreatedPersonID"].value;
		}
		if (form.elements[prefix + "CreatedDate"] != null) 
		{
			this.CreatedDate = form.elements[prefix + "CreatedDate"].value;
		}
		if (form.elements[prefix + "UpdatedPersonID"] != null) 
		{
			this.UpdatedPersonID = form.elements[prefix + "UpdatedPersonID"].value;
		}
		if (form.elements[prefix + "UpdatedDate"] != null) 
		{
			this.UpdatedDate = form.elements[prefix + "UpdatedDate"].value;
		}
	}

	return ob;
}

function QuickEdit(sourceRow, masterRow)
{
	if (document.qbo.QuickEditCurrent != null)
		document.qbo.QuickEditCurrent.Clear();
	this.SourceRow = (typeof sourceRow == "string") ? document.getElementById(sourceRow) : sourceRow;
	this.MasterRow = (typeof masterRow == "string") ? document.getElementById(masterRow) : masterRow;

	this.EditRow = this.SourceRow.parentElement.insertBefore(this.MasterRow.cloneNode(true), this.SourceRow);
	this.EditRow.className = this.SourceRow.className;
	this.EditRow.SourceObject = ObjectBaseFetch(null, this.SourceRow);
	
	this.SourceRow.style.display = "none";
	this.EditRow.style.display = "inline";
	
	var SourceCells = this.SourceRow.all.tags("TD");
	var EditCells = this.EditRow.all.tags("TD");

	var id = this.SourceRow.all("ID");
	if (id == null) 
		id = this.SourceRow.all(this.EditRow.SourceObject.ClassPrefix + "ID");
	if (id != null) 
	{
		switch (id.type) 
		{
			case "checkbox":
				this.EditRow.SourceObject.SetIdentity(id.value);
				break;
			default:
				alert("Cannot set identity from " + id.outerHTML);
		}
	}
	
	for (var i=0; i<EditCells.length; i++)
	{
		EditCells[i].className = SourceCells[i].className;
		var source = SourceCells[i];

		while ((source.nodeType == 1) && (source.childNodes.length > 0))
			source = source.childNodes[0];
		var value = (source.nodeType == 3) ? source.nodeValue : source.innerHTML;

		if (EditCells[i].innerHTML == "")
		{
			EditCells[i].innerHTML = value;
		}
		else if (EditCells[i].all.tags("SELECT").length > 0)
		{
			element = EditCells[i].all.tags("SELECT")[0];
			document.qbo.dropdownSetValue(element, value);
		}
		else if (EditCells[i].all.tags("INPUT").length > 0)
		{
			element = EditCells[i].all.tags("INPUT")[0];
			element.value = value;
		}
		// else alert("Need to deal with " + EditCells[i].outerHTML);
	}
	this.Clear = function()
	{
		if (this.SourceRow.parentElement != null)
		{
			this.SourceRow.parentElement.removeChild(this.EditRow);
			this.SourceRow.style.display = "inline";
		}
		document.detachEvent("onkeypress", document.qbo.QuickEditCurrent.KeyClear);
		document.detachEvent("onclick", document.qbo.QuickEditCurrent.MouseClear);
		document.qbo.QuickEditCurrent = null;
	}
	this.KeyClear = function()
	{
		if (window.event.keyCode == 27)
		{
			this.Clear();
		}
	}
	this.MouseClear = function()
	{
		var element = event.srcElement;
		while (element != null)
		{
			if (element == this.EditRow)
				return;
			element = element.parentElement;
		}
		this.Clear();		
	}
	document.qbo.QuickEditCurrent = this;
	document.attachEvent("onkeypress", document.qbo.QuickEditCurrent.KeyClear);
	document.attachEvent("onclick", document.qbo.QuickEditCurrent.MouseClear);
}

