/*js_standard.js

This file contains standard javascript functions used throughout the site
*/

//universal variables
var winArray; //the array that keeps track of windows;
var listingArray = new Array();//the array that stores listing info;
var colors = '00ccff,ff0000,00ff00';
var mZ; // tracks z-index
var maxMin; // tracks how many windows can be minimized at one time based on users screen size
var cW; // client width
var cH; // client height
var dFunctions = new Object();//provides an object to which can be add additional functions
var spelled = false;
var popup = false;
var generic;//an extremely temporary variable for passing info between functions - use with caution
var true_user = 0;
var true_groups = 0;
var chat;
var recEvt;//records the last event that fired.  This can be used for browsers that do not implicitly pass the event to a function
var browserArray = ['msie','chrome','firefox','opera','safari','gecko','konqueror'];
var browser = 'na';
var version = 'na';
for(i=0; i<browserArray.length; i++){
	if(navigator.userAgent.toLowerCase().indexOf(browserArray[i]) > -1){
		browser = browserArray[i];
		version = navigator.userAgent.toLowerCase().substring(navigator.userAgent.toLowerCase().indexOf(browserArray[i]));
		version = version.substring(version.indexOf('/')+1,version.indexOf(' '));
		break;
		//alert(browser + ' | ' + version);
	}
}


function siteLoad(){
try{
	winSize();
	$('MTable').style.height = cH - 30;
	winArray = new Array();
	mZ = 101;
	maxMin = Math.floor((cW-10)/155);
	var status = document.createElement("div");
	status.id = 'Status';
	status.style.height = 20;
	status.className = 'e7';
	status.style.cssText = 'position:absolute; left:0; top:0; text-align:center; background-color:FF0000; padding:1; visibility:hidden; z-index:1000;';
	document.body.appendChild(status);
	xProp();
	if(!document.body.outerHTML){//creates an outerHTML prototype for browser that do not support it
		if (document.body.__defineGetter__) {
			if (HTMLElement) {
				var element = HTMLElement.prototype;
				if (element.__defineGetter__) {
					element.__defineGetter__("outerHTML",function () {
						try{
						
						var parent = this.parentNode;
						var html = this.innerHTML;
						if(!document.getElementById('TempOut')){
							var tempOut = document.createElement('div');
							tempOut.id = 'TempOut';
							tempOut.style.display = 'none';
							document.body.appendChild(tempOut);
						} else {
							purge('TempOut');
							document.getElementById('TempOut').innerHTML = '';
						}
						if(this.id == null || this.id == ''){
							this.id = 'abcdefg';	
						}
						var findID = this.id;
						document.getElementById('TempOut').innerHTML = parent.innerHTML;
						var removeArray = new Array();
						var children = document.getElementById('TempOut').getElementsByTagName('*');//byTag('*',$('TempOut'));
						for(abcdefg = 0; abcdefg < children.length; abcdefg++){
							if(children.item(abcdefg).id != findID){
								removeArray[removeArray.length] = children.item(abcdefg);
							} else {
								var theChild = children.item(abcdefg);	
							}
						}
						for(abcdefg = 0; abcdefg < removeArray.length; abcdefg++){
							purge(removeArray[abcdefg]);
							removeArray[abcdefg].parentNode.removeChild(removeArray[abcdefg]);
						}
						if(theChild){
							theChild.innerHTML = html;
						}
						return $('TempOut').innerHTML;
						}
						catch(ex){
							alert('Sorry, but I couldn\'t get the value of ' + this.id);	
						}
					}
					);
				}
			}
		}
		if (document.body.__defineSetter__) {
			try{
			if (HTMLElement) {
				var element = HTMLElement.prototype;
				if (element.__defineSetter__) {
					element.__defineSetter__("outerHTML",function (html) {
						var newEl = document.createElement('remove');
						var parent = this.parentNode;//d('Change to: ' + html);
						newEl.innerHTML = html;
						parent.replaceChild(newEl,this);//d('New HTML: ' + parent.innerHTML);
						parent.innerHTML = parent.innerHTML.replace(/\<remove\>/gi,'').replace(/\<\/remove\>/gi,'');
					}
					);
				}
			}
			}
			catch(ex){
				alert('I failed!');	
			}
		}
	}
	setTimeout("docDefaults()",500);
}
catch(ex){
	alert('Error on siteLoad(): ' + ex);
}
}


function closeWeb(){
	if(true_user != 0){
		ajaxLoader('../system/log_user.cfm?LogUser=Out');
	}
	var els = byTag('*');
	for(i = 0; i < els.length; i++){
		els.onclick = null;
		els.oncontextmenu = null;
		els.onmouseover = null;
		els.onmouseout = null;
	}
	document.body.onunload = null;
}

function winSize(){
	if (typeof window.innerWidth != 'undefined'){
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		cW = window.innerWidth;
		cH = window.innerHeight;
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document
		cW = document.documentElement.clientWidth;
		cH = document.documentElement.clientHeight;
	} else {
		// older versions of IE
		cW = document.getElementsByTagName('body')[0].clientWidth;
		cH = document.getElementsByTagName('body')[0].clientHeight;
	}
	$('Screen').style.width = cW;
	$('Screen').style.height = cH;
	ajaxLoader('../system/client.cfm?cH=' + cH + '&cW=' + cW + '&Browser=' + browser); // sends the client width and height to cold fusion session variables
	adjustA();
}

function docDefaults(){//sets the document to default behaviors
try{
	document.onmousedown=drags;
	restrict = false;
	initMouseXY();
	document.onmouseup=new Function("dragapproved=false;");
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		//document.onmousedown=clickNS;
	} else {
		//document.onmousedown = function(e){recEvt = e;}
		document.onmouseup=clickNS;
		document.oncontextmenu=clickIE;
	}
	document.onclick = cxtHide;
	document.oncontextmenu=rClick;//new Function("return false");
	window.onresize = winSize;
	if($('CA') != null){
		adjustA();
	}
}
catch(ex){
	alert('Error on docDefaults(): ' + ex);
}
}

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com

var message="";
///////////////////////////////////
function clickIE(e) {
try{
	//recEvt = e;
	if (document.all) {
		(message);
		return false;
	}
}
catch(ex){
	alert('Error on clickIE(): ' + ex);
}
}

function rClick(e){
	recEvt = e;
	return false;	
}

function clickNS(e) {
try{
	//recEvt = e;
	//ddClose();
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			(message);
			return false;
		}
	}
}
catch(ex){
	alert('Error on clickNS(): ' + ex);
}
}

function loadFlash(){
try{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="235" id="dy_flash5" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" /><param name="movie" value="../images/dy_flash.swf" style="z-index:1;" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="../images/dy_flash.swf" loop="false" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="550" height="235" name="dy_flash5" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}
catch(ex){
	alert('Error on loadFlash(): ' + ex);
}
}



function id2Obj(id){//deprecated
	try{
		return document.getElementById(id);
	}
	catch(x){
		d("Could not find " + id);
	}
}

function $(id){
	try{
		return document.getElementById(id);
	}
	catch(x){
		d("Could not find " + id);
	}
}
function byTag(tag,obj){//tag - html tag of elements*,obj - the object or its id (null for whole page)
try{
	if(obj == null){
		return document.getElementsByTagName(tag);
	} else if(typeof obj == 'object'){
		return obj.getElementsByTagName(tag);
	} else {
		return $(obj).getElementsByTagName(tag);
	}
}
catch(x){
	d('Could not find ' + tag + ' tags for ' + id);
}
}

function noBubble(e){
	if(window.event){
		window.event.cancelBubble = true;	
	} else {
		e.stopPropagation();	
	}
}

//ajax loader
//zXML - modified for firefox 3.x by http://www.aiso.net/scripts/zxml.js
var zXml={useActiveX:(typeof ActiveXObject!="undefined"),useDom:document.implementation&&document.implementation.createDocument,useXmlHttp:(typeof XMLHttpRequest!="undefined")};zXml.ARR_XMLHTTP_VERS=["MSXML2.XmlHttp.6.0","MSXML2.XmlHttp.3.0"];zXml.ARR_DOM_VERS=["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.3.0"];function zXmlHttp(){}zXmlHttp.createRequest=function(){if(zXml.useXmlHttp){return new XMLHttpRequest();}else if(zXml.useActiveX){if(!zXml.XMLHTTP_VER){for(var i=0;i<zXml.ARR_XMLHTTP_VERS.length;i++){try{new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);zXml.XMLHTTP_VER=zXml.ARR_XMLHTTP_VERS[i];break;}catch(oError){;}}}if(zXml.XMLHTTP_VER){return new ActiveXObject(zXml.XMLHTTP_VER);}else{throw new Error("Could not create XML HTTP Request.");}}else{throw new Error("Your browser doesn't support an XML HTTP Request.");}};zXmlHttp.isSupported=function(){return zXml.useXmlHttp||zXml.useActiveX;};function zXmlDom(){}zXmlDom.createDocument=function(){if(zXml.useDom){var oXmlDom=document.implementation.createDocument("","",null);oXmlDom.parseError={valueOf:function(){return this.errorCode;},toString:function(){return this.errorCode.toString()}};oXmlDom.__initError__();oXmlDom.addEventListener("load",function(){this.__checkForErrors__();this.__changeReadyState__(4);},false);return oXmlDom;;}else if(zXml.useActiveX){if(!zXml.DOM_VER){for(var i=0;i<zXml.ARR_DOM_VERS.length;i++){try{new ActiveXObject(zXml.ARR_DOM_VERS[i]);zXml.DOM_VER=zXml.ARR_DOM_VERS[i];break;}catch(oError){;}}}if(zXml.DOM_VER){return new ActiveXObject(zXml.DOM_VER);}else{throw new Error("Could not create XML DOM document.");}}else{throw new Error("Your browser doesn't support an XML DOM document.");}};zXmlDom.isSupported=function(){return zXml.useDom||zXml.useActiveX;};var oMozDocument=null;if(typeof XMLDocument!="undefined"){oMozDocument=XMLDocument;}else if(typeof Document!="undefined"){oMozDocument=Document;}if(oMozDocument&&!window.opera){try{XMLDocument.prototype.readyState = 0;} catch(e) {};oMozDocument.prototype.onreadystatechange=null;oMozDocument.prototype.__changeReadyState__=function(iReadyState){try{this.readyState=iReadyState;} catch(e) {};if(typeof this.onreadystatechange=="function"){this.onreadystatechange();}};oMozDocument.prototype.__initError__=function(){this.parseError.errorCode=0;this.parseError.filepos=-1;this.parseError.line=-1;this.parseError.linepos=-1;this.parseError.reason=null;this.parseError.srcText=null;this.parseError.url=null;};oMozDocument.prototype.__checkForErrors__=function(){if(this.documentElement.tagName=="parsererror"){var reError=/>([\s\S]*?)Location:([\s\S]*?)Line Number(\d+),Column(\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;reError.test(this.xml);this.parseError.errorCode=-999999;this.parseError.reason=RegExp.$1;this.parseError.url=RegExp.$2;this.parseError.line=parseInt(RegExp.$3);this.parseError.linepos=parseInt(RegExp.$4);this.parseError.srcText=RegExp.$5;}};oMozDocument.prototype.loadXML=function(sXml){this.__initError__();this.__changeReadyState__(1);var oParser=new DOMParser();var oXmlDom=oParser.parseFromString(sXml,"text/xml");while(this.firstChild){this.removeChild(this.firstChild);}for(var i=0;i<oXmlDom.childNodes.length;i++){var oNewNode=this.importNode(oXmlDom.childNodes[i],true);this.appendChild(oNewNode);}this.__checkForErrors__();this.__changeReadyState__(4);};oMozDocument.prototype.__load__=oMozDocument.prototype.load;oMozDocument.prototype.load=function(sURL){this.__initError__();this.__changeReadyState__(1);this.__load__(sURL);};Node.prototype.__defineGetter__("xml",function(){var oSerializer=new XMLSerializer();return oSerializer.serializeToString(this,"text/xml");});Node.prototype.__defineGetter__("text",function(){var sText="";for(var i=0;i<this.childNodes.length;i++){if(this.childNodes[i].hasChildNodes()){sText+=this.childNodes[i].text;}else{sText+=this.childNodes[i].nodeValue;}}return sText;});}function zXslt(){}zXslt.transformToText=function(oXml,oXslt){if(typeof XSLTProcessor!="undefined"){var oProcessor=new XSLTProcessor();oProcessor.importStylesheet(oXslt);var oResultDom=oProcessor.transformToDocument(oXml);var sResult=oResultDom.xml;if(sResult.indexOf("<transformiix:result")>-1){sResult=sResult.substring(sResult.indexOf(">")+1,sResult.lastIndexOf("<"));}return sResult;;}else if(zXml.useActiveX){return oXml.transformNode(oXslt);}else{throw new Error("No XSLT engine found.");}};function zXPath(){}zXPath.selectNodes=function(oRefNode,sXPath,oXmlNs){if(typeof XPathEvaluator!="undefined"){oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var aNodes=new Array;if(oResult!=null){var oElement=oResult.iterateNext();while(oElement){aNodes.push(oElement);oElement=oResult.iterateNext();}}return aNodes;}else if(zXml.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"=\'"+oXmlNs[sProp]+"\' ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectNodes(sXPath);}else{throw new Error("No XPath engine found.");}};zXPath.selectSingleNode=function(oRefNode,sXPath,oXmlNs){if(typeof XPathEvaluator!="undefined"){;oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(oResult!=null){return oResult.singleNodeValue;}else{return null;};}else if(zXml.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:\'"+sProp+"="+oXmlNs[sProp]+"\' ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectSingleNode(sXPath);}else{throw new Error("No XPath engine found.");}};function zXMLSerializer(){}zXMLSerializer.prototype.serializeToString=function(oNode){var sXml="";switch(oNode.nodeType){case 1:sXml="<"+oNode.tagName;for(var i=0;i<oNode.attributes.length;i++){sXml+=" "+oNode.attributes[i].name+"=\""+oNode.attributes[i].value+"\"";}sXml+=">";for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}sXml+="</"+oNode.tagName+">";break;case 3:sXml=oNode.nodeValue;break;case 4:sXml="<![CDATA["+oNode.nodeValue+"]]>";break;case 7:sXml="<?"+oNode.nodevalue+"?>";break;case 8:sXml="<!--"+oNode.nodevalue+"-->";break;case 9:for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}break;};return sXml;};

