
/* RegEX   : (function)\s*([\w,_]+)\s*(\([\w,-_\s]*\))\s*({)
 * Replace : $1 $2 $3 $4
 * 
 * will format function declarations as : function [function name] (arguments) { };
 * */

document.write('<style> .dummy {} </style>');

/* Include PIE.js for CSS3 style compatibility in all browsers */
if (Prototype.Browser.IE) {
	var script = $(document.createElement('script'));
	script.src = "/wwwroot/stylesheets/PIE.js";
	document.getElementsByTagName('head')[0].appendChild(script);
}

Array.prototype.index = 0;
Array.prototype.incrementIndex = function (i) {
	if (!i) return this.index;
	if (this.length < 2)
		return this.index = 0;
	this.index = this.index+i;
	while (this.index < 0)
		this.index = this.length+this.index;
	while (this.index > (this.length-1))
		this.index = this.index - this.length;
	return this.index;
}

$ce = function (tagName, optObj) {
	var elm = $(document.createElement(tagName));

	if (optObj) {
		Object.keys(optObj).each(function (key) {
			if (Object.isString(optObj[key])) {
				try {
					if (/html|class/ig.test(key)) {
						elm[key] = optObj[key];
					} else {
						elm.setAttribute
							? elm.setAttribute(key, optObj[key])
							: elm[key] = optObj[key];
					}
				} catch (err) { }
			}
			else if (typeof optObj[key] === 'object') {
				Object.extend(elm[key], optObj[key]);
			}
		});
	}
	return elm;
};

Number.prototype.format= function (d) {
	var a,m,m2;
	var rgx = /(\d+)(\d{3})/;
	var d = d || 0;

	if (d){
		a = this.toString().split('.');
		a[1] = a[1] || '0'
		m = Math.pow(10,d)
		m2 = Math.pow(10,-(a[1].length-d))
		a[1] = (Math.round(a[1]*m2)/m).toString().substr(2)
		while (a[1].length < d) 
			a[1] += '0';
	}
 	else 
		a = [Math.round(this).toString()];

	while (rgx.test(a[0])) 
		a[0] = a[0].replace(rgx, '$1' + ',' + '$2');
	return a.join('.')
}

Number.prototype.formatMoney = function (c, d, t) {
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n =Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + '$' + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

String.prototype.getUrlParms = function () {
	
	if (!(/\?/.test(this))) { return false; }
	
	var  qObj = {}
		,qArr = this.split('?')[1].split('&')
		,len  = qArr.length;
	
	while (len--) {
		var  qsArr = qArr[len].split('=')
			,prop  = decodeURIComponent(qsArr[0])
			,val   = decodeURIComponent(qsArr[1]);
		qObj[prop] = val === 'undefined' ? undefined : val;
	}
	return qObj;
}


CSI = {

	/* 	print : function (str) {
		var myWindow = window.open("", "myWindow", "toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, width="+myAjaxBox.clientWidth+", height="+myAjaxBox.clientHeight)
		var myHtml = "<html><body onload='print();window.close();'>" + str + "</body></html>"
		myWindow.document.open()
		window.focus();
		myWindow.document.write(myHtml);
		myWindow.document.close();
	} */
	print : function (text) {
		if (!window.CSI.printFrame) {
			var frame = document.createElement('iframe');
			frame.style.visibility = 'hidden';
			CSI.printFrame = document.body.appendChild(frame);
			
			Event.observe(CSI.printFrame.contentWindow, 'message', function (e) {
				CSI.printFrame.contentWindow.document.body.innerHTML = e.data;
				//alert(e.data);
				var cssLink = document.createElement("link");
				cssLink.href = "printSearch.css";
				cssLink.rel = "stylesheet";
				cssLink.type = "text/css";
				CSI.printFrame.contentWindow.document.body.appendChild(cssLink);

				if (Prototype.Browser.IE) {
					setTimeout('CSI.printFrame.contentWindow.document.execCommand("print", false, null)', 100);
				}
				else{
					setTimeout('CSI.printFrame.contentWindow.print()', 100);
				}
			});
		}
		CSI.printFrame.contentWindow.postMessage(text, "*");
	}
	,clearSelection : function () {
		if (document.selection) {
			document.selection.clear();
		} else if (window.getSelection) {
			window.getSelection().removeAllRanges();
		}
	}
	,domMethods : {
		scrollToView : function (elm) {
			var telm = $(elm);
			var pause;
			var left=0;
			var top=0;
			outer:
			do {
				pause = telm;
				inner:
				while (telm && telm.tagName){
					if (telm.getStyle('overflowY')=='scroll')
						break outer;
					if (telm.parentNode == pause.offsetParent)
						break inner;
					telm = $(telm.parentNode);
				}
				left += pause.offsetLeft;
				top += pause.offsetTop;
				telm = $(telm.parentNode);
			} while (telm);
			
			if (telm){
				var x = (top+elm.offsetHeight) - ((telm.offsetHeight/2)+telm.scrollTop);
				if (x>0){
					telm.scrollTop += x;
				}
				else if (top < telm.scrollTop) {
					telm.scrollTop = top;
				}
			}
			return elm;
		}
	}
	,arrayMethods : {
		hasAll : function (val) {
			if (typeof val == 'number') {
				val = [val];
			}
			if (!val.length) {
				return false;
			}
			for (var i = 0;i<val.length;i++) {
				if (!(this.indexOf(val[i])+1)) {
					return false;
				}
			}
			return true;
		}
		,forceType : function () {
			for (var i = 0; i < this.length; i++) {
				if (/^true$|^false$/.test(this[i].toString())) {
					continue;
				}
				this[i] = !isNaN(Number(this[i])) ? Number(this[i]) : this[i];
			}
			return this;
		}
	}
	,dateMethods : {
		startOfMonth : function () {
			return new Date(this.getFullYear(), this.getMonth(), 1)
		}
		,endOfMonth : function () {
			return new Date(this.getFullYear(), this.getMonth()+1, 0)
		}
		,add : function (sInterval, iNum) {
			var d = new Date();
			d.setTime(this.getTime());
			if (sInterval && iNum){
				switch (sInterval.toLowerCase()){
					case "ms":
					case "millisecond":
						d.setMilliseconds(d.getMilliseconds() + iNum);
						break;
					case "s":
					case "second":
						d.setSeconds(d.getSeconds() + iNum);
						break;
					case "mi":
					case "minute":
						d.setMinutes(d.getMinutes() + iNum);
						break;
					case "h":
					case "hour":
						d.setHours(d.getHours() + iNum);
						break;
					case "d":
						d.setDate(d.getDate() + iNum);
						break;
					case "mo":
					case "month":
						d.setMonth(d.getMonth() + iNum);
						break;
					case "y":
						d.setFullYear(d.getFullYear() + iNum);
						break;
				}
				return d;
			}
			else
				return undefined;
		}
		,dayDiff : function (date, abs) {
			var mil = 86400000
				,d1 = new Date(this.toDateString()).getTime()
				,d2 = new Date(date.toDateString()).getTime()
				,ms = (d1 - d2) / mil
			return ms <= 0 /*!abs ? Math.floor(ms) */
				? Math.ceil(Math.abs(ms))
				: Math.floor(Math.abs(ms));
		}
	}
	,convertSqlDate : function (sqlDate, formatStr) {
		var  year = sqlDate.substr(0, 4)
			,month = Number(sqlDate.substr(5, 2)) - 1
			,day = sqlDate.substr(8, 2)
			,hours = sqlDate.substr(11, 2)
			,minutes = sqlDate.substr(14, 2)
			,seconds = sqlDate.substr(17, 2)
			,milliseconds = sqlDate.substr(20, 2)
			,finalDate = new Date(year, month, day, hours, minutes, seconds, milliseconds);

		if (formatStr) {
			try {
				var formatted = formatDate(finalDate, formatStr);
				return {
					 date : finalDate
					,formatted : formatted
				}
			} catch (err) { }
		}
		return finalDate;
	}
	,formatPrice : function (a) {
		if (1E3 > a) {
			return '$' + a;
		}
		if (1E4 > a) {
			return a = Math.round(a / 100) / 10,
			'$' + (a + '').replace(/\.$/, '') + 'K';
		}
		if (1E5 > a) {
			return a = Math.round(a / 100) / 10,
			'$' + (a + '').substr(0, 2) + 'K';
		}
		if (1E6 > a) {
			return a = Math.round(a / 1E3),
			1E3 <= a ? '$1M' : '$' + a + 'K';
		}
		a = 1E7 > a ? Math.round(a / 1E4) / 100 : Math.round(a / 1E5) / 10;
		a += '';
		-1 !== a.indexOf('.') && (a = a.substr(0, 4));
		return '$' + a + 'M';
	}
	,updPrefs : function (aid,b) {    // b = true = Option is on,   b = false = option is off.
		if (!window.aids) 
			return;
		new Ajax.Request('updPersonAttributes.php',{
			parameters : {aid : aid, on : b}
			,onException : function (t,e) {alert(e.message)}
		});
		if (b)
			aids.push(aid);
		else
			aids = aids.without(aid);
	}
	,isEmpty : function (obj) {
		return objToString(obj) == '{}'
	}
	,iMsgTillCancelled : function () {
		var msgs = [];
		var mtcf;
		var cancelCkBx;
		var button;
		
		return function (aid) {
			if (aids.indexOf(aid) > -1){
				return;
			}
			
			var mtcf;
			if (!mtcf){
				mtcf = createForm();
				var b = mtcf.footer.getElementsByTagName('button')[0];
				b.innerHTML = 'OK'
				var cbDiv = mtcf.footer.insertBefore($(document.createElement('div')),b);
				cbDiv.innerHTML = '<input type="checkbox" class="cancel"><span onclick="this.previousSibling.click();" style="cursor:pointer">Don\'t Show this message Again</span>';
				cbDiv.style.lineHeight = '1px'
				cbDiv.style.cssFloat = cbDiv.style.styleFloat = 'left';
				var k = mtcf.cancelCkBx = cbDiv.getElementsByClassName('cancel')[0];
				k.setStyle({position:'relative',top:'3px'});
				mtcf.setTitle('<span style="color:#ff0033;fontWeight:bold">Important Information!</span>')
				cancelCkBx = mtcf.footer.getElementsByTagName('input')[0];
				button = mtcf.footer.getElementsByTagName('button')[0];
				mtcf.onEnterKey = function () {
					if (cancelCkBx.checked)
						CSI.updPrefs(aid,true);
					this.close()
				}
			}
			
			cancelCkBx.checked = false;
			
			if (msgs[aid]){
				mtcf.formBody.innerHTML = msgs[aid];
				setTimeout(function () {mtcf.push().center();button.focus();},170);
			}
			else {
				new Ajax.Request('getMsg.php',{
					parameters : {aid:aid}
					,onSuccess : function (t) {
						msgs[aid] = t.responseText;
						mtcf.formBody.innerHTML = t.responseText;
						mtcf.push().center();
						setTimeout(function () {button.focus()},70);
					}
					,onException : function (t,e) {alert('Xcept44:'+e.message)}
				})
			}
		}
	}()
	,jsToPhpDate : function (d) {
		return d.getFullYear()+'-'+padZero((d.getMonth()+1),2)+'-'+padZero(d.getDate(),2);
	}
	,formatDate : function (d,optObj) {
		optObj = optObj || {};
		var y;
		if (!d || !d.getDate) 
			return '';
		if (optObj.yr2digit){
			y = d.getFullYear().toString().substr(2,2);
		}
		
		else {
			y = d.getFullYear()
		}
		return padZero((d.getMonth()+1),2)+'/'+padZero(d.getDate(),2)+'/'+y
	}
	,formatTime : function (d) {
		if (!d || !d.getDate) 
			return '';
		var h = d.getHours()
		var p = (h > 11) ? ' pm' : ' am';
		
		if (h > 12)
			h -= 12;
		if (h == 0)
			h = 12;
		return h+':'+ padZero(d.getMinutes(),2)+p
	}
	,formToPhpDate : function (formDate) {
		if (formDate == 'mm/dd/yyyy' || formDate == 'mm/dd/yy' || formDate == "")
			return '';
		var a = formDate.split('/');
		var y;
		if ((y = parseInt(a[2])) < 100){
			if (y > 30)
				y += 1900;
			else
				y+= 2000;
		}
		return y+'-'+padZero(a[0],2)+'-'+padZero(a[1],2);
	}
	,getVisibility : function (elm) {
		var v = false;
		var done = false;
		elm = $(elm);
		while (elm && elm.getStyle){  //!elm.readAttribute('visibility'))
			if (elm.getStyle('visibility') == 'hidden' || elm.getStyle('display') == 'none')
				return false
			else if (elm.getStyle('visibility') == 'visible' || elm.getStyle('display') == 'block')
				return true;
			elm = $(elm.parentNode)
		}	
		return true;
	}
	,mouseCoords : function (ev) {
		if(ev.pageX || ev.pageY){
			return {x:ev.pageX, y:ev.pageY};
		}
		return {
			x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
			y:ev.clientY + document.body.scrollTop  - document.body.clientTop
		};
	}
	,getMouseOffset : function (target, ev) {
		e = ev || window.event;
		var docPos    = CSI.getPosition(target);
		var mousePos  = CSI.mouseCoords(ev);
		return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
	}
		
	,getPosition : function (e) {
		var left = 0;
		var top  = 0;
		while (e.offsetParent){
			left += e.offsetLeft;
			top  += e.offsetTop;
			e     = e.offsetParent;
		}
		left += e.offsetLeft;
		top  += e.offsetTop;
		return {x:left, y:top};
	}
	
	,UP_ARROW : '&#9650'
	,DOWN_ARROW : '&#9660'
	,RIGHT_ARROW : '&#9658'
	,LEFT_ARROW : '&#9668'
	
	,getSelectedText : function () {
		return (document.selection) ? document.selection : (window.getSelection || document.getSelection)();
	}
	
	/* --------------------------------------------------------------------
	   Auto-Suggest feature:  optObj = {field:elementToAdd, searchFunction:localFunctionName} 
	   This will attach a results Div to the field you are adding auto-auggest for and attach the
	   event handlers for the different keypresses that are possible - Will Zablocki 12/2010

	   These are the different options that can be passed.
	   elm = element having auto-suggest added (required),
	   name = a name to assign to a hidden input to store the clicked result's value (optional),
	   searchFunction = local JS function that returns the result set for the autoSuggest box (required),
	   overrideCSS = override style sheet object for suggestion box results, pass highlightColor in the obj
		   to override the row highlight color.
	   suggestionHint = Pass the grayed out suggestion hint that will display in the subject elm
	   ---------------------------------------------------------------------
	*/
	,autoSuggest : function (optObj) {
		var elm = optObj.field;
		/* Cannot add an autoSuggest box twice, "overwrite" the first one */
		if (elm.getAttribute('autoSuggest')) $$('.autoSuggest')[0].remove();

		/* set up the element */
		elm.setAttribute('autoSuggest','true');
		elm.setAttribute('autocomplete','off');

		var elmHeight = elm.getHeight();
		var elmWidth = elm.getWidth();
		
		var widthCSStype = (elm.naturalWidth) ? 'minWidth' : 'width';

		/* Default CSS Attributes for Auto Suggest Results Div.  Can be overridden by passing overrideCSS to CSI.autoSuggest() */
		var autoSuggestCSS = {position:'absolute', backgroundColor:'#FFF', top:elmHeight+'px', 
						left:elm.offsetLeft+'px', zIndex:'+500', widthCSStype:(elmWidth-1)+'px', display:'inline',
						overflowY:'scroll', visibility:'hidden', whiteSpace:'nowrap', fontSize: '12px', 
						cursor: 'pointer', padding:'0px', maxHeight:(document.viewport.getHeight() - (elm.cumulativeOffset().top + elm.getHeight())) + 'px'};

		optObj.overrideCSS = optObj.overrideCSS || {};
		var autoSuggestCSS = Object.extend(autoSuggestCSS, optObj.overrideCSS);
		CSSRule('.autoSuggest', autoSuggestCSS);

		/* Handle the highlighting/unhighlighting of the result row */
			/*If they pass a highlightColor in the overrideCSS or use default */
		var highlightColor = optObj.overrideCSS.highlightColor || '#CCFFFF';
		CSSRule('.selectedElement', {backgroundColor:highlightColor});

		var searchFunction = optObj.searchFunction || {};
		elm.parentNode.style.position = elm.style.position = 'absolute';
		elm.parentNode.style.width = elm.style.width = 'auto';

		/* SET UP THE RESULTS DIV */
		var resultsDiv = document.createElement('div');
		resultsDiv.className = 'autoSuggest';
//			resultsDiv.setAttribute('height', (document.viewport.getHeight() - (elm.cumulativeOffset().top + elm.getHeight())) + 'px');
		$(elm.parentNode).insertBefore(resultsDiv, elm);

		/* If they pass a name, the record rows should set the value when clicked */
		if (optObj.valueField.name) {
			elm.setAttribute('valueField', optObj.valueField.name);
			var valueField = document.createElement('input');
			valueField.setAttribute('type', 'hidden');
			valueField.name = optObj.valueField.name;
			if (optObj.valueField.defaultVal) {
				valueField.setAttribute('value', optObj.valueField.defaultVal);
			}
			elm.parentNode.appendChild(valueField);
		}
		
		var suggestionHint = optObj.suggestionHint || 'Type to search';
		var suggestionCSS = {position:'absolute', backgroundColor:'transparent', top:elm.offsetTop+'px', left:elm.offsetLeft+'px', color:'#999999',
						height:elm.getHeight()+'px', width:elm.getWidth()+'px', cursor: 'selection', zIndex:+1, padding:'3px'};

		var suggestionDiv = document.createElement('div');
		CSSRule('.suggestionHint', suggestionCSS);
		suggestionDiv.className = 'suggestionHint';
		
		suggestionDiv.innerHTML = optObj.suggestionHint || 'Type to search';
		elm.parentNode.appendChild(suggestionDiv);
		Event.observe(suggestionDiv, 'click', function () {elm.focus()});

		/* if it already has a value hide the suggestionDiv */
		if (elm.value > '') {
			suggestionDiv.style.visibility = 'hidden';
		}

		/* Assign the Search function passed as a method of the input element */
		elm.search = function (searchString) {
			var recordSet = searchFunction(searchString);
			if (searchString > '' && recordSet) {
				this.innerHTML = '';
				this.style.visibility = 'visible';
				this.appendChild(recordSet);
				this.style.height = recordSet.getAttribute('totalHeight');
				this.style.width = recordSet.getAttribute('totalWidth');
				try{
					$(recordSet.firstChild).addClassName('selectedElement');
				}
				catch(err){
					/*For When no results are returned*/
				}
				for (var i=0;i<=recordSet.childNodes.length-1;i++) {
					/* this is for the event observes on the result row elements */
					Event.observe(recordSet.childNodes[i], 'click', function () {
						resultsDiv.nextSibling.value = this.getAttribute('rowText');
						if (elm.nextSibling) elm.nextSibling.value = this.getAttribute('value');
						resultsDiv.style.visibility = 'hidden';
						$$('.selectedElement')[0].removeClassName('selectedElement');
						if(optObj.callBackFunction){
							optObj.callBackFunction(this.getAttribute('value'));	
						}
					}.bind(recordSet.childNodes[i].firstChild));
					Event.observe(recordSet.childNodes[i], 'selection:enterKey', function () {
						resultsDiv.nextSibling.value = this.getAttribute('rowText');
						if (elm.nextSibling) elm.nextSibling.value = this.getAttribute('value');
						resultsDiv.style.visibility = 'hidden';
						$$('.selectedElement')[0].removeClassName('selectedElement');
						if(optObj.callBackFunction){
							optObj.callBackFunction(this.getAttribute('value'));	
						}
					}.bind(recordSet.childNodes[i].firstChild));
					Event.observe(recordSet.childNodes[i], 'mousemove', function () {
						if ($$('.selectedElement')[0]) $$('.selectedElement')[0].removeClassName('selectedElement');
						this.addClassName('selectedElement');
					}.bind(recordSet.childNodes[i]));
				}
			} else {
				resultsDiv.style.visibility = 'hidden';
				suggestionDiv.style.visibility = 'visible';
				if ($$('.selectedElement')[0]) $$('.selectedElement')[0].removeClassName('selectedElement');
			}
		}.bind(resultsDiv);

		/* Handle the keypress events for the tab and enter, these fire differently and need to be handled first */
		Event.observe(elm, 'keydown', function (event) {
			isShowingBox = (resultsDiv.style.visibility == 'visible') ? true : false;
			if(event.keyCode == 8 && elm.value == ''){
				resultsDiv.style.visibility = 'hidden';
				suggestionDiv.style.visibility = 'visible';
				return;
			}
			
			switch (event.keyCode) {
				case Event.KEY_RETURN:
					try{
						if (!isShowingBox) break;
						event.stop();//Cancel the enter key so we dont submit the form, then fire my own enter key event
						$$('.selectedElement')[0].fire('selection:enterKey');
						break;
					}
					catch(err){
						break;	
					}
				case Event.KEY_TAB:
					try{
						if (!isShowingBox) break;
						$$('.selectedElement')[0].fire('selection:enterKey');
						break;
					}
					catch(err){
						break;	
					}
				/* I created my own event observe above and fire a custom event called selection:enterKey for return and tab */
				case Event.KEY_DOWN:
					try{
						if (!isShowingBox) break;
						var nextElement = $$('.selectedElement')[0].nextSibling || $$('.selectedElement')[0];
						$$('.selectedElement')[0].removeClassName('selectedElement');
						nextElement.addClassName('selectedElement');
						if (nextElement.cumulativeOffset().top > resultsDiv.scrollTop + resultsDiv.cumulativeOffset().top +  resultsDiv.getHeight() - 14) {
							resultsDiv.scrollTop += nextElement.getHeight() +2;
						}
						break;
					}
					catch(err){
						break;	
					}
				case Event.KEY_UP:
					try{
						if (!isShowingBox) break;
						var prevElement = $$('.selectedElement')[0].previousSibling || $$('.selectedElement')[0];
						$$('.selectedElement')[0].removeClassName('selectedElement');
						prevElement.addClassName('selectedElement');
						if (prevElement.cumulativeOffset().top - resultsDiv.scrollTop < resultsDiv.cumulativeOffset().top) {
							resultsDiv.scrollTop -= prevElement.getHeight() + 2;
						}
						break;
					}
					catch(err){
						break;	
					}
				default:
					if ((event.keyCode >= 48 && event.keyCode <= 90) || (event.keyCode >= 186 && event.keyCode <= 222) || (event.keyCode >= 96 && event.keyCode <= 111)) {
						suggestionDiv.style.visibility = 'hidden';
					}
			}
		});

		/* Handle the keypress events for the records */
		Event.observe(elm, 'keyup', function (event) {
			isShowingBox = (resultsDiv.style.visibility == 'visible') ? true : false;
			if(event.keyCode == 8 && elm.value == ''){
				resultsDiv.style.visibility = 'hidden';
				suggestionDiv.style.visibility = 'visible';
				return;
			}
			
			switch (event.keyCode) {
				case Event.KEY_BACKSPACE:
					if(this.value != ''){
						this.search(elm.value.replace(/\\/gi,'\\\\'));
						break;
					}
				default:
					if ((event.keyCode >= 48 && event.keyCode <= 90) || (event.keyCode >= 186 && event.keyCode <= 222) || (event.keyCode >= 96 && event.keyCode <= 111) && this.value != '') {
						this.search(this.value.replace(/\\/gi,'\\\\'));
					}
					else if(event.keyCode == 40 && !isShowingBox){
						this.search(' ');   
					}
					break;
			}
		});
		Event.observe(document.body, 'click', function () {
			  resultsDiv.style.visibility = 'hidden';
			  //suggestionDiv.style.visibility = 'visible';
			  elm.value = '';
		});
	}
	,mailtoForm : function (optObj) {
		var optObj = optObj || {};
		//Email Required
		if(!optObj.email) {
			alert("mailtoForm must be passed an email");
		}
		//if sent a subject then text, if not inputbox
		if(!optObj.subject){
			var subject = '<tr><tr><td align="right" style="color: red; font-weight: bold; vertical-align: top;">*</td><td>Subject:</td><td align="right"><input id="subj" size="37" maxlength="50"></td></tr>';	
		} else {
			var subject ='<tr><td></td><td>Subject:</td><td id="subj"><b>'+optObj.subject+'</b></td></tr>';
		}
		//if show email is false email will be kept private
		var showEmail = '<center><tr><td></td><td colspan="2" align="right"><font size="3pt">To:&nbsp;&nbsp;</td><td id="mailTo"><b>'+optObj.email+'</b></font></td></tr></center><br><br>';
		if(optObj.showEmail){
			if(optObj.showEmail == 'false') showEmail = '';
		}
		if (!window.messageBox){
			if(!optObj.innerHTML) {
				var iHTML = ['<center>'];
				iHTML.push(showEmail);
				iHTML.push('<table style="font-family: Verdana,Arial; font-size: 11px; vertical-align: top;" cellspacing="0">');
				iHTML.push('<tr><td align="right" style="color: red; font-weight: bold;">*</td><td>Your Name:</td><td align="right"><input id="replyName" size="37" maxlength="50"></td></tr>');
				iHTML.push('<tr><td align="right" style="color: red; font-weight: bold;">*</td><td>Your Email:</td><td align="right"><input id="replyEmail" size="37" maxlength="50"></td></tr>');
				iHTML.push('<tr><td align="right" style="color: red; font-weight: bold;">*</td><td>Confirm Email:</td><td align="right"><input id="confirmReplyEmail" size="37" maxlength="50"></td></tr>');
				iHTML.push('<tr><td></td><td>Your Phone:</td><td align="right"><input id="replyPhone" size="37" maxlength="30"></td></tr>');
				iHTML.push('<tr><td>&nbsp;</td></tr>'+subject);
				iHTML.push('<tr><td align="right" style="color: red; font-weight: bold; vertical-align: top;">*</td><td colspan="2"><textarea rows="5" cols="40" id="msg"></textarea></td></tr></table><br>');
				iHTML.push('<div style="font-size: 10px; padding-bottom: 12px; text-align: center; font-style: italic;">Items marked with <span align="right" style="color: red; font-weight: bold;">*</span> are Required</div></center>');
	
				optObj.innerHTML = 	iHTML.join('');
				
			}	
			var messageBox = createForm(optObj);	
			messageBox.setTitle(optObj.title || 'Send Message');
			messageBox.button.innerHTML = optObj.buttontext || 'Send';
	
			if(optObj.width) messageBox.style.width = optObj.width;
			if(optObj.titleStyle) messageBox.setTitle(optObj.title || 'Send Message',optObj.titleStyle);
	
			messageBox.onEnterKey = function () {
				if((testEmails(messageBox.form.replyEmail.value) == false)&& messageBox.form.replyEmail.value != '' ){
					alert(messageBox.form.replyEmail.value + " is not a valid email address. Please correct");
				}
				else if(messageBox.form.replyEmail.value == ''){
					//test reply email
					alert("Please enter your email address");
				}
				else if(messageBox.form.replyEmail.value != messageBox.form.confirmReplyEmail.value){
					alert("The confirm email address does not match");
				}
				//test phone
				else if((testPhone(messageBox.form.replyPhone.value) == false)&& messageBox.form.replyPhone.value != '' ){
					alert(messageBox.form.replyPhone.value + " is not a valid phone number.\nPlease correct or leave the Phone Number box empty\n\n*Area code must be inside parentheses");
				}
				//if no message
				else if(messageBox.form.msg.value == ''){
					alert("Please enter a message");	
				}
				else{
					optObj.replyName = messageBox.form.replyName.value;
					optObj.replyEmail = messageBox.form.replyEmail.value;
					optObj.replyPhone = messageBox.form.replyPhone.value;
					if(!optObj.subject){
						optObj.subject = messageBox.form.subj.value;
					}
					optObj.message = messageBox.form.msg.value;
					var url ='/wwwroot/lib/ajax/sendEmail.cfm';
					var params = optObj;
					var myAjax = new Ajax.Request(url,{
						method: 'post',
						parameters: Object.toQueryString(params),
						onSuccess: function () {
							alert('Email sent successfully');
							if(!optObj.leaveOnSend) {
								messageBox.close();
							} else {
								history.go(-1);
							}
						}
					});
				}
			};
		}
		(optObj.position && optObj.postiton != 'center') ? messageBox.show().position(optObj.position) : messageBox.show().center();
		return messageBox;
	}
	,createLimitedTextArea: function (optObj) {
		//defaults
		var style = {width: '100%'};
		var headStyle = {background:'#EEEEEE', fontSize:'1.2em', fontWeight:'bold', height:'20px'};
		var fieldStyle = {width:'100%'};
		
		//extend with user defined styles
		Object.extend(style, optObj.style || {});
		Object.extend(headStyle, optObj.headStyle || {});
		Object.extend(fieldStyle, optObj.fieldStyle || {});
		
		//container Div
		var container = document.createElement('div');
		Object.extend(container.style, style);
		
		//head
		var head = document.createElement('div');
		Object.extend(head.style, headStyle);
		//--title
		var titleDiv = document.createElement('div');
		titleDiv.style.cssText = 'float:left';
		titleDiv.innerHTML = optObj.title;
		head.appendChild(titleDiv);
		//--count
		var countDiv = document.createElement('div');
		countDiv.style.cssText = 'float:right';
		//used label
		var usedLabel = document.createElement('span');
		usedLabel.innerHTML = ' Used: ';
		countDiv.appendChild(usedLabel);
		//----used Count
		var usedCount = countDiv.appendChild(document.createElement('span'));
		usedCount.innerHTML = '0';
		//of Label
		var ofLabel = document.createElement('span');
		ofLabel.innerHTML = '&nbsp;of&nbsp;';
		countDiv.appendChild(ofLabel);
		//----max count
		var maxCount = document.createElement('span');
		maxCount.innerHTML = optObj.limit;
		countDiv.appendChild(maxCount)
		head.appendChild(countDiv);
		container.appendChild(head);
		
		//textarea
		var fieldContainer = document.createElement('div');
		Object.extend(fieldContainer.style, fieldStyle);
		var field = document.createElement('textarea');
		field.style.padding = '0px';
		field.style.margin = '0px';
		field.style.width = '100%';
		field.style.height = '100%';
		if(optObj.name){
			field.setAttribute('name', optObj.name);
		}
		if(optObj.value){
			field.value = optObj.value;
		}
		
		
		Event.observe(field, 'keydown', function (event) {
			setTimeout(container.checkLength, 3);
		});
		Event.observe(field, 'change', function () {
			container.checkLength();
		});
		Event.observe(field, 'paste', function () {
			setTimeout(container.checkLength, 3);
		});
		Event.observe(field, 'cut', function () {
			setTimeout(container.checkLength, 3);
		});
		fieldContainer.appendChild(field);
		container.appendChild(fieldContainer);
		
		if(optObj.attributes){
			Object.extend(container, optObj.attributes);
		}
		Object.extend(container, {
			checkLength: function () {
					if(field.value.length > optObj.limit){
						field.value = field.value.slice(0, (optObj.limit));
					}
					usedCount.innerHTML = field.value.length;
					return field.value.length;
				}
			,setValue: function (value) {
					field.value = value;
					this.checkLength();
				}
			,clear: function () {
					this.setValue('');
				}
			,getValue: function () {
					return field.value;
				}
			,setLimit: function (limit) {
					optObj.limit = limit;
					maxCount.innerHTML = limit;
					this.checkLength();
				}
			,setTitle: function (title) {
					titleDiv.innerHTML = title;
				}
			,getTitle: function () {
					return titleDiv.innerHTML;
				}
			,getAttribute: function (name) {
					return optObj.attributes[name];
				}
			}
		);
		container.checkLength();
		return container;
	}
	,createMultiSelect : function (optArr, optObj) {
		var _cols		 = optObj.cols  || 1;
		var _width   	 = optObj.width || '160px';
		var _name 		 = optObj.name  || '';
		var _hint		 = optObj.hint  || '';
		var _allHint	 = optObj.allHint || '';
		var _type		 = optObj.type  || 'checkbox';
		var _selectAll   = optObj.selectAll || false;
		var _formStyle	 = {backgroundColor: '#fff', color: '#444', border: '1px solid #bbb', overflowX: 'hidden', overflowY: 'auto'};
		var _cxSelStyle  = {background: '#E0E0E0'};
		var _cxOverStyle = {background: '#EAEAEA'};
		var _headerStyle = {backgroundColor:'#999', color:'#fff', padding:'0px 0px 0px 5px'};
		var _chkDivStyle = {};
		var _onChange 	 = optObj.onChange || function () {};
		var _onClose   	 = optObj.onClose  || function () {};
		var allHint;
		optObj.allAsNone = optObj.allAsNone === undefined ? true : optObj.allAsNone;
		
		var d1	   = $(document.createElement('div'));
		var hDiv   = $(document.createElement('div'));
		var iWrap  = $(document.createElement('div'));
		var input  = $(document.createElement('input'));
		var cDiv   = $(document.createElement('div'));
		var cDiv2  = $(document.createElement('div'));
		var cTable = $(document.createElement('table'));
		var cBody  = $(document.createElement('tbody'));
		var cTr    = $(document.createElement('tr'));
		
		d1.iVals 		= [];
		d1.selected 	= [];
		d1.unselected   = [];
		d1.prevSelected = [];
		
		Object.extend(_formStyle  , optObj.formStyle      || {});
		Object.extend(_chkDivStyle, optObj.checkDivStyle  || {});
		Object.extend(_cxOverStyle, optObj.mouseOverStyle || {});
		Object.extend(_cxSelStyle , optObj.selectedStyle  || {});
		Object.extend(_headerStyle, optObj.headerStyle    || {});
		
		CSSRule('.cxSelected', _cxSelStyle);
		CSSRule('.cxOver', _cxOverStyle);

		/* wrapper div */
		d1.style.position = 'relative';
		d1.style.fontSize = '0.9em';
		d1.style.width    = parseInt(_width, 10) - 20 + 'px';
		d1.optArr         = optArr;
		d1.className      = 'multiSelect'
		
		/* input select arrow */
		var selImg = new Image(17,20);
		selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
		(new Image(17,20)).src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
		(new Image(17,20)).src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonUp.png';
		
		function addMouseEvents (elm) {
			
			Event.observe(elm, 'mouseenter', function () {
				if (cDiv.style.visibility === 'hidden') {
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
				}
			});
			
			Event.observe(elm, 'mouseleave', function () {
				if (cDiv.style.visibility === 'hidden') {
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
				}
			});
			
			Event.observe(elm, 'click', function () {
				if (cDiv.style.visibility === 'hidden') {
					
					hDiv.style.display = _selectAll === true ? 'block' : 'none';
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonUp.png';
					
					setTimeout(function () {
					
						var borderW = (parseInt(cDiv2.style.borderLeftWidth, 10) + parseInt(cDiv2.style.borderRightWidth, 10)) || 0;
						var borderH = (parseInt(cDiv2.style.borderTopWidth, 10) + parseInt(cDiv2.style.borderBottomWidth, 10)) || 0;
						
						if (cDiv.getWidth() < input.getWidth()) {
							var width = (parseInt(_width, 10) - borderW);
							cDiv2.style.width = cTable.style.width = width + 'px';
						} else {
							cDiv2.style.width = 'auto';
						}
						
						var headerH = hDiv.getHeight();
						var inputW  = input.getWidth();
						var inputH  = input.getHeight();
						var cDiv2W  = cDiv2.getWidth();
						var cDivW   = cDiv.getWidth();
						var cDivH   = cDiv.getHeight();
						var inputLeft   = Math.ceil(input.viewportOffset().left);
						var inputTop    = Math.ceil(input.viewportOffset().top);
						var inputRight  = Math.ceil(document.viewport.getWidth() - inputLeft);
						var inputBottom = Math.ceil(document.viewport.getHeight() - inputTop - inputH);
						
						/* fit bottom */
						if (cDivH < inputBottom) {
							cDiv.style.top = inputH + 'px';
						}
						/* fit top */
						else if (cDivH < inputTop) {
							cDiv.style.top = -(cDiv.getHeight()) + 'px';
						}
						/* fit bottom with scrollbar */
						else if (inputBottom > (document.viewport.getHeight() / 3)) {
							cDiv2.style.height = (inputBottom - borderH - headerH - 5) + 'px';
							cDiv2.style.width  = (cDiv2W + 15) + 'px';
							cDiv.style.top     = inputH + 'px';
						}
						/* fit top with scrollbar */
						else {
							cDiv2.style.height = (inputTop - borderH - headerH - 5) + 'px';
							cDiv2.style.width  = (cDiv2W + 15) + 'px';
							cDiv.style.top     = -(cDiv.getHeight()) + 'px';
						}
						
						/* fit right */
						if (cDivW < inputRight) {
							cDiv.style.left = '0px';
						}
						/* fit left */
						else if (cDivW <= (inputLeft + inputW)) {
							cDiv.style.left = -(cDiv2.getWidth() - inputW) + 'px';
						}
						
						cDiv.style.visibility = 'visible';
						
					}, 1);
					
				} else {
				
					cDiv.style.visibility = 'hidden';
					cDiv2.style.height    = 'auto';
					cDiv2.style.width     = 'auto';
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
					setTimeout(_close, 1);
				}
			});
		};
		addMouseEvents(input);
		addMouseEvents(selImg);
		
		d1.style.marginRight = (parseInt(selImg.width) + 5) + 'px';
		
		selImg.style.display = 'inline';
		selImg.style.margin  = '0px 0px -5px 0px';
		selImg.style.marginLeft = -parseInt(selImg.width, 10) + 'px';
		
		iWrap.style.whiteSpace = 'nowrap';
		iWrap.style.width = parseInt(_width, 10) + 'px';
		
		input.style.cursor = 'default';
		input.style.width  = (parseInt(_width, 10) - 6) + 'px';
		input.setAttribute('readonly','readonly');
		
		/* header div */
		Object.extend(hDiv.style, _headerStyle);
		hDiv.style.display = 'none';
		
		/* select all, select none, & done options */
		var allSpan  = document.createElement('span');
		var noneSpan = document.createElement('span');
		var doneSpan = document.createElement('span');
		
		hDiv.style.paddingTop    = '2px';
		hDiv.style.paddingBottom = '2px';
		
		noneSpan.style.marginLeft  = '10px';
		doneSpan.style.cssFloat    = 'right';
		doneSpan.style.styleFloat  = 'right';
		doneSpan.style.marginRight = '5px';
		allSpan.style.cursor  = 'pointer';
		noneSpan.style.cursor = 'pointer';
		doneSpan.style.cursor = 'pointer';
		allSpan.style.textDecoration  = 'underline';
		noneSpan.style.textDecoration = 'underline';
		doneSpan.style.textDecoration = 'underline';
		
		allSpan.innerHTML  = 'All';
		noneSpan.innerHTML = 'None';
		doneSpan.innerHTML = 'Done';

		hDiv.appendChild(allSpan);
		hDiv.appendChild(noneSpan);
		hDiv.appendChild(doneSpan);
		
		/* select all */
		Event.observe(allSpan, 'click', function () {

			/* loop through check divs */
			$A(cTr.getElementsByTagName('div')).each(function (chkDiv) {
				chkDiv.firstChild.checked = 'checked';
				chkDiv.firstChild.setAttribute('checked', 'checked');
				chkDiv.addClassName('cxSelected');
			});
			
			setInput();
		});
		
		/* deselect all */
		Event.observe(noneSpan, 'click', function () {

			/* loop through check divs */
			$A(cTr.getElementsByTagName('div')).each(function (chkDiv) {
				chkDiv.firstChild.checked = false;
				chkDiv.firstChild.removeAttribute('checked');
				chkDiv.removeClassName('cxSelected');
			});
			
			setInput();
		});
		
		/* close drop down menu */
		Event.observe(doneSpan, 'click', function () {
			cDiv.style.visibility = 'hidden';
			cDiv2.style.height    = 'auto';
			cDiv2.style.width     = 'auto';
			setTimeout(_close, 1);
		});
		
		/* div that holds the form & table */
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 1;
		
		/* Chrome spacing issue */
		if (Prototype.Browser.WebKit) {
			input.style.width = (parseInt(_width, 10) - 4) + 'px';
		}

		Object.extend(cDiv2.style, _formStyle);
		
		/* table for the form */
		cTable.setAttribute('cellspacing',0);
		cTable.setAttribute('cellpadding',0);
		cTable.style.width = cDiv2.style.width;
		
		iWrap.appendChild(input);
		iWrap.appendChild(selImg);
		d1.appendChild(iWrap);
		d1.appendChild(cDiv);
		cTable.appendChild(cBody);
		cBody.appendChild(cTr);
		cDiv2.appendChild(cTable);
		cDiv.appendChild(hDiv);
		cDiv.appendChild(cDiv2);
		
		cDiv.style.visibility = 'hidden';

		function _buildForm (optArr) {

			var last = 0;
			var rows = Math.ceil(optArr.length / _cols);

			/* loop through the specified number of columns */
			for (var i = 0; i < _cols; i++) {
				
				var cTd = document.createElement('td');
				cTd.setAttribute('valign', 'top');
				
				/* loop through options array */
				for (var ii = 0; ii < rows; ii++) {
					
					if (last >= optArr.length) { break; }
					
					var elm = optArr[last];
					
					var d2  = $(document.createElement('div'));
					var st  = $(document.createElement('span'));
					var cx  = $(document.createElement('input'));
					var str = elm.text;
					var val = elm.value;
					
					d2.style.paddingRight = '5px';
					d2.style.whiteSpace   = 'nowrap';
					d2.style.cursor 	  = 'pointer';
					st.style.cursor 	  = 'pointer';
					cx.style.cursor 	  = 'pointer';
					
					Object.extend(d2.style, _chkDivStyle);
					
					cx.type 	 = _type;
					cx.value 	 = val;
					st.innerHTML = str;
					
					if (_name && _name !== '') {
						cx.setAttribute('name', _name);
					}
					
					if (elm.checked) {
						cx.checked = 'checked';
						cx.setAttribute('checked', 'checked');
						
						d1.prevSelected.push(val);
						d2.addClassName('cxSelected');
					}
					
					d2.appendChild(cx);
					d2.appendChild(st);
					
					Event.observe(d2, 'click', function () {
						this.removeClassName('cxOver');
						this.toggleClassName('cxSelected');

						var ckd = this.firstChild.checked = this.hasClassName('cxSelected');

						if (!ckd) {
							this.addClassName('cxOver');
						}

						setInput();
					});

					Event.observe(d2, 'mouseenter', function () {
						if (!this.firstChild.checked) {
							this.addClassName('cxOver');
						}
					});
					
					Event.observe(d2, 'mouseleave', function () {
						this.removeClassName('cxOver');
					});

					cTd.appendChild(d2);

					last++;
				}

				cTr.appendChild(cTd);
			}

			setInput();
		};
		
		/* makes sure the value of the checkbox ( clicked ) matches the datatype of the corresponding value in the optArr */
		function getValue (val) {
			//for (var i = 0; i < d1.optArr.length; i++) {
			for (var i = 0, l = d1.optArr.length; i < l; i++) {
				if (val == d1.optArr[i].value.toString()) {
					if (typeof d1.optArr[i].value == 'number') {
						//return Number(val);
						return parseInt(val, 10);
					}
					return val;
				}
			}
		};

		function setInput () {
			var  a1 = []  /* selected options (values) */
				,a2 = []  /* array of display values (text) that correspond to a1 */
				,a3 = []  /* unselected options (values) */
				,div  = $(document.createElement('div')) /* dummy to test for spans in the hint / allHint */
				,divs = cTable.select('div')
				,spans, childs, hint = allHint = '';

			for (var i = 0, l = divs.length; i < l; i++) {
				//if (divs[i].hasClassName('cxSelected')) {
				if (~divs[i].className.indexOf('cxSelected')) {

					a1.push(getValue(divs[i].firstChild.value));
					spans = divs[i].down('span').childElements();
					
					if (spans.length) {
						for (var ii = 0; ii < spans.length; ii++) {
							//if (spans[ii].getStyle('display') !== 'none') {
							if (spans[ii].style.display !== 'none') {
								if (!~spans[ii].className.indexOf('suppress')) {
									a2.push(spans[ii].innerHTML);
								}
							}
						}
					} else {
						a2.push(divs[i].down('span').innerHTML);
					}
				} else {
					a3.push(getValue(divs[i].firstChild.value));
				}
			}
			
			if (_hint !== '') {
				
				div.innerHTML = _hint;
				childs = div.childElements();

				if (childs.length) {
					for (i = 0; i < childs.length; i++) {
						if (childs[i].style.display != 'none') {
							hint = childs[i].innerHTML;
						}
					}
				}
				else { hint = _hint; }
			}
			
			if (_allHint !== '') {
				
				div.innerHTML = _allHint;
				childs = div.childElements();
				
				if (childs.length) {
					for (i = 0; i < childs.length; i++) {
						if (childs[i].style.display != 'none') {
							allHint = childs[i].innerHTML;
						}
					}
				} else { allHint = _allHint; }
			}

			div = null;

			d1.selected   = d1.value = a1;
			d1.text       = d1.iVals = a2;
			d1.unselected = a3;

			/* all selected */
			if (d1.unselected.length === 0 && d1.selected.length !== 0) {
				if (optObj.allAsNone) {
					d1.selected = d1.value = [];
				}
				
				input.title = input.value = allHint || d1.iVals.join(', ');
				input.style.color = optObj.allHint ? 'gray' : '#000';
			}
			/* some selected */
			else if (d1.selected.length !== 0) {
				input.value = d1.iVals.join(', ');
				input.title = input.value;
				input.style.color = '#000';
			}
			/* none selected */
			else {
				input.value = hint;
				input.title = hint;
				input.style.color = 'gray';
			}
		};
		d1.setInput = setInput;

		function _resetOpt (optArr, optObj) {
			cTr.childElements().invoke('remove');
			d1.optArr = optArr;
			
			if (optObj) {
				_cols		 = optObj.cols || _cols;
				_type		 = optObj.type || _type;
				_selectAll   = optObj.selectAll !== undefined ? optObj.selectAll : _selectAll;
				_headerStyle = {backgroundColor:'#143F4E',color:'white', padding: '0px 0px 0px 5px'};
				_chkDivStyle = {};

				Object.extend(_chkDivStyle, optObj.checkDivStyle || {});
				Object.extend(_headerStyle, optObj.headerStyle   || {});
			}

			cDiv2.style.width  = 'auto';
			cDiv2.style.height = 'auto';

			d1.iVals		= [];
			d1.prevSelected = [];
			d1.selected   	= [];
			d1.unselected 	= [];

			_buildForm(optArr);

			_onChange.bind({
				value         : d1.value
				,selected     : d1.selected
				,unselected   : d1.unselected
			})();
		};

		function _close () {
			if (_onClose) {
				_onClose();
			}
			
			var tempSelected = [];
			var changed = false;

			for (var i = 0, l = d1.selected.length; i < l; i++){
				if (!(d1.prevSelected.indexOf(d1.selected[i])+1)) {
					changed = true;
				}
				tempSelected.push(d1.selected[i]);
			}

			if (changed || (d1.prevSelected.length !== d1.selected.length)) {
				d1.prevSelected = tempSelected;
				
				_onChange.bind({
					value         : d1.value
					,selected     : d1.selected
					,unselected   : d1.unselected
				})();
			}
		}
		
		_buildForm(optArr);
		
		Object.extend(d1, {
			onClose	      : _onClose
			,onChange	  : _onChange
			,resetOptions : _resetOpt
		});
		
		Event.observe(document, 'click', function (e) {

			/* Google Maps street view throws an error */
			try {
				var elm = Event.findElement(e);
				if (!($(elm).descendantOf(d1))) {
					if (cDiv.style.visibility !== 'hidden') {
						cDiv.style.visibility = 'hidden';
						selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
						setTimeout(_close, 5);
					}
				}
			} catch (err) { }
		});
		
		return d1;
	}
	,createDropdown : function (optObj) {
		var _width = optObj.width || '160px';
		var formStyle = {
			 color : '#444'
			,border : '1px solid #bbb'
			,overflowX : 'hidden'
			,overflowY : 'auto'
			,backgroundColor : '#fff'
		};
		
		var d1	  = $(document.createElement('div'));
		var iWrap = $(document.createElement('div'));
		var input = $(document.createElement('input'));
		var cDiv  = $(document.createElement('div'));
		var cDiv2 = $(document.createElement('div'));
		
		d1.iVals 		= [];
		d1.selected 	= [];
		d1.unselected   = [];
		d1.prevSelected = [];
		
		Object.extend(formStyle, optObj.formStyle || {});

		/* wrapper div */
		d1.style.position = 'relative';
		d1.style.fontSize = '0.9em';
		d1.style.width    = parseInt(_width, 10) - 20 + 'px';
		d1.className      = 'multiSelect'
		
		/* input select arrow */
		var selImg = new Image(17,20);
		selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
		(new Image(17,20)).src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
		(new Image(17,20)).src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonUp.png';
		
		[input, selImg].each(function (elm) {
			
			Event.observe(elm, 'mouseenter', function () {
				if (cDiv.style.visibility === 'hidden') {
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
				}
			});
			
			Event.observe(elm, 'mouseleave', function () {
				if (cDiv.style.visibility === 'hidden') {
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
				}
			});
			
			Event.observe(elm, 'click', function () {
				if (cDiv.style.visibility === 'hidden') {
					
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonUp.png';
					
					setTimeout(function () {
					
						var borderW = (parseInt(cDiv2.style.borderLeftWidth, 10) + parseInt(cDiv2.style.borderRightWidth, 10)) || 0;
						var borderH = (parseInt(cDiv2.style.borderTopWidth, 10) + parseInt(cDiv2.style.borderBottomWidth, 10)) || 0;
						
						if (cDiv.getWidth() < input.getWidth()) {
							var width = (parseInt(_width, 10) - borderW);
							cDiv2.style.width = width + 'px';
						} else {
							cDiv2.style.width = 'auto';
						}

						var inputW = input.getWidth();
						var inputH = input.getHeight();
						var cDiv2W = cDiv2.getWidth();
						var cDivW  = cDiv.getWidth();
						var cDivH  = cDiv.getHeight();
						var inputLeft   = Math.ceil(input.viewportOffset().left);
						var inputTop    = Math.ceil(input.viewportOffset().top);
						var inputRight  = Math.ceil(document.viewport.getWidth() - inputLeft);
						var inputBottom = Math.ceil(document.viewport.getHeight() - inputTop - inputH);
						
						/* fit bottom */
						if (cDivH < inputBottom) {
							cDiv.style.top = inputH + 'px';
						}
						/* fit top */
						else if (cDivH < inputTop) {
							cDiv.style.top = -(cDiv.getHeight()) + 'px';
						}
						/* fit bottom with scrollbar */
						else if (inputBottom > (document.viewport.getHeight() / 3)) {
							cDiv2.style.height = (inputBottom - borderH - 5) + 'px';
							cDiv2.style.width  = (cDiv2W + 15) + 'px';
							cDiv.style.top     = inputH + 'px';
						}
						/* fit top with scrollbar */
						else {
							cDiv2.style.height = (inputTop - borderH - 5) + 'px';
							cDiv2.style.width  = (cDiv2W + 15) + 'px';
							cDiv.style.top     = -(cDiv.getHeight()) + 'px';
						}
						
						/* fit right */
						if (cDivW < inputRight) {
							cDiv.style.left = '0px';
						}
						/* fit left */
						else if (cDivW <= (inputLeft + inputW)) {
							cDiv.style.left = -(cDiv2.getWidth() - inputW) + 'px';
						}
						
						cDiv.style.visibility = 'visible';
					}, 1);
					
				} else {
					cDiv.style.visibility = 'hidden';
					cDiv2.style.height    = 'auto';
					cDiv2.style.width     = 'auto';
					selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOver.png';
				}
			});
		});
		
		d1.style.marginRight = (parseInt(selImg.width) + 5) + 'px';
		
		selImg.style.display = 'inline';
		selImg.style.margin  = '0px 0px -5px 0px';
		selImg.style.marginLeft = -parseInt(selImg.width, 10) + 'px';
		
		iWrap.style.whiteSpace = 'nowrap';
		iWrap.style.width = parseInt(_width, 10) + 'px';
		
		input.style.cursor = 'default';
		input.style.width  = (parseInt(_width, 10) - 6) + 'px';
		input.setAttribute('readonly','readonly');
		
		/* div that holds the form & table */
		cDiv.style.visibility = 'hidden';
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 1;
		
		/* Chrome spacing issue */
		if (Prototype.Browser.WebKit) {
			input.style.width = (parseInt(_width, 10) - 4) + 'px';
		}

		Object.extend(cDiv2.style, formStyle);
		
		iWrap.appendChild(input);
		iWrap.appendChild(selImg);
		d1.appendChild(iWrap);
		d1.appendChild(cDiv);
		cDiv.appendChild(cDiv2);
		
		d1.content = cDiv2;
		d1.input = input;
		
		if (optObj.content) {
			if (object.isString(optObj.content)) {
				cDiv.innerHTML = optObj.content;
			} else {
				cDiv.appendChild(optObj.content);
			}
		}
		
		Event.observe(document, 'click', function (e) {

			/* Google Maps street view throws an error */
			try {
				var elm = Event.findElement(e);
				if (!($(elm).descendantOf(d1))) {
					if (cDiv.style.visibility !== 'hidden') {
						cDiv.style.visibility = 'hidden';
						cDiv2.style.height    = 'auto';
						cDiv2.style.width     = 'auto';
						selImg.src = 'http://dev.comsoftinc.com/remaint/publicsearch/images/selectButtonOut.png';
					}
				}
			} catch (err) { }
		});
		
		return d1;
	}
	/* fit text into a div with a specified number of lines - if the text exceeds the required number of lines */
	/* the div will have a 'more' option to view the remainder of the text */
	,createHiddenTextDiv : function (str, optObj) {
		
		var optObj    = optObj || {};
		optObj.expand = optObj.expand === undefined ? true : optObj.expand;
		
		var breakOn   = optObj.breakOn || 'word';
		var wrapper   = $(document.createElement('div'));
		var container = $(document.createElement('div'));
		var openStyleString = optObj.openStyleString || '';
		
		wrapper.style.position = 'relative';
		wrapper.style.padding  = '0px';
		wrapper.style.margin   = '0px';
		
		var closeStyle = {
			fontSize: '11px'
			,paddingLeft: '3px'
			,paddingRight: '3px'
			,textAlign: 'justify'
			,color: '#2A3E45'
			,fontFamily: 'Verdana,Arial,Helvetica,sans-serif'
			,overflow: 'hidden'
			,border: '1px solid'
			,borderColor: '#fff'
			,backgroundColor: '#fff'
			,borderRadius: '2px'
			,MozBorderRadius: '2px'
			,WebkitBorderRadius: '2px'
		}
		Object.extend(closeStyle, optObj.style    || {});
		Object.extend(container.style, closeStyle || {});
		closeStyle.borderColor = container.style.borderColor = container.style.backgroundColor;

		setTimeout(function() {
			var saveStyle;
			var lines = parseInt(optObj.displayLines) || 2;
			
			if ($(wrapper.parentNode).getStyle('display') === 'none') {
				saveStyle = wrapper.parentNode.style.display;
				wrapper.parentNode.style.display = 'block';
			}
			
			/* get height of single line */
			container.innerHTML = 'test';
			
			var lineHeight = container.clientHeight;
			if (Prototype.Browser.IE) {
				lineHeight = lineHeight + 2;
			}
			var height = lineHeight * lines;
			
			/* strip html tags */
			str = str.replace(/</g, ' <CSI');
			
			/* trim leading / trailing whitespace */
			str = str.replace(/^\s+|\s+$/g, '');
			
			/* reduce excess whitespace to single space */
			str = str.replace(/\s+/g, ' ');
			
			/* replace all recurring non-word non-digit chars that repeat more than 5 times */
			str = str.replace(/([^\d\w]{5,})/g, function (str) {
				return str.substring(0, 1);
			});
			
			/* add full text to determine text div max height */
			container.innerHTML = str.replace(/[.]+$/g,'').replace(/ <CSI/g, '<') + '. less';
			
			var width      = $(container).getWidth();
			var fullHeight = parseInt($(container).getHeight(), 10);
			
			/* needed for closing after opening, morph doesn't get the width right */
			var paddingL = parseInt(container.style.paddingLeft, 10);
			var paddingR = parseInt(container.style.paddingRight, 10);
			var borderL  = parseInt(container.style.borderLeftWidth, 10);
			var borderR  = parseInt(container.style.borderRightWidth, 10);
			var totalX   = paddingL + paddingR + borderL + borderR;
			
			container.style.width = width - totalX + 'px';
			container.innerHTML = str;

			/* text exceeds number of desired lines */
			if (container.clientHeight > height) {
				
				/* prepare div for text insertion */
				container.innerHTML = '';
				
				/* replace trailing periods with single period and a space */
				str = str.replace(/[.]+$/g,'') + '. ';
				
				var more = $(document.createElement('span'));
				more.style.padding = '0px';
				more.style.margin  = '0px';
				more.style.color   = 'blue';
				more.style.cursor  = 'pointer';
				more.innerHTML = 'more';
				more.title     = 'View More';
				more.addClassName('closed');
				more.addClassName('link');
				Object.extend(more.style, optObj.linkStyle || {});
				
 				if (!optObj.expand) {
					more.style.display = 'none';
				}
				
				var less = $(document.createElement('span'));
				less.style.cursor = 'pointer';
				less.style.color  = 'blue';
				less.title = 'View Less';
				less.innerHTML = 'less';
				less.addClassName('link');
				Object.extend(less.style, optObj.linkStyle || {});
				
				var last   = 0;
				var newStr = [];
				
				/* split text into an array of words */
				var tStr = str.replace(/<[^>]+>/g, ' ');   // string without any tags.

				var textArr = tStr.split(/\s+/);

				do {
					newStr.push(textArr[last]);
					container.innerHTML = newStr.join(' ') + '... more';
					last++;
				}
				while (container.clientHeight <= height);
				
				last--;
				var popped = newStr.pop();

				if (breakOn === 'char') {
					last = 0;
					
					do {
						var string = newStr.join(' ') + ' ' + popped.substr(0,last);
						container.innerHTML = string + '... more';
						last++;
					}
					while (container.clientHeight <= height);
					
					if (string) {
						newStr.push(popped.substr(0,last-2));
					}
					more.style.position = 'absolute';
					more.style.right    = Math.floor(totalX / 2) + 'px';
				}
				container['long']   = str.replace(/<CSI/g, '<');
				container['short'] = newStr.join(' ').replace(/\s+$|[^\w]*$/g,'') + '... ';
				container.innerHTML = container['short'];
				container.appendChild(more);
				
				if (openStyleString != '') {
					openStyleString = openStyleString.replace(/\s+$/g, '');
					if (openStyleString.charAt(openStyleString.length-1) !== ';') {
						openStyleString += ';';
					}
				}
				openStyleString  += 'height:' + fullHeight + 'px;';
				closeStyle.height = height + 'px';
				closeStyle.width  = width - totalX + 'px';

				Event.observe(more, 'click', function(){
					expand();
				});
				Event.observe(less, 'click', function(){
					collapse();
				});
				
				/* close expanded text drop down if user clicks away from the text field */
				Event.observe(document, 'click', function (e) {
					var elm = Event.findElement(e);
					if (!($(elm).descendantOf(wrapper)) && elm !== more) {
						if (more.hasClassName('open')) {
							more.removeClassName('open');
							more.addClassName('closed');
							collapse(0.01);
						}
					}
				});
				
				/* view full text */
				function expand () {
					more.removeClassName('closed');
					more.addClassName('open');
					more.remove();
					container.style.position = 'absolute';
					container.innerHTML = container['long'];
					container.appendChild(less);
					container.style.zIndex = 100;
					new Effect.Morph(container, {
						style: openStyleString
						,duration: optObj.duration || 0.3
					});
				}
				/* view less text */
				function collapse (force) {
					more.removeClassName('open');
					more.addClassName('closed');
					new Effect.Morph(container, {
						style: closeStyle
						,duration: force || optObj.duration || 0.3
						,afterFinish: (function () {
							less.remove();
							container.style.position = '';
							container.innerHTML = container['short'];
							container.appendChild(more);
							container.style.zIndex = '';
							Object.extend(container.style, closeStyle);
						})
					});
					container.appendChild(less);
				}
				wrapper.expand   = expand;
				wrapper.collapse = collapse;
			}
			container.style.height = height + 'px';
			wrapper.style.height   = height + 'px';
			wrapper.style.width	   = parseInt(container.clientWidth, 10) + 'px';
			
			if (saveStyle !== undefined) {
				wrapper.parentNode.style.display = saveStyle;
			}
		}, 1);
		
		wrapper.appendChild(container);
		
		return wrapper;
	}
	,createPromptInput : function (optObj) {
		
		var optObj = optObj || {};
		optObj.onChange = optObj.onChange || function () {};
		optObj.onInput = optObj.onInput || function () {};
		
		optObj.numericFormat = optObj.numericFormat || optObj.dollarFormat;
		
		if (optObj.numericFormat){
			optObj.validChars = '0123456789';
			optObj.maxLength = parseInt(optObj.maxLength) || 15;
		} 
		else {
			optObj.maxLength = parseInt(optObj.maxLength) || 20;
		}
		
		optObj.errorStyle = optObj.errorStyle || {};
		
		//create wrapper element
		var inputWrapper = document.createElement('div');
		inputWrapper.style.display  = 'inline';
		inputWrapper.style.whiteSpace = 'nowrap';
		inputWrapper.style.background = 'transparent';
		Object.extend(inputWrapper.style, optObj.wrapperStyle || {});
		
		inputWrapper.backupStyle = Object.extend({}, inputWrapper.style);
		
		//create input element
		var inputElm = document.createElement(optObj.isTextArea ? 'textarea' : 'input');
		inputElm.setAttribute('lastValue', '');
		inputElm.length = optObj.length || '';
		inputElm.name   = optObj.name || optObj.id || '';
		inputElm.id     = optObj.name || optObj.id || '';
		inputElm.style.fontSize = '13px';
		
		optObj.inputElm = inputElm;
		
		if (optObj.length) {
			inputElm.style.width  = optObj.length;
		}
		if (optObj.maxLength) {
			inputElm.maxLength = optObj.maxLength;
		}
		if (optObj.size) {
			inputElm.size = optObj.size;
		}
		Event.observe(inputElm, 'blur', function(){
			if(this.getAttribute('lastValue') != this.value){
				optObj.onChange(this.value);
				inputElm.setAttribute('lastValue', this.value);
			}
		});
		Object.extend(inputElm.style, optObj.inputStyle || {});
		
		//create prompt element
		var promptElm = inputElm.promptElm = document.createElement('span');
		promptElm.innerHTML = optObj.prompt || '...';
		promptStyle = {
			fontStyle : 'italic'
			,color : 'gray'
			,position : 'absolute'
			,fontFamily : 'arial, helvetica, sans-serif'
			,fontSize : '13px'
			,paddingTop : '3px'
			,paddingLeft : '4px'
			,cursor : 'text'
		};
		Object.extend(promptStyle, optObj.promptStyle || {});
		Object.extend(promptElm.style, promptStyle);
		
		Event.observe(promptElm, "click", function () {
			inputElm.focus();
		});
		
		inputElm.formatNumeric = formatNumeric;
		function formatNumeric (code) {
			var p = this.getCaretPosition();  //  position
			
			var myArray = this.value.split('');
			if (this.getAttribute('skip')){
				myArray.splice(p,1);
				this.value = myArray.join('');
				this.setAttribute('skip',null);
				this.setCaretPosition(p);
			}

			if (p>0 && p==this.value.length){
				if (this.value[p-1]=='.'){
					return;
				}
				//if (this.value[p-1]=='0' && myArray.indexOf('.')+1 ){
				//	return;
				//}
			}
			
			var dotPos = myArray.indexOf('.')+1;

			var x = dotPos ? this.value.length-dotPos : 0;
			
			var f = parseFloat(this.value.replace(/[$,]/g, '' ))
			
			var c = 0;  // commas before the insertion point
			for (var i=0;i<p;i++) {
				if (this.value[i] == ',' || this.value[i]=='$') {
					c++;
				}
			}

			var pAdj = 0; // adjust p for an inserted 0 before the decimal on numbers less than 1
			if (myArray[p]="." && f < 1 && f>0)
				if (p==0 || myArray[p-1]=="$")
					pAdj = 1;
			
			if (!dotPos){
				var fStr = this.value.replace(/[$,]/g, '' );
				if (fStr[0]=='0')  // leading 0
					pAdj = -1;
			}
			
			this.value = (optObj.dollarFormat && f ? '$' : '') + (f ? f.format(x) : '');
			this.parentNode.value = f || '';
			
			var d = 0;  // commas before the insertion point
			for (var i=0;i<p;i++){
				if (this.value[i] == ',' || this.value[i]=='$')
					d++;
			}
			
			p = p + (d-c) + pAdj;
			
			if (code==36)  /* home */
				p=0;
				
			if (code==35)  /* end */
				p = this.value.length;
				
			if (optObj.dollarFormat)
				p = Math.max(1,p);
			
			this.setCaretPosition(p);
		}
		
		inputElm.setPrompt = function () {
			if (this.value === '') {
				this.promptElm.style.display = 'inline';
			} else {
				this.promptElm.style.display = 'none';
			}
			/*Object.extend(this.style,optObj.errorStyle); @Issue */
			return this;
		}
		
		Event.observe(inputElm, 'keydown', function (e) {
			var code = e.keyCode;

			/* this will execute after the .value property has been updated with latest keystroke */
			setTimeout(function () {
				
				/* FireFox fix for arrow,  and tab keys ... */
				if ([9,37,38,39,40,Event.KEY_RETURN].indexOf(code)+1) { return; }
					
				if (optObj.numericFormat) {
					inputElm.formatNumeric(code);
				}
				else {
					inputElm.parentNode.value = inputElm.value;
				}

				optObj.onInput.call(inputElm.parentNode);
				inputElm.setPrompt();
			}, 0);
		});


		Event.observe(inputElm, 'keypress', function (e) {
			var code = e.charCode || e.keyCode || e.which;
			var p = this.getCaretPosition();
			var Char = inputElm.value[p]; 
			if (code==46 && e.charCode == '46' && optObj.numericFormat){// decimal (.)
				if (Char=='$' || Char==',') {
					inputElm.setAttribute('skip',true);
				}
			}

			// FireFox fix for arrow, del, backspace, and tab keys ...
			if ([8,9,37,38,39,40].indexOf(code)+1)
				return;
			if (code == Event.KEY_RETURN) {
				return;
			}

			if (code==46 && e.charCode == '46'){ // decimal (period) (.)
				if (optObj.numericFormat){
					if (!optObj.decimals){
						Event.stop(e);
						return;
					}
					var myArray = inputElm.value.split('');
					var dotPos = myArray.indexOf('.')+1;
					if (dotPos){
						Event.stop(e);
						return;
					}
					return;
				}
			}
			if (code==46)
				return;
				
			// if it has a decimal
			// and cursor is to the right of decimal
			// and already have enough decimals
			// and tye keystroke would add another decimal digit
			if (code >= 48 && code <= 57 && optObj.numericFormat && optObj.decimals){
				var myArray = inputElm.value.split('');
				var dotPos = myArray.indexOf('.');
				var decimals = inputElm.value.length-dotPos;
				if (dotPos+1 && p>dotPos && decimals>optObj.decimals){
					Event.stop(e);
				}
			}
			
			if (optObj.validChars){
				if (optObj.validChars.indexOf(String.fromCharCode(code))== -1)
					Event.stop(e);
			}
		});

		inputWrapper.setValue = function (value, lastValue) {
			//if (value == '') return;
			//promptElm.style.display = 'none';
			inputElm.value = value;
			if (optObj.numericFormat) {
				inputElm.formatNumeric(0);
			}
			else {
				inputElm.parentNode.value = inputElm.value;
			}
			inputElm.setAttribute('lastValue', inputElm.value);
			inputElm.setPrompt();
		}
		
		if (optObj.target) {
			$(optObj.target).appendChild(inputWrapper);
		}

		inputElm.getCaretPosition = function () {
			if (this.createTextRange) {
				var r = document.selection.createRange().duplicate()
				r.moveEnd('character', this.value.length)
				if (r.text == '') return this.value.length
				return this.value.lastIndexOf(r.text)
			} else return this.selectionStart
		}
		inputElm.setCaretPosition = function (i) {
			if(this.setSelectionRange)	{
				try {
					this.setSelectionRange(i, i);
				} catch (err) { }
			}
			else if (this.createTextRange) {
				try {
					var range = this.createTextRange();
					range.moveStart('character', i);
					range.select();
				} catch (err) { }
			}	
		}

		inputWrapper.appendChild(inputElm);
		
		/* Chrome positioning is buggy with absolutely positioned elements
		 * append prompElm After the inputElm has been appended to the DOM */

		window.setTimeout(function () {
			inputWrapper.insertBefore(promptElm, inputElm);
		}, 0);
		
		return inputWrapper;
	}
	,slideshowExists : false
	/* Advanced slideshow - Added September 29th, 2011. Ensure it is identical to /csitools/2.0.2/advancedslideshow.js */
	,slideshow : function (images, options) {
		if (!CSI.slideshowExists || options.embedded) { //the embedded check allows for multiple iterations of the embedded slideshow.
			return prepareSlideshow(images);
		}
		function prepareSlideshow(images) {
			CSI.slideshowExists = true;
			if (!images || images.length < 1) return;
			if (images.length == 1) options.hideButtons = true;
			//Preload images
			var imgs = [];
			for (var i=0;i<images.length;i++) {
				var img = new Image();
				img.src = images[i].src;
			}
			options = options || {};
			var delay = options.delay || 3000;
			var captionBoxHeight = 0;
			if (options.styles && !options.separateCaptionBox && !options.embedded) {
				if (options.styles.captionBox) {
					captionBoxHeight = parseInt(options.styles.captionBox, 10);
				} else {
					captionBoxHeight = 54;
				}
			}
			options.height = options.height || 484 - captionBoxHeight;
			getScroll();
			var testHeight = windowHeight - 40;
			if (options.height > testHeight - 50 && !options.embedded) {
				options.height = testHeight - 50;
				options.width = options.height * 1.3;
			}
			options.height = options.height || 440;
			options.width = options.width || options.height * 1.3;
			if (!CSI.slideshowDiv){ 
				var d = CSI.slideshowDiv = createBox();
				if (options.embedded) {
					d.style.postion = 'relative';
				} /*else {
					if (options.overlay) {
						d.overlay = document.createElement('div');
						Object.extend(d.overlay.style, {
							width : 1000 + 'px',
							height : 1000 + 'px',
							background : '#000000',
							opacity : '.5'
						});
						document.body.appendChild(d.overlay);
					}
				}*/
				Object.extend(d.style,{background:'black', padding:'0px'});
				d.innerHTML = '<ul id="slide-images"><li class="showLi"><img /></li><li class="showLi"><img /></li></ul>';
				Object.extend(d.firstChild.style,{position:'relative', margin:'0px', padding:'0px', right: '0', top:'0', width:'25px'});
				Object.extend(d.firstChild.firstChild.style,{listStyleType:'none',position:'absolute', display:'block', margin:'0px', padding:'0px'});
				Object.extend(d.firstChild.lastChild.style,{listStyleType:'none',position:'absolute', display:'block', margin:'0px', padding:'0px'});
				if (!options.embedded) d.parentNode.style.zIndex = 3000;
				//adds close button if popup
				if (!options.embedded) {
					//set srcs for button, create
					var closeSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-close.png' : (options.buttons.close || '/wwwroot/remaint/images/sc-close.png');
					var closeDownSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-close-d.png' : (options.buttons.closeDown || '/wwwroot/remaint/images/sc-close-d.png');
					var myImg = document.createElement('img');
					//necessary attribute adding
					myImg.style.cssText = ';position:relative; float:right; margin-top:-1px; z-index:999;cursor:pointer;';
					if (Prototype.Browser.IE && document.compatMode == 'BackCompat') {
						myImg.style.cssText = myImg.style.cssText  + '; margin-left:5px !important';
					}
					myImg.className = 'ssCloseButton';
					myImg.src = closeSrc;
					if (options.styles) Object.extend(myImg.style, options.styles.closeButton);
					//smallbuttons option makes this small also
					if (options.smallButtons) {
						myImg.width = myImg.height = 23;
					} else if (options.buttonSize) {
						myImg.width = myImg.height = parseInt(options.buttonSize, 10);
					}
					//function called on close of slideshow - popup only
					d.terminate = function(){
						if (d) {
							clearTimeout(d.timeoutHolder);
							clearTimeout(d.getNextTimeout);
							//var lis = d.getElementsByClassName('showLi');
							lis = $('slide-images').children;
							lis[1].style.visibility = lis[0].style.visibility = '';  
							lis[1].style.display = lis[0].style.display = '';  
							//var caps = d.getElementsByClassName('captionLi');
							var caps = $('slide-captions').children;
							caps[1].style.visibility = caps[0].style.visibility = '';  
							caps[1].style.display = caps[0].style.display = '';  
							d.active = false;
							d.style.visibility='hidden';
							d.style.display='block';
							//if (d.overlay) d.overlay.remove();
							d.close();
							d.remove();
							d = undefined; 
							CSI.slideshowExists = false;
							CSI.slideshowDiv = null;
						}
					};
					//append to wrapper
					d.appendChild(myImg);
					//close button functionality
					Event.observe(myImg,'click', d.terminate);
					Event.observe(window,'scroll', d.terminate);
					Event.observe(myImg, 'mouseleave', function() { myImg.src = closeSrc; });
					Event.observe(myImg, 'mouseenter', function() { myImg.src = closeDownSrc; });
				}
				//set button sources
				var previousSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-left.png' : (options.buttons.previous || '/wwwroot/remaint/images/sc-left.png');
				var previousDownSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-left-d.png' : (options.buttons.previousDown || '/wwwroot/remaint/images/sc-left-d.png');
				var pauseSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-pause.png' : (options.buttons.pause || '/wwwroot/remaint/images/sc-pause.png');
				var pauseDownSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-pause-d.png' : (options.buttons.pauseDown || '/wwwroot/remaint/images/sc-pause-d.png');
				var playSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-play.png' : (options.buttons.play || '/wwwroot/remaint/images/sc-play.png');
				var playDownSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-play-d.png' : (options.buttons.playDown || '/wwwroot/remaint/images/sc-play-d.png');
				var nextSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-right.png' : (options.buttons.next || '/wwwroot/remaint/images/sc-right.png');
				var nextDownSrc = (options.buttons === undefined) ? '/wwwroot/remaint/images/sc-right-d.png' : (options.buttons.nextDown || '/wwwroot/remaint/images/sc-right-d.png');
				//build control div
				d.controlDiv = document.createElement('div');
				d.controlDiv.className = 'ssControlDiv';
				d.controlDiv.style.display = 'none';
				//creates fade effect variables, so back and forth buttons work seamlessly
				d.frameFadeEffect = '';
				d.frameAppearEffect = '';
				//create the buttons
				var previousButton = new Image();
				var pauseButton = new Image();
				var playButton = new Image();
				var nextButton = new Image();
				//set button load variable to zero
				d.buttonLoadCount = 0;
				//set function onload of the image
				previousButton.onload = function() { placeButtons() };
				pauseButton.onload = function() { placeButtons() };
				playButton.onload = function() { placeButtons() };
				nextButton.onload = function() { placeButtons() };
				//set visibility to hidden (set to visible in placeButtons() )
				previousButton.style.visibility = nextButton.style.visibility = pauseButton.style.visibility = playButton.style.visibility = 'hidden';
				//set button styles
				if (options.styles) {
					if (options.styles.previousButton) {
						Object.extend(previousButton.style, options.styles.previousButton)
					}
					if (options.styles.nextButton) {
						Object.extend(nextButton.style, options.styles.nextButton);
					}
					if (options.styles.pauseButton) {
						Object.extend(pauseButton.style, options.styles.pauseButton);
					}
					if (options.styles.playButton) {
						Object.extend(playButton.style, options.styles.playButton);
					}
				}
				//preload images, so positioning works all the time
				var preloadImg = new Image();
				preloadImg.src = playSrc;
				preloadImg.src = playDownSrc;
				preloadImg.src = pauseSrc;
				preloadImg.src = pauseDownSrc;
				preloadImg.src = nextSrc;
				preloadImg.src = nextDownSrc;
				preloadImg.src = previousSrc;
				preloadImg.src = previousDownSrc;
				//set srcs, loading images
				previousButton.src = previousSrc;
				pauseButton.src = pauseSrc;
				playButton.src = playSrc;
				nextButton.src = nextSrc;
				//set class names
				previousButton.className = 'ssPrevious';
				pauseButton.className = 'ssPause';
				playButton.className = 'ssPlay';
				nextButton.className = 'ssNext';
				//set titles correctly
				previousButton.title = 'Previous';
				nextButton.title = 'Next';
				pauseButton.title = 'Pause';
				playButton.title = 'Play';
				//set class name
				previousButton.className = pauseButton.className = playButton.className = nextButton.className = 'ssControlButton';
				//set cursor
				previousButton.style.cursor = pauseButton.style.cursor = playButton.style.cursor = nextButton.style.cursor = 'pointer'
				playButton.style.display = 'none';
				//append to control div IFF more than one image
				d.controlDiv.appendChild(previousButton);
				d.controlDiv.appendChild(pauseButton);
				d.controlDiv.appendChild(playButton);
				d.controlDiv.appendChild(playButton);
				d.controlDiv.appendChild(nextButton);
				//removes buttons if only one image
				//allows smallbutton settings for normal images
				if (options.smallButtons) {
					previousButton.height = previousButton.width = pauseButton.height = pauseButton.width = playButton.height = playButton.width = nextButton.height = nextButton.width = 23;
				} else if (options.buttonSize) {
					previousButton.height = previousButton.width = pauseButton.height = pauseButton.width = playButton.height = playButton.width = nextButton.height = nextButton.width = parseInt(options.buttonSize, 10);
				}
				//function called on pause press
				d.pause = function(){
					playButton.style.display = 'inline';
					pauseButton.style.display = 'none';
					clearTimeout(d.timeoutHolder);
					clearTimeout(d.getNextTimeout);
					d.paused = true;
				}
				//button functionality
				Event.observe(pauseButton,'click',function(){ // pause
					d.pause();
				});
				Event.observe(playButton,'click',function(){ // play
					this.style.display = 'none';
					this.previousSibling.style.display = 'inline';
					d.paused = false;
					d.timeoutHolder = setTimeout(transition(), 500);
				});
				Event.observe(previousButton,'click',function(){ // previous
					d.pause();
					setImage(-1);
				});
				Event.observe(nextButton,'click',function(){ // next
					d.pause();
					if (d.isFading) {
						d.isFading = false;
					} else {
						setImage(1);
					}
				});
				//button rollover style effects
				Event.observe(previousButton, 'mouseenter', function() { previousButton.src = previousDownSrc; });
				Event.observe(previousButton, 'mouseleave', function() { previousButton.src = previousSrc; });
				Event.observe(pauseButton, 'mouseenter', function() { pauseButton.src = pauseDownSrc; });
				Event.observe(pauseButton, 'mouseleave', function() { pauseButton.src = pauseSrc; });
				Event.observe(playButton, 'mouseenter', function() { playButton.src = playDownSrc; });
				Event.observe(playButton, 'mouseleave', function() { playButton.src = playSrc; });
				Event.observe(nextButton, 'mouseenter', function() { nextButton.src = nextDownSrc; });
				Event.observe(nextButton, 'mouseleave', function() { nextButton.src = nextSrc; });
				//fade of pause button on mouse out
				if (options.fadePause) {
					var fadeOutEffect = new Effect.Fade(pauseButton, { duration : 2});
					var fadeInListener = Event.observe(d.firstChild, 'mouseover', function() { 
						fadeOutEffect.cancel();
						pauseButton.style.filter = 'alpha(opacity=100)';
						pauseButton.style.opacity = '1.0';
						if (playButton.style.display == 'none') {
							pauseButton.style.display = 'block';
						}
					});
					var newFadeInListener = Event.observe(pauseButton, 'mouseover', function() {
						fadeOutEffect.cancel();
						pauseButton.style.filter = 'alpha(opacity=100)';
						pauseButton.style.opacity = '1.0';
						if (playButton.style.display == 'none') {
							pauseButton.style.display = 'block';
						}
					});
					var fadeOutListener = Event.observe(d.firstChild, 'mouseout', function() { fadeOutEffect = new Effect.Fade(pauseButton, { duration : 2, from : 1.0, to : 0 }); })
				}
				d.caption = d.appendChild(document.createElement('div'));
				//determine caption height - taller if displayed as address and button
				var captionHeight = (options.classId) ? '44px' : '54px';
				//default styles for caption div
				Object.extend(d.caption.style, {
					width: options.width - 6 + 'px'
					,padding:'3px'
					,height:'54px'
					,position:'absolute'
					,backgroundColor:'black'
					,color:'white'
					,fontWeight : 'normal'
					,fontSize : '13px'
					,fontFamily:'Arial, Helvetica, Sans Serif'
					,textAlign:'center'
					,overflow:'hidden'
					,lineHeight:'18px'
				});
				if (options.separateCaptionBox) Object.extend(d.caption.style, { marginTop:options.height + 'px' });
				else  Object.extend(d.caption.style, { bottom:'0px' });
				//make caption <ul> for rotating captions
				d.caption.innerHTML = '<ul id="slide-captions"><li class="captionLi"><span>This is caption 1</span></li><li class="captionLi"><span>This is caption 2</span></li></ul>';
				//allows for hiding of caption box
				if (options.hideCaptions) {
					d.caption.style.visibility='hidden';
					d.caption.style.display='none';
				}
				//adds controlDiv to wrapper div
				if (!options.hideButtons && images.length != 1) {
					d.appendChild(d.controlDiv);
					d.controlDiv.style.position = 'absolute';
					d.controlDiv.style.backgroundColor = 'transparent';
				}
				//preloads images
				var imgs = d.getElementsByTagName('img');
				for (var i=0; i<=1; i++) {
					imgs[i].onload = sizeImage;
				}
				//allows fully custom CSS from caller
				if (options.styles) {
					if (options.styles.captionBox) Object.extend(d.caption.style, options.styles.captionBox);
					if (options.styles.pictureBox) Object.extend(d.style, options.styles.pictureBox);
				}
				//finish declaring styles, respecting caller's css for caption box overflow: 'inherit',
				Object.extend(d.caption.firstChild.style,{ position:'relative', margin:'auto', padding : '0px',paddingLeft:'5px', paddingRight : '5px', right: '0', top:'0',height: '' +  d.caption.style.height + '' });
				Object.extend(d.caption.firstChild.firstChild.style,{listStyleType:'none', width: d.caption.style.width, margin : 'auto !important', position:'absolute', display:'block', margin:'0px', padding:'0px', textAlign: 'center', overflow:'visible', left : '0px'});
				Object.extend(d.caption.firstChild.lastChild.style,{listStyleType:'none', width: d.caption.style.width, margin: 'auto !important', position:'absolute', display:'none', margin:'0px', padding:'0px', textAlign: 'center', overflow:'visible', left : '0px'});
				if (Prototype.Browser.IE && document.compatMode == 'BackCompat') {
					//Object.extend(d.caption.style, {paddingTop : '0px')};
					Object.extend(d.caption.firstChild.style,{ marginLeft : '0px', paddingTop : '0px' });
					Object.extend(d.caption.firstChild.firstChild.style,{ marginTop : '-5px', paddingTop : '0px' });
					Object.extend(d.caption.firstChild.lastChild.style,{ marginTop : '-5px', paddingTop : '0px' });
				}
				//adds appropriate space in wrapper
				if ((!options.embedded && !options.hideCaptions) || !options.separateCaptionBox) {
					d.style.paddingBottom = parseInt(d.caption.style.paddingBottom, 10) + parseInt(d.caption.style.paddingTop, 10) + 3+ 'px';
				}
			}		
			d.initialize = d.active = true;
			d.controlDiv.children[2].style.display = 'none';
			d.controlDiv.children[1].style.display = 'inline';
			
			if (d.clonedCaption){
				d.removeChild(d.clonedCaption)
				d.clonedCaption = false;
			}
			if (options.caption){
				d.caption.innerHTML = options.caption;
				d.caption.style.display = 'block';
				var tds = d.caption.getElementsByTagName('td');
				for (var i=0; i<tds.length; i++){
					Object.extend(tds[i].style,{padding:'3px', color:'#fff'});
				}
				d.clonedCaption = d.caption.cloneNode(true);
				Object.extend(d.clonedCaption.style,{backgroundColor:'',opacity:'',filter:''});
				d.appendChild(d.clonedCaption);
				for (var i=0; i<tds.length; i++){
					Object.extend(tds[i].style,{padding:'3px', color:''});
				}
			}
			var height, width;
			d.images = images;
			//lis = d.getElementsByClassName('showLi');
			lis = $('slide-images').children;
			slideshowCounter = 0;
			d.images.index = 1;
			d.paused = false;	

			lis[0].style.display = 'none';
			lis[1].style.display = 'none';
			lis[0].style.visibility = 'hidden';  
			lis[1].style.visibility = 'hidden';
			lis[0].firstChild.style.width = lis[0].firstChild.style.height = '';
			lis[1].firstChild.style.width = lis[1].firstChild.style.height = '';
			lis[0].firstChild.src = d.images[0].src;
			sizeImage(lis[0].firstChild);
			//Allows hyperlinking of an image
			if (d.images[0].href !== undefined) {
				Event.observe(lis[0], "click", function() {
					window.location = d.images[0].href;
				});
				lis[0].firstChild.style.cursor = 'pointer';
			} else {
				Event.observe(lis[0], "click", function(e) {
					Event.stop(e);
				});
				lis[0].firstChild.style.cursor = 'normal';
			}
			
			caps = $('slide-captions').children;
			caps[0].innerHTML = d.images[0].caption;
			caps[1].innerHTML = d.images[1].caption;
			if (d.images.length > 1){
				setTimeout(function(){
					//var lis = d.getElementsByClassName('showLi');
					lis = $('slide-images').children;
					lis[1].firstChild.src = d.images[1].src;
					sizeImage(lis[1].firstChild);
				},1);
			}
			else {
				d.controlDiv.style.display = 'none';
			}
			
			if (options.paused || d.images.length == 1){
				d.pause();
			}
			else {
				d.timeoutHolder = setTimeout(transition(), delay);
			}
			caps[0].style.marginLeft = ((parseInt(d.caption.style.width, 10) - caps[0].offsetWidth)/2 - 1) + 'px';
			caps[1].style.marginLeft = ((parseInt(d.caption.style.width, 10) - caps[0].offsetWidth)/2 - 1) + 'px';
				
			//appends or shows wrapper div so the first image sizes correctly
			Event.observe(lis[1].firstChild, "load", function() {
				if (options.embedded) {
					//this fixed the annoying issue of text-align ruining everything in IE7.
					$(options.targetDiv).style.textAlign = 'left';
					$(options.targetDiv).appendChild(d);
				} else {
					d.show();
					Event.observe(window, "resize", function() { if (d !== undefined) d.center(); });
				}	
				//place the buttons
				if (d.images.length != 1) placeButtons();
			});	
			Event.observe(lis[0].firstChild, "load", function() {
				//place the buttons
				if (d.images.length != 1) placeButtons();
			});
			
			//button positioning function, called on slideshow load to ensure correct positioning.
			function placeButtons() {
				d.buttonLoadCount++;
				if (d.buttonLoadCount >= 4) {
					//set visibility to visible so they don't show up in the wrong spot
					previousButton.style.visibility = 'visible';
					nextButton.style.visibility = 'visible';
					pauseButton.style.visibility = 'visible';
					playButton.style.visibility = 'visible';
				}
				//Event observes for all buttons so placing works actually.
				//vertical - defaults to top
				if (options.buttonVertPos == 'middle') {
					d.controlDiv.style.marginTop = (options.height - previousButton.height)/2 + 'px';
				} else if (options.buttonVertPos == 'bottom') {
					d.controlDiv.style.bottom = (options.separateCaptionBox ? 0 : d.caption.offsetHeight) + 'px';
				}
				//horizontal - defaults to left
				if (options.buttonHorizPos == 'outside') {
					previousButton.style.position = pauseButton.style.position = playButton.style.position = nextButton.style.position = 'absolute';
					previousButton.style.marginLeft = '-' + previousButton.width + 'px';
					pauseButton.style.marginLeft = (options.width - pauseButton.width)/2 + 'px';
					playButton.style.marginLeft = (options.width - playButton.width)/2 + 'px';
					if (options.buttonVertPos == 'middle') {
						pauseButton.style.marginTop = (options.height - pauseButton.height)/2 + 'px';
						playButton.style.marginTop = (options.height - playButton.height)/2 + 'px';
					}
					nextButton.style.marginLeft = options.width + 'px';
				} else if (options.buttonHorizPos == 'center') {
					d.controlDiv.style.marginLeft = (options.width - (pauseButton.width + previousButton.width + nextButton.width))/2 + 'px'; 
				} else if (options.buttonHorizPos == 'right') {
					d.controlDiv.style.marginLeft = (options.width - (pauseButton.width + previousButton.width + nextButton.width)) + 'px';
				}
				d.controlDiv.style.display = '';
			}
			
			function setImage(i) {
				i--;
				var theIndex = d.images.incrementIndex(i);
				var on = slideshowCounter%2;
				var off = (slideshowCounter+1)%2;
				lis[on].firstChild.style.height = lis[on].firstChild.style.width = '0px';
				lis[on].firstChild.src = d.images[d.images.index].src;
				
				//Allows custom hyperlinking of an image
				currentIndex = d.images.index;
				if (d.images[d.images.index].href !== undefined) {
					Event.observe(lis[on], "click", function() {
						window.location = d.images[currentIndex].href;
					});
					lis[on].firstChild.style.cursor = 'pointer';
				} else {
					Event.observe(lis[on], "click", function(e) {
						Event.stop(e);
					});
					lis[on].firstChild.style.cursor = 'normal';
				}
				
				lis[on].firstChild.style.opacity = 1;
				lis[off].firstChild.src = d.images[d.images.incrementIndex(1)].src;
				if (options.rotateCaptions) {
					caps[on].innerHTML = d.images[theIndex].caption;
					caps[off].innerHTML = d.images[d.images.index].caption;
				}
			}
			function sizeImage() {
				if(this !== window) {
					if (d.initialize && lis[0]==this.parentNode) {
						d.initialize = false;
						lis[0].style.display = 'block';
						lis[0].style.visibility = 'visible';
						height = options.height || this.height;
						width = options.width || this.width;
						if (!options.hideCaptions && !options.separateCaptionBox) {
							height = height + parseInt(d.caption.style.height, 10);
						}
						getScroll();
						var testHeight = windowHeight - 30;
						if (height > testHeight){
							var adj = testHeight/height;
							options.height = height = height * adj
							options.width = width = width * adj
						}
						d.style.width = width+'px';
						d.style.height = height+'px';
						if (options.embedded) {
							$(options.targetDiv).appendChild(d);
						} else {
							d.center().show();
							myImg.style.left = '0px';
						}
					}
					if(!width) {
						width = options.width;
					}
					
					var disp = this.parentNode.style.display;
					this.parentNode.style.display = 'block';
					this.style.width = this.style.height = '';
					this.style.width = options.width + 'px';
					var adj = Math.max((this.offsetWidth-width)/width,(this.offsetHeight-height)/height);

					try {
						//fix for quirks mode
						if (Prototype.Browser.IE && document.compatMode == 'BackCompat') {
							this.style.width = (parseInt(this.offsetWidth / (1+adj), 10) - 2) +'px';
							this.parentNode.style.marginLeft = '-1px';
						} else {
							this.style.width = parseInt(this.offsetWidth / (1+adj), 10) +'px';
						}
					}
					catch (err){
						if (window.console)
							console.log('|---'+this.width+'|\n'+lis[0]==this.parentNode);
					}
					
					if (this.offsetHeight > options.height) {
						this.style.height = options.height + 'px';
						this.style.width = '';
					}
					
					this.style.marginLeft = this.style.marginRight = parseInt((width-parseInt(this.offsetWidth, 10))/2, 10)+'px';
					this.style.marginTop = parseInt((options.height-this.offsetHeight)/2, 10)+'px';
					this.parentNode.style.display = disp;
					
					if (this.parentNode.style.visibility=='hidden') {  
						this.parentNode.style.visibility='visible';
						this.parentNode.style.display='none';
					}
				}
			}
			function transition(frame) {
				return (function() {
					var off = (slideshowCounter++)%2;
					var on = slideshowCounter%2;
					//var lis = d.getElementsByClassName('showLi');
					lis = $('slide-images').children;
					//separate if statements due to instantaneous nature of d becoming closed, thereby undefined.
					//fixes error regarding d.frameAppearEffect when slideshow is closed during transitions.
					if (d) d.isFading = true;
					if (d) d.frameFadeEffect = Effect.Fade(lis[off], { afterFinish : function() { if (d) d.isFading = false; } });
					if (d) d.frameAppearEffect = Effect.Appear(lis[on]);
					//This allows caption changing
					if (options.rotateCaptions) {
						//var caps = d.getElementsByClassName('captionLi');
						var caps = $('slide-captions').children;
						Effect.Fade(caps[off]);
						caps[on].style.display = 'none';
						caps[on].style.visibility = 'visible';
						Effect.Appear(caps[on]);
					}
					//Allows custom hyperlinking of an image
					if (d.images[d.images.index].href) {
						var currentIndex = d.images.index;
						Event.observe(lis[on].firstChild, "click", function() {
							window.location = d.images[currentIndex].href;
						});
						lis[on].firstChild.style.cursor = 'pointer';
					} else {
						Event.observe(lis[on].firstChild, "click", function(e) {
							Event.stop(e);
						});
						lis[on].firstChild.style.cursor = 'normal';
					}
					
					d.images.incrementIndex(1);
					
					d.getNextTimeout = setTimeout(function(){
						var img = lis[off].firstChild;
						img.style.marginLeft = img.style.marginRight = img.style.marginTop = img.style.marginBottom = '';
						img.style.height = img.style.width = '0px';
						img.parentNode.style.display = 'block';
						img.parentNode.style.visibility = 'hidden';
						img.style.visibility = 'visible';
						img.style.display = 'block';
						img.src = d.images[d.images.index].src;
						//change caption text
						if (options.rotateCaptions) {
							var cap = caps[off];
							cap.style.display = 'block';
							cap.style.visibility = 'hidden';
							cap.innerHTML = d.images[d.images.index].caption;
						}
					},1200);
					if (!d.paused) d.timeoutHolder = setTimeout(transition(frame), delay + 1850);
				})
			}
			return d;
		}
	}
}

try{ 
	CSI.localStorage   = (localStorage.CSI   || '{}').evalJSON();
	CSI.sessionStorage = (sessionStorage.CSI || '{}').evalJSON();
}
catch(err) { }

Event.observe(window, 'unload', function () {
	localStorage.CSI   = Object.toJSON(CSI.localStorage);
	sessionStorage.CSI = Object.toJSON(CSI.sessionStorage);
});

Object.extend(Date.prototype,CSI.dateMethods);
Object.extend(Array.prototype,CSI.arrayMethods);
Element.addMethods(CSI.domMethods);

function clearBoth () {
	var clr = document.createElement('br');
	clr.style.clear = 'both';
	return clr;
}

function getScroll () {
	if (window.pageYOffset) {
		scrollTop = window.pageYOffset;
		scrollLeft = window.pageXOffset;
	}
	else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
		scrollTop = document.documentElement.scrollTop;
		scrollLeft = document.documentElement.scrollLeft;
	}
	else if (document.body){
		scrollTop = document.body.scrollTop;
		scrollLeft = document.body.scrollLeft;
	}
	
	if (window.innerHeight){
		windowHeight = window.innerHeight
		windowWidth = window.innerWidth
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight
		windowWidth = document.documentElement.clientWidth
	}
	else if (document.body) {
		windowHeight = document.body.clientHeight;
		windowWidth = document.body.clientWidth;
	}
	
	return {Top:scrollTop, Left:scrollLeft, top:scrollTop, left:scrollLeft, width:windowWidth, height:windowHeight}
}