function ajaxLoader(l,c,m,j) {//l - form obj or url*,c - obj to return content to (use "NA" for method "j",m - method (r,a,p,l,j - see below),j - javascript to execute following success
try{
	if(m == null){
		var m = 'r';
	}
	if(j == null){
		var j = '';
	}
	var http_request = false;
	http_request = zXmlHttp.createRequest();
	http_request.onreadystatechange = function() {if(c != null){postResponse(http_request,c,m,j,l);}};
	if(typeof l == 'object'){//alert('form submission');
		var fields = getFormFields(l);
		http_request.open("post",l.action, true);
		http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		http_request.send(fields);
	} else {//d('url submission');
		if(l.indexOf('?') > 0){//include a random variable to ensure browser doesn't simply use a cached page
			l += '&Random=' + Math.round(Math.random()*1000);
		} else {
			l += '?Random=' + Math.round(Math.random()*1000);
		}
		http_request.open('GET', l, true);
		http_request.send(null);
	}
}
catch(ex){
	d('Error on ajaxLoader(): ' + ex);
}
}

function getFormFields(oForm){
try{
	var aParams = new Array();
	for( var i=0; i < oForm.elements.length; i++){
		var sParam = encodeURIComponent(oForm.elements[i].name);
		sParam += "=";
		if(oForm.elements[i].type == 'checkbox'){
			sParam += encodeURIComponent(oForm.elements[i].checked);
		} else if(oForm.elements[i].type == 'radio'){
			if(oForm.elements[i].checked == true){
				sParam += encodeURIComponent(oForm.elements[i].value);
			}
		} else {
			sParam += encodeURIComponent(oForm.elements[i].value);
		}
		aParams.push(sParam);
	}//alert('got form fields');
	return aParams.join("&");
}
catch(ex){
	d('Error on getFormFields(): ' + oForm.id + ' ' + ex);
}
}

function postResponse(r,c,m,j,l){//response,content,method,javascript,location
try{
	if (r.readyState == 4) {
		if (r.status == 200) {
			if(m == 'r'){//replace
				purge(c);
				$(c).innerHTML = r.responseText;
			} else if(m == 'p'){//prepend
				$(c).innerHTML = r.responseText + $(c).innerHTML;
			} else if(m== 'a'){//append
				$(c).innerHTML += r.responseText;
			} else if(m == 'l'){//alert
				if(r.responseText != ''){alert(r.responseText);}
			} else if(m == 'j'){//process as javascript
				var js = trim(r.responseText);
				eval(js);
			} else {
				alert("Invalid AJAX Method.  Use r=replace, p=prepend, a=append, l=alert, or j=javascript.");
			}
			if(m == 'r' || m == 'p' || m == 'a'){
				var inputs = byTag('input',c);//$(c).getElementsByTagName('input');
				for(x=0; x < inputs.length; x++){
					if(inputs.item(x).onfocus != null && inputs.item(x).onfocus.toString().indexOf('iLister') > -1){
						inputs.item(x).style.backgroundImage = 'url(../images/lister_arrow.gif)';
						inputs.item(x).style.backgroundRepeat = 'no-repeat';
						inputs.item(x).style.backgroundPosition = 'right bottom';
					}
				}
			}
			if(j != ''){
				eval(j);
			}
			r.onreadystatechange = null;
		} else {
			d('Sorry, the requested page (' + l + ' couldn\'t be completed.  Error ' + r.status + ': ' + r.statusText + '.');
		}
	}
}
catch(ex){
	d('Error on postResponse(): ' + ex + '\nVars: r=' + r.responseText + ' c=' + c + ' m=' + m);
}
}


function loadXJS(url){
/*Based on script by Pramod S Nair
http://www.wisdombay.com/articles/article000015.htm
Dynamically adds a external js file
*/
try{
	var hdEl = document.getElementsByTagName("head")[0];
	if(hdEl.innerHTML.indexOf(url) == -1){
		var scrptE = document.createElement("script");
		scrptE.setAttribute("type", "text/javascript");
		scrptE.setAttribute("language", "JavaScript");
		scrptE.setAttribute("src", url);
		if (hdEl.childNodes.length > 1) {
			hdEl.removeChild(hdEl.lastChild);
		}
		hdEl.appendChild(scrptE);
	}
}
catch(ex){
	alert('Error on loadXJS(): ' + ex);
}
}


var dragapproved=false;
var x,y;
var dobj;
var restrict;

function movemouse(e){
	if (dragapproved){
		if(e != null){var evt = e;var evtButton = 0;} else {var evt = event;var evtButton = 1;}
		if(evt.button == evtButton){
			if(parseInt(dobj.style.left)+100 < (tx + evt.clientX - x) ||parseInt(dobj.style.left)-100 > (tx + evt.clientX - x)){//stops the object from "jumping" left when new content is added to the page by ajax
				dobj.style.left = dobj.style.left;
				tx = parseInt(dobj.style.left+0,10);
				x = evt.clientX;
			} else {
				if(restrict != 'y'){
					dobj.style.left = tx + evt.clientX - x;
				}
				if(restrict != 'x'){
					dobj.style.top  = ty + evt.clientY - y;
				}
			}
			return false;
		} else {
			docDefaults();
		}
	}
}

function drags(e){
	recEvt = e;
	if(e != null){var evt = e;var fobj = e.target;var topelement = 'HTML';} else {var evt = event;var fobj = event.srcElement;var topelement = 'BODY';}
	if(fobj.tagName == 'INPUT' || fobj.tagName == 'TEXTAREA' || (fobj.id != null && fobj.id == 'Resize') || evt.shiftKey || (fobj.getAttribute('nodrag') != null && fobj.getAttribute('nodrag') == 'true')){
		return;	
	}
	if((fobj.clientHeight == 0 || fobj.clientHeight + 5 >= fobj.scrollHeight) && (fobj.clientWidth == 0 || fobj.clientWidth + 5 >= fobj.scrollWidth)){
		while (fobj.tagName != topelement && fobj.className.indexOf('drag') == -1 && fobj.className.indexOf('DragContainer') == -1){
			if(fobj.getAttribute('nodrag') != null && fobj.getAttribute('nodrag') == 'true'){return;}
			if(browser == 'msie'){var fobj = fobj.parentElement;} else {var fobj = fobj.parentNode;}
		}
	}
	
	if (fobj.className.indexOf('drag') > -1){
		dragapproved = true;
		dobj = fobj;
		tx = parseInt(dobj.style.left+0,10);
		ty = parseInt(dobj.style.top+0,10);
		x = evt.clientX; y = evt.clientY;
		if(dobj.className.indexOf('dragx') > -1){
			restrict = 'x';
		} else if(dobj.className.indexOf('dragy') > -1){
			restrict = 'y';
		}
		document.onmousemove=movemouse;
		document.onmouseup=docDefaults;
		return false;
	}
}