function padZero (n, totalDigits) {
	n=n+'';
	while (n.length<totalDigits)
		n='0'+n
	return n;
}
/*
function formatDate (d) {
	if (!d || !d.getDate) 
		return '';
	return padZero((d.getMonth()+1),2)+'/'+padZero(d.getDate(),2)+'/'+d.getFullYear().toString().substr(2,2)
}
*/
function iraStatus (adstatus,expiredate) {
	switch (adstatus){
		case 'e':
			return 'Expired';
		case 'w':
			return 'Withdrawn';
		case 's':
			return 'Sold';
		case 'b':
			return 'Backup Offers';
		case 'p':
			return 'Pending';
		case 'c':
			return 'CMA';
		case 't':
			return 'Cancelled';
		case 'a':
			if (expiredate > new Date())
				return 'Active';
			else
				return 'Expired';
	}
	return '';
}

function CSSRule (cName,styleObj,optObj) {
	if (!optObj)
		var optObj = {};
	if(document.styleSheets.length == 0)
		return;
	for (var i=0;i<document.styleSheets.length;i++){
		var cx = document.styleSheets[i].cssRules || document.styleSheets[i].rules
		for (var x=0;x<cx.length;x++){
			if (cx[x].selectorText == cName){
				if (!optObj.insertOnly)
					Object.extend(cx[x].style,styleObj)
				else
					for (var y in styleObj){
						if (!cx[x].style[y])
							cx[x].style[y] = styleObj[y]
					}
				return;
			}
		}
	}
	var s='';
	delim = '';
	for (var i in styleObj){
		if (i == 'cssFloat' || i == 'styleFloat')
			s+= 'float:'+styleObj[i]+';';
		else
			s += i.underscore().dasherize()+':'+styleObj[i]+';';
	}
	var myStyle = document.styleSheets[0];
	if (myStyle.addRule){//ie
		try { x = myStyle.addRule(cName,s) }
		catch(err){
			alert(cName);
		}
	}
	else {
		myStyle.insertRule(cName+'{'+s+'}',  myStyle.cssRules.length-1)
	}

}

function debug (obj) {
	var msg=[];
	for (i in obj){
		try {msg[msg.length] = i+':'+obj[i];}
		catch(e) {msg[msg.length] = i+':'}
	}
	if (!window.debugBox){
		debugBox = document.createElement('div')
		debugBox.style.position = 'absolute';
		debugBox.style.top="10px";
		debugBox.style.left="10px";
		debugBox.style.border="1px solid #576c86";
		debugBox.style.height="100px";
		debugBox.style.padding="10px";
		debugBox.style.backgroundColor="lightblue";
		document.body.appendChild(debugBox);
		debugBox.onclick=function () {debugBox.style.visibility="hidden"};
	}
	
	debugBox.innerHTML = msg.join('<br>')
	debugBox.style.visibility='visible';
}

function createCookie (name,value,days,mydomain) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
		var expires = "";

	if (!mydomain)
		var mydomain = '';
	else
		mydomain = 'domain='+mydomain;
		
	document.cookie = name+"="+value+expires+"; path=/; "+mydomain;
}

function readCookie (name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie (name) {
	createCookie(name,"",-1);
}

function isObject (a) {
    return (a && typeof a === 'object') || isFunction(a);
}

function isFunction (a) {
    return typeof a === 'function';
}
function trim (str_var) {
	return str_var.replace(/^\s+|\s+$/g, '');
}
function mainmenu () {
	window.location = '/wwwroot/remaint/index.cfm';
	return;
}
function checklength (event, obj) {
	setTimeout("updateCounter(textarea.value.length)",3);
	//var uselessKeys = /^9|16|17|35|36|37|8|46|91|38|66|39|40$/
	var uselessKeys = /^9|16|35|36|37|8|46|91|38|66|39|40$/
	if (uselessKeys.test(event.keyCode)) {
		return;
	}
	if (!event.keyCode == "17") {
		if (obj.value.length >= obj.maxlength) {
			return false;
		}
	}
}
function updateCounter (used) {
	//if (!textarea.maxlength)
	textarea.maxlength=textarea.getAttribute('maxlength');

	if (textarea.value.length > textarea.maxlength){
		textarea.value = textarea.value.substring(0,textarea.maxlength);
		used = textarea.maxlength;
	}
	_from.innerHTML = 'used '+used+' ';
	_to.innerHTML = ' of '+textarea.maxlength;
}
function init_from_to (obj) {
	textarea = obj;
	_from = document.getElementById(textarea.name+'_from');
	_to   = document.getElementById(textarea.name+'_to');
	updateCounter(obj.value.length);
}

function testEmails (str) {
	str = str.replace(/;/g,',')
	str = str.replace(/\s/g,',')
	var r = /,,/;
	while (r.test(str))
		str=str.replace(r,',')
	var a = str.split(',')
	var v = true;
	for (var i=0;i<a.length;i++)
		if (!testEmail(a[i])){
			v = false;
			break;
		}
	return (v) ? str : v
}

function testEmail (str) {
	if (!(/@/.test(str))) return false;
	var emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	return emailRe.test(str)
}
CSSRule('.fLink',{cursor:'pointer',color:'blue',textDecoration:'underline'});

// End of CSITools.js                                           //


// start of dates.js by matt kruse:
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
/// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ (x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate (val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates (date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2 || d1 == d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate (date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger (val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt (str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat (val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate (val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}

/*
					End of dates.js 				
					
					Start of Mybox.js
*/

CSSRule('.theBox',{fontSize:'12px',border:'1px solid black',padding:'6px',position:'absolute',backgroundColor:'#ffffef'});
CSSRule('.theBoxParent', {filter: 'alpha(opacity=100)', opacity:1});

//will create a box that on .show() will overlap the page
function createBox (optObj) {
	optObj = optObj || {};
	
	/* false, undefined, null, '', and 0 will be false */
	optObj.hideOnBlur = !!optObj.hideOnBlur;
	
	var b = $(document.createElement('div'));
	b.className = 'theBox';
	b.overlay = optObj.overlay;
	
	var par = $(document.createElement('div'));
	
	Object.extend(par.style, {
		 position : 'absolute'
		,visibility : 'hidden'
		,display : ''
		,left : '0px'
		,right : '0px'
	});
	par.appendChild(b);
	
	Object.extend(b, boxMethods);
	
	if (optObj.fullScreen) {
		b.fullScreen = true;
		optObj.shadowWidth = 0;
	}

	// opacity //
	
	if (optObj.opacity){
		b.style.filter = 'alpha(opacity='+(optObj.opacity*100)+')';
		b.style.MozOpacity = b.style.KhtmlOpacity = b.style.opacity = optObj.opacity;
	}

	var shadowWidth   = (optObj.shadowWidth != undefined) ? optObj.shadowWidth : 5;
	var shadowOpacity = optObj.shadowOpacity || 24;
	b.addShadow(shadowWidth,shadowOpacity);

	if (optObj.insert){
		b.inline = true;
		var elm = $(optObj.insert);
		if(elm.getStyle('position')=='static') {
			elm.style.position = 'relative';
		}
		b.parentNode.style.top = b.parentNode.style.left = '0px';
		elm.appendChild(par);
		return b;
	}
	document.body.appendChild(par);
	
	return b;
}

insertDivReg = (function () {
	var dr = [];
	
	var fx = function (elm) {
		var  arr = []
			,box
			,last;
		
		if (!!dr.length) {
			last = (dr.length - 1);
			box  = $(elm.up('.theBox'));
			
			if (dr[last].close && (box === undefined || !elm)) {
				dr[last].close();
				last--;
			} else {
				return;
			}

			while (last > -1) {
				arr.push(dr[last]);
				last--;
			}
		}
		dr = arr;
	};
	
	Event.observe(window, 'load', function () {
		Event.observe(document, 'click', function (e) {
			var elm = Event.element(e);
			fx(elm);
		})
	});
	
	return function (div) {
		
		if (arguments[1]) {
			dr.pop();
			return;
		}
		if (!div) {
			fx();
		}
		else if (dr.indexOf(div) === -1) {
			dr.push(div);
		}
	};
}());

boxMethods = { 
	//displays the box on the screen
	show : function (focusElm) {
		var oThis = this;

		if (oThis.overlay) {
			if (!window.overlay) {
				overlay = document.createElement('div');
				overlay.id = 'overlay';
				overlay.onclick = 'event.cancelBubble=true';
				overlay.style.position = 'absolute';
				overlay.style.top = '0px';
				overlay.style.left = '0px';
				overlay.style.display = 'none';
				overlay.style.opacity = '.5';
				overlay.style.filter = 'Alpha(Opacity=50)';
				overlay.style.backgroundColor = '#000000';
				document.body.appendChild(overlay);
				overlay.style.zIndex = 0;
				overlayArray = [];
				overlay.onclick = 'return false';
				
				// resizeOverlay methodized
				overlay.resizeOverlay = function () {
					if (window.overlay && overlay.style.display == 'block') {
						var bodyDims = $(document.body).getDimensions();
						var viewportDims = document.viewport.getDimensions();
						overlay.style.width  = Math.max(bodyDims.width, viewportDims.width) + 'px';
						overlay.style.height = Math.max(bodyDims.height, viewportDims.height) + 'px';
					}
				}

				Event.observe(window, 'resize', overlay.resizeOverlay);
			};
			/* breaks when a string (ie. "black") is passed as a color value */
			if (oThis.overlay.color) {
				if (/^#/.test(oThis.overlay.color)) {
					oThis.overlay.color = oThis.overlay.color.substring(1);
				}
				overlay.color = overlay.style.backgroundColor = '#' + oThis.overlay.color;
			}
			if (oThis.overlay.opacity) {
				overlay.style.opacity = oThis.overlay.opacity / 100;
				overlay.style.filter  = 'alpha(opacity=' + oThis.overlay.opacity + ')';
			}
			overlay.style.zIndex  = overlay.style.zIndex || 0;
			overlay.style.zIndex  = parseInt(overlay.style.zIndex) + 10;
			overlay.style.display = "block"
			
			this.bodyOverflow = document.body.style.overflow.toString();
			document.body.style.overflow = 'hidden';
			
			/*
			 * TEMP FIX
			 * 
			 * mailto.js && emptybox.js define their own overlay, resizeOverlay won't be available
			 * http://dev.comsoftinc.com/Remaint/myprops.cfm ---> "Text" had this issue
			 * 
			 * TODO
			 * 
			 * consider making overlay a CSI method: CSI.createOverlay
			 * update programs defining their own overlay to use ( unimplemented as of 01/07/2012 ) CSI.createOverlay
			 * 
			 */
			try {
				overlay.resizeOverlay();
			} catch (err) {
				var bodyDims = $(document.body).getDimensions();
				var viewportDims = document.viewport.getDimensions();
				overlay.style.width  = Math.max(bodyDims.width, viewportDims.width) + 'px';
				overlay.style.height = Math.max(bodyDims.height, viewportDims.height) + 'px';
			}
			
			oThis.parentNode.style.zIndex = parseInt(overlay.style.zIndex) + 5;
			overlayArray.push(oThis);
		}
		oThis.showTimeout = window.setTimeout(function () {
			oThis.parentNode.style.visibility = '';
			if (focusElm && oThis.form[focusElm]){
				oThis.form[focusElm].focus();
			}
		}, 25);
		this.positionShadow();
		
		if (!oThis.inline && !oThis.pushed && oThis.hideOnBlur) {
			setTimeout(function () {insertDivReg(oThis)}, 0);
		}
		if (this.saveValues){
			this.saveValues();
		}
		if (this.fullScreen) {
			//this.bodyOverflow = document.body.style.overflow.toString();
			this.style.top = this.cumulativeScrollOffset().top + 'px';
			//document.body.style.overflow = 'hidden';

			var subX = (parseInt(this.hdr.style.paddingLeft, 10) + parseInt(this.hdr.style.paddingRight, 10) + 2) || 18;
			var subY = (parseInt(this.formBody.style.paddingTop, 10) + parseInt(this.formBody.style.paddingBottom, 10) + 2) || 18;
			
			Object.extend(this.style, {
				width: (window.innerWidth || document.viewport.getWidth()) - 2 + 'px'
				,height: (window.innerHeight || document.viewport.getHeight()) - 2 + 'px'
			});
			
			setTimeout(function () {
				oThis.formBody.setStyle({
					height: (oThis.getHeight() - oThis.hdr.offsetHeight - subY) + 'px'
					,overflowY: 'auto'
				})
			}, 0);
		}
		
		return this;
	}
	//closes the box
	,close : function () {
		this.parentNode.style.visibility = 'hidden';
		if (this.overlay) {
			overlayArray.pop();
			// added by Kevin August 5th 2011 - closes stacked forms in order of last --> first
			// pops last form obj from dr Array
			if (this.hideOnBlur) {
				insertDivReg('', true);
			}
			document.body.style.overflow = this.bodyOverflow == '' ? '' : this.bodyOverflow;
			if (overlayArray.length > 0){
				var myForm = overlayArray[overlayArray.length-1];
				overlay.style.display = "block"
				overlay.style.zIndex  = parseInt(overlay.style.zIndex) - 10;
				overlay.style.width   = (window.innerWidth || document.viewport.getWidth()) + 'px';
				overlay.style.height  = (window.innerHeight || document.viewport.getHeight()) + 'px';
				myForm.parentNode.style.zIndex = parseInt(overlay.style.zIndex, 10) + 5;
				myForm.focus();
			}
			else {
				overlay.style.display = 'none';
				overlay.style.zIndex = 0;
			}
		}
		return this;
	}
	,fadeOut : function (delay) {
		delay = delay || 3000;
		var box = this;
		var opacity = 1;

		var elms = $(box.parentNode).descendants();
		if (box.fadeTimeout){
			//alert(box.fadeTimeout);
			clearTimeout(box.fadeTimeout);
			box.fadeTimeout = null;
			finishUp();
		}
		for (var i=0;i<elms.length;i++){
			elms[i].saveOpacity = elms[i].getStyle('opacity');
		}
		elms[0].setOpacity(.98);
		box.fadeTimeout = setTimeout(fade,delay);
		return this;
		function fade () {
			opacity = opacity - .02;
			for (var i=0;i<elms.length;i++){
				if (elms[i].saveOpacity > opacity){
					elms[i].setOpacity(opacity);
				}
			}
			if (opacity > 0){
				box.fadeTimeout = setTimeout(fade,40);
			}
			else {  // cleanup and finish
				finishUp();
			}
		}
		function finishUp () {
			for (var i=0;i<elms.length;i++){
				elms[i].setOpacity(elms[i].saveOpacity);
			}
			box.close();
		}
	}
	//will try to position in selected position under elm, default below/left
	,position : function (elm,optObj) {
		
		var optObj = optObj || {};
		var p, jA, kA, i, x, fits, top, otop, ttop, left, oleft, tleft, tElm, eWidth, eHeight, shadow;
		var validPlacements = ['below/right','above/left','above/right','right/top','right/bottom','left/top','left/bottom'];

		getScroll();

		var bodyScroll = scrollTop;
		var cumulativeScroll = $(elm).cumulativeScrollOffset();
		scrollTop = cumulativeScroll.top;
		scrollLeft = cumulativeScroll.left;

		if (optObj.placement == 'pointer'){
			var x = optObj.event.x || optObj.event.clientX || 0;
			var y = optObj.event.y || optObj.event.clientY || 0;
			
			if (x>windowWidth/2)
				left = (x-this.offsetWidth)+scrollLeft-3;
			else
				left = x+scrollLeft+3;
				
			if (y>windowHeight/2)
				top = (y-this.offsetHeight)+scrollTop-3;
			else
				top = y+scrollTop+3;
				
			if (y>windowHeight/2 && x>windowWidth/2){
				top-=4;
				left-=4;
			}		
			top = Math.max(top,0);
			left = Math.max(left,0);
			
			this.parentNode.style.top = top+'px';
			this.parentNode.style.left = left+'px';
			this.positionShadow()
			return this;
		}
		tElm  = elm;
		tleft = ttop = 0;
		
		while (tElm && tElm.tagName != 'HTML' ){
			ttop  += tElm.offsetTop;
			tleft += tElm.offsetLeft;
			tElm   = tElm.offsetParent;
		}
		shadow = Element.select(this.parentNode,'.vShadow')[0];
		//shadow = this.parentNode.getElementsByClassName('vShadow')[0];
		if (shadow){
			eWidth  = this.offsetWidth + shadow.offsetWidth 
			eHeight = this.offsetHeight  + shadow.offsetWidth 
		}
		else {
			eWidth  = this.offsetWidth 
			eHeight = this.offsetHeight 
		}
			
		if (optObj.placement == 'below' || optObj.placement == 'above')
			optObj.placement += '/left'
		else if (optObj.placement == 'left' || optObj.placement == 'right')
			optObj.placement += '/top'
		
		if (!optObj.placement || validPlacements.indexOf(optObj.placement) == -1)
			optObj.placement = 'below/left'
		
		var p = optObj.placement.split('/')
		if (p[0] == 'below')
			jA = ['below','above','right','left']
		else if (p[0] == 'above')
			jA = ['above','below','right','left']
		else if (p[0] == 'right')
			jA = ['right','left','below','above']
		else if (p[0] == 'left')
			jA = ['left','right','below','above']
			
		outer_loop:
		for (i=0; i<jA.length; i++){
			if (jA[i] == 'above' || jA[i] == 'below')
				kA = (p[1] == 'left') ? ['left','right'] : ['right','left']
			else
				kA = (p[1] == 'top') ? ['top','bottom'] : ['bottom','top']

			if (optObj.cover) {
				if ( jA[i] == 'above') 
					otop = -eHeight;
				else if (jA[i] == 'below')
					otop = 0;
				else if (jA[i] == 'left')
					oleft = -eWidth;
				else if (jA[i] == 'right')
					oleft = elm.offsetWidth;
			}
			else {
				if ( jA[i] == 'above') 
					otop = -eHeight;
				else if (jA[i] == 'below')
					otop = elm.offsetHeight;
				else if (jA[i] == 'left')
					oleft = -eWidth;
				else if (jA[i] == 'right')
					oleft = elm.offsetWidth;
			}
			for (x=0;x<kA.length;x++){
				left = oleft;
				top = otop;
				if (kA[x] == 'left')
					left =  0;
				else if (kA[x] == 'right')
					left = (eWidth - elm.offsetWidth)*-1
				else if (kA[x] == 'top')
					top = 0
				else if (kA[x] == 'bottom')
					top = (eHeight - elm.offsetHeight)*-1
				
				top += ttop;
				left += tleft;
				
				fits = true;
				if (optObj.force)
					break outer_loop;
					
				if (((left + eWidth) - scrollLeft > windowWidth)
				|| ((top + eHeight) - scrollTop > windowHeight)
				|| (top - scrollTop < 0)
				|| (left - scrollLeft < 0)){
					fits = false;
				}
				else {
					break outer_loop;
				}
			}
				
		}
		if (!fits){
			for (var i=0;i<jA.length; i++) {
				if ( jA[i] == 'above') {
					top = -eHeight+ttop;
					left = scrollLeft;
				}
				else if (jA[i] == 'below') {
					top = elm.offsetHeight+ttop;
					left = scrollLeft;
				}
				else if (jA[i] == 'left') {
					left = -eWidth+tleft;
					top = scrollTop;
				}
				else if (jA[i] == 'right') {
					left = elm.offsetWidth+tleft;
					top = scrollTop;
				}
				
				fits = true;
				if (((left + eWidth) - scrollLeft > windowWidth)
				|| ((top + eHeight) - scrollTop > windowHeight)
				|| (top - scrollTop < 0)
				|| (left - scrollLeft < 0)) {
					fits = false;
				}
				else {
					break;
				}
			}
		}		
		//Only account if the body has not been scrolled
		top = (bodyScroll == 0) ? Math.max(top-scrollTop,0) : Math.max(top,0);
		left = (bodyScroll == 0) ? Math.max(left-scrollLeft,0) : Math.max(left,0);
		this.parentNode.style.top = top+'px';
		this.parentNode.style.left= left+'px';
		this.positionShadow()
		return this;
	}
	//centers the box based on the available space in the document.body
	,center : function () {
		var par = this.parentNode;
		if (par.style.position != 'absolute') {
			return;
		}
		getScroll();
		var divTop  = Math.round(scrollTop + ((windowHeight - this.offsetHeight)/2))
		var divLeft = Math.round(scrollLeft + ((windowWidth - this.offsetWidth)/2))
		par.style.top  = Math.max(divTop,0) + 'px'
		par.style.left = Math.max(divLeft,0) + 'px'

		getScroll();
		if (this.offsetHeight > windowHeight && this.formBody){
			var oThis = this;
			var fHeight = (oThis.footer) ? oThis.footer.offsetHeight : 0;
			oThis.formBody.style.height = (windowHeight - (oThis.hdr.offsetHeight + fHeight + parseInt(oThis.formBody.getStyle('paddingTop')) + parseInt(oThis.formBody.getStyle('paddingBottom')) ) )+'px';
			oThis.formBody.style.overflowY = 'scroll';
		}
		
		this.positionShadow();
		return this
	}/*
	,center : function () {
		var par = this.parentNode;
		var windowWidth = !!window.innerWidth
				? window.innerWidth
				: !document.documentElement.clientWidth
					? document.body.clientWidth
					: document.documentElement.clientWidth
				
			,windowHeight = !!window.innerHeight
				? window.innerHeight
				: !document.documentElement.clientHeight
					? document.body.clientHeight
					: document.documentElement.clientHeight;
		
		if (this.offsetWidth <= windowWidth) {
			par.style.left = (windowWidth - this.offsetWidth) / 2 + 'px';
		}
		if (this.offsetHeight <= windowHeight) {
			par.style.top  = (windowHeight - this.offsetHeight) / 2 + 'px';
		}
		return this;
	}*/
	,addShadow : function (width,opacity) {
		if (width==0)
			return this;
		var par = this.parentNode
		var width = width || 3;
		var opacity = opacity || 28;
		var vShadow = $(document.createElement('div'))
		var hShadow = $(document.createElement('div'))
  
  		vShadow.className = 'vShadow';
  		hShadow.className = 'hShadow';
		var bb = parseInt(this.getStyle('borderBottomWidth')) || 0;
		var br = parseInt(this.getStyle('borderRightWidth')) || 0;
		var bt = parseInt(this.getStyle('borderTopWidth')) || 0;
		var bl = parseInt(this.getStyle('borderLeftWidth')) || 0;
  
		vShadow.setStyle({position:'absolute',backgroundColor:'black',opacity:opacity/100,filter:'alpha(opacity='+opacity+')'})
		hShadow.setStyle({overflow:'hidden',position:'absolute',backgroundColor:'black',opacity:opacity/100,filter:'alpha(opacity='+opacity+')'})
		hShadow.style.height = vShadow.style.width = width+'px';
		vShadow.style.top = ((2*width))+'px'
		hShadow.style.left = ((2*width))+'px';
		par.appendChild(vShadow);
		par.appendChild(hShadow);
		return this;
	}
	,positionShadow : function () {
		var shadowWidth = 0;
		//if (vShadow = this.parentNode.getElementsByClassName('vShadow')[0]){
		if (Element.select && (vShadow = Element.select(this.parentNode,'.vShadow')[0])){
			//var hShadow = this.parentNode.getElementsByClassName('hShadow')[0]
			var hShadow = Element.select(this.parentNode,'.hShadow')[0];
			shadowWidth = vShadow.offsetWidth;
			
			vShadow.style.height = (((this.offsetHeight)+shadowWidth)-2*shadowWidth) + 'px';
			hShadow.style.width  = ((this.offsetWidth)-2*shadowWidth) + 'px';
			vShadow.style.left = (this.offsetWidth) + 'px';
			hShadow.style.top  = (this.offsetHeight) + 'px';
		}
		if (this.inline){
			var offsetHeight = this.offsetHeight + shadowWidth;
			var offsetWidth  = this.offsetWidth + shadowWidth;
			var par  = this.parentNode.parentNode;
			var dims = par.getDimensions();
			par.style.height = Math.max(dims.height,offsetHeight)+'px';
			par.style.width  = Math.max(dims.width,offsetWidth)+'px';
		}
		return this;
	}
	,adjLeft	: function (v) {
		this.parentNode.style.left = (parseInt(this.parentNode.style.left)+v)+'px';
		return this
	}
	,adjTop	: function (v) {
		this.parentNode.style.top = (parseInt(this.parentNode.style.top)+v)+'px';
		return this;
	}
}

/*							End of mybox.js
							
							
							
							Start of dmenu.js
*/

CSSRule('.dMenu',{padding:'2px',cursor:'pointer',border:'1px solid #aaa',fontFamily:'tahoma',fontSize:'.7em'});
CSSRule('.dMenu div',{position:'relative',color:'black',padding:'2px 16px 2px 3px',backgroundColor:'white',whiteSpace:'nowrap'});
CSSRule('.dMenu .sel',{color:'white',backgroundColor:'#3B46BF'});
CSSRule('.dMenu span',{position:'absolute',right:'5px',fontSize:'xx-small',paddingTop:'1px'});

if (!window.menuObject) {
	menuObject = {};
}
if (!window.menuObject2) {
	menuObject2 = {};
}

function showMenu (t,str,e) {
	t=$(t);
	var o = {};
	if (!menuObject2[str])
		if (menuObject[str])
			menuObject2[str] = createMenu(str,t);
		else {
			alert('no menu')
			return;
		}

	var m = menuObject2[str];
	m.linkElm = t;
	
	if (!t.hasClassName('menuItem') && $(t.parentNode).hasClassName('menuItem')){
		t=$(t.parentNode);
	}
	if (t.hasClassName('menuItem')){
		m.instigator = t;
		m.parentMenu = t.parentNode;
	}
	if (m.parentMenu){
		m.parentMenu.subMenu = m;
		if (!m.parentMenu.horizontal)
			o = {placement:'right'};
	}
	if (m.placement)
		o = {placement:m.placement};
	
	m.show();
	if (m.placement == 'pointer' && e){
		x = e.x || e.clientX
		y = e.y || e.clientY
		o = {placement:'pointer',x:x,y:y}
		m.position(t,o);
	}
	else if (m.placement != 'inline')
		m.position(t,o);
	return m;
}

menuMethods = {
	closeSubMenu : function () {
		var m = this;
		var a = [];
		while (m.subMenu){
			if (a.indexOf(m)>-1){
				alert('error : circular reference')
				return;
			}
			a.push(m)
			if (m.subMenu.selectedItem){
				m.subMenu.selectedItem.removeClassName('sel');
				m.subMenu.selectedItem = null;
			}
			m.subMenu.close()
			m = m.subMenu;
			m.parentMenu.subMenu = null;
		}
	}
	,evaluate : function () {
		var divs = this.getElementsByTagName('div');
		for (var i=0;i<divs.length;i++){
			try {divs[i].disabld = !eval(divs[i].condition)}
			catch(err){divs[i].disabld = true;}
			if (divs[i].disabld)
				divs[i].style.color = 'lightgrey'
			else
				divs[i].style.color = ''
		}
	}
	,setTitle : function (str,styleObj) {
		this.titleSpan.innerHTML = str;
		if (styleObj){
			Object.extend($(this.titleSpan).style, styleObj);
		}
		this.titleSpan.style.display = '';
		return this;
	}
	,onmouseover : function (e) {
		var ev = (e) ? e : event;
		var t = $(ev.target || ev.srcElement)
		if (t.className == 'menuItem' && !t.disabld){
			var m = t.parentNode;
			m.selectItem(t);
		}
	}
	,onclick : function (e) {
		var ev = (e) ? e : event;
		var t = $(ev.target || ev.srcElement)

		if (!t.hasClassName('menuItem'))
			t=t.parentNode;
		
		if (t.disabld){
			Event.stop(ev);
			return
		}
		
		var controlObj;
		
		if (t.hasClassName('menuItem')){
			var m = t;
			while (!controlObj && m){
				if (m.controlObj) {
					controlObj = m.controlObj;
				}
				else if (m.readAttribute && (controlObj = m.readAttribute('controlObj'))) { }
				else if (m == this) {
					break;
				}
				else {
					m = m.parentNode;
				}
			}
			controlObj = controlObj || {};			
		
			if (typeof(t.fx)=='function'){
				if (typeof (controlObj) == 'string')
					eval ('controlObj = '+ controlObj);
					
				t.fx(ev,controlObj);
			}
			else {
				if (m.autoOpen && m.subMenu){
					m.subMenu.close();
					m.autoOpen = false;
				}
				else{
					showMenu(t,t.fx);
					if (m.horizontal)
						m.autoOpen = true;
				}
			}
		}
	}
	,onmouseenter	:	function () {
		if (this.timeout)
			clearTimeout(this.timeout)
		if (this.instigator && this.parentMenu.selectedItem != this.instigator)
			this.parentMenu.selectItem(this.instigator);
	}
	,selectItem	:	function (t) {
		var m = this;
		if (m.selectedItem){
			if (m.selectedItem == t)
				return;
			if (m.subMenu && m.subMenu.instigator == m.selectedItem && !m.autoOpen)
				m.subMenu.timeout = setTimeout(function () {m.closeSubMenu()},700);
			if (m.selectedItem.timeout)
				clearTimeout(m.selectedItem.timeout)
			m.selectedItem.removeClassName('sel')
		}
		t.addClassName('sel')
		m.selectedItem = t;
		if (m.subMenu && m.subMenu.instigator == t && m.subMenu.timeout)
			clearTimeout(m.subMenu.timeout);
			
		if (m.autoOpen){
			m.closeSubMenu()
			if (!t.disabld && typeof(t.fx)=='string')
				showMenu(t,t.fx);
		}
		else if (!m.horizontal && !t.disabld && typeof(t.fx)=='string')
			t.timeout = setTimeout(function () {showMenu(t,t.fx)},700)
	}
}

function createMenu (str,t) {
	var optObj = {}
	optObj.shadowOpacity = menuObject[str].shadowOpacity || 24;
	optObj.shadowWidth = (menuObject[str].shadowWidth == undefined) ? 3 : menuObject[str].shadowWidth


	var x = t;
	var z = 0;
	while (x && x.getStyle){
		z = Math.max( x.getStyle('zIndex'),z)
		x = $(x.parentNode);
	}
	
	var box = createBox(optObj)
	box.parentNode.style.zIndex = z+1;
	box.placement = menuObject[str].placement || 'jj';

	
	if (menuObject[str].placement == 'inline'){
		t.appendChild(box.parentNode);
		box.style.position = box.parentNode.style.position = 'relative'
	}


	box.addClassName(menuObject[str].className || 'dMenu');
	box.dMenu = true;
	
	Object.extend(box,menuMethods);
	box.style.padding = '';
	
	box.hideOnClick = menuObject[str].hideOnClick || false;
	
	var d,h,arrow;
	var a;
	
	box.horizontal = !!menuObject[str].horizontal;
	var hideArrows = !!menuObject[str].hideArrows;
	
	arrow = (box.horizontal) ? '&#9660' : '&#9658';
	var left = parseInt(box.getStyle('paddingLeft'));
	var item;
	box.titleSpan = box.appendChild(document.createElement('div'));
	box.titleSpan.style.display='none';
	
	for (var i=0;i<menuObject[str].items.length;i++){
		item = menuObject[str].items[i];
		if (!item.length){
			if (!box.horizontal){
				box.appendChild(document.createElement('hr')).style.width='1px'
				var followhr = true;
			}
		}
		else{
			d = $(document.createElement('div'));
			d.className = 'menuItem';
			try{
				d.disabld = !eval(item[2]);
			}
			catch(err){
				d.disabld = true;
			}
			if (d.disabld)
				d.style.color = 'lightgrey'
			a=[item[0]]
			
			if (typeof(item[1])=='string' && !hideArrows)
				a.push('<span>'+arrow+'</span>');
			d.fx = item[1];
			d.condition = item[2];
			d.innerHTML = a.join('');
			box.appendChild(d)
			if(followhr){
				d.style.marginTop='-7px'
				followhr = false;
			}
			if(box.horizontal){
				d.style.position = 'absolute';
				d.style.left = left+(parseInt(d.getStyle('marginLeft') || 0))+'px';
				left += d.offsetWidth+(parseInt(d.getStyle('marginLeft') || 0))+(parseInt(d.getStyle('marginRight') || 0));
			}
		}
	}
	var hrs = box.getElementsByTagName('hr');
	var width = box.offsetWidth-12;

	for (var i=0;i<hrs.length;i++){
		hrs[i].style.width = width+'px';
		hrs[i].style.marginTop = '-4px'
	}
	if (box.horizontal){
		box.style.width = (left-parseInt(box.getStyle('paddingLeft')))+'px'
		box.style.height = d.offsetHeight+'px';
	}
	menuObject2[str] = box;
	return box;
}


function closeMenu (e) {
	var t= $(e.srcElement || e.target);
	var elm = t;
	while (t && !$(t).dMenu && t.tagName != 'BODY'){
		t = $(t.parentNode);
	}

	var ea = [];
	if (t && t.selectedItem && t.selectedItem.subMenu){
		ea.push(t.selectedItem.subMenu)
	}
	
	while (t && t.dMenu && !t.hideOnClick){
		alert(t.innerHTML)
		ea.push(t)
		if (t.parentMenu){
			if (t == t.parentMenu){
				alert('error:circular reference')
				return;
			}
			t=t.instigator.parentNode
		}
		else
			t=null
	}
	var mo = menuObject2;
	var moi;
	for(var i in mo){
		moi = mo[i];
		if (mo.hasOwnProperty(i)){
			if (ea.indexOf(moi) == -1 && elm != moi.linkElm){
				if (moi.placement != 'inline'){
					moi.close();
				}
				moi.autoOpen = false;
				if (moi.selectedItem){
					moi.selectedItem.removeClassName('sel')
					moi.selectedItem = null;
				}
			}
		}
	}
}

// removed july 2009 tim obrien not needed for newspage at this time.
//Event.observe(window,'load',function () {
//	Event.observe(document.body,'click',closeMenu)
//})

/*
									End of dmenu.js
									
									
									Start of jsform.js
*/
CSSRule('.formHdr',{backgroundColor:'#eee',borderBottom:'1px solid #666',padding:'8px 24px 8px 8px'});
CSSRule('.jsForm .formBody',{padding:'8px',fontSize:'10px',fontFamily:'verdana'});
CSSRule('.formFooter',{backgroundColor:'#eee',borderTop:'1px solid #666',padding:'8px'});
CSSRule('.jsForm',{padding:'0px'});
CSSRule('.jsForm .icon',{padding:'4px 3px',position:'absolute',top:'6px',cursor:'pointer'});
CSSRule('.jsForm form',{margin:'0px',fontFamily:'Verdana',fontSize:'12px'});
CSSRule('.jsForm .error',{color:'red'});
CSSRule('.jsForm .title',{fontSize:'14px',fontWeight:'bold',whiteSpace:'nowrap'});
CSSRule('.jsForm .formFooter',{textAlign:'right',padding:'3px 8px',whiteSpace:'nowrap',fontSize:'.8em'});
CSSRule('.jsForm button',{backgroundColor:'#016066',color:'#eee'});

CSSRule('.resultsDiv',{padding:'1px',cursor:'pointer',fontSize:'12px',fontFamily:'verdana'});
CSSRule('.resultsDiv td',{padding:'3px 6px',whiteSpace:'nowrap'});
CSSRule('.resultsDiv .odd',{backgroundColor:'#bbb'});
CSSRule('.resultsDiv .highlight',{backgroundColor:'brown',color:'white'});
CSSRule('.msg',{padding:'6px',backgroundColor:'brown',color:'white',fontWeight:'bold',fontSize:'12px'});
CSSRule('.reportForm td',{padding:'0px 12px 0px 0px',whiteSpace:'nowrap',fontSize:'12px'});
CSSRule('.reportForm .noPad',{padding:'0px'});
CSSRule('.reportForm .colHdr',{fontWeight:'bold',whiteSpace:'nowrap'});
CSSRule('.filter',{cursor:'pointer',textDecoration:'underline'});
CSSRule('.notFound',{color:'red',fontSize:'1.2em'});
CSSRule('.b',{fontWeight:'bold'});
CSSRule('.foundText',{backgroundColor:'#007',color:'#ffd'});
/**************************************************************/
CSI.png =  function (src) {
	// returns either a div with a background image(ie <=6.0) or an image everything else
		
	var i = $(document.createElement('img'));
	i.src = src;
	//if (!window.XMLHttpRequest){
	//	var d = $(document.createElement('div'));
		//d.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="/lib/icons/printer.png",sizingMethod="image")';
	//	d.style.height = (i.height+8)+'px';
	//	d.style.width = (i.width+8)+'px';
	//	i = d;
	//}
	i.className = 'icon';
	return i;
}

/*
//            Drag Drop                              //
var dragObject;
Event.observe(window,'load',function () {
	Event.observe(document.body,'mousemove',function (event) {
		if(dragObject){
			var mousePos = CSI.mouseCoords(event);
			dragObject.style.top  = (mousePos.y - mouseOffset.y)+'px';
			dragObject.style.left = (mousePos.x - mouseOffset.x)+'px';
			//return false;
		}
	});
	Event.observe(document,'mouseup',function (event) {
		dragObject  = null;
		document.body.style.cursor = '';
	});
});
*/

/**************************************************************/
function createMultiOptForm (optObj) {
	// extended select multiple checkboxes
	optObj = optObj || {};

	var f = createForm();
	f.footer.innerHTML = '<button>Save</button>';
	Event.observe(f.footer.getElementsByTagName('button')[0],'click',function () {this.onEnterKey()}.bind(f));
	
	Event.observe(f.formBody,'click',function (e) {
		var t = $(e.srcElement || e.target);
		if (t.tagName == 'DIV' && t.firstChild.click)
			t.firstChild.click();
		if (t.tagName == 'DIV' || t.tagName == 'INPUT')
			setTimeout(this.refreshSelColor,10);
	}.bindAsEventListener(f))

	f.refreshSelColor = function () {
		var divs = $A(this.formBody.getElementsByTagName('div'));
		for (var i = 0;i<divs.length;i++){
			if (divs[i].firstChild.checked)
				$(divs[i]).addClassName('sel');
			else
				$(divs[i]).removeClassName('sel');
		}
		return this;
	}.bind(f);
	
	return f;
}
// user notifications will continue to on each page load until the user checks the "do not show this message again" checkbox 
// all parms are passed in the optObj and should include at least innerHTML, title, and pid.
// the user pid will be created once "do not show this message again" is checked and the submit button is clicked
// each program must check the user preference for the user/pid combination to determine whether to call this function.
function createUserNotification (optObj) {
	optObj = optObj || {};
	var form = createForm(optObj);
	form.style.zIndex = 1000;
	
	var b = form.getElementsByTagName('button')[0];
	var f = b.parentNode;
	f.style.textAlign = 'left';
	b.innerHTML = 'ok';
	b.style.position = 'absolute';
	b.style.right = '6px';
	var span = document.createElement('span');
	span.innerHTML = '<input type="checkbox" id="doNotShow"><label for="doNotShow">Do not show this message again</label>'; //
	var footer = form.select('.formFooter')[0];
	footer.insertBefore(span,footer.firstChild);
	form.center().show();

	form.onEnterKey = function () {
		if(form.getElementsByTagName('input')[0].checked){
			new Ajax.Request('/wwwroot/remaint/ajax/upduserprefs.cfm',{
				parameters:{user_id:cfo_user_id,pidsOn:'478',pidsOff:''},
				onComplete: function (t) {
					try{eval(t.responseText)}
					catch(err){
						alert('error');
						document.write(t.responseText);
					}
				}
			});
		}
		form.close();
	};
	return form;
}

CSI.dragEvent = function (ev) {
	CSI.dragObject.style.top  = Event.pointerY(ev) - CSI.dragObject.mosY + 'px';
	CSI.dragObject.style.left = Event.pointerX(ev) - CSI.dragObject.mosX + 'px';
};

CSI.registerDragEvent = function () {
	Event.observe(document.body, 'mousemove', CSI.dragEvent);
};

CSI.unregisterDragEvent = function () {
	Event.stopObserving(document.body, 'mousemove', CSI.dragEvent);
};

//creates a customizable form that has an onEnter function
function createForm (optObj) {
	optObj = optObj || {};
	
	/* will be false for undefined, false, '', null, and 0 */
	optObj.hideOnBlur = !!optObj.hideOnBlur;
	
	var box = createBox(optObj);
	box.form = box.appendChild($(document.createElement('form')));
	box.form.onsubmit = function () {return false;};
	box.hdr = box.form.appendChild($(document.createElement('div')));
	box.hdr.className = 'formHdr';
	box.id = optObj.id || '';
	
	Object.extend(box.style, optObj.style || {});
	Object.extend(box.hdr.style, optObj.headerStyle || {});
	
	/*
	if (!optObj.disableDragDrop){
		Event.observe(box.hdr,'mousedown',function (ev) {
			var e = ev || event;
			var t = $(e.srcElement || e.target);
			if (t.hasClassName('fLink') || t.tagName=='IMG')
				return false;
			
			dragObject = box.parentNode;
			mouseOffset = CSI.getMouseOffset(box.parentNode, e);
			document.body.style.cursor = 'move'
		});
	}
	*/

	if (!optObj.disableDragDrop) {
		if (!CSI.dragObject) {
			CSI.dragObject = null;
		}

		Event.observe(box.hdr, 'mousedown', function (ev) {
			var elm = Event.element(ev);
			if (elm.hasClassName('fLink') || /img/i.test(elm.tagName)) {
				return false;
			}
			
			CSI.dragObject = box.parentNode;
			var mouseOffsets = CSI.getMouseOffset(box.parentNode, ev);
			
			Object.extend(CSI.dragObject, {
				 mosX : mouseOffsets.x
				,mosY : mouseOffsets.y
			});
			
			box.style.cursor = 'move';
			CSI.registerDragEvent();
		});
		
		Event.observe(box.hdr, 'mouseup', function (ev) {
			var elm = Event.element(ev);
			if (elm.hasClassName('fLink') || /img/i.test(elm.tagName)) {
				return false;
			}
			CSI.dragObject  = null;
			box.style.cursor = '';
			CSI.unregisterDragEvent();
		});
	}
	box.titleSpan = box.hdr.appendChild($(document.createElement('span')));
	box.titleSpan.className = 'title';
	box.rightMargin = 4;

	if (!optObj.insert && !optObj.disableClose) {
		var i = $(document.createElement('img'));
		i.className='icon';
		i.style.right = box.rightMargin+'px';
		i.src = optObj.closeImg || '/wwwroot/lib/csitools/2.0/close_small.gif';
		i.title = "Close";
		box.hdr.appendChild(i);
		box.rightMargin += (i.offsetWidth + 6);

		Event.observe(i, 'click', function () {
			box.close();
			
			if (optObj.onClose) {
				optObj.onClose.call(box);
			}
		});
		
		Object.extend(i.style, optObj.closeImgStyle || {});
	};
	box.addClassName('jsForm');
	box.formBody = box.form.appendChild($(document.createElement('div')));
	box.formBody.className = 'formBody';
	Object.extend(box.formBody.style, optObj.bodyStyle || {});
	
 	if (box.fullScreen) {
		optObj.noFooter = true;
		
		var subX = (parseInt(box.hdr.style.paddingLeft, 10) + parseInt(box.hdr.style.paddingRight, 10) + 2) || 18;
		var subY = (parseInt(box.formBody.style.paddingTop, 10) + parseInt(box.formBody.style.paddingBottom, 10) + 2) || 18;
		
		Object.extend(box.style, {
			width: (window.innerWidth || document.viewport.getWidth()) - 2 + 'px'
			,height: (window.innerHeight || document.viewport.getHeight()) - 2 + 'px'
		});
		box.parentNode.style.top  = '0px';
		box.parentNode.style.left = '0px';
		
		setTimeout(function () {
			box.formBody.setStyle({
				height: (box.getHeight() - box.hdr.offsetHeight - subY) +'px'
				,overflowY: 'auto'
			})
		}, 0);
	}
	
	// keepOpen  [ checked | unchecked ]
	
	Object.extend(box, formMethods);
	
	if (optObj.formMethods) {
		Object.extend(box,optObj.formMethods);
	}
	
	if (optObj.title){
		box.setTitle(optObj.title);
	}
	
	if (!optObj.noFooter) {
		box.footer = box.appendChild($(document.createElement('div')));
		
		if (optObj.keepOpen) {
			var div = box.footer.appendChild($(document.createElement('div')));
			div.innerHTML = '<input type="checkbox" class="keepOpen" onclick="CSI.updPrefs(2,this.checked);"><span onclick="this.previousSibling.click();" style="cursor:pointer">Keep this form Open</span>';
			div.style.lineHeight = '1px'
			div.style.cssFloat = div.style.styleFloat = 'left';
			var k = box.keepOpenCkBx = div.getElementsByClassName('keepOpen')[0];
			k.setStyle({position:'relative',top:'3px'});
			if (optObj.keepOpen == 'checked'){
				box.keepOpenCkBx.checked=true;
			}
		}
		box.footer.className = 'formFooter';
		box.button = box.footer.appendChild(document.createElement('button'));
		box.button.innerHTML = optObj.buttonText || 'Save';
		Event.observe(box.button,'click',function (ev) {box.onEnterKey(ev)}.bindAsEventListener(box));
	}

	var boxCloseMethod = box.close;

	box.close = function () {
		if (this.pushed) {
			popForm(true)
		};

		boxCloseMethod.call(box);
		return box;
	}

	box.__insert = box.insert;
	
	Event.observe(box,'keydown',box.handleKeys.bindAsEventListener(box));
	
	if (optObj.innerHTML){
		if (typeof optObj.innerHTML === 'string') box.formBody.innerHTML = optObj.innerHTML;
		if (typeof optObj.innerHTML === 'object') box.formBody.appendChild(optObj.innerHTML);
		box.finish();
	}
	box.hideOnBlur = optObj.hideOnBlur;
	return box;
}

//chkDiv
CSSRule ('.chkDivChecked',{backgroundColor:'#ccc'});
CSSRule ('.chkDiv',{marginRight:'2px'});

formMethods = {
	updateValues : function (updateObj) {
		var o = updateObj;
        for (var i in o){
            if (o.hasOwnProperty(i)){
                if (this.form[i]){
                    if (this.form[i].type=='checkbox'){
						//alert(i);
						if(this.form[i].parentNode.check) 
							this.form[i].parentNode.check(!!o[i]);
						else
							this.form[i].checked = !!o[i];
                    }
                    else 
                        this.form[i].value = o[i];
                }
            }
        }
		return this;
	}
	,getValues : function () {
		// returns a hash object with name/value pairs.  includes checkboxes that are not checked (value = '')
		var vObj = {};
		var a = this.form.getInputs('checkbox');
		for (var i=0; i<a.length; i++){
			vObj[a[i].name] = a[i].getAttribute('offValue') || "";
			//if (a[i].name == 'headHeadlineTextDecoration')
				//alert('xx:'+a[i].getAttribute('offValue'));
			//alert(a[i].name+':'+a[i].getAttribute('offValue'));
		}
		Object.extend(vObj,this.form.serialize(getHash=true));
		return vObj;
	}
	,saveValues : function () {
		this.savedValues = this.getValues();
	}
	,getChanged : function () {
		// returns null if nothing changed otherwise an object with the name of each changed item and a 2 item array of values {name:[oldval,newval],...}
		var s = this.savedValues || {};
		var c = this.getValues();
		var o ={};
		var changed = false;
		for (var i in s){
			if (s.hasOwnProperty(i)){
				if (s[i] != c[i]){
					o[i] = [s[i],c[i]];
					changed = true;
				}
			}
		}
		return changed ? o : null;
	}
	,done : function () {
		if (this.keepOpenCkBx){
			if (this.keepOpenCkBx.parentNode.style.visibility == 'hidden' || !this.keepOpenCkBx.checked ){
				this.close();
			} else {
				this.resetVals().focus();
			}
		} else {
			this.close();
		}
		return this;
	}
	//sets the title of the form, uses a div on the top of the form
	,setTitle : function (str,styleObj) {
		menuMethods.setTitle.call(this,str,styleObj)
		return this;
		//this.titleSpan.innerHTML = str;
	}
	//adds a button to the footer
	,addButton : function (obj) {
		var str = obj.str || '';
		var fx = obj.fx || function () {};
		var b = this.footer.insertBefore(document.createElement('button'),this.footer.getElementsByTagName('button')[0]);
		b.innerHTML = str;
		Event.observe(b,'click',fx);
	}
	//resets the value of any item on the form, or all of them
	,resetVals : function () {
		var defaultVal, prompt, ai;
		if (!this.elms)
			this.elms = this.form.getElements();
		//alert(this.elms.length+':'+this.form.getElements().length);
		var a = this.elms;
		for (var i=0;i<a.length;i++){
			ai = a[i];
			//alert(ai.name+':'+ai.value+':'+ai.checked+':'+ai.getAttribute('defaultVal'));
			if (ai.autoSuggest)
				ai.searchResults = undefined;
				
			defaultVal =  ai.getAttribute('defaultVal');
			if (ai.type == 'checkbox'){
				//ai.checked = (defaultVal == 'checked') ? true : false;
				//alert(a[i].name+':'+defaultVal);
				
				if(ai.parentNode.hasClassName('chkDiv'))  // if it's a chkDiv,
					ai.parentNode.check(!!defaultVal)  //  use the method to turn if on/off
				else
					ai.checked = !!defaultVal ;
			}
			else {
				ai.style.color = '';
				if (defaultVal)
					ai.value = defaultVal;
				else {
					prompt = ai.getAttribute('prompt');
					if (prompt){
						ai.value=prompt;
						ai.style.color = '#999';
					}
					else
						ai.value = '';
				}
			}
		}
		return this;
	}
	/* USE .show() instead */
	//shows box and puts shadow over body, body is not clickable
	,push	:	function () {
		pushForm(this.parentNode,{opacity:.25})
		this.pushed = true;
		//this.formBody.style.width = (this.offsetWidth+2)+'px';
		if (this.fullScreen){
			this.parentNode.style.top = this.parentNode.style.left = '0px';
		}
		if (this.keepOpenCkBx) {
			this.keepOpenCkBx.checked = (window.aids && aids.indexOf(2) > -1) ? true : false;
		}
		if (this.resultsDiv){
			this.resultsDiv.parentNode.style.zIndex = parseInt(this.parentNode.style.zIndex)+2;
		}
		return this;
	}
	,finish : function () {
		this.elms = this.form.getElements();

		var myElms = $A(this.elms)
		myElms.push(this.getElementsByTagName('button')[0]);
		
		this.dates = [];
		var popupCalendar = false, prompt;
			
		if (this.form.select('.popupDate').length > 0) {
			popupCalendar = true;
		}

		// if footer is disabled and no button elements exist,
		// last value will be undefined and the form will break
		if (myElms[myElms.length-1] === undefined) {
			myElms.pop();
		}
		else {	
			for (var i=0;i<myElms.length;i++){
				var elm = $(myElms[i]);
				if (elm.autoSuggest) {
					elm.autoSuggest.minSearchChars = elm.autoSuggest.minSearchChars || 
						((typeof(elm.autoSuggest.searchProvider) == 'string') ? 2 : 1);
					Event.observe(elm,'blur',function () {
						this.resultsDiv.close();
					}.bind(this));
					Event.observe(elm,'focus',function (elm) {
						if (elm.searchResults)
							this.processMatches(elm);
					}.bind(this,elm));
					// add a resultsDiv
					if (!this.resultsDiv){
						this.resultsDiv = createBox({shadowWidth:3,shadowOpacity:50});
						this.resultsDiv.addClassName('resultsDiv');
						this.resultsDiv.parentForm = this;

						var close = this.close;
						this.close = function () {
							if (this.http && this.http.transport.readyState != 4)
								this.http.transport.abort();
							this.resultsDiv.removeHighlight();
							this.resultsDiv.close();
							close.call(this);
						}
						
						
						Object.extend(this.resultsDiv,resultsDivMethods);
						var cachedShowMethod = this.resultsDiv.show;
						
						this.resultsDiv.show = function () {
							
							this.style.overflow = this.style.height = this.style.width = '' ;
							var elm = this;
							var top = 0;
							getScroll();
							while (elm && elm != 'BODY' && elm != 'HTML'){
								top += elm.offsetTop;
								elm = elm.offsetParent;
							}
							var distanceFromTop = top - scrollTop;
							var distanceFromBottom = windowHeight - distanceFromTop;
							if (this.offsetHeight > distanceFromBottom){
								this.style.height = (distanceFromBottom-17)+'px';
								this.style.width = (this.offsetWidth + 13)+'px'
								this.style.overflow = 'auto';
								this.scrollTop = 0;
							}

							return cachedShowMethod.call(this);
						}.bind(this.resultsDiv);

						Object.extend(this,searchMethods);

						this.resultsDiv.moBound = this.resultsDiv.mouseover.bind(this.resultsDiv);
						Event.observe(this.resultsDiv,'mouseover',this.resultsDiv.moBound)
					}
				}

				if (elm.hasClassName('popupDate') || elm.getAttribute('popupDate')){
					this.dates.push(elm);
					Event.observe(elm,'focus',showCalendarControl.bind(this,elm));
					Event.observe(elm,'click',function (e) {showCalendarControl(this);Event.stop(e)}.bindAsEventListener(elm));
					Event.observe(elm,'blur',validateDate.bind(this,elm));
					Event.observe(elm,'change',function () {this.validate='wait'}.bind(elm));
				}
				else {
					if (popupCalendar)
						Event.observe(elm,'focus',hideCalendarControl.bind(this,elm));
				}
				if (prompt = elm.getAttribute('prompt')){
					Event.observe(elm,'blur',function () {
						var prompt = this.getAttribute('prompt');
						if (trim(this.value) == '')
							this.value = prompt;
							
						this.style.color = (this.value==prompt) ? '#999' : '';
					}.bind(elm));
					Event.observe(elm,'focus',function () {
						var prompt = this.getAttribute('prompt');
						if (trim(this.value) == prompt){
							var oThis = this
							setTimeout(function () {oThis.select()},150);
						}
					}.bind(elm));
					Event.observe(elm,'keyup',function () {
						var prompt = this.getAttribute('prompt');
						if (trim(this.value) == prompt)
							this.style.color = '#999'
						else
							this.style.color = '';
					}.bind(elm));
					if (elm.value == ''){
						elm.value = prompt;
						elm.style.color = '#999';
					}
				}
				if (elm.getAttribute('date'))
					Event.observe(elm,'blur',validateDate.bind(this,elm));
			}
		}

		var a = this.form.select('.chkDiv');
		var cb, ts;
		for (var i=0;i<a.length;i++){
			cb = document.createElement('input');
			cb.type = 'checkbox';
			
			//chkDiv
			cb.setAttribute('defaultVal',a[i].getAttribute('defaultVal'));
			cb.setAttribute('value',a[i].getAttribute('value'));
			//cb.setAttribute('name',a[i].getAttribute('name'));
			cb.name = a[i].getAttribute('name');
			cb.setAttribute('offValue',a[i].getAttribute('offValue'));
			
			ts = document.createElement('span');
			ts.innerHTML = a[i].getAttribute('label');
			Object.extend(a[i].style,{padding:'0px 4px 2px 1px', cursor:'pointer',  display:'inline-block'});//border:'1px solid #999',
			a[i].check = function (checked) { // if no parm is passed will return current setting.  pass true to turn on or false to turn off.
				if (checked == undefined){
					checked = this.getAttribute('checked');
					return (checked=='false') ? false : checked;
				}
				return this.setClass(checked);
			};
			a[i].setClass = function (checked) {
				this.setAttribute('checked',checked)
				this.firstChild.checked = checked;
				(checked) ? this.addClassName('chkDivChecked') : this.removeClassName('chkDivChecked');
				return checked;
			};
			//alert(a[i].parentNode.innerHTML);
			cb.getValue = function () {
				return this.checked ? this.value : this.getAttribute('offValue');
			};
			Event.observe(a[i],'click',function () {
				var checked = this.getAttribute('checked');
				checked = (checked=='false') ? true : !checked;
				this.setClass(checked);
			}.bind(a[i]));
			a[i].appendChild(cb);
			a[i].appendChild(ts);
			//alert(a[i].parentNode.innerHTML);
		}
		this.elms = this.form.getElements();
		return this;
	}

	,insert	:	function (elm) {
		this.getElementsByClassName('closeImg')[0].style.display='none';
		this.close = function () {return}
		this.__insert(elm);
	}
	//what the box will do when the default button is pressed, or the enter key is pressed
	,onEnterKey		:	function () { alert('Error!\nMissing onEnterKey callback function.');}
	
	,focus			:	function () {
		var tries = 0;
		var oThis = this;
		if (!this.elms)
			this.elms = this.form.getElements();
		var fx = function () {
			if (!oThis.elms.length){
				return;
			}
			//try {oThis.elms[0].focus()}
			try {oThis.form.focusFirstElement()}
			catch (err) {
				if (tries++ < 5)
					setTimeout(fx,50)
			};
		}
		setTimeout(fx,50);
		return this;
	}
	,onkeypress		:	function (e) {
		var vChars;
		var ev = (e)?e:event;
		var t = $(ev.srcElement || ev.target);
		var k = ev.keyCode || ev.charCode;
		if (k==9)
			return;
			
		if (vChars = t.getAttribute('vChars'))
			vChars = vChars.split('');
		else
			return k!=13 || t.tagName == 'TEXTAREA';
		if (vChars.indexOf(String.fromCharCode(k))==-1)
			return false
	}
	,reset	: function () {this.form.reset();return this}
	,cursorPos : function (elm) {
		
		var i=elm.value.length+1;
		if (elm.createTextRange){
			theCaret = document.selection.createRange().duplicate();
			elm.selectedLength = theCaret.text.length
			while ( theCaret.parentElement() == elm	&& theCaret.move("character",1)==1 ) 
				--i;
		}
		return  i-1
	}
	,handleKeys 	:	function (e) {
		var t = $(e.srcElement || e.target);
		var k = e.keyCode;
		if (k==13){
			if (t.tagName === 'TEXTAREA') 
				return;
			this.onEnterKey(e);
			Event.stop(e);
			return;
		}
		
		if(e.ctrlKey && k != 17)
			if (k == 88 || k == 86 || k==67)
				return;
		
		if (k!=9){
			var digits = t.getAttribute('digits');
			if (digits){
				var a = digits.split('.')
				digits = a[0];
				var decimal = (a.length>1) ? a[1] : 0;
			}
		}
		if (!digits && k!=9)
			return;
			
		if (k==39 || k==37 || k==46 || k==8 || k==35 || k==36) //allowed keys
			return;

		t.cursorPos = this.cursorPos(t);
		
		var ta = t.value.split('');
		var d=null;
		
		var a = t.value.split('.')
		
		for (var i=0;i<ta.length;i++){
			if (ta[i]=='.'){
				d=i;
				break;
			}
		}
		if (k!=9){
			if (digits && (a.length==1 || d >= t.cursorPos) && a[0].replace(/,/g,  '').length >= digits && k!=190 && !t.selectedLength){
				Event.stop(e)
				return
			}
			if (a.length > 1 && decimal && ((d < t.cursorPos && a[1].replace(/,/g,  '').length >= decimal) || k==190)){
				Event.stop(e)
				return
			}
		
			if (!(k >= 48 && k<=57) && !(k >= 96 && k<=105))
				if (!decimal || k!=190){
					Event.stop(e)
					return
				}
		}
		if(k==9){
			var myElms = $A(this.elms)
			var buttons = this.getElementsByTagName('button');
			for (var i =0;i<buttons.length;i++)
				myElms.push(buttons[i]);
				
			if(t==myElms[0] && e.shiftKey)
				var toElm = myElms[myElms.length-1]
			else if (t==myElms[myElms.length-1] && !e.shiftKey)
				var toElm = myElms[0]

			if (toElm){
				CSI.clearSelection();
				toElm.focus();
				if (toElm.select)
					toElm.select();
				Event.stop(e);
			}
		}
	}
}

function createSearchForm (optObj) {
	optObj = optObj || {}
	f = createForm(optObj);
	f.formBody.innerHTML = '<span style="display:inline;overflow:auto"><input type=text></span>'
	f.searchInput = f.formBody.getElementsByTagName('input')[0];
	var rsw = optObj.resultsShadowWidth==undefined ? 3 : optObj.resultsShadowWidth;
	var rso = optObj.resultsShadowOpacity==undefined ? 50 : optObj.resultsShadowOpacity;
	f.resultsDiv = createBox({shadowWidth:rsw,shadowOpacity:rso});
	f.resultsDiv.addClassName(optObj.resultsClassName || 'resultsDiv');
	f.resultsDiv.innerHTML = 'aaa';
	f.titleSpan.innerHTML = optObj.Title || 'Search';
	f.resultsDiv.position(f.searchInput).adjLeft(1).adjTop(1);
	f.resultsDiv.parentForm = f;
	f._sf_positionShadow = f.positionShadow;
	f._sf_close = f.close;
	f.resultsDiv._rd_show = f.resultsDiv.show;
	Object.extend(f.resultsDiv,resultsDivMethods);
	Object.extend(f,searchMethods);
	f.resultsDiv.moBound = f.resultsDiv.mouseover.bind(f.resultsDiv);
	Event.observe(f.resultsDiv,'mouseover',f.resultsDiv.moBound)
	
	Event.observe(f.resultsDiv,'click',f.resultsDiv.on_click.bindAsEventListener(f.resultsDiv))

	Event.observe(f.searchInput,'click',function () {
		if (this.searchResults && this.searchResults.length > 0){
			//$('ta').value += 'settimeout;';
			setTimeout(this.resultsDiv.show.bind(this.resultsDiv),25);
		}
	}.bind(f));
	return f;
}

searchMethods = {
	onclick : function (ev) {
		e = ev || event;
		t = $(e.srcElement || e.target);
		if (t.autoSuggest && t.searchResults)
			this.processMatches(t);
	}

	,onkeydown: function (ev) {
		var e = ev || event;
		if (e.keyCode == 38){	// up arrow
			if (this.resultsDiv.highlighted)
				this.move($(this.resultsDiv.highlighted.previousSibling))
			Event.stop(e);
		}else if (e.keyCode == 40){ 	// down arrow
			if (this.resultsDiv.highlighted)
				this.move($(this.resultsDiv.highlighted.nextSibling))
			Event.stop(e);
		}else if (e.keyCode == 27) {   // esc
			this.resultsDiv.close();
			this.resultsDiv.removeHighlight();
			Event.stop(e);
		}
	}
	,getSearchInput : function (e) {
		var t = $(e.srcElement || e.target);
		if (!t.autoSuggest)
			return null;
		return t;
	}
	,onkeyup	: function (ev) {
		e = ev || event;
		var searchInput = this.getSearchInput(e);
		if (!searchInput)
			return;
			
		if (searchInput.savedValue && trim(searchInput.savedValue) == trim(searchInput.value))
			return;
		searchInput.savedValue = searchInput.value
		if (searchInput.timeoutId){
			clearTimeout(searchInput.timeoutId);
			searchInput.timeoutId = null;
		}
		var oThis = this;
		if (e.keyCode == 8 || e.keyCode == 32 || (e.keyCode >= 46 && e.keyCode <= 111) || e.keyCode >123){
			if (this.resultsDiv.hasClassName('msg'))
				this.resultsDiv.close();
				
			this.resultsDiv.removeHighlight();
			searchInput.searchResults = null;
			if (searchInput.value.strip().length >= searchInput.autoSuggest.minSearchChars){
				if (typeof(searchInput.autoSuggest.searchProvider) == 'function'){
					searchInput.searchResults = searchInput.autoSuggest.searchProvider();
					this.processMatches(searchInput);
				}
				else if (typeof(searchInput.autoSuggest.searchProvider) == 'string')
					this.timeoutId = setTimeout(function () {
						oThis.search(searchInput);},225);

				if (this.http){
					if (this.http.transport.readyState != 4) {
						this.http.transport.abort();
					}
					this.http.transport.readyState = 5;
				}
			}
			else {
				this.resultsDiv.close();
				this.searchResults = null;
			}
		}
					
	}
	,search	: function (searchInput) {
		if (this.http){
			this.http.transport.abort();
		}
		var parms = {data:searchInput.value};
		if (this.parameters)
			Object.extend(parms,this.parameters);
			
		this.http = new Ajax.Request(searchInput.autoSuggest.searchProvider+'?data='+this.searchInput.value,{
			parameters:parms
			,method:'post'
			,onSuccess:function (t) {eval(t.responseText)}.bind(this)
		})
		this.timeoutId = null;
	}
	,noMatches:function () {
		var rd = this.resultsDiv;
		rd.innerHTML = 'No Matches';
		rd.removeHighlight();
		rd.addClassName('msg').show()
	}
	,highlight : function (i) {
		var trs = this.resultsDiv.getElementsByTagName('tr')
		//if (!trs || !trs.length)
		//	return;
		this.resultsDiv.removeHighlight();
		$(trs[i]).addClassName('highlight');
		this.resultsDiv.highlighted = trs[i];
	}
	,move : function (elm) {
		if (elm){
			var rd = this.resultsDiv;
			var h = this.resultsDiv.highlighted;
			if (h) 
				h.removeClassName('highlight')
			elm.addClassName('highlight')
			rd.highlighted = elm;
			var table = rd.firstChild;
			if (table.offsetHeight > rd.offsetHeight){
				if (elm.offsetTop+elm.offsetHeight > rd.offsetHeight+rd.scrollTop){
					Event.stopObserving(rd,'mouseover',rd.moBound);
					rd.scrollTop += elm.offsetHeight;
					rd.timeoutId = setTimeout(function () {Event.observe(rd,'mouseover',rd.moBound)},25)
				}
				else
				if (elm.offsetTop < rd.scrollTop){
					Event.stopObserving(this.resultsDiv,'mouseover',this.resultsDiv.moBound)
					rd.scrollTop -= elm.offsetHeight;
					rd.timeoutId = setTimeout(function () {Event.observe(rd,'mouseover',rd.moBound)},25)
				}
			}
		}
	}
	,onEnterKey : function (ev) {
		e = ev || event;
		var searchInput = this.getSearchInput(e);
		if (!searchInput)
			return;

		var tries = 0;
		var oThis = this;
		var rd = this.resultsDiv;
		
		if (!rd.highlighted)
			return;
			
		// waitForAjax is only needed if search Provider is an ajax program.  this handles the situation where the user hit 
		// enter before the ajax program displayed.  wait for the response, then select the first result from searchResults;
		if (typeof(searchInput.autoSuggest.searchProvider)=='string'){
			var waitForAjax = function () {
				if (tries++ > 100){
					alert('timed out');
					return;
				}
				if (!oThis.timeoutId && !oThis.http)
					return;
			
				if (oThis.timeoutId || oThis.http.transport.readyState != 4 || oThis.resultsDiv.style.visibility=='hidden'){   // pending Ajax request
					setTimeout(fx,50)
					return;
				}
	
				if ((searchInput.value.length < searchInput.autoSuggest.minSearchChars)
				&& (rd.parentNode.visibility == 'hidden' || rd.hasClassName('msg'))){
					alert('Please enter at least \n'+searchInput.autoSuggest.minSearchChars+' characters to search.')
					return;
				}
				
				if (rd.hasClassName('msg')){
					return;
				}
				
				if (searchInput.autoSuggest.onSelect && rd.highlighted){
					searchInput.autoSuggest.onSelect.call(searchInput,e,rd.highlighted.getAttribute('i'));
					window.clearTimeout(rd.showTimeout)
					setTimeout(function () {rd.close()},25);
				}
			};
			waitForAjax();
			return;
		}
		searchInput.autoSuggest.onSelect.call(searchInput,e,rd.highlighted.getAttribute('i'))
		rd.close();
	}
	,ondblclick : function () {
		if (this.searchResults){
			this.resultsDiv.show();
		}
	}
	,createCells : function (i) {  // this function should normally be overwritten
		return '<td>tim is great</td>';
	}
	,processMatches : function (searchInput) {
		var sr = searchInput.searchResults;
		var rd = this.resultsDiv;
		if (!sr || !sr.length){
			if (searchInput.autoSuggest.onNoResults)
				searchInput.autoSuggest.onNoResults.call(searchInput);
			else
				rd.close();
			return;
		}
				
		rd.removeClassName('msg')
		var a = ['<table cellspacing=0 cellpadding=0>'];
		for (var i = 0;i<sr.length;i++){
			a.push('<tr i="'+i+'"')
			if (!(i%2))
				a.push(' class="odd"');
			a.push('>'+searchInput.autoSuggest.resultsFilter(sr[i])+'</tr>')
		}
		a.push('</table>');
		rd.innerHTML = a.join('');
		rd.style.width = '';
		var w = rd.offsetWidth;
		var sIw = searchInput.offsetWidth;
		if (w < sIw)
			$(rd.getElementsByTagName('table')[0]).setStyle({width:(sIw-5)+'px'})
		
		rd.onSelect = searchInput.autoSuggest.onSelect.bind(searchInput) || function () {};
		rd.position(searchInput).show();
		this.highlight(0);
	}
}
resultsDivMethods = {
	mouseover : function (ev) {
		var e = ev || event;
		t = $(e.srcElement || e.target);
		if (t.tagName == 'TD'){
			var tr = t.parentNode;
			if (tr == this.highlighted)
				return;
			if (this.highlighted)
				this.highlighted.removeClassName('highlight');
			$(tr).addClassName('highlight');
			this.highlighted = tr;
		}
	}
	,removeHighlight : function () {
		if (this.highlighted){
			this.highlighted.removeClassName('highlight');
			this.highlighted = null;
		}
	}
	,onclick : function (e) {
		var ev = e || event;
		var t = $(ev.srcElement || ev.target);
		if (this.onSelect && this.highlighted){
			this.onSelect(e,this.highlighted.getAttribute('i'));
		}
	}
}
/*
							End of jsform.js
							
							
							
							
							
							
							
							
							
							
							
							
							
							
							
							Start of pushform.js
*//*
pushformVPath = "/wwwroot/lib/csitools/2.0/";
var d = new Date().getTime();
document.write('<iframe name="timiscool" id="testFrame" style="display:none" src="'+pushformVPath+'pushform.html?'+d+'"></iframe>')
//*/

overlayArray=[];

Event.observe(window, 'load', function () {
	Event.observe(document, 'keyup', function (e) {
		if (e.keyCode == 27) {
			if(overlayArray.currentPage >= 0) {
				history.go(-1);
				insertDivReg();// calling insert DivReg with no div parameter, will result in all divs being flushed;
			}
		}
	}.bindAsEventListener(this))
})

initScript = '<script>alert(37);par=window.parent;'+
	'if(par.overlay)'+
	'	par.cleanupOverlay(-1);'+
	'if (par.overlayArray && par.overlayArray.reInit){'+
	'	par.overlayArray.reInit()'+
	'}</script>'
	
overlayArray.truncate = function (index) {
	for (var i = index; i < overlayArray.length; i++) {
		overlayArray.close(i)
	}
}


function pushForm (div, optionsObj) {
	optionsObj = optionsObj || {};
	var last=prev=0; 

	truncateOverlayArray();

	getScroll();
	if (window.pageYOffset)	{
		  var scrollTop = window.pageYOffset
		  var scrollLeft = window.pageXOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop)	{
		var scrollTop = document.documentElement.scrollTop
		var scrollLeft = document.documentElement.scrollLeft
	}
	else if (document.body){
		  var scrollTop = document.body.scrollTop
		  var scrollLeft = document.body.scrollLeft
	}
	
	if (window.innerHeight){
		var windowHeight = window.innerHeight
		var windowWidth = window.innerWidth
	}
	else if (document.documentElement && document.documentElement.clientHeight)	{
		var windowHeight = document.documentElement.clientHeight
		var windowWidth = document.documentElement.clientWidth
	}
	else if (document.body)	{
		var windowHeight = document.body.clientHeight;
		var windowWidth = document.body.clientWidth;
	}
	if (overlayArray.length==0)
		var currentZ = 0;
	else {
		var x = overlayArray.length-1;
		while (overlayArray[x] && !overlayArray[x].style && x > 0)
			x--;
		if (overlayArray[x] && overlayArray[x].style)
			var currentZ = parseInt(overlayArray[x].style.zIndex)
		else
			var currentZ = 0;
	}
	
	if (!window.overlay){
		overlay = document.createElement('div');
		overlay.id = 'overlay';
		overlay.onclick='event.cancelBubble=true';
		overlay.style.position='absolute';
		overlay.style.top='0px';
		overlay.style.left='0px';
		overlay.style.display='none';
		overlay.style.opacity='.5';
		overlay.style.filter='Alpha(Opacity=50)';
		overlay.style.backgroundColor='black';
		document.body.appendChild(overlay); 
	}
	if (optionsObj.opacity){
		overlay.style.opacity=optionsObj.opacity;
		overlay.style.filter='Alpha(Opacity='+optionsObj.opacity*100+')';
	}
	if (optionsObj.color){
		overlay.style.backgroundColor=optionsObj.color;
	}
	overlay.style.height = document.viewport.getHeight() + 'px';
	overlay.style.width  = document.viewport.getWidth() + 'px';
	
	last = overlayArray.length
	overlayArray[last]= div;
	
	div.screenTop = div.saveScreenTop = scrollTop;

	overlayArray.currentPage = last;
	
	div.style.zIndex = currentZ+20;
	
	var divTop = Math.max(scrollTop, Math.round(scrollTop+((windowHeight-div.clientHeight)/2)))
	var divLeft = Math.round(scrollLeft+((windowWidth-div.clientWidth)/2))
	
	div.style.top = Math.max(divTop,0)+'px'
	div.style.left = Math.max(divLeft,0)+'px'

	var newZ = currentZ+10;
	//div.boundHandler = lockWindow.bindAsEventListener(div);
	//writeScript(initScript)
	writeScript(createDivJs(last,newZ));
}

CSI.fixRefresh = function (idx) {
	if (!overlayArray.reachedStart){
		overlayArray.close(idx);
		history.back();
	}
}
function createDivJs (x,newZ) {
	var a=['<script>;'
	,'	var par=window.parent;'
	,'	var fe, back;'
	,'	var me = '+x+';'
	,'  if (me < par.overlayArray.currentPage) {back = true; };'
	,'	if (par.userClickedRefresh){'
	,'		par.CSI.fixRefresh(me);'
	,'	}else {'
	,'		if(par.overlayArray[me]=="end"){	'
	,'			history.back();	'
	,'		}else if(par.overlayArray[me]=="closed"){	'
	,'			if (back)	{ 	'
	,'				history.back();} '
	,'			else {	'
	,'				history.forward(); }'
	,'		}else if (!par.overlayArray[me]){		'
	,'			par.overlayArray.close(me);	'
	//,'			//par.userClickedRefresh = true;	'
	,'			history.back();	'
	,'		}else{			'
	,'			par.overlay.style.display="";'
	,'			par.overlay.style.zIndex='+newZ+'; '
	,'			par.overlayArray[me].style.visibility="visible";'
	,'			if(par.overlayArray[me].firstChild.focus) par.overlayArray[me].firstChild.focus();'
	,'			par.cleanupOverlay(me);'
	,'		}	'
	,'	}'
	,'</script>'];
	
	return a.join('\n');
}
function createFxJs (x) {
	var a=['<script>'
	,'	par=window.parent;'
	,'	var me = '+x+';'
	,'	par.cleanupOverlay(me);'
	,'	if (par.overlayArray.length-1 > me && par.overlayArray[me+1].style && par.overlay.style.display==""){ '
	,'		par.overlay.style.display="none";'
	,'		par.overlayArray[me+1].style.visibility="hidden";'
	,'	}else if (par.overlayArray[me] == "closed"){	'
	,'		par.overlayArray.close(me);	'
	,'		history.go(-1);	'
	,'	}else if (par.overlayArray[me] == "closed"){	'
	,'		par.overlayArray.close(me);	'
	,'		history.forward();	'
	,'	}else if (par.overlayArray.length-1 >= me){ '
	,'		par.overlayArray[me]();'
	,'	};	'
	,'</script>']
	return a.join('');
}

function truncateOverlayArray () {
	if (window.overlayArray && overlayArray.currentPage < overlayArray.length-1){
		overlayArray.splice(overlayArray.currentPage+1,999)
	}
}




function pushF (fx) {
	truncateOverlayArray();
	var x = overlayArray.length;
	overlayArray[x]= fx;
	overlayArray.currentPage = x;
	writeScript(createFxJs(x))
}

function writeScript (historyScript) {
	if (!window.sessionFrame){
		sessionFrame = $('testFrame');
	}	
	
	var doc = sessionFrame.contentWindow.document;
	if (sessionFrame.contentDocument){
		sessionFrame.src= pushformVPath+'echo.cfm?data='+historyScript;
	}
	else {
		doc.open();
		doc.write(historyScript)
		doc.close();
	}
}

function popForm (destroy) {
	if (destroy){
		overlayArray.close(overlayArray.currentPage);
	}
	history.back();
}

overlayArray.close = function (i) {
	turnItOff(i);
	this[i] = 'closed';
}


function turnItOff (ixx) {
	var item = overlayArray[ixx];
	
	if (!item)
		return;
	if (item.saveScreenTop)
		scroll(0,item.saveScreenTop);
		
	if (item.style)
		item.style.visibility="hidden";

}

 function cleanupOverlay (current) {
	overlayArray.currentPage = current;
	if (current == -1){
		turnItOff(0);
		return;
	} 
	
	for (var i = 0;i<overlayArray.length;i++){
		//Event.stopObserving(document.body,'scroll',overlayArray[i].boundHandler)
		//Event.stopObserving(window,'scroll',overlayArray[i].boundHandler)
		
		if (i>current){
			if (overlayArray[i].style){
				overlayArray[i].style.visibility="hidden";
			}
		}
		else if (i==current){
			if (i+1 < overlayArray.length && overlayArray[i+1].saveScreenTop)
				scroll(0,overlayArray[i+1].saveScreenTop)
			//if (window.parent.isFunction(overlayArray[i].boundHandler)){
			//	Event.observe(document.body,'scroll',overlayArray[i].boundHandler)
			//	Event.observe(window,'scroll',overlayArray[i].boundHandler)
			//}
		}
	}
}

/*
function lockWindow (div) {
	if (window.pageYOffset)	{
		  var scrollTop = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop)	{
		var scrollTop = document.documentElement.scrollTop
	}
	else if (document.body)	{
		  var scrollTop = document.body.scrollTop
	}
	
	if (window.innerHeight)	{
		var clientHeight = window.innerHeight-16
	}
	else if (document.documentElement && document.documentElement.clientHeight)	{
		var clientHeight = document.documentElement.clientHeight
	}

	else if (document.body)	{
		var clientHeight = document.body.clientHeight
	}
	
	
	if (clientHeight >= this.offsetHeight){
		if (scrollTop < this.screenTop){
			if (this.offsetTop+this.offsetHeight > scrollTop+clientHeight){
				scroll(0,this.offsetTop+this.offsetHeight-clientHeight)
				this.screenTop = this.offsetTop+this.offsetHeight-clientHeight
			}
		}
		if (scrollTop > this.screenTop){
			if (scrollTop > this.offsetTop){
				scroll(0,this.offsetTop)
				this.screenTop = this.offsetTop
			}
		}
	}
	else {
		if (scrollTop < this.screenTop){
			if (this.offsetTop > scrollTop){
				scroll(0,this.offsetTop)
				this.screenTop = this.offsetTop
			}
		}
		if (scrollTop > this.screenTop){
			if (this.offsetTop+this.offsetHeight < scrollTop+clientHeight){
				scroll(0,this.offsetTop+this.offsetHeight-clientHeight)
				this.screenTop = this.offsetTop+this.offsetHeight-clientHeight
			}
		}
	}
}
*/



/*
							End of pushform.js
							
							
							
							
							
							
							
							
							
							
							
							
							
							
							
							
							Start of Calendar Control.js
*/
CSSRule('#CalendarControlIFrame', {display:'none',left: '0px', position: 'absolute',top: '0px', height: '250px',width: '250px',zIindex: 99});
CSSRule('#CalendarControl',{position:'absolute',backgroundColor:'#FFF',margin:0,padding:0,display:'none',zIndex: 100});
CSSRule('#CalendarControl table',{fontFamily:'arial, verdana, helvetica, sans-serif',fontSize:'8pt',borderLeft:'1px solid #336',borderRight:'1px solid #336'});
CSSRule('#CalendarControl th',{fontWeight:'normal'});
CSSRule('#CalendarControl th a',{fontWeight:'normal',textDecoration:'none',color:'#FFF',padding:'1px'});
CSSRule('#CalendarControl td',{textAlign:'center'});
CSSRule('#CalendarControl .header',{backgroundColor:'#336'});
CSSRule('#CalendarControl .weekday',{backgroundColor:'#DDD',color:'#000'});
CSSRule('#CalendarControl .weekend',{backgroundColor:'#FFC',color:'#000'});
CSSRule('#CalendarControl .current',{border:'1px solid #339',backgroundColor:'#336',color:'#FFF'});

var tObj = {display:'block',textDecoration:'none',border:'1px solid #FFF',width:'2em'}
CSSRule('#CalendarControl .current',tObj);
CSSRule('#CalendarControl .weekday',tObj);
CSSRule('#CalendarControl .weekend',tObj);

tObj = {border:'1px solid #999',backgroundColor:'#336',color:'#fff'};
CSSRule('#CalendarControl .weekday:hover',tObj);
CSSRule('#CalendarControl .weekend:hover',tObj);
CSSRule('#CalendarControl .current:hover',tObj);

CSSRule('#CalendarControl .previous', {textAlign:'left',padding:'1px 3px 1px 3px',fontSize:'1.4em'});
CSSRule('#CalendarControl .next',{textAlign:'right',padding:'1px 3px 1px 3px',fontSize:'1.4em'});

tObj = {color:'#fff',textDecoration:'none',fontWeight:'bold'};

CSSRule('#CalendarControl .previous a',tObj);
CSSRule('#CalendarControl .next a',tObj);

CSSRule('#CalendarControl .title', {textAlign: 'center',fontWeight: 'bold',color: '#FFF'});

CSSRule('#CalendarControl .empty',{backgroundColor: '#CCC',border: '1px solid #FFF'});

//document.write('<style>@import "/lib/csitools/2.0/calendarcontrol.css";</style>');

function positionInfo (object) {
  var p_elm = object;

  this.getElementLeft = getElementLeft;
  function getElementLeft () {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }

  this.getElementWidth = getElementWidth;
  function getElementWidth () {
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
  }

  this.getElementRight = getElementRight;
  function getElementRight () {
    return getElementLeft(p_elm) + getElementWidth(p_elm);
  }

  this.getElementTop = getElementTop;
  function getElementTop () {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }

	if ((y - document.body.scrollTop) > (document.body.clientHeight/2))
		y = y - (calendar.clientHeight + getElementHeight());
	
    return parseInt(y);
  }

  this.getElementHeight = getElementHeight;
  function getElementHeight () {
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
  }

  this.getElementBottom = getElementBottom;
  function getElementBottom () {
    return getElementTop(p_elm) + getElementHeight(p_elm);
  }
}