//show/hide functions
function sH(id){//id - an id of an object or the object itself
try{
	if(typeof id == 'object'){
		var obj = id;	
	} else {
		var obj = $(id);
	}
	if(obj.style.display == 'block'){
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
	}
}
catch(ex){
	d('Error on sH(): ' + ex);
}
}

function sHG(p,id){
try{
	var objs = byTag('div',p);
	for(x = 0; x < objs.length; x++){
		if(objs.item(x).className == 'shg'){
			if(id == null || (id != null && objs.item(x).id != id)){
				objs.item(x).style.display = 'none';
			}
		}
	}
	if(id != null){
		sH(id);
	}
}
catch(ex){
	d('Error on sHG(): ' + ex);
}
}

function trim(value){
try{
	return value.replace(/^\s+|\s+$/g,"");
}
catch(ex){
	//alert(typeof value);
	//d('|' + value + '|');
	//alert('Error on trim(): ' + ex);
	return '';
}
}

function stripHTML(oldString){
try{
	//function to strip all html
	var newString = oldString.replace(/(<([^>]+)>)/ig,"");
	//replace carriage returns and line feeds
   newString = newString.replace(/\r\n/g," ");
   newString = newString.replace(/\n/g," ");
   newString = newString.replace(/\r/g," ");
	//trim string
	newString = trim(newString);
	return newString;
}
catch(ex){
	alert('Error on stripHTML(): ' + ex);
}
}

function stripSymbols(str){
try{
	str = str.replace(/\s/gi,'_');
	str = str.replace(/\W/gi,'');
	str = str.replace(/_/gi,' ');
	return str;
}
catch(ex){
	alert('Error on stripSymbols(): ' + ex);
}
}