Event.observe(window,'load',function () {
	Event.observe(document.body,'click',function (event) {
		var src = event.target || event.srcElement;
		while (src && src.id != 'CalendarControl'){
			src = src.parentNode;
		}
		if (!src || src.id != 'CalendarControl'){
			setTimeout(hideCalendarControl,1);
		}
	})
})

function CalendarControl () {

  var calendarId = 'CalendarControl';
  var currentYear = 0;
  var currentMonth = 0;
  var currentDay = 0;

  var selectedYear = 0;
  var selectedMonth = 0;
  var selectedDay = 0;

  var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var dateField = null;

  /*function getProperty (p_property) {
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object") {
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
  }*/

  function setElementProperty (p_property, p_value, p_elmId) {
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
  }

  function setProperty (p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
  }

  function getDaysInMonth (year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
  }

  function getDayOfWeek (year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
  }

  this.clearDate = clearDate;
  function clearDate () {
    dateField.value = '';
    hide();
  }

  this.setFocus = setFocus;
  function setFocus () {
    dateField.focus();
  }

  this.setDate = setDate;
  function setDate (year, month, day) {
    if (dateField) {
      if (month < 10) {month = "0" + month;}
      if (day < 10) {day = "0" + day;}

      var dateString = month+"/"+day+"/"+year;
      dateField.value = dateString;
      setTimeout(hide,25);
    }
    return;
  }

  this.changeMonth = changeMonth;
  function changeMonth (change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  this.changeYear = changeYear;
  function changeYear (change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  function getCurrentYear () {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
  }

  function getCurrentMonth () {
    return new Date().getMonth() + 1;
  } 

  function getCurrentDay () {
    return new Date().getDate();
  }

  function calendarDrawTable () {
    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";

    table += " <td colspan='2' class='previous'>"
	if (notbefore && currentMonth <= notbefore.getMonth()+1 && currentYear <= notbefore.getFullYear())
		table += "<a style='color:#999999'>&lt;</a>"
	else
		table += "<a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a>" //href='javascript:changeCalendarControlMonth(-1)
		
	if (notbefore && (((currentYear - 1) < notbefore.getFullYear()) || ((currentYear - 1) == notbefore.getFullYear() && currentMonth < notbefore.getMonth()+1)))
		table += "<a  style='color:#999999'>&laquo;</a></td>";
	else
		table += "<a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";

    table += "<td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
	table += "<td colspan='2' class='next'>"
	
	if (notafter && (((currentYear + 1) > notafter.getFullYear()) || ((currentYear + 1) == notafter.getFullYear() && currentMonth > notafter.getMonth()+1)))
	    table = table + "<a style='color:#999999' >&raquo;</a>";
	else
	    table = table + "<a href='javascript:changeCalendarControlYear(1);'>&raquo;</a>";

	if (notafter && (currentMonth >= notafter.getMonth()+1 && currentYear >= notafter.getFullYear()))
		table = table + "  <a style='color:#999999' >&gt;</a></td>";
	else
		table = table + "  <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";

    table = table + "</tr>";
    table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
		if(week == 0 && startDayOfWeek == dayOfWeek) {
			validDay = 1;
		} else if (validDay == 1 && dayOfMonth > daysInMonth) {
			validDay = 0;
		}

		if(validDay) {
			if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
				css_class = 'current';
			} else if (dayOfWeek == 0 || dayOfWeek == 6) {
				css_class = 'weekend';
			} else {
				css_class = 'weekday';
			}
			if (notafter && ((currentYear == notafter.getFullYear() && currentMonth == notafter.getMonth()+1 && dayOfMonth > notafter.getDate()))
			|| (notbefore && (currentYear == notbefore.getFullYear() && currentMonth == notbefore.getMonth()+1 && dayOfMonth < notbefore.getDate())))
				table = table + "<td><a class='"+css_class+"' style='color:#999999' >"+dayOfMonth+"</a></td>";
			else
				table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
			dayOfMonth++;
		} else {
			table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
	}
	if (!dateRequired)
	    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:clearCalendarControl();'>Clear</a> | <a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
	else
	    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
    table = table + "</table>";

    return table;
  }

  this.show = show;
  function show (field) {
    can_hide = 0;
	dateRequired = !!eval(field.getAttribute('required'));  // convert the string "false" and null object to a boolean false
		
	initAfterBefore(field);

	if (dateField == field) {
		return;
	} 
	else {
		dateField = field;
	}

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("/");
        
        selectedMonth = parseInt(dateParts[0],10);
        selectedDay = parseInt(dateParts[1],10);
        selectedYear = parseInt(dateParts[2],10);
      } catch(e) {}
    }
	if (selectedYear < 80) {
		selectedYear += 2000;
	}
	else if (selectedYear < 100) {
		selectedYear += 1900;
	}
	else if (selectedYear < 2099 && selectedYear > 1899) { }
	else {
		selectedYear = null;
	}
		
    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

	if (notafter){
		if (currentYear > notafter.getFullYear() || (currentYear == notafter.getFullYear() && currentMonth > notafter.getMonth()+1) || (currentYear == notafter.getFullYear() && currentMonth == notafter.getMonth()+1 && currentDay > notafter.getDate())){
		    currentMonth = notafter.getMonth()+1;
		    currentDay = notafter.getDate();
		    currentYear = notafter.getFullYear();
		}
		if (selectedYear > notafter.getFullYear() || (selectedYear == notafter.getFullYear() && selectedMonth > notafter.getMonth()+1) || (selectedYear == notafter.getFullYear() && selectedMonth == notafter.getMonth()+1 && selectedDay > notafter.getDate())){
		    selectedMonth = notafter.getMonth()+1;
		    selectedDay = notafter.getDate();
		    selectedYear = notafter.getFullYear();
		}
	}
	
	if (notbefore){
		if (currentYear < notbefore.getFullYear() || (currentYear == notbefore.getFullYear() && currentMonth < notbefore.getMonth()+1) || (currentYear == notbefore.getFullYear() && currentMonth == notbefore.getMonth()+1 && currentDay < notbefore.getDate())){
		    currentMonth = notbefore.getMonth()+1;
		    currentDay = notbefore.getDate();
		    currentYear = notbefore.getFullYear();
		}
		if (selectedYear < notbefore.getFullYear() || (selectedYear == notbefore.getFullYear() && selectedMonth < notbefore.getMonth()+1) || (selectedYear == notbefore.getFullYear() && selectedMonth == notbefore.getMonth()+1 && selectedDay < notbefore.getDate())){
		    selectedMonth = notbefore.getMonth()+1;
		    selectedDay = notbefore.getDate();
		    selectedYear = notbefore.getFullYear();
		}
	}
	

    if(document.getElementById){
		if (!(calendar = $(calendarId))){
			// create the iframe and div for the calendar only when needed.
			var iFrame = document.createElement('iframe');
			iFrame.id = 'CalendarControlIFrame';
			iFrame.frameBorder='1';
			iFrame.scrolling = 'no';
			document.body.appendChild(iFrame);
			
			calendar = document.createElement('div');
			calendar.id = 'CalendarControl';
			calendar.onClick = 'event.cancelBubble=true';
			document.body.appendChild(calendar);
		}
		calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
		setProperty('display', 'block');
		
		if (dateField.calendarPositionParent)
			var fieldPos = new positionInfo(dateField.parentNode);
		else
			var fieldPos = new positionInfo(dateField);
			
		var calendarPos = new positionInfo(calendarId);
		
		var x = fieldPos.getElementLeft();
		var y = fieldPos.getElementBottom();
		
		setProperty('left', x + "px");
		setProperty('top', y + "px");
 
      if (document.all) {
        setElementProperty('display', 'block', 'CalendarControlIFrame');
        setElementProperty('left', x + "px", 'CalendarControlIFrame');
        setElementProperty('top', y + "px", 'CalendarControlIFrame');
        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
      }
    }
  }

  this.hide = hide;
  function hide () {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
  }

  this.visible = visible;
  function visible () {
    return dateField
  }

  this.can_hide = can_hide;
  var can_hide = 0;
}
var calendarControl = new CalendarControl();

function initAfterBefore (field) {
	notafter = new Date();
	notbefore = new Date();

	notafter.setFullYear(2079,11,31)
	notafter.setHours(23,59,59,999)

	notbefore.setFullYear(1900,0,1)
	notbefore.setHours(0,0,0,0)

	if (field.notafter = field.getAttribute('notafter')){
		if (document.getElementById(field.notafter)){
			var myObj = document.getElementById(field.notafter)
			var dateString = trim(myObj.value)
			if (dateString == '' && (myObj.notafter=myObj.getAttribute('notafter')))
				if (!document.getElementById(myObj.notafter))
					dateString = myObj.notafter
		}
		else
			var dateString = field.notafter;
		if (dateString > ' '){
	        var dateParts = dateString.split("/");
			myYear = parseInt(dateParts[2],10);
			if (myYear < 80)
				myYear += 2000;
			else if (myYear < 100)
				myYear += 1900;
			notafter.setFullYear(myYear,parseInt(dateParts[0]-1,10),parseInt(dateParts[1],10))
		}
	}
	
	if (field.notbefore = field.getAttribute('notbefore')){
		if (document.getElementById(field.notbefore))
			var dateString = document.getElementById(field.notbefore).value
		else
			var dateString = field.notbefore;
		if (dateString > ' '){
	        var dateParts = dateString.split("/");
			myYear = parseInt(dateParts[2],10);
			if (myYear < 80)
				myYear += 2000;
			else if (myYear < 100)
				myYear += 1900;
			notbefore.setFullYear(myYear,parseInt(dateParts[0]-1,10),parseInt(dateParts[1],10))
		}
	}
}