function stripReserved(str){
	str = str.replace(/\#/gi,'&#35;');
	str = str.replace(/\'/gi,'&#39;');
	return str;
}

function insertReserved(str){
	str = str.replace(/\&\#35/gi,'#');
	str = str.replace(/\&\#39/gi,"'");
	return str;
}

function createFileName(str){
	str = stripHTML(str);
	str = trim(str);
	str = insertReserved(str);
	str = stripSymbols(str);
	str = str.replace(/[ ]/gi,'_');
	str = str.replace(/,/gi,'');
	str = str.replace(/\./gi,'');
	str = str.replace(/\'/gi,'');
	return str;
}

function numLen(num){//get the length of a number
try{
	num = 'C' + num;
	return num.substring(1).length;
}
catch(ex){
	alert('Error on numLen(): ' + ex);
}
}

function validateUrl(url){ 
	pattern = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; 
	if( !pattern.test(url)){ 
		return false; 
	} 
	return true; 
} 

function size2FontSize(size){
	if(size == null){return null;}
	if(isNaN(parseInt(size))){
		if(size == 'x-small'){fontSize=10;}
		else if(size=='small'){fontSize=12;}
		else if(size=='medium'){fontSize=16;}
		else if(size=='large'){fontSize=19;}
		else if(size=='x-large'){fontSize=24;}
		else if(size=='xx-large'){fontSize=32;}
		else if(size=='-webkit-xxx-large'){fontSize=48;}
		else {alert('The ' + size + ' font size is not recognized by size2FontSize() function.  Please contact your system administrator.');}
	} else {
		size = parseInt(size);
		if(size <= 1){fontSize=10;}
		else if(size==2){fontSize=12;}
		else if(size==3){fontSize=16;}
		else if(size==4){fontSize=19;}
		else if(size==5){fontSize=24;}
		else if(size==6){fontSize=32;}
		else if(size==7){fontSize=48;}
		else if(size > 7){fontSize=56;}
		else {alert('The ' + size + ' font size is not recognized by size2FontSize() function.  Please contact your system administrator.');}
	}
	return fontSize;
}

function fontSize2Size(fontSize){
	fontSize= parseInt(fontSize);
	if(browser == 'chrome' || browser == 'safari'){
		if(fontSize <= 11){size='x-small';}
		else if(fontSize >= 12 && fontSize <= 14){size='small';}
		else if(fontSize >= 15 && fontSize <= 17){size='medium';}
		else if(fontSize >= 18 && fontSize <= 22){size='large';}
		else if(fontSize >= 23 && fontSize <= 28){size='x-large';}
		else if(fontSize >= 29 && fontSize <= 40){size='xx-large';}
		else if(fontSize >= 41){size='-webkit-xxx-large';}
	} else {
		if(fontSize <= 11){size=1;}
		else if(fontSize >= 12 && fontSize <= 14){size=2;}
		else if(fontSize >= 15 && fontSize <= 17){size=3;}
		else if(fontSize >= 18 && fontSize <= 22){size=4;}
		else if(fontSize >= 23 && fontSize <= 28){size=5;}
		else if(fontSize >= 29 && fontSize <= 40){size=6;}
		else if(fontSize >= 41){size=7;}
	}
	return size;
}


function status(m){
try{
	if(m != 'clear' && m != null){
		$('Status').innerHTML = m;
		$('Status').style.visibility = 'visible';
	} else {
		$('Status').innerHTML = '';
		$('Status').style.visibility = 'hidden';
	}
}
catch(ex){
	alert('Error on status(): ' + ex);
}
}

function checkspell(node,afterJS) {
	//function to perform spell check
	try {
		var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
		spelled = true;
		if(node != null){
			//return tmpis.CheckDocumentNode2(node, true);
			tmpis.CheckDocumentNode2(node, true);
			if(afterJS){
				eval(afterJS);
			}
		}
	} catch(exception) {
		if (browser == 'msie') {
			var choice = confirm("To run a spell check, you must have IE Spell installed on your computer.\n\nDo you wish to install this program now?");
			if(choice){
				//nWin('p','http://www.dyrealty.com/system/ieSpellSetup251106.exe');
				window.open("http://www.iespell.com/download.php","Download");
			} else {
				spelled = true;
				alert("Spell check has not been run.");
			}
		} else {
			d('Spell check is only available when using Internet Explorer.');
			spelled = true;	
		}
	}

}

function selectObj(id){
	var obj = $(id);
	var range = obj.createTextRange();
	range.moveStart("character",0);
	range.moveEnd("character",obj.value.length);
	range.select();
	obj.focus();
}

function event2String(obj,evt,obj2){//obj* - the object or the id; evt (oncontextmenu) - the event type to convert; obj2 - the object to transfer the event to - if not present, returns the function
	if(typeof obj != 'object'){var obj = $(obj);}
	if(!evt){
		var evt = 'oncontextmenu';	
	}
	if(evt == 'oncontextmenu'){
		var funct = obj.oncontextmenu.toString();
	} else if(evt == 'onclick'){
		var funct = obj.onclick.toString();
	} else if(evt == 'onmouseover'){
		var funct = obj.onmouseover.toString();
	} else if(evt == 'onmouseout'){
		var funct = obj.onmouseout.toString();
	} else if(evt == 'onkeydown'){
		var funct = obj.onkeydown.toString();
	} else if(evt == 'onkeyup'){
		var funct = obj.onclick.toString();
	} else if(evt == 'onmousemove'){
		var funct = obj.onmousemove.toString();
	} else {
		alert('The ' + evt + ' event type is not supported.  Ask your system administrator to modify the event2String() function.');	
	}
	if(funct && funct != ''){
		if(obj2){
			addEvent(obj2,evt.substring(2),funct);	
		} else {
			funct = funct.substring(funct.indexOf('{')+1);
			funct = funct.substring(0,funct.lastIndexOf('}')-1).replace(/"/gi,'\'');//fix for FF and Safari
			return funct;
		}
	} else {
		return false;	
	}
}

function addEvent(obj,type,fn){//obj* - the object or it's id; type* - the type of event minus the "on"; fn* - the anonymous function to attach
	if(typeof obj != 'object'){var obj = $(obj);}
	if(type.substring(0,2) == 'on'){type = type.substring(2);}
    if (obj.addEventListener){
        obj.addEventListener(type,fn,false);
    } else if(obj.attachEvent){
        obj['e'+type+fn]=fn;
        obj[type+fn]=function(){
            obj['e'+type+fn](window.event);
        }
        obj.attachEvent("on"+type,obj[type+fn]);
    }
}

function rgb2Hex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}

function isBGColor(color,obj){//color - hex color to test for; obj - obj to test (obj or id)
	if(typeof obj != 'object'){var obj = $(obj);}
	if(color.substr(0,1) == '#'){
		color.substr(1).toLowerCase();
	}
	//d('color |' + color + '| bgcolor |' + obj.style.backgroundColor + '|');
	if(color == '' && (obj.style.backgroundColor == '')){
		return true;	
	}
	var bg = obj.style.backgroundColor;
	if(bg.substring(0,1) == '#'){
		if(bg.substring(1) == color){
			return true;
		} else {
			return false;
		}
	} else if(bg.substring(0,3) == 'rgb'){
		var rgb = bg.substring(4);
		rgb = rgb.substring(0,rgb.length-1);
		rgb = rgb.split(',');
		if(rgb.length == 3){
			bgColor = rgb2Hex(rgb[0],rgb[1],rgb[2]);//d('Calc bgcolor = ' + bgColor.toLowerCase());
			if(bgColor.toLowerCase() == color){
				return true;
			} else {
				return false;
			}
		}
	}
}

function mZZoom(z){
	if(z.indexOf('scale(') > -1){
		return parseFloat(z.substring(6,z.length-1));	
	}
}

function xProp(){
try{
	ajaxLoader('../marketing/x_prop1.cfm','XProp','r');
	setTimeout("xProp()",15000);
}
catch(ex){
	alert('Error on xProp(): ' + ex);
}
}

var forceWins = 0;
//window functions
function nWin(t,l,m,h){//type=i(frame) or d(iv) or p(opup) or a (main window) or r(eload - assumes d if not open),location=url,mode=s(tandard),f(orce),g(adget),h = header(win title)
/* winArray
	0 = type ([d]iv  or [i]frame or [p]op-up)
	1 = location (url)
	2 = width
	3 = height
	4 = left
	5 = top
	6 = focus
	7 = status (active, close, gadget)
	
*/
try{
	//alert(t + ' ' + l + ' ' + m);
	if(m == null){var m = 's';}
	var evt = window.event || recEvt;
	if(h == null && evt != null && evt.srcElement != null){
		var h = evt.srcElement.innerHTML;
	} else if(h == null){
		var h = 'Window' + winArray.length;
	}
	if(t == 'p'){
		window.open(l);
		return;
	} else if(t == 'a'){
		status('Loading...');
		if(l.indexOf("?") > 0){
			var j = "&";
		} else {
			var j = "?";
		}
		l = l + j + 'W=A';
		$('DivA').style.display = 'none';
		$('CA').style.display = 'none';
		$('CA').scrollTop -= $('CA').scrollTop;
		ajaxLoader(l,'CA','r','pageCode(\'A\');adjustA();status();');
		return;
	}
	for(i=0; i<winArray.length; i++){
		if(typeof winArray[i][1] != 'object' && typeof l != 'object' && winArray[i][1].indexOf('map.cfm') == -1 && winArray[i][7] != 'close'){
			if(winArray[i][1].indexOf(l) == 0){
				if(winArray[i][7] == 'max'){
					setTimeout("fWin(" + i + ")",100);
					if(t == 'r'){
						setTimeout('$(\'WinT' + i + '\').setAttribute(\'ueids\',\'\');pageCode(' + i + ')',250);//erases the ueids so can reload	
					}
					return;
				} else if(winArray[i][7] == 'min'){
					setTimeout("mxWin($('MxMn" + i + "')," + i + ")",100);
					if(t == 'r'){
						setTimeout('pageCode(' + i + ')',250);	
					}
					return;
				}
			}
		}
	}
	if(t == 'r'){t='d';}//sets the type to "d"iv if was "r"eload, but window wasn't open
	status('Loading ' + h);
	var newW = document.createElement("div");
	var i = winArray.length;
	newW.id = 'W' + i;
	newW.style.left = 20;
	newW.style.top = 20;
	if(typeof l != 'object'){
		if(l.indexOf("?") > 0){
			var j = "&";
		} else {
			var j = "?";
		}
		l = l + j + 'W=' + i;
	}
	winArray[i] = new Array();
	winArray[i][0] = t;
	winArray[i][1] = l;
	newW.className = 'win1 dragW';
	document.body.appendChild(newW);
	if(m == 'f'){//force window
		newW.innerHTML = '<table id="T' + i + '" cellpadding="0" cellspacing="0" bgcolor="FF0000"><tr height="15"><td id="R' + i + '"><div id="WinT' + i + '" style="overflow:hidden; height:15;" class="winT pdrgW">' + h + '</div></td><td align="right" valign="top"><img src="../images/close.gif" alt="Close Window" onclick="cWin(\'W' + i + '\')" class="p"></td></tr><tr><td colspan="2"><div id="C' + i + '" style="overflow:auto; cursor:auto; background-color:ffffff;"></div></td></tr></table>';
		if(forceWins == 0){
			sH('Screen');
			$('Screen').style.zIndex = 199;
		}
		forceWins++;
	} else if(m == 'g'){//gadgets
		newW.innerHTML = '<table id="T' + i + '" cellpadding="1" cellspacing="0" height="20" bgcolor="FFFFFF"><tr><td id="R' + i + '"><div id="WinT' + i + '" style="overflow:hidden; width:100%; height:17; text-align:center; font-weight:bold; border-bottom-style:solid; border-bottom-color:000000; border-bottom-width:1;" class="f3 pdrgW" oncontextmenu="cxt(\'gadgets\',\'A\',\'GID=W' + i + '\')">' + h + '</div></td></td></tr></table>';
		newW.innerHTML += '<div id="C' + i + '" style="overflow:hidden; cursor:auto;"></div>'
		newW.style.zIndex = 1;
	} else {//standard
		newW.innerHTML = '<table id="T' + i + '" cellpadding="0" cellspacing="0" bgcolor="003366"><tr height="15"><td id="R' + i + '"><div id="WinT' + i + '" style="overflow:hidden; height:15;" class="winT pdrgW" onclick="fWin(' + i + ')" addcxtmenu>' + h + '</div></td><td align="right" valign="top"><img id="MxMn' + i + '" src="../images/min.gif" alt="Minimize Window" onclick="mxWin(this,' + i + ')" class="p"><img src="../images/close.gif" alt="Close Window" onclick="cWin(\'W' + i + '\')" class="p"></td></tr><tr><td colspan="2" bgcolor="ffffff"><div id="C' + i + '" style="overflow:auto; cursor:auto; background-color:ffffff;" onclick="fWin(' + i + ')"></div></td></tr><tr id="WinF' + i + '" bgcolor="ffffff" style="display:table-row;"><td align="right" valign="bottom" colspan="2"><nobr><div id="Resize" style="width:5; height:5; overflow:hidden; background-color:003366; cursor:nw-resize;" onmousedown="rWin(' + i + ',event)" ondblclick="rWinReset(' + i + ')"></div></nobr></td></tr></table>';
	}
	
	if(t == 'd' && m != 'g'){
		ajaxLoader(l,'C' + i,'r','sDiv(' + i + ')');
	} else if(t == 'd' && m == 'g'){
		ajaxLoader(l,'C' + i,'r','gWin(' + i + ')');
	} else if(t == 'i') {
		//$('C' + i).innerHTML += '<iframe id="F' + i + '" src="' + l + '" frameborder="0" scrolling="yes" width="100%" height="100%"></iframe>';
		$('C' + i).innerHTML += '<iframe id="F' + i + '" src="../system/iframe.htm" frameborder="0" scrolling="yes" width="100%" height="100%"></iframe>';
		$('F' + i).src = l;
		$('C' + i).style.width = Math.round(cW*.75);
		$('C' + i).style.height = Math.round(cH*.75);
		sWin(i);
	} else {
		alert('"' + t + '" is an invalid window type.  Please use "d" for DIV or "i" for IFRAME.');
	}
}
catch(ex){
	alert('Error on nWin(): ' + ex);
}
}

function sDiv(i){
try{
	var c = $('C' + i);
	var t = $('T' + i);
	c.style.width = parseInt(c.offsetWidth) + 37;
	c.style.height = parseInt(c.offsetHeight) + 37;
	c.style.paddingTop = 5;
	c.style.paddingLeft = 5;
	if(c.offsetHeight + 25 >= cH){
		c.style.height = cH-25;
	} else {
		c.style.height = c.offsetHeight;
	}
	if(c.offsetWidth + 25 >= cW){
		c.style.width = cW-25;
	} else {
		c.style.width = c.offsetWidth;
	}
	$('WinT' + i).style.width = parseInt(c.style.width) - 40;
	if($('F' + i) != null){$('F' + i).style.width = $('WinT' + i).style.width;}
	sWin(i);
}
catch(ex){
	alert('Error on sDiv(): ' + ex);
}
}

function sWin(i){
try{
	var w = $('W' + i);
	var c = $('C' + i);
	w.style.left = (cW - parseInt(w.offsetWidth))/2;
	w.style.top = (cH - parseInt(w.offsetHeight))/2;
	winArray[i][2] = parseInt(c.style.width);
	winArray[i][3] = parseInt(c.style.height);
	winArray[i][4] = parseInt(w.style.left);
	winArray[i][5] = parseInt(w.style.top);
	winArray[i][6] = 200;
	winArray[i][7] = 'max';
	status('clear');
	$('W' + i).style.visibility = 'visible';
	fWin(i);
	pageCode(i);
}
catch(ex){
	alert('Error on sWin(): ' + ex);
}
}

function gWin(i){
try{
	var c = $('C' + i);
	var w = $('W' + i);
	var c = $('C' + i);
	c.style.padding = 5;
	var t = $('T' + i);
	if(c.offsetWidth > 738){
		t.style.width = 760;
		c.style.width = 738;
	} else {
		t.style.width = c.offsetWidth + 22;
		c.style.width = c.offsetWidth;
	}
	c.style.height = c.offsetHeight;
	w.style.left = 800;
	w.style.top = 20;
	winArray[i][2] = parseInt(c.style.width);
	winArray[i][3] = parseInt(c.style.height);
	winArray[i][4] = parseInt(w.style.left);
	winArray[i][5] = parseInt(w.style.top);
	winArray[i][6] = 1;
	winArray[i][7] = 'gadget';
	status('clear');
	$('W' + i).style.visibility = 'visible';
	pageCode(i);
}
catch(ex){
	alert('Error on gWin(): ' + ex);
}
}

function fWin(i){
try{
	if(i == null){
		var i = -1;
		var gtf = 0;
		for(x=0; x < winArray.length; x++){
			if(winArray[x][7] == 'max' && winArray[x][6] > gtf){
				i = x;
				gtf = winArray[x][6];
			}
		}
		if(i == -1){
			//setTimeout("if(WinA.document.getElementById('HelpA') != null){loadHelp(WinA.document.getElementById('HelpA').innerHTML);}",1000);
			return;
		}
	}
	if(mZ == 199){
		var t = winArray.length + 101;
		for (x = 0; x < winArray.length; x++){
			if(winArray[x][7] != 'close'){
				winArray[x][6] = t - (199 - winArray[x][6]);
				$('W' + x).style.zIndex = winArray[x][6];
			}
		}
		mZ = t;
	}
	for(x = 0; x< winArray.length; x++){
		if(winArray[x][6] == 200 && winArray[x][7] != 'close'){
			$('W' + x).style.zIndex = mZ;
			winArray[x][6] = mZ;
			mZ++;
		}
	}
	$('W' + i).style.zIndex = 200;
	winArray[i][6] = 200;
	setTimeout("if($('Help' + " + i + ") != null){loadHelp($('Help' + " + i + ").innerHTML);}",1000);
}
catch(ex){
	alert('Error on fWin(): ' + ex);
}
}


function mxWin(b,i){
try{
	if(b.src.indexOf('min.gif') > 0){//minimize
		var mCount = 0;
		var c = $('C' + i);
		var w = $('W' + i);
		for(x = 0; x < winArray.length; x++){
			if(winArray[x][7] == 'min'){
				mCount++;
			}
		}
		if(mCount >= maxMin){
			alert("Your screen resolution only allows for " + maxMin + " windows to be minimized at one time.  You will need to close or maximize another window in order to minimize this one.");
			return;
		}
		winArray[i][4] = w.style.left;
		winArray[i][5] = w.style.top;
		winArray[i][7] = 'min';
		b.src = '../images/max.gif';
		b.alt = 'Maximize Window';
		c.style.display = 'none';
		$('WinF' + i).style.display = 'none';
		if($('F' + i) != null){
			$('F' + i).style.display = 'none';
		}
		$('WinT' + i).style.width = 110;
		w.style.left = mCount*155 + 5;
		w.style.top = cH - 25;
		fWin();
	} else {//maximize
		b.src = '../images/min.gif';
		b.alt = 'Minimize Window';
		var c = $('C' + i);
		var w = $('W' + i);
		for(x = 0; x < winArray.length; x++){
			if(winArray[x][7] == 'min'){
				if(parseInt($('W' + x).style.left) > parseInt(w.style.left)){
					$('W' + x).style.left = parseInt($('W' + x).style.left) - 155;
				}
			}
		}
		if(c.style.zoom != '' && c.style.zoom != '100%'){
			$('WinT' + i).style.width = Math.round(parseInt(c.style.width)*parseInt(c.style.zoom)/100) - 40;
		} else {
			$('WinT' + i).style.width = parseInt(c.style.width) - 40;
		}
		w.style.left = winArray[i][4];
		w.style.top = winArray[i][5];
		c.style.display = 'block';
		$('WinF' + i).style.display = 'table-row';
		if($('F' + i) != null){
			$('F' + i).style.display = 'block';
		}
		winArray[i][7] = 'max';
		fWin(i);
	}
}
catch(ex){
	alert('Error on mxWin(): ' + ex);
}
}

var cancelCWin = false;
function cWin(id){
try{
	status('Closing window...');
	var w = $(id);
	pageCode(id.substring(1),'OnClose');
	if(cancelCWin == false){
		var focus2Win = -1;
		var gtFocus = 0;
		if(winArray[id.substring(1)][7] == 'min'){
			for(x=0; x < winArray.length; x++){
				if(winArray[x][6] > winArray[id.substring(1)][6]){
					winArray[x][6] = winArray[x][6] - 1;
					$('W' + x).style.zIndex = winArray[x][6];
					if(winArray[x][7] == 'min' && parseInt($('W' + x).style.left) > parseInt(w.style.left)){//d('Moving ' + id + ': ' + winArray[id.substring(1)][7]);
						$('W' + x).style.left = parseInt($('W' + x).style.left) - 155;
					}
				}
			}
		}
		if(forceWins > 0){
			forceWins--;
			if(forceWins == 0){
				sH('Screen');
				$('Screen').style.zIndex = 202;
			}
		}
		purge(id);
		document.body.removeChild($(id));
		mZ--;
		winArray[id.substring(1)][6] = 0;
		winArray[id.substring(1)][7] = 'close';
		fWin();
		status();
	} else {
		cancelCWin = false;
		status();
	}
}
catch(ex){
	alert('Error on cWin(): ' + ex);
}
}

var rX = 0;
var rY = 0;
var rW = 0;
var rH = 0;
var searchW = 0;
var searchH = 0;
var inDiv = false;
function rWin(i,e){
try{
	var c = $('C' + i);
	var wT = $('WinT' + i);
	if(e != null){var evt = e;var evtButton=0;} else {var evt = event;var evtButton=1;}
	//var evt = window.event || e;
	//var wF = $('F' + i);
	if(rW == 0){
		rX = evt.clientX;
		rY = evt.clientY;
		rW = parseInt(c.style.width);
		rH = parseInt(c.style.height);
		/*if($('SearchDiv' + i) != null){
			searchW = parseInt($('SearchDiv' + i).style.width);
			searchH = parseInt($('SearchDiv' + i).style.height);
		}*/
		if(e != null){
			document.onmousemove = function(event){rWin(i,event);}
			document.onmouseup = function(){stopRWin(i);}
		} else {
			document.onmousemove = function(){rWin(i);}
		}
	} else if(evt.button == evtButton){
		c.style.width = rW - (rX-evt.clientX) + 'px';
		c.style.height = rH - (rY-evt.clientY) + 'px';
		if(c.style.zoom != null && c.style.zoom != '' && c.style.zoom != '100%'){
			wT.style.width = Math.round(rW*parseInt(c.style.zoom)/100) - (rX-evt.clientX)-40;
		} else {
			wT.style.width = rW - (rX-evt.clientX)-40;
		}
		var tags = byTag('*',c);
		/*for(rI = tags.length-1; rI > -1; rI--){
			if(tags.item(rI).className.indexOf('winSize') > -1){
				tags.item(rI).style.width = parseInt(tags.item(rI).style.width)	- rW - c.offsetWidth + 'px';
				tags.item(rI).style.height = parseInt(tags.item(rI).style.height) - rH - c.offsetHeight + 'px';
			}
		}*/
		pageCode(i,'OnResize');
		//wF.style.width = wT.style.width;
		
		/*if($('SearchDiv' + i) != null){
			$('SearchDiv' + i).style.width = searchW - (rX-evt.clientX);
			$('SearchDiv' + i).style.height = searchH - (rY-evt.clientY);
			$('ColDiv' + i).style.width = searchW - (rX-evt.clientX);
			$('TagDiv' + i).style.height = searchH - (rY-evt.clientY);
		}*/
	} else if(evt.button == 2){
		wT.style.width = rW - (rX-evt.clientX)-40;
		//wF.style.width = wT.style.width;
		c.style.zoom = Math.round(100 - ((rX-evt.clientX)/rW * 100)) + '%';
	} else {
		stopRWin(i);
	}
}
catch(ex){
	alert('Error on rWin(): ' + ex);
}
}

function stopRWin(i){
try{
	if($('SearchDiv' + i) != null && $('SearchSet' + i) != null){
		setReturn(i);
	}
	if($('Resize' + i) != null){
		pageCode(i,'Resize');
	}
	docDefaults();
	rX = 0;
	rY = 0;
	rW = 0;
	rH = 0;
	searchW = 0;
	searchH = 0;
	inDiv = false;
}
catch(ex){
	alert('Error on stopRWin(): ' + ex);
}
}

function rWinReset(i){
try{
	var c = $('C' + i);
	var wT = $('WinT' + i);
	c.style.width = winArray[i][2];
	c.style.height = winArray[i][3];
	wT.style.width = winArray[i][2] - 40;
	if($('F' + i) != null){
		$('F' + i).style.width = wT.style.width;
	}
	c.style.zoom = '100%';
	if($('SearchDiv' + i) != null){
		$('SearchDiv' + i).style.width = 715;
		$('SearchDiv' + i).style.height = 500;
		$('ColDiv' + i).style.width = 715;
		$('TagDiv' + i).style.height = 500;
	}
	stopRWin(i);
}
catch(ex){
	alert('Error on rWinReset(): ' + ex);
}
}

function uWin(){
try{
	status('Updating Windows');
	nWin('a','/home_page.cfm');
	uMM();
	if($('JSLogin') == null){
		var script = document.createElement("script");
		script.id = 'JSLogin';
		script.src="../system/js_login.js";
		script.type="text/javascript";
		document.body.appendChild(script);
	}
	uWin2(0);
}
catch(ex){
	alert('Error on uWin(): ' + ex);
}
}

function uWin2(i){
try{
	if(winArray[i][7] != 'close'){
		if(winArray[i][0] == 'd'){
			if(typeof winArray[i][1] != 'object'){
				if($('WinT' + i).ueids != null){
					$('WinT' + i).ueids = '';
				}
				ajaxLoader(winArray[i][1],'C' + i,'r','pageCode(' + i + ')');
			}
		} else {
			$('F' + i).location.reload(true);
		}
		var n = 200;
	} else {
		var n = 0;
	}
	i++;
	if(i != winArray.length){
		setTimeout("uWin2(" + i + ")",n);
	} else {
		status('clear');
	}
}
catch(ex){
	alert('Error on uWin2(): ' + ex);
}
}

function uMM(){
try{
	ajaxLoader('../system/main_menu.cfm','MainMenu','r');
}
catch(ex){
	alert('Error on uMM(): ' + ex);
}
}

function cGadget(){
try{
	for(n=0; n<winArray.length; n++){
		if(winArray[n][7] == 'gadget'){
			cWin('W' + n);
		}
	}
}
catch(ex){
	alert('Error on cGadget(): ' + ex);
}
}

function adjustA(){
try{
	$('CA').style.height = cH - 190 - $('DivA').offsetHeight;
	$('CA').style.display = 'block';
	$('MTable').style.height = '100%';
}
catch(ex){
	d('Error on adjustA(): ' + ex);
}
}



function pageCode(i,which){
try{
	if(which == null){
		which = 'JSCode';
	}//d(i + ' ' + which);
	if($(which + i) != null){
		var theStartCode = $(which + i).innerHTML;//alert(theStartCode);
		var theCode = '';
		for(i=0; i<theStartCode.length; i++){//this code is necessary for some loading, particularly where XML is involved.  Puts in extra [return]s, line feeds and something that doesn't even have a charCode.
			if(theStartCode.charCodeAt(i) != 10 && theStartCode.charCodeAt(i) != 13 && theStartCode.charCodeAt(i) !== ''){
				theCode += theStartCode.substr(i,1);
			}
		}
		rpl = /&amp;/gi;
		theCode = theCode.replace(rpl,"&");
		rpl = /&lt;/gi;
		theCode = theCode.replace(rpl,"<");
		rpl = /&gt;/gi;
		theCode = theCode.replace(rpl,">");
		rpl = /\n/gi;
		theCode = theCode.replace(rpl,"");
		eval(theCode);
	}
}
catch(ex){
	alert('Error on pageCode() for ' + which + ': ' + ex);
}
}


var subLevel = 0;
var cxtObj;
var orgObj;
var cxtMenu;
var cxtL = 0;
var cxtT = 0;
var cxtTimer;

function resetCxt(){
	cxtHide();
	subLevel = 0;
	cxtObj = null;
	orgObj = null;
	cxtMenu = null;
	cxtL = 0;
	cxtT = 0;
	cxtTimer = null;	
}
function cxt(t,w,v,y,g){ //t=type/menu to call, w=window, v=variables to pass, y=the id of the item opening the submenu; causes a delay in case user moves on to another item, g=if present released delayed opening
try{
	clearInterval(cxtTimer);
	if(y != null && g == null){
		cxtTimer = setTimeout('cxt("' + t + '","' + w + '","' + v + '","' + y + '",1);',250);
		return;
	}
	if(y == null || y == 'undefined'){
		if(!window.event && g == null){
			cxtTimer = setTimeout('cxt("' + t + '","' + w + '","' + v + '","' + y + '",1);',250);//rerun so recEvt has time to be filled with the event - docDefaults	
			return;
		}
		var evt = window.event || recEvt;
		if(evt.type == 'contextmenu'){
			cxtHide();
		}
		if(evt.srcElement){
			cxtObj = evt.srcElement;
		} else {
			cxtObj = evt.target;
		}
		if(cxtObj.id == ''){
			try{
			var f = cxtObj.parentNode;//offsetParent;
			while(f.id == ''){
				f = f.parentNode;//offsetParent;
			}
			cxtObj = f;
			}
			catch(x){d('weirdo no cxt parent error');resetCxt();}
			
		}
	} else {
		cxtObj = $(y);
	}
	subLevel++;
	if(subLevel == 1){
		cxtL = evt.clientX;
		cxtT = evt.clientY;
		orgObj = cxtObj;//used to determine what was originally clicked, eg on search return columns
	} else {
		cxtL = cxtObj.offsetParent.offsetWidth - 3;
		cxtT = 0;
		var pObj = cxtObj;
		while(pObj.tagName != 'BODY'){
			cxtL += pObj.offsetLeft;
			cxtT += pObj.offsetTop;
			if(pObj.offsetParent){
				pObj = pObj.offsetParent;
			} else {
				break;	
			}
		}
	}
	if($('Cxt' + subLevel) == null){
		var menu = document.createElement('div');
		menu.id = 'Cxt' + subLevel;
		menu.className = 'cxt';
		document.body.appendChild(menu);
		var menu = $('Cxt' + subLevel);
	} else {
		var menu = $('Cxt' + subLevel);
		menu.style.height = '';
		menu.style.width = '';
		menu.innerHTML = '';
	}
	if(v == null || (v != null && (v == 'NA' || v == 'undefined'))){var v = ''}//alert(t + ' ' + w + ' ' + subLevel + ' ' + v);
	ajaxLoader('../cxt/cxt.cfm?type=' + t + '&w=' + w + '&sub=' + subLevel + '&vars=' + v,'NA','j','adjustCxt(' + subLevel + ');');
}
catch(ex){
	d('Error on cxt(): ' + ex);
	resetCxt();
}
}

function adjustCxt(subLevel){
try{
	var menu = $('Cxt' + subLevel);
	var left = 0;
	var top = 0;
	if(parseInt(menu.style.left) + menu.offsetWidth > cW){
		if(subLevel == 1){
			left = menu.offsetWidth - 2;
		} else {
			left = $('Cxt' + (subLevel-1)).offsetWidth + menu.offsetWidth - 2;
		}
	}
	if(parseInt(menu.style.top) + menu.offsetHeight > cH){
		if(subLevel == 1){
			top = menu.offsetHeight;
		} else {
			top = $('Cxt' + (subLevel-1)).offsetHeight + menu.offsetHeight;
		}
	}
	left -= document.body.scrollLeft;
	top -= document.body.scrollTop;
	menu.style.left = parseInt(menu.style.left) - left;
	menu.style.top = parseInt(menu.style.top) - top;
}
catch(ex){
	alert('Error on adjustCxt(): ' + ex);
	resetCxt();
}
}

function addCxt(id,f){ // id = id of the object to add the cxt menu to, f = the function to add.  This is for adding a cxt menu through pageCode.  It's necessary because JSCode is loaded through eval(), which does not support function().
try{
	$(id).oncontextmenu = function(){
		eval(f);
	}
}
catch(ex){
	alert('Error on addCxt(): ' + ex);
}
}
function cxtAItem(jS,display,subMenu,cSS){ // a = js script to run, d = title to display, s = submenu count, c = css class to use, other than default.  !cxtMenu global variable must be defined!
try{
	if(cSS == null){
		var cSS = "b2 p";
	}
	cxtMenu.innerHTML += '<div class="' + cSS + '" style="white-space:nowrap;" onclick="' + jS + '" onmouseover=cxtHide(' + subMenu + ');this.style.backgroundColor=\'FFFF00\' onmouseout=this.style.backgroundColor=\'CCCCCC\';>' + display + '</div>';
}
catch(ex){
	alert('Error on cxtAItem(): ' + ex);
}
}

function cxtSItem(t,w,v,display,sM,cSS){ //t=type (e.g. Attribute, Column), w=window, v=variables to pass, d = title to display, s = submenu count, c=css class to use, other than default  !cxtMenu global variable must be defined!
try{
	if(cSS == null){
		var cSS = "b2 p";
	}
	cxtMenu.innerHTML += '<div id="Cxt' + display + sM +  w + '" class="' + cSS + '" style="white-space:nowrap;" onmouseover="cxtHide(' + sM + ');cxt(\'' + t + '\',\'' + w + '\',\'' + v + '\',\'Cxt' + display + sM + w + '\');">' + display + ' &raquo;</div>';
}
catch(ex){
	alert('Error on cxtSItem(): ' + ex);
}
}
	
function cxtHide(index){
try{
	if(index == null || typeof index == 'object'){
		var index = 0;
	}
	i =  index + 1;
	while($('Cxt' + i) != null){//hides menus further down the line
		$('Cxt' + i).style.visibility = 'hidden';
		i++;
	}
	for(i=subLevel; i > index; i--){
		$('Cxt' + i).style.visibility = 'hidden';
	}
	subLevel = i;
}
catch(ex){
	alert('Error on cxtHide(): ' + ex);
}
}

function loadHelp(value){
try{
	if($('HelpDiv') != null && value != ''){
		ajaxLoader('../system/help_search.cfm?Query=' + value,'HelpDiv','r');
	} else if($('HelpDiv') != null && value == ''){
		$('HelpDiv').innerHTML = 'No help topics available.';
	}
}
catch(ex){
	alert('Error on loadHelp(): ' + ex);
}
}

var sSpeed = 5;
function iSlideshow(ueid,w){
	sH('Screen');
	$('Screen').style.zIndex = 201;
	if($('ImgViewer') == null){
		var viewer = document.createElement("div");
		viewer.id = 'ImgViewer';
		viewer.style.width = cW;
		viewer.style.height = cH;
		viewer.style.zIndex = 203;
		viewer.style.position = 'absolute';
		viewer.style.left = 0;
		viewer.style.top = 0;
		viewer.style.display = 'block';
		viewer.style.overflow = 'hidden';
		document.body.appendChild(viewer);
	} else {
		sH('ImgViewer');
	}
	status('Loading Images...');
	ajaxLoader('../listings/img_viewer.cfm?UEID=' + ueid + '&W=' + w,'ImgViewer','r','lSlideshow(' + w + ')');
}

function lSlideshow(w){
try{
	$('ShowImg' + w).setAttribute('curthumb',-1);
	/*var img = $('MainImg');
	img.style.left = (cW-img.offsetWidth)/2;
	img.style.top = (cH-img.offsetHeight)/2;*/
	document.onmousemove = function(){opacity('ImgControl',.1);}
	
	document.onkeyup = function (e){
		if(e){recEvt=e;}else{recEvt=event;}
		pageCode(w,'Keyboard');
	}
	
	hider = setTimeout('opacity(\'ImgControl\',-.1);',3000);
	setTimeout('generic=\'\';pageCode(' + w + ',\'ShowImg\');pageCode(' + w + ',\'Slideshow\');status();',1000);
	
}
catch(ex){
	alert('Error on lSlideshow(): ' + ex);
}
}



function opacity(id,delta,speed,hideAfter){//id - of the object, delta - amount of opacity change as decimal: + for up, - for down, speed (100) - in milliseconds, hideAfter (3000) - to hide the obj after milliseconds, use 0 to cancel
	obj = $(id);
	clearTimeout(obj.getAttribute('hider'));
	if(!speed){var speed = 100;}
	if(!hideAfter){hideAfter = 1000;}
	if(!obj.getAttribute('NoHide')){
		obj.setAttribute('NoHide','false');	
	}
	if(hideAfter == 0){
		obj.setAttribute('NoHide','true');	
	}
	if(delta > 0){d(obj.getAttribute('NoHide'));
		if(obj.style.opacity && parseFloat(obj.style.opacity) < 1){
			obj.style.opacity = parseFloat(obj.style.opacity) + delta;
			hider = setTimeout('opacity(\'' + obj.id + '\',' + delta + ',' + speed + ',' + hideAfter + ');',speed);
			obj.setAttribute('hider',hider);
		} else if(obj.filters && obj.filters.alpha && parseInt(obj.filters.alpha.opacity) < 100){
			obj.filters.alpha.opacity = parseInt(obj.filters.alpha.opacity)+(delta*100);
			hider = setTimeout('opacity(\'' + obj.id + '\',' + delta + ',' + speed + ',' + hideAfter + ');',speed);
			obj.setAttribute('hider',hider);
		} else if(obj.getAttribute('NoHide') == 'false'){//
			hider = setTimeout('opacity(\'' + obj.id + '\',' + (-1*delta) + ',' + speed + ',' + hideAfter + ');',hideAfter);
			obj.setAttribute('hider',hider);
		}
	} else {
		var again = true;
		if(obj.style.opacity && parseFloat(obj.style.opacity) > 0){
			obj.style.opacity = parseFloat(obj.style.opacity)+delta;
		} else if(obj.filters && obj.filters.alpha && parseInt(obj.filters.alpha.opacity) > 0){
			obj.filters.alpha.opacity = obj.filters.alpha.opacity+(delta*100);
		} else {
			again = false;
		}	
		if(again){
			hider = setTimeout('opacity(\'' + obj.id + '\',' + delta + ',' + speed + ',' + hideAfter + ');',speed);
			obj.setAttribute('hider',hider);
		}
	}
	
}

function xSlideshow(){
	clearInterval($('ImgControl').getAttribute('run'));
	purge('ImgViewer');
	$('ImgViewer').innerHTML = '';
	sH('ImgViewer');
	sH('Screen');
	docDefaults();
}


function moveRec(ueids,cur,w){
try{
	ajaxLoader('../listings/listing.cfm?UEIDs=' + ueids + '&Cur=' + cur + '&W=' + w,'C' + w,'r','pageCode(' + w + ')');
}
catch(ex){
	alert('Error on moveRec(): ' + ex);
}
}



function iLister(o,l,a,s,m,r,c,f){//Initiate lister - o*=object, l*=list, a=action (function to call after select), s=start after char [0], m=limit to list (true,[false]), r=replace all [true], c=clear object value [false], f=return obj to focus [false]
// action will only run after a selection if obj does not get focus.  for an object that receives focus after select, action only runs on enter key.  If you need both, the action function will need to run fLister() itself.
try{
	//this stops iLister from running when the user uses the lister scroll bar
	if(iLister.v != null && iLister.v == true){
		return;
	}
	//set iLister properties
	if(o != iLister.o){//checks if initiate same object, and if not set up the blur events appropriately
		if(iLister.o != null && iLister.b != null){//if the blur variable was filled from a previous lister obj, give it back to the original obj before setting for the new
			iLister.o.onblur = iLister.b;
			iLister.b = null;
		}
		if(o.onblur != null){// if object has a blur event, then save it to iLister.b
			iLister.b = o.onblur;
		}
	}/* else if(o != iLister.o){
		iLister.b = null;
	}*/
	iLister.o = o;
	o.onblur = function(){
		try{
			if(window.event && browser != 'chrome' && browser != 'safari'){//though chrome acts like IE on events basically, it doesn't capture the right clientX-Y, so use recEvt
				var evt = window.event;
			} else {
				var evt = recEvt;
			}
			if($('Lister').style.visibility == 'hidden' || (evt.clientX < parseInt($('Lister').style.left) || evt.clientX > (parseInt($('Lister').style.left) + $('Lister').offsetWidth) || evt.clientY < parseInt($('Lister').style.top) || evt.clientY > (parseInt($('Lister').style.top) + $('Lister').offsetHeight))){
				if(iLister.b != null){
					var exec = iLister.b.toString();
					if(exec.indexOf('xLister') == -1){
						exec = exec.substring(exec.indexOf('{')+1);
						exec = exec.substring(0,exec.lastIndexOf('}')-1);
						eval(exec);
					}
				}		
				setTimeout("xLister('" + this.id + "'," + iLister.m + ")",250);
			}
		}
		catch(ex){
			d('Error on lister blur event: ' + ex);
		}
	}
	o.onkeyup = function(){
		var evt = window.event || arguments[0];
		lLister(evt,null);
	}
	o.onkeydown = function(){
		try{
		var evt = window.event || arguments[0];
		if(evt.keyCode == 9){
			xLister();
		}
		}
		catch(ex){
			alert('Error on lister onkeydown event: ' + ex);
		}
	}
	if(o.value == null){
		o.value = '';
	}
	iLister.l = l;
	iLister.t = 'set';
	iLister.v = false;//determines if user is over the lister
	if(a == null){iLister.a = 'NA';} else {iLister.a = a;}
	if(s == null){iLister.s = 0;} else {iLister.s = s;}
	if(m == null){iLister.m = true;} else {iLister.m = m;}
	if(r == null){iLister.r = true;} else {iLister.r = r;}
	if(c == null){iLister.c = false;} else {iLister.c = c;}
	iLister.d = o.value;
	if(o.getAttribute('selection') && o.getAttribute('selection') != ''){//stores the current selection
		iLister.e = o.getAttribute('selection');
	}
	if(c != null && c == true){
		iLister.o.value = '';
	}
	if(f == null){iLister.f = false;} else {iLister.f = f;}
	iLister.m1 = null;
	if($('Lister') == null){
		var lister = document.createElement("div");
		lister.id = 'Lister';
		lister.style.height = '100';
		if(o.style.backgroundColor != ''){
			lister.style.backgroundColor == o.style.backgroundColor;
		}
		lister.onmouseout = function(){setTimeout("iLister.v = false;",250);}//these two are added for lister scroll bar functionality
		lister.onmousedown = function(){if(event.srcElement.id == 'Lister'){iLister.v = true;setTimeout("fLister()",100);}}
		document.body.appendChild(lister);
	} else {
		var lister = $('Lister');
		lister.innerHTML = '';
	}
	lister.className = 'lister ' + o.className;
	lister.style.width = o.offsetWidth;
	var pObj = o.offsetParent;
	var lL = o.offsetLeft + 1;
	var lT = o.offsetTop + o.offsetHeight;
	while(pObj.tagName != 'BODY'){
		lL += pObj.offsetLeft - pObj.scrollLeft;
		lT += pObj.offsetTop - pObj.scrollTop;
		pObj = pObj.offsetParent;
	}
	lister.style.left = lL;
	lister.style.top = lT;
	lLister();
}
catch(ex){
	alert('Error on iLister(): ' + ex);
}
}

	
function lLister(evt,time){//Get list items - if time is not null, runs list.  if is null sets to run again.
try{
	if(evt != null && (evt.keyCode == 40 || evt.keyCode == 38 || evt.keyCode == 13)){
		kLister(evt.keyCode);
	} else {
		clearTimeout(iLister.t);
		if(iLister.p == null){
			var sValue = iLister.s;
		} else {
			var sValue = iLister.s + iLister.o.value.lastIndexOf(iLister.p) + 1;
		}
		if(iLister.o.value.length >= sValue){
			if(time == null){
				<!---if(iLister.m == true){time=1000;}else{time=2500;}--->
				iLister.t = setTimeout('lLister(null,1)',iLister.s*250);//waits 250 milliseconds x number of characters to wait before submitting the request
			} else {
				if(iLister.l.indexOf('?') > -1){
					var list = iLister.l.substr(0,iLister.l.indexOf('?'));
					var specifier = iLister.l.substring(iLister.l.indexOf('?') + 1);
				} else {
					var list = iLister.l;
					var specifier = '';
				}
				ajaxLoader('../lister/list.cfm?l=' + list + '&s=' + specifier + '&q=' + iLister.o.value,'NA','j');
				
			}
		} else {
			$('Lister').style.visibility = 'hidden';
		}
	}
}
catch(ex){
	alert('Error on lLister(): ' + ex);
}
}

function kLister(key){
try{
	var selected = -1;
	var listed = byTag('div','Lister');
	for(i=0; i < listed.length; i++){
		if(isBGColor('ffff00',listed.item(i)) == true){
			selected = i;
		}
	}
	if(key == 40){//down arrow key
		selected++;
		if(selected > 3 && selected < listed.length){
			$('Lister').scrollTop += listed.item(selected).offsetHeight;
		} else if(selected >= listed.length){
			$('Lister').scrollTop -= 1000;
			selected = 0;
		}
	} else if(key == 38){//up arrow key
		if(selected == 0){
			selected = listed.length-1;
			$('Lister').scrollTop += 1000;
		} else {
			selected--;
			if(selected >= 3){
				$('Lister').scrollTop -= listed.item(selected).offsetHeight;
			}
		}
	} else if(key == 13){//Enter key
		if(iLister.o.value != '' && $('Lister').innerText == 'Invalid Selection' && iLister.m == true){
			alert('You must select a value from the list provided.');
			iLister.o.setAttribute('selection','');
			iLister.o.value = '';
		} else if(iLister.o.value != '' && iLister.m == true && selected == -1){
			if(iLister.a != 'NA'){
				eval(iLister.a);
			}
			return;
		} else {
			if($('Lister').style.visibility == 'visible'){
				var exec = listed.item(selected).onclick;
				exec();
			} else {
				if(iLister.a != 'NA'){
					eval(iLister.a);
				}
			}
		}
	}//d('You selected ' + selected);
	if(selected > listed.length || selected == -1){
		hLister();
	} else {
		hLister(listed.item(selected));
	}
}
catch(ex){
	alert('Error on kLister(): ' + ex);
}
}

function cLister(code,display){//add items to list
try{
	var choice = '<div id="choice" onmouseover="hLister(this);" onmouseout="hLister(this)" onclick="sLister(\'' + code.replace(/'/gi,'\\\'') + '\',\'' + display.replace(/'/gi,'\\\'') + '\')">' + display + '</div>';
	return choice;
	
}
catch(ex){
	alert('Error on cLister(): ' + ex);
}
}

function hLister(obj){//highlight current item
try{
	var choices = byTag('div','Lister');
	for(i=0; i < choices.length; i++){
		choices.item(i).style.backgroundColor = '';
	}
	if(obj != null){
		obj.style.backgroundColor = 'ffff00';
	}
}
catch(ex){
	alert('Error on hLister(): ' + ex);
}
}

function sLister(code,display){//select item
try{
	if(iLister.p != null){
		iLister.o.value = iLister.o.value.substr(0,iLister.o.value.lastIndexOf(iLister.p)+1) + display;
	} else {
		iLister.o.value = display;
	}
	iLister.o.setAttribute('selection',code);
	if(iLister.f == true){
		fLister();
	} else {
		if(iLister.a != 'NA'){
			eval(iLister.a);
		}
	}
	xLister();
}
catch(ex){
	alert('Error on sLister(): ' + ex);
}
}

function fLister(){
try{
	if(iLister.o.tagName == 'INPUT' || iLister.o.tagName == 'TEXTAREA'){
		if(window.getSelection){
			iLister.o.focus();
			iLister.o.setSelectionRange(iLister.o.value.length,iLister.o.value.length);
		} else if(iLister.o.createTextRange) {
			var range = iLister.o.createTextRange();
			range.moveStart("character",iLister.o.value.length);
			range.moveEnd("character",iLister.o.value.length);
			range.select();
			iLister.o.focus();
		}
	}
	iLister.noI = true;
}
catch(ex){
	alert('Error on fLister(): ' + ex);
}
}

function xLister(oID,oM,e){//close lister - uses the iLister variables usually.  Input variables are present for when a limited list is closed by moving to another lister obj
try{
	if(((oID != null && oID == iLister.o.id) || oID==null) && iLister.v == false){
		if(iLister.o.value != '' && iLister.m == true && (iLister.o.getAttribute('selection') == null || iLister.o.getAttribute('selection') == '')){
			iLister.o.setAttribute('selection','');
			iLister.o.value = '';
			alert('You must select a value from the list provided.');
		}
		iLister.p = null;
		setTimeout("$('Lister').style.visibility = 'hidden'",200);
	} else if(oID != null){
		if($(oID).value != '' && oM == true && ($(oID).getAttribute('selection') == null || $(oID).getAttribute('selection') == '')){
			$(oID).setAttribute('selection','');
			$(oID).value = '';
			alert('You must select a value from the list provided.');
		}
	}
	//d(iLister.m + ' ' + iLister.c + ' |' + iLister.o.value + '| ' + iLister.d);
	if(iLister.m == true && iLister.c == true && iLister.o.value == ''){
		iLister.o.value = iLister.d;
		iLister.o.setAttribute('selection',iLister.e);
	}
}
catch(ex){
	alert('Error on xLister(): ' + ex);
}
}

function validateEmail(str){
try{
	if(str.indexOf(',') > -1 && str.indexOf(';') > -1){
		alert('E-mails should be separated by a comma OR a semi-colon, not both.\n\nPlease choose only one as a seperator.');
		return false;
	} else {
		var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		if(str.indexOf(';') > -1){var sep = ';';} else {var sep=',';}
		var checkArray = str.split(sep);
		var action = true;
		for(ei = 0; ei < checkArray.length; ei++){
			var checkIt = trim(checkArray[ei]);
			if(checkIt != '' && checkIt != ' '){
				if(checkIt.indexOf('<') > -1 && checkIt.indexOf('>')){
					checkIt = checkIt.substring(checkIt.indexOf('<')+1,checkIt.indexOf('>'));
				}
				if (!filter.test(checkIt)) {
					alert('"' + checkArray[ei] + '" does not appear to be a valid e-mail adddress.  Please double-check the address.');
					action = false;
				}
			}
		}
		return action;
	}
}
catch(ex){
	alert('Error on validateEmail(): ' + ex);
}
}

function d(value){
try{
	if($('Diagnostic') != null){
		if(value == 'ClearDiagnostic'){
			$('Diagnostic').value = '';
		} else {
			$('Diagnostic').value += value + '\n';
		}
	}
}
catch(ex){
	alert('Error on d(): ' + ex);
}
}

<!-- Original:  CodeLifter.com (support@codelifter.com) -->
<!-- Web Site:  http://www.codelifter.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

var tempX = 0;
var tempY = 0;
function initMouseXY(){
try{
	if($('MouseX') != null){
		if (!document.all){document.captureEvents(Event.MOUSEMOVE);}
		document.onmousemove = getMouseXY;
	} else {
		document.onmousemove = '';
	}
}
catch(ex){
	alert('Error on initMouseXY(): ' + ex);
}
}

function getMouseXY(e) {
try{
	if (window.event) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	} 
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}
	if($('MouseX') != null){
		$('MouseX').innerHTML = tempX;
		$('MouseY').innerHTML = tempY;
	}
	return true;
}
catch(ex){
	alert('Error on getMouseXY(): ' + ex);
}
}
//  End -->

/*function pdfIt(items,t){
	var pdfHTML = $('PDFHTML');
	pdfHTML.value  = '';
	if(t == null && $('PTitle') != null && $('PTitle').value != ''){
		var t = $('PTitle').value;
	}
	if(t != null){
		pdfHTML.value = '<span style="width:100%; text-align:center;" class="b3">' + t + '</span>';
	}
	while(items.indexOf('|') > -1){
		var what = $(items.substring(0,items.indexOf('|')));
		pdfHTML.value += '' + what.innerHTML;
		items = items.substring(items.indexOf('|')+1);
	}
	if(items != 'NA'){
		var what = $(items);
		pdfHTML.value += '' + what.innerHTML;
	}alert('hi!');
	ajaxLoader($('PDFForm'));
}*/

function printIt(items,t,a,s,o){ //items="|" delimited list of objects to print (or 'NA'), t=title to print, a=auto scale, s=page size, o=page orientation
	if(window.PrintWin == null){
		alert('The print window is not accessible.  Please contact your system administrator.');
		return;
	}
	var printWin = window.PrintWin;
	if(window.PrintWin.document.getElementById('PrintDiv') == null){
		alert('There is a problem accessing the Print Div.  Please contact your system administrator.');
		return;
	}
	var printDiv = window.PrintWin.document.getElementById('PrintDiv');
	var printTitle = window.PrintWin.document.getElementById('PrintTitle');
	if(items != 'NA'){
		printDiv.innerHTML = '';
	}d('1');
	printTitle.innerHTML = '';
	//printDiv.style.zoom = '100%';
	//for multiple objs to be printed
	while(items.indexOf('|') > -1){
		var what = $(items.substring(0,items.indexOf('|')));
		printDiv.innerHTML += '' + what.innerHTML;
		items = items.substring(items.indexOf('|')+1);
	}d('2');
	if(items != 'NA'){
		var what = $(items);
		printDiv.innerHTML += '' + what.innerHTML;
	}
	if(a == null && $('PScaleOn') != null && $('PScaleOn').checked){
		var a = 'on';
	} else if(a==null && $('PScaleWarn') != null) {
		var a = 'warn';
	} else {
		var a = 'off';
	}d('3');
	if(a != 'off'){
		if(s == null && $('PLegal') != null && $('PLegal').checked){
			var s = 'legal';
		} else {
			var s = 'letter';
		}
		if(o == null && $('PLandscape') != null && $('PLandscape').checked){
			var o = 'landscape';
		} else {
			var o = 'portrait';
		}
		if(s == 'letter' && o == 'landscape'){
			var pWidth = 900;
		} else if (s == 'letter'){
			var pWidth = 640;
		} else if (s == 'legal' && o == 'landscape'){
			var pWidth = 1200;
		} else {
			var pWidth = 640;
		}
		
		if(printDiv.offsetWidth > pWidth){
			if(a == 'on'){
				printDiv.style.zoom = Math.round(pWidth/printDiv.offsetWidth * 100) + '%';
			} else {
				var choice = confirm("The width of the window you are trying to print exceeds the page width by " + (100 - Math.round(pWidth/printDiv.offsetWidth * 100)) + "%.  The whole window may not print.\n\nClick OK to continue.\nClick Cancel to cancel printing.");
				if(choice == false){
					return;
				}
			}
		}
		
	}d('4');
	if(t == null && $('PTitle') != null && $('PTitle').value != ''){
		var t = $('PTitle').value;
		printTitle.innerHTML = t + '<br><br>';
	}d('5');
	printWin.focus();
	printWin.print();
}

function goListing(w,index){//w= w value of the listing, c=counter used to specify a section to load
try{
	var win = $('WinT' + w);
	if(win.getAttribute('ueids') != null && win.getAttribute('ueids') != ''){
		var wArray = win.getAttribute('ueids').split(',');
		if(index < 0 || index >= wArray.length){
			if(index < 0){
				alert('You are already viewing the first record.');
			} else {
					alert('You are already viewing the last record.');
			}
			return;
		}
		var ueid = wArray[index];
		if($('RDisplay' + w) != null){
			$('RDisplay' + w).innerHTML = (index + 1) + ' of ' + wArray.length + ' Records';
		}
		ajaxLoader('../listings/listing.cfm?W=' + w + '&UEIDs=' + ueid,'C' + w,'r','goListingSection(' + w + ');');
	} else {
		alert('The required information was not supplied.  The listing cannot be loaded.');
	}
}
catch(ex){
	alert('Error on goListing(): ' + ex);
}
}

function goListingSection(w,index){
try{
	if(index == null){
		var spans = byTag('span','C' + w);
		generic = new Array();
		for(i = 0; i < spans.length; i++){
			if(spans.item(i).getAttribute('loads') == 'yes'){
				generic[generic.length] = $(spans.item(i).id);
			}
		}
		index = 0;
	}
	if(isNaN(index) == true){
		var span = $(index);
		var l = span.getAttribute('url') + '?W=' + w;
		if(span.getAttribute('vars') != null && span.getAttribute('vars') != ''){
			l += '&' + span.getAttribute('vars');
		}
		ajaxLoader(l,span.id,'r');
	} else {
		if(index < generic.length){
			var l = generic[index].getAttribute('url') + '?W=' + w;
			if(generic[index].getAttribute('vars') != null && generic[index].getAttribute('vars') != ''){
				l += '&' + generic[index].getAttribute('vars');
			}
			ajaxLoader(l,generic[index].id,'r','goListingSection(' + w + ',' + (index + 1) + ');');
		} else {
			pageCode(w); //this is here to reload listing window when multiple listings.
			pageCode(w,'ResetUser'); // reloads the true user
		}
	}
}
catch(ex){
	alert('Error on goListingSection(): ' + ex);
}
}

function goNYCData(w,index){
try{
	var win = $('WinT' + w);
	if(win.ueids != null && win.ueids != ''){
		var wArray = win.ueids.split(',');
		if(index < 0 || index >= wArray.length){
			if(index < 0){
				alert('You are already viewing the first record.');
			} else {
					alert('You are already viewing the last record.');
			}
			return;
		}
		var ueid = wArray[index];
		if($('RDisplay' + w) != null){
			$('RDisplay' + w).innerHTML = (index + 1) + ' of ' + wArray.length + ' Records';
		}
		ajaxLoader('../listings/listing_nyc.cfm?W=' + w + '&UEIDs=' + ueid,'C' + w,'r','pageCode(' + w + ');');
	} else {
		alert('The required information was not supplied.  The listing cannot be loaded.');
	}
}
catch(ex){
	alert('Error on goNYCData(): ' + ex);
}
}

function updatePresenter(w,p){//an unfortunate necessity
	pageCode(w,'Reset' + p);
	pageCode(w,'Adjust' + p);
	setTimeout("pageCode(" + w + ",'RequireApproval');",3000);
}

function purge(id) {
	var els = byTag('*',id);
	for(purgeI = 0; purgeI < els.length; purgeI++){
		els.onclick = null;
		els.oncontextmenu = null;
		els.onmouseover = null;
		els.onmouseout = null;
	}
	if(typeof id != 'object'){var obj = $(id);} else {var obj = id;}
	obj.onclick = null;
	obj.oncontextmenu = null;
	obj.onmouseover = null;
	obj.onmouseout = null;
}

function bytes(b){
	if(b == 0){
		return '0 KB';
	} else if(b < 1024){
		return '&lt; 1 KB';
	} else if(b >= 1024 && b < 1048576){
		return Math.round((b*10)/1024)/10 + ' KB';
	} else if(b >= 1048576 && b < 1073741824){
		return Math.round((b*10)/1048576)/10 + ' MB';
	} else if(b >= 1073741824 && b < 1099511627776){
		return Math.round((b*10)/1073741824)/10 + ' GB';
	} else {
		return '&gt 1 TB';
	}
}

function iTip(text){//text = the text to display
	if(typeof text == 'object'){
		text = text.getAttribute('description');	
	}
	if(text != ''){
		var evt = window.event || recEvt;
		var tipDiv = $('Tip');
		tipDiv.innerHTML = text;
		if(evt.clientX + document.body.scrollLeft+210 > cW){
			tipDiv.style.left = evt.clientX + document.body.scrollLeft-210;
		} else {
			tipDiv.style.left = evt.clientX + document.body.scrollLeft+10;
		}
		if(evt.clientY + document.body.scrollTop+210 > cH){
			tipDiv.style.top = evt.clientY + document.body.scrollTop-tipDiv.offsetHeight;
		} else {
			tipDiv.style.top = evt.clientY + document.body.scrollTop+10;
		}
		tipDiv.style.display = 'block';
		if(evt.srcElement){
			evt.srcElement.onmouseout = function(){$('Tip').style.display = 'none';}
		} else {
			evt.target.onmouseout = function(){$('Tip').style.display = 'none';}
		}
	}
}