function showCalendarControl (textField) {
	calendarControl.show(textField);
}

function clearCalendarControl () {
	var myobj = calendarControl.visible();
	calendarControl.clearDate();
	myobj.focus();
	try {
		if (myObj.fireEvent)
			myobj.fireEvent("onchange");
	} catch (err) { }
}

function hideCalendarControl () {
  if (calendarControl.visible()) {
    calendarControl.hide();
  }
}
function cancelTimeOuts () {
	if (window.myVtimeoutholder) {
		window.clearTimeout(myVtimeoutholder)
	}
}

function setCalendarControlDate (year, month, day) {
	//window.cancelBubble = true;
	var mystring = year + '';
	//year = mystring.substr(2,2)
	var myobj = calendarControl.visible();
	myobj.focus();
	calendarControl.setDate(year, month, day);
	if (myobj.fireEvent) {
		myobj.fireEvent("onchange");
	}
	if (myobj.simulate) myobj.simulate('change');
}

function changeCalendarControlYear (change) {
	if (window.myVtimeoutholder)
		window.clearTimeout(myVtimeoutholder)
	calendarControl.changeYear(change);
	calendarControl.setFocus();
}

function changeCalendarControlMonth (change) {
	if (window.myVtimeoutholder)
		window.clearTimeout(myVtimeoutholder)
	calendarControl.changeMonth(change);
	calendarControl.setFocus();
}

function parseDate (dateString) {
	var myDate = new Date();
    var dateParts = dateString.split("/");
	var myYear = parseInt(dateParts[2],10);
	if (myYear < 80)
		myYear += 2000;
	else if (myYear < 100)
		myYear += 1900;
	myDate.setFullYear(myYear,parseInt(dateParts[0]-1,10),parseInt(dateParts[1],10))
	return(myDate);
	
}

function validateDate (fld) {
	if (window.myVtimeoutholder)
		window.clearTimeout(myVtimeoutholder)
	
	if (validateDate.arguments.length > 0){
		gfld = fld;
		myVtimeoutholder = setTimeout("validateDate()",300);
		return;
	}

	if (gfld.style.visibility == 'hidden' || gfld.parentNode.style.visibility == 'hidden'  )
	 	return;
		
	var fld = gfld;

	var prompt = fld.getAttribute('prompt');
	if (prompt && fld.value == prompt)
		var testValue = '';
	else
		var testValue = fld.value;
		


	initAfterBefore(fld);
	
	fld.style.backgroundColor = '';
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    var errorMessage = 'Please enter valid date as month, day, and two digit year.\nFormat is mm/dd/yy.\nOr select a valid date from the Calendar.';



	var required = !!eval(fld.getAttribute('required'));  // convert the string "false" and null object to a boolean false
	//Dec2010 Tim O'Brien  above line replaces following:
	//var required = false;
	//if (fld.required)
	//	required = true;

	var t = $(fld);
	while (t.getStyle && t.getStyle('visibility')==='inherit'){
		t = $(t.parentNode);
	}
	
	if (t.getStyle && t.getStyle('visibility')!= 'visible')
		return true;

	if (!required && trim(testValue) == ''){
		fld.validate = 'passed';
		return true;
	}

    if (testValue.match(RegExPattern)){
		var secondaryError = false;
		testValue = testValue.replace(/\-/g,"/")
		testValue = testValue.replace(/\./g,"/")
		if (notbefore){
			if (parseDate(testValue) < notbefore){
				errorMessage = 'Date out of Range.\nMust be after '+notbefore
				secondaryError = true;
			}
		}
		if (notafter){
			if (parseDate(testValue) > notafter){
				errorMessage = 'Date out of Range.\nMust be before '+notafter
				secondaryError = true;
			}
		}
		if (!secondaryError){
			fld.validate = 'passed';
	        return true; 
		}
	}
	if (window.submitAction) {
		window.clearTimeout(submitAction)
	}
	if (trim(testValue) == ''){
		errorMessage = 'Date is required.\n' + errorMessage;
	}
	else
		errorMessage = 'Date Formatting error.\n' + errorMessage;
		
	
	fld.style.backgroundColor = "#DE6C74";
	alert(errorMessage);
	fld.validate = 'failed';
	//setTimeout("gfld.focus()",3);
	if (window.myVtimeoutholder)
		window.clearTimeout(myVtimeoutholder)
	return(false)
}
function tabKey (event) {
	if (event.keyCode == 9)
		hideCalendarControl();
}

function testPhone (phoneNum) {
	var exp = new RegExp(/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x|x| ext)\d{1,5}){0,1}$/);
	if (phoneNum.match(exp)) {
   		return true;
 	} else {
 		return false;
 	}
}

//abort cancels the response of an ajax in FF, Chrome, and others. In IE it atually stops the server side operations.
Ajax.Request.prototype.abort = function () {
    this.transport.onreadystatechange = Prototype.emptyFunction;
    this.transport.abort();
    Ajax.activeRequestCount--;
	if (Ajax.activeRequestCount < 0) {
		Ajax.activeRequestCount = 0;
	}
	return true;
};

//cancel response just cancels the onSuccess, onFailure, etc. functions of an ajax request.
Ajax.Request.prototype.cancelResponse = function () {
    this.transport.onreadystatechange = Prototype.emptyFunction;
	return true;
};

// simulate event ( Prototype extension )
(function () {
		
		var eventMatchers = {
			'HTMLEvents' : /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll|ready)$/,
			'MouseEvents' : /^(?:click|mouse(?:down|up|over|move|out))$/
		}
		var defaultOptions = {
			pointerX : 0,
			pointerY : 0,
			button : 0,
			ctrlKey : false,
			altKey : false,
			shiftKey : false,
			metaKey : false,
			bubbles : true,
			cancelable : true
		}
		
		Event.simulate = function (element, eventName) {
			var options = Object.extend(defaultOptions, arguments[2] || {});
			var oEvent,
				eventType = null;
			
			element = $(element);
			
			for (var name in eventMatchers) {
				if (eventMatchers[name].test(eventName)) {
					eventType = name;
					break;
				}
			}
			
			if (!eventType)
				throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
			
			if (document.createEvent) {
				oEvent = document.createEvent(eventType);
				if (eventType == 'HTMLEvents') {
					oEvent.initEvent(eventName, options.bubbles, options.cancelable);
				} else {
					oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
						options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
						options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
				}
				element.dispatchEvent(oEvent);
			} else {
				options.clientX = options.pointerX;
				options.clientY = options.pointerY;
				oEvent = Object.extend(document.createEventObject(), options);
				element.fireEvent('on' + eventName, oEvent);
			}
			return element;
		}
		
		Element.addMethods({
				simulate : Event.simulate
			});
	})() 


// -------------------------------------------------------------------------------
// ------------------------------- DEPRECATED ------------------------------------
// -------------------------------------------------------------------------------



// 08/09/2011 Kevin J. Gay
// ----- USE -------
// Event.simulate($(elm), 'eventName') || $(elm).simulate('eventName');
// -----------------
// available in prototype 1.7.0 /wwwroot/lib/prototype/1.7.0/prototype.js

function fireEvent (element,event) {
    if (document.createEventObject){  //  IE
		var evt = document.createEventObject();
		return element.fireEvent('on'+event,evt)
    }
    else{	// all others
		var evt = document.createEvent("HTMLEvents");
		evt.initEvent(event, true, true ); // event type,bubbling,cancelable
		return !element.dispatchEvent(evt);
    }
}


// 08/09/2011 Kevin J. Gay
// Unused in all of wwwroot, utilities, and templates 
// ----- USE --------
// CSI.createMultiSelect(optArr, optObj) for a select menu with checkboxes

function createSelect (optObj) {
	var options = optObj.options;
	CSSRule('.jsSelect', {backgroundColor:'white', paddingLeft:'3px', border:'1px solid #000', position:'relative', backgroundPosition: 'right center', backgroundRepeat:'no-repeat', backgroundImage: 'url(down-arrow.gif)'});
	CSSRule('.jsSelectPullDown', {backgroundColor:'white', borderStyle:'solid', borderColor: '#999', borderLeftWidth:'3px',  borderWidth:'1px', cursor:'pointer', position:'absolute'}); //, borderWidth:'0px 1px 1px 1px', borderStyle:'solid'
	CSSRule('.jsSelectOption',{paddingLeft:'3px', cursor:'pointer'});
	CSSRule('.test', {position: 'absolute', height:'auto', width:'auto', visibility:'hidden'});  //
	CSSRule('.coverDiv', {position:'absolute', top:'0px', left: '0px', height:'25px', cursor:'pointer'});
	var hoverStyle = {backgroundColor:'red'}
	if (optObj.optionHoverStyle){
		Object.extend(hoverStyle,optObj.optionHoverStyle);
	}
	CSSRule('.jsSelectHover',hoverStyle);
	
	var maxWidth = 0;
	var selected;
	var initialize = true;
	
	var name= optObj.name || optObj.id;
	var id = optObj.id || optObj.name;
	
	var test, test2, test3, testItems;
	testItems = document.getElementsByClassName('test');
	if (!testItems.length) { 
		test = $(document.createElement('div'));
		test2 = $(document.createElement('div'));
		test3 = $(document.createElement('div'));
		test.className = 'jsSelect test';
		test2.className = 'jsSelectOption test';
		test3.className = 'jsSelectPullDown test';
		document.body.appendChild(test);
		document.body.appendChild(test2);
		document.body.appendChild(test3);
	}
	else {       // if creating a second pulldown,  use the same test elements already created.
		test = testItems[0];  // the select div
		test2 = testItems[1];  // option div
		test3 = testItems[2];	// pulldown div (holds all the options);
	}
	
	var div = document.createElement('div');
	
	var select = $(document.createElement('div'));
	select.className = 'jsSelect';
	if (optObj.selectStyle){
		Object.extend(select.style,optObj.selectStyle);
		Object.extend(test.style,optObj.selectStyle);
	}
	var paddingLeft = parseInt(test.getStyle('paddingLeft'));
	select.appendChild(document.createElement('span'));
	select.name = name;
	Event.observe(select,'mousedown',function (event) {
		pullDown.toggle();
		Event.stop(event);
	});
	Event.observe(select,'mouseover',function (event) {
		document.body.style.cursor = 'pointer';
	});
	Event.observe(select,'mouseout',function (event) {
		document.body.style.cursor = '';
	});
	Event.observe(select,'mousemove',CSI.clearSelection);
	select.set = function (obj) {
		var val = obj.value || obj.text;
		if (input.value == val){
			return;
		}
		this.firstChild.innerHTML = obj.text;
		input.value = val;
		if (!initialize){
			if (div.fx){
				div.fx(input);
			}
			fireEvent(input,'change');
		}
		initialize = false;
	}
	var coverDiv = document.createElement('div');
	coverDiv.className='coverDiv';
	select.appendChild(coverDiv);
	div.appendChild(select);
	
	var pullDown = $(document.createElement('div'));
	pullDown.className = 'jsSelectPullDown';
	if (optObj.pullDownStyle){
		Object.extend(pullDown.style,optObj.pullDownStyle);
		Object.extend(test3.style,optObj.pullDownStyle);
	}
	pullDown.style.borderTopWidth = '0px';
	pullDown.toggle();
	Event.observe(document,'mousedown',function () {
		this.hide();
	}.bind(pullDown));
	div.appendChild(pullDown);
	Event.observe(pullDown,'mousemove',CSI.clearSelection);
	
	var input = document.createElement('input');
	input.type = 'hidden';
	input.id = id;
	input.name = name;
	
	for (var i=0;i<options.length;i++){
		pullDown.appendChild(createOption(options[i]));
	}
	if (!selected){
		select.set(options[0]);
	}
	// these calculations are necessary in case the css border width(s) are changed.
	// this will allow the right and left borders to be set 

	var borderAdj = (parseInt(test3.getStyle('borderLeftWidth'))+parseInt(test3.getStyle('borderRightWidth')))
					-(parseInt(test.getStyle('borderLeftWidth'))+parseInt(test.getStyle('borderRightWidth')));

	coverDiv.style.width = pullDown.style.width = 	(maxWidth+(Math.max(borderAdj*-1,0)))+'px';
	select.style.width = (maxWidth-paddingLeft+(Math.max(borderAdj,0)))+'px';
	coverDiv.style.height = test.getHeight()+'px';
	
	div.appendChild(input);
	
	return div;
	
	function createOption (obj) {
		test2.innerHTML = test.innerHTML = obj.text;
		maxWidth = Math.max(maxWidth, Math.max(test.getWidth()+15,test2.getWidth()));
		
		var o = document.createElement('div');
		o.className = 'jsSelectOption';
		if (optObj.optionStyle){
			Object.extend(o.style,optObj.optionStyle);
			Object.extend(test2.style,optObj.optionStyle);
		}
		o.innerHTML = obj.text;
		if (obj.selected && !selected){
			select.set(obj);
			selected= true;
		}
		Event.observe(o,'mouseup',function  () {
			select.set(obj);
			pullDown.hide();
		});
		Event.observe(o,'mousedown',function  (event) {
			Event.stop(event);
		});
		Event.observe(o,'mouseover',function  (event) {
			o.addClassName('jsSelectHover');
		});
		Event.observe(o,'mouseout',function (event) {
			o.removeClassName('jsSelectHover');
		});
		return o;
	}
}

Array.prototype.incrementIndex = function (i) {
	if (!i) return this.index;
	if (this.length < 2)
	return this.index = 0;
	this.index = this.index+i;
	while (this.index < 0)
	this.index = this.length+this.index;
	while (this.index > (this.length-1))
	this.index = this.index - this.length;
	return this.index;
}
