	
		//register onload events here.
		//EventListener.addEvent(window, 'load', function() {
		//});
		// ----------------------


		
		/*corespin form js bug*/		
		function validateForm_2(loForm, loInput){ //stub doesn't really do anything just forces a return value of true.
		    var oURLField = $('slug');  
			if (oURLField!==false) {
				setRecordURL(oURLField.value,oURLField);
			}
			loForm = $(loForm);
			lsFormID = '';
			if(loForm) {
			  if(loForm.id) {
			      lsFormID = loForm.id
			  }
			}
			lsSubmitID = '__submitjs' + lsFormID;
			lsConfirmID = '__confirmjs' + lsFormID;
			loSubmit = $(lsSubmitID);
			loConfirm = $(lsConfirmID);
			if(loSubmit) {
			  loSubmit.value=true;
			}
			if(loConfirm) {
			  loConfirm.value=true;
			}
			lsSubmitID = '__submitjs';
			lsConfirmID = '__confirmjs';
			loSubmit = $(lsSubmitID);
			loConfirm = $(lsConfirmID);
			if(loSubmit) {
			  loSubmit.value=true;
			}
			if(loConfirm) {
			  loConfirm.value=true;
			}
			return true;
		}
		/*corespin form js bug*/		
		
		
		
		
		
		
		
		
		
		//JS SCROLLING
		//*****************************************
		
		var scrollUpInterval;
		var scrollDownInterval;
		var oScrollDiv;
		//*****************************************
		function scrollUp(iElementId, iJumpRate, iRate) {
			if (scrollUpInterval != null) {
				return;	
			}
			oScrollDiv = document.getElementById(iElementId);
			scrollUpInterval = window.setInterval("oScrollDiv.scrollTop-="+iJumpRate, iRate);
		}
		//*****************************************
		
		//*****************************************
		function scrollDown(iElementId, iJumpRate, iRate) {
			if (scrollDownInterval != null) {
				return;	
			}
			oScrollDiv = document.getElementById(iElementId);
			scrollDownInterval = window.setInterval("oScrollDiv.scrollTop+="+iJumpRate, iRate);
		}
		//*****************************************
		
		//*****************************************
		function scrollStop() {
			if (scrollUpInterval != null) {
				window.clearInterval(scrollUpInterval);
				scrollUpInterval = null;
			}
			if (scrollDownInterval != null) {
				window.clearInterval(scrollDownInterval);	
				scrollDownInterval = null;
			}
		}
		//*****************************************		
		
		
		//HIGHLY USED FUNCTIONS
		//*****************************************
		function $() { // returns object reference || array of object references
			var loElements = new Array();
			for (var i = 0; i < arguments.length; i++) {
				var loElement = arguments[i];
				if (typeof(loElement) == 'string') {
					loElement = (document.getElementById(loElement)||false);
				}
				if (arguments.length==1) {
					return loElement;
				}
				loElements.push(loElement);
			}
			return loElements;
		}
		//*****************************************

		function insertAfter(loInsertThisElement,loAfterThisElement) { //why is there no DOM.insertAfter?
			if(loAfterThisElement.nextSibling) {
				return (loAfterThisElement.parentNode.insertBefore(loInsertThisElement,loAfterThisElement.nextSibling));
			} else {
				return (loAfterThisElement.parentNode.appendChild(loInsertThisElement));
			}
		}
		//*****************************************

		function getDimensions() { //set up "cross browser" document dimensions
			this.IE=document.all && !window.opera;
			this.CommonBody = (document.compatMode=='CSS1Compat')?(document.documentElement):(document.body);
			this.CommonBody = (this.IE) ? (document.body) : (document.documentElement) //create reference to common body across doctypes
			this.scrollbarwidth=window.innerWidth-(this.CommonBody.offsetLeft+this.CommonBody.offsetWidth); //http://www.howtocreate.co.uk/emails/BrynDyment.html
			this.scrollbarwidth=(Number(this.scrollbarwidth))?(this.scrollbarwidth):(0);
			this.iScrollTop = (this.IE) ? (this.CommonBody.scrollTop) : (window.pageYOffset);
			this.iScrollLeft = (this.IE) ? (this.CommonBody.scrollLeft) : (window.pageXOffset);
			this.iDocWidth = (this.IE) ? (this.CommonBody.clientWidth) : (window.innerWidth-this.scrollbarwidth);
			this.iDocHeight = (this.IE) ? (this.CommonBody.clientHeight) : (window.innerHeight);
			this.iDocHeightComplete = (this.CommonBody.offsetHeight>this.CommonBody.scrollHeight) ? (this.CommonBody.offsetHeight) : (this.CommonBody.scrollHeight);
			this.posX=0;
			this.posY=0;
			this.lastX=this.posX;
			this.lastY=this.posY;
		} getDimensions.prototype = {
			refresh:function() {
				this.IE=document.all && !window.opera;
				this.CommonBody = (document.compatMode=='CSS1Compat') ? (document.documentElement) : (document.body) //create reference to common "body" across doctypes
				this.CommonBody = (this.IE) ? (document.body) : (document.documentElement) //create reference to common body across doctypes
				this.scrollbarwidth=window.innerWidth-(this.CommonBody.offsetLeft+this.CommonBody.offsetWidth); //http://www.howtocreate.co.uk/emails/BrynDyment.html
				this.scrollbarwidth=(Number(this.scrollbarwidth))?(this.scrollbarwidth):(0);
				this.iScrollTop = (this.IE) ? (this.CommonBody.scrollTop) : (window.pageYOffset);
				this.iScrollLeft = (this.IE) ? (this.CommonBody.scrollLeft) : (window.pageXOffset);
				this.iDocWidth = (this.IE) ? (this.CommonBody.clientWidth) : (window.innerWidth-this.scrollbarwidth);
				this.iDocHeight = (this.IE) ? (this.CommonBody.clientHeight) : (window.innerHeight);
				this.iDocHeightComplete = (this.CommonBody.offsetHeight>this.CommonBody.scrollHeight) ? (this.CommonBody.offsetHeight) : (this.CommonBody.scrollHeight);
			},
			coordinates:function(e,llTrackLast) {
				if (e.pageX || e.pageY) {
					this.posX = e.pageX;
					this.posY = e.pageY;
				} else if (e.clientX || e.clientY) {
					this.posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
					this.posY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
				} else {
					this.posX=0;
					this.posY=0;
				}
				if(llTrackLast) {
					this.lastX=this.posX;
					this.lastY=this.posY;
				}
			}
		}
		//*****************************************


		//GENERIC CORESPIN IMPLEMENTATION FUNCTIONS
		//*****************************************
		function automaton(lsFunction,liTime) { //used for brokering function requests via setTimeout for rapid events (onkeypress) so they aren't so spastic
			if (!this.bFiring) { //polluting the global scope here a bit, bad practice in general. fix...
				if(!liTime) {liTime=200;}
				this.bFiring = true;
				this.sQueryCommand=lsFunction;
				setTimeout(this.sQueryCommand,liTime); //fire whatever function
			} //change this so the event is delayed until user pauses typing, later.
		}
		//*****************************************

		//ARCHITECTURE CONTENT AND PAGE LINKAGE MANAGEMENT BLOCK
		
		function newPage (iNodeID) { //stub
			return;
		}
		//*****************************************
		
		
		
		//******************************************************


		function ChangePageLinkage (iObjectID,iLinkageId) {
			var lsID = interstate(iObjectID, 440, 400, '/corespin/content_linkage?_linkage_id='+iLinkageId);
			return lsID;
		}
		//*****************************************

		function select_tier(lsTierType,liValue,lsContext) {
			if (lsTierType=='architecture_type_id') { //update architecture list as well, indicate type
				if(lsContext=='architecture') {
					$('_architecture_id').value=''; //remove architecture id, or query returns bad results
				} else {
					$('_linkage_architecture_id').value=''; //remove architecture id when type changes, or query returns bad results
				}
				ArchitectureLinkageSelector('architecture','_architecture_type_id='+liValue,lsContext);
			} else {
				updateArchitectureLinkageSelectors(lsContext);
			}
		}
		//*****************************************

		function ArchitectureLinkageSelector(lsSelector,lsKey,lsContext) {
			var lsSelectCallBack = '';
			if(lsContext!='architecture') {
				lsSelectCallBack = '_linkage_';
			}
			lsSelectCallBack += lsSelector + '_selector';

			if (!$(lsSelectCallBack)) {return;}
			var loSelectCallBack = $(lsSelectCallBack);
			loSelectCallBack.disabled=true;
			ClassFX.addClass(loSelectCallBack,'obscured');
			var lsRequest = '/corespin/' + lsSelector + '_select_list/?' + lsKey + '&_context='+lsContext;
			ajaxEvent(lsRequest,loSelectCallBack,false,true); //synch
			ClassFX.removeClass(loSelectCallBack,'obscured');
			loSelectCallBack.disabled=false;
		}
		//*****************************************

		function updateArchitectureLinkageSelectors(lsContext) {
			var oArchitectureField;
			var oArchitectureTypeField;
			var oArchitectureSelector = $(lsContext+'_architecture_select_list');
			var oArchitectureTypeSelector = $(lsContext+'_architecture_types_select_list');
			if(lsContext=='architecture') {
				oArchitectureField = $('_architecture_id');
				oArchitectureTypeField = $('_architecture_type_id');
			} else {
				oArchitectureField = $('_linkage_architecture_id');
				oArchitectureTypeField = $('_linkage_architecture_type_id');
			}
			if(oArchitectureSelector.selectedIndex>-1) { //get select box values
				oArchitectureField.value=oArchitectureSelector.options[oArchitectureSelector.selectedIndex].value;
			} else {
				oArchitectureField.value='';
			}
			if(oArchitectureTypeSelector.selectedIndex>-1) {
				oArchitectureTypeField.value=oArchitectureTypeSelector.options[oArchitectureTypeSelector.selectedIndex].value;
			} else {
				oArchitectureField.value='';
			}
			refreshContent(lsContext);
		}
		//*****************************************

		function refreshContent(lsContext) {
			if(lsContext=='architecture') {
				refreshContentList(lsContext);
			} else {
				refreshContentLinkage(lsContext);
			}
		}
		//*****************************************

		function refreshContentLinkage(lsContext) { //called from automaton for content linkage
			if(!lsContext){lsContext='';}
			var oArchitectureField;
			var sArchitectureField;
			var oArchitectureTypeField;
			var sArchitectureTypeField;
			var oLinkage;
			var sLinkage;
			var lsURI;
			var loCallBack;
			var loLoadingIMG = $('_linkage_search_icon');
			var oFilter;
			var sFilter;
			oArchitectureField = $('_linkage_architecture_id');
			sArchitectureField = (oArchitectureField.value!=undefined)?(oArchitectureField.value):('');
			oArchitectureTypeField = $('_linkage_architecture_type_id');
			sArchitectureTypeField = (oArchitectureTypeField.value!=undefined)?(oArchitectureTypeField.value):('');
			oFilter = $('_linkage_slug');
			sFilter = (oFilter.value!=undefined)?(oFilter.value):('');
			oLinkage = $('_linkage_id');
			sLinkage = (oLinkage.value!=undefined)?(oLinkage.value):('');
			lsURI = '/corespin/content_linkage/?_linkage_filter='+sFilter+'&_linkage_architecture_id='+sArchitectureField+'&_linkage_architecture_type_id='+sArchitectureTypeField+'&_linkage_id='+sLinkage+'&_context='+lsContext;
			loCallBack = $('DDFX_linkage').parentNode;
			loLoadingIMG.src='/box/system/loading-small.gif';
			ajaxEvent(lsURI,loCallBack,false,true);
			loLoadingIMG.src='/box/system/arrow_switch.png';
			this.bFiring = false; //global reference?
			if($('_linkage_slug')) {
				setTimeout("$('_linkage_slug').focus()",200);
			}
		}
		//*****************************************

		function refreshContentList(lsContext) { //called from automaton for content list
			if(!lsContext){lsContext='';}
			var oArchitectureField;
			var sArchitectureField;
			var oArchitectureTypeField;
			var sArchitectureTypeField;
			var oFilter;
			var sFilter;
			var lsURI;
			var loCallBack;
			var loLoadingIMG = $('_search_icon');
			oArchitectureField = $('_architecture_id');
			sArchitectureField = (oArchitectureField.value!=undefined)?(oArchitectureField.value):('');
			oArchitectureTypeField = $('_architecture_type_id');
			sArchitectureTypeField = (oArchitectureTypeField.value!=undefined)?(oArchitectureTypeField.value):('');
			oFilter = $('_architecture_slug');
			sFilter = (oFilter.value!=undefined)?(oFilter.value):('');
			lsURI = '/corespin/content_list/?_architecture_filter='+sFilter+'&_architecture_id='+sArchitectureField+'&_architecture_type_id='+sArchitectureTypeField+'&_context='+lsContext;
			loCallBack = $('content_list');
			loLoadingIMG.src='/box/system/loading-small.gif';
			ajaxEvent(lsURI,loCallBack,false,true);
			loLoadingIMG.src='/box/system/arrow_switch.png';
			this.bFiring = false; //global reference?
			if($('_architecture_slug')) {
				setTimeout("$('_architecture_slug').focus()",200);
			}
		}
		//*****************************************

		//******************************************************
		//ARCHITECTURE CONTENT AND PAGE LINKAGE MANAGEMENT BLOCK
		//******************************************************

		//******************************************************

		//INSERT or UPDATE relationships
		function PassKey(liKey, loElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID) {
			if(!liKey||liKey==0) {
				BigLeagueChew(liKey, loElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, 'insert');
			} else {
				BigLeagueChew(liKey, loElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, 'update');
			}
		}
		//*****************************************
		//INSERT or UPDATE relationships
		function BigLeagueChew(liKey, loElement, lsPrimary, lsRelation, liPrimaryID, liRelationID, liStatusID, lsOperation) {  //When ur in the BigLeague Chew http://www.youtube.com/watch?v=0GyEkvqtHPs
			if (!lsPrimary){return;}
			if (lsOperation=='update') {
				this.YURI='/corespin/pattern_update_relation/'; //
			} else {
				this.YURI='/corespin/pattern_insert_relation/'; //
			}
			lsRequest='?_key='+liKey;
			lsRequest+='&_primary='+lsPrimary;
			lsRequest+='&_relation='+lsRelation;
			lsRequest+='&_primary_id='+liPrimaryID;
			lsRequest+='&_relation_id='+liRelationID;
			lsRequest+='&_status_id='+liStatusID;
			this.YURI+=lsRequest;
			ajaxEvent(this.YURI,loElement,false,true); //callback, replace contents, synchronous.
		}
		//*****************************************
		//this is specifically for INSERTION of a NEW relational value = misnamed, use PassKey|BigLeagueChew Instead
		function UpdateRelationalField(loElement,lsPrimary,lsRelation,liPrimaryID,liRelationID,llCallBack,lsContextArguments) { //Single Field Edit
			if (!lsPrimary){return;} //lsContextArguments = 'name=value'; //additional arguments can be supplied here, parsed and validated.
			this.UpdateURI='/corespin/pattern_insert_saved/'; //current XML HTTP Request URI
			lsRequest='?_primary='+lsPrimary;
			lsRequest+='&_relation='+lsRelation;
			lsRequest+='&_primary_id='+liPrimaryID;
			lsRequest+='&_relation_id='+liRelationID;
			this.UpdateURI+=lsRequest;
			ajaxEvent(this.UpdateURI,(llCallBack)?(loElement):(false),false,false); //callback, replace contents, synchronous.
		}
		//*****************************************

		function UpdateSingleField(loElement,lsContext,lsID,lsField,luValue,llCallBack,sFunction) { //Single Field Edit
			if (!lsContext){return;}
			if (!lsID){return;}
			if (!lsField){return;}
			this.UpdateURI='/corespin/_update_single_field/';//current XML HTTP Request URI //this.UpdateURI='/corespin/pf_update/';//current XML HTTP Request URI
			lsRequest='?_context='+lsContext;
			lsRequest+='&_id='+lsID;
			lsRequest+='&_field='+lsField;
			lsRequest+='&_value='+PrepValue(luValue);
			this.UpdateURI+=lsRequest;
			if (!llCallBack) {
				//loElement=false;
			}
			var lsFunction='';
			var lsArguments='';
			if (loElement) {
				if(loElement.id){
					if (loElement.id=='RTESaveEdit') {
						lsFunction='RTERemoveFrame';
						lsArguments='';
						loElement = false;
					}
				}
			}
			if(sFunction!='') {
				lsFunction = sFunction;
			}
			llQueued=false;
			if(lsContext=='payments'){llQueued=true;} //custom
			ajaxEvent(this.UpdateURI,loElement,false,llQueued,lsFunction,lsArguments); //callback, replace contents, synchronous.
			return true;
		}
		//*****************************************


		
		//custom functions for insert forms default value completion
		function setTitleFields(lsQualifier,lsValue) {
			if(lsQualifier=='locations::schools') {
				$('location').value=lsValue;
				$('company').value=lsValue;
				$('meta_keywords').value=lsValue;
				setRecordURL(lsValue,$('slug'));
			}
			if(lsQualifier=='pages') {
				$('meta_keywords').value=lsValue;
				setRecordURL(lsValue,$('slug'));
			}
		}
		//*****************************************

		function setRecordURL(lsValue,loElement) {
			if (!loElement){return;}
			if (typeof(lsValue) == 'string') {
				lsValue = lsValue.replace(/\//g,"");
				lsValue = lsValue.replace(/\s/g,"-");
				lsValue = lsValue.replace(/\'/g,"''");
				lsValue = lsValue.replace(/\"/g,"");
				lsValue = encodeRE(lsValue);
			}
			loElement.value=lsValue;//.toLowerCase();
		}
		//*****************************************

		function encodeRE(lsValue) {
			lsValue=lsValue.replace(/\s/g,"");
			lsValue=lsValue.replace(/\'/g,"");
			lsValue=lsValue.replace(/\"/g,"");
  			lsValue = lsValue.replace(/[^a-zA-Z0-9\-\_\\]/g,'');
  			return lsValue; //.replace(/([~`@#%*^&*=!+?^${}()|[\]\/\\])/g,'');
		}
		//*****************************************

		
		

		function spacer(loContainer) { //returns a reference to a spacer object (used frequently in drag and drop routines as a UI trigger)
			var loSpacer = loContainer.nextSibling;
			if(loSpacer=='[object Text]') { //while?
				loSpacer = loContainer.nextSibling.nextSibling;
				if(loSpacer=='[object Text]') { //screw it
					loSpacer = loContainer.nextSibling.nextSibling.nextSibling;
				}
			} else {
				loSpacer = loContainer.nextSibling;
			}
			if (ClassFX.hasClass(loSpacer,'spacer')) {
				return loSpacer;
			}
			return false; //no spacer where in places where it should be.
		}
		//*****************************************

		function showLoadingGIFWOW() { //really unimpressive ui effect
			if($('loading')) {
				$('loading').style.display='block';
				ClassFX.removeClass($('loading'),'none');
				return(true);
			}
		}
		//*****************************************

		/*
		function LinkStatus(loElement,liID,liStatus,liPagesID,liSortOrder) {
			loElement=(!loElement)?(false):(loElement.parentNode);
			lsRequest='/corespin/_pages_architecture_links_update/?';
			lsRequest+='architecture_links_id='+liID;
			lsRequest+='&pages_id='+liPagesID;
			if(!liSortOrder) {
				if(liStatus==null) {
					LinksRelationalField(loElement,'pages','architecture_links',liPagesID,liID,false,true);
				} else if(liStatus==1) {
					lsRequest+='&status_id='+3;
					ajaxEvent(lsRequest,loElement,false,false);
				} else {
					lsRequest+='&status_id='+1;
					ajaxEvent(lsRequest,loElement,false,false);
				}
			} else {
				lsRequest+='&sort_order='+liSortOrder;
				ajaxEvent(lsRequest,loElement,false,false);
			}
		}
		//*****************************************

		function LinksRelationalField(loElement,lsPrimary,lsRelation,liPrimaryID,liRelationID,llCallBack,lsContextArguments) { //Single Field Edit
			if (!lsPrimary){return;} //lsContextArguments = 'name=value'; //additional arguments can be supplied here, parsed and validated.
			this.UpdateURI='/corespin/architecture_links_insert/'; //current XML HTTP Request URI
			lsRequest='?_primary='+lsPrimary;
			lsRequest+='&_relation='+lsRelation;
			lsRequest+='&_primary_id='+liPrimaryID;
			lsRequest+='&_relation_id='+liRelationID;
			this.UpdateURI+=lsRequest;
			ajaxEvent(this.UpdateURI,loElement,false,false); //callback, replace contents, synchronous.
		}
		//*****************************************

		function associateLinks(lsURI) {
			var loContainer = createOverlayDiv(750,500);
			ajaxEvent(lsURI,loContainer,false,false); //callback, replace contents, synchronous.
		}
		//*****************************************
		*/
		
		function NewRelation(lsURI) {
			var loContainer = createOverlayDiv(750,500);
			loContainer.appendChild(theLove(lsURI));
		}
		//*****************************************

		

		
		function UpdateFile(loElement,lsContext,lsID,lsField,luValue,llCallBack) { //Singular File for record insert/updating
			if (!lsContext){return;}
			if (!lsID){return;}
			if (!lsField){return;}
			this.URI='/corespin/add-file/'; //current XML HTTP Request URI
			lsRequest='?_context='+lsContext;
			lsRequest+='&_id='+lsID;
			lsRequest+='&_field='+lsField;
			lsRequest+='&_value=';
			this.URI+=lsRequest;
			var loTheAggravatingIframe = theLove(this.URI); // Variable naming
			loTheAggravatingIframe.width='337px';
			loTheAggravatingIframe.height='430px';
			var iFileUpload = interstate(null, 357, 482, loTheAggravatingIframe);
		}
		//*****************************************
							
		/*
		function oldUpdateFile(loElement,lsContext,lsID,lsField,luValue,llCallBack) { //Singular File for record insert/updating
			var loContainer = createOverlayDiv(750,500);
			if (!lsContext){return;}
			if (!lsID){return;}
			if (!lsField){return;}
			this.URI='/corespin/add-file/'; //current XML HTTP Request URI
			lsRequest='?_context='+lsContext;
			lsRequest+='&_id='+lsID;
			lsRequest+='&_field='+lsField;
			lsRequest+='&_value=';
			this.URI+=lsRequest;
			var loTheAggravatingIframe = theLove(this.URI); // Variable naming
			loContainer.appendChild(loTheAggravatingIframe);
		}
		*/

		function UpdateRTE(loElement,lsContext,lsID,lsField,luValue,llCallBack) { //Single Field Editing
			var loContainer = createOverlayDiv(750,500);
			if (!lsContext){return;}
			if (!lsID){return;}
			if (!lsField){return;}
			this.URI='/corespin/rte/'; //current XML HTTP Request URI
			lsRequest='?_context='+lsContext;
			lsRequest+='&_id='+lsID;
			lsRequest+='&_field='+lsField;
			lsRequest+='&_value=';
			this.URI+=lsRequest;
			var loTheAggravatingIframe = theLove(this.URI);
			loContainer.appendChild(loTheAggravatingIframe);
			//EventListener.addEvent(loTheAggravatingIframe, 'load', function() {});
		}
		//*****************************************

		function RTERemoveFrame(loElement) { //Single Field Editing
			parent.$('content_edit_container').innerHTML=$('_value').innerHTML;
			//alert(parent.$('content_edit_container').innerHTML);
			parent.removeOverlayDiv();
		}
		//*****************************************


		//UI EFFECTS
		//*****************************************
		// Change opacity of element. IE requires the element to have (layout) specific width.
		function changeOpacity(loElement, iOpacity) {
			if(!loElement) {return(false);}
			if(!iOpacity) {return(false);}
			var lsTagName=loElement.tagName.toLowerCase();
			var loElementStyle = loElement.style;
			if(!loElementStyle) {return;}
			loElementStyle.opacity = (iOpacity / 100);
			loElementStyle.MozOpacity = (iOpacity / 100);
			loElementStyle.KhtmlOpacity = (iOpacity / 100);
			loElementStyle.filter = "alpha(opacity=" + iOpacity + ");"; //WOW talk about obscure, if you dont add the semicolon in the filter attrib IE bombs.
			if (iOpacity==0) {
				loElementStyle.display = 'none';
			} else {
				if (lsTagName=='div') {
					loElementStyle.display = 'block';
				} else {
					loElementStyle.display = 'inline';
				}
			}
		}
		//*****************************************

		
		// Style based fading. -MM
		function fadeControl(lsItem, iOpacStart, iOpacEnd, iMilliseconds) {
			var speed = Math.round(iMilliseconds / 100); //speed for each frame
			var timer = 0;
			if(iOpacStart > iOpacEnd) { //determine the direction for the blending, if start and end are the same use pulse effect
				for(i = iOpacStart; i >= iOpacEnd; i--) {
					setTimeout("changeOpacity($('" + lsItem + "'),'" + i + "')",(timer*speed));
					timer++;
				}
			} else if(iOpacStart < iOpacEnd) {
				for(i = iOpacStart; i <= iOpacEnd; i++) {
					setTimeout("changeOpacity($('" + lsItem + "'),'" + i + "')",(timer*speed));
					timer++;
				}
			} else if(iOpacStart==iOpacEnd) { //pulse, not finished -- just pulses without considering value from/to which it's pulsing (just from full opacity to zero and back)
				for(i=0; i<3.1; i+=0.1) {
					setTimeout("changeOpacity($('" + lsItem + "'),'" + Math.round(Math.abs(Math.cos(i)*100)) + "')",(timer*speed));
					timer++;
				}
				changeOpacity($(lsItem),iOpacEnd); //hard set back to iOpacEnd, temp...
			}
		}
		//*****************************************


		//SOME POTENTIALLY USEFUL TOOLS
		//*****************************************
		function $$() { //returns object reference || array of object references.... $$ bill y'all
			//still working on this one...
			var loElements = document.getElementsByTagName(arguments[0]);
			var loElement = loElements[0]; //mostly just want to get the first element in the list
			loElements = null; //discard for now
			return loElement;
		}
		//*****************************************

		function functionBroker() { //used for brokering function requests (in dev stage :: doesn't really work yet)
 			if(typeof(this[arguments[0]])=='function') {
				var loArguments = arguments[0]; //ditch first arg as function name, start from first argument if any.
				for (var a=1;a<arguments.length;a++ ) {
					loArguments += ',' + arguments[a];
				}
				this[arguments[0]](loArguments);
			}
		}
		//*****************************************

		
		function UpdateFileName(oElement) { //auto populate elements for files...
			oName = $('name');
			if(oName) {
				oName.value=justStemAndExtension(oElement.value);
			}
			oSlug = $('slug');
			if(oSlug) {
				oSlug.value=justStemAndExtension(oElement.value.toLowerCase());
			}
			oMetaKeywords = $('meta_keywords');
			if(oMetaKeywords) {
				oMetaKeywords.value=justStemAndExtension(oElement.value);
			}
			oMetaDescription = $('meta_description');
			if(oMetaDescription) {
				oMetaDescription.value=justStemAndExtension(oElement.value);
			}
			oTitle = $('title');
			if(oTitle) {
				oTitle.value=justStemAndExtension(oElement.value);
			}
			oIntro = $('intro');
			if(oIntro) {
				oIntro.value=justStemAndExtension(oElement.value);
			}
		}
		//*****************************************
		
		function justStemAndExtension(lsFileName) { //
			lsFileName=(lsFileName.substring(lsFileName.lastIndexOf('/')+1));
			lsFileName=(lsFileName.substring(lsFileName.lastIndexOf('\\')+1));
			return lsFileName;
		}
		//*****************************************

		function RID() { //Scrappy Random ID Generator...
			var result, i, j;
			result = '';
			for(j=0; j<32; j++) {
			if( j == 8 || j == 12|| j == 16|| j == 20)
				result = result + '-';
				i = Math.floor(Math.random()*16).toString(16).toUpperCase();
				result = result + i;
			}
			return result;
		}
		//*****************************************

		function trace(lsEvent) {
			lsTracer='tracer';
			loTracer=$(lsTracer);
			(loTracer)?(loTracer.value=lsEvent+'\r'+loTracer.value):(false);
			lsTracer='debugForm';
			loTracer=$(lsTracer);
			(loTracer)?(loTracer.value=lsEvent+'\r'+loTracer.value):(false);
		}
		//*****************************************


		function escapeSearch(lsValue) {
			lsValue=lsValue.replace(/\'/g," ");
			lsValue=lsValue.replace(/\"/g," ");
  			return lsValue;
		}
		//*****************************************


		//NOT RECOMMENDED
		Date.ONE_SECOND = 1000;
		Date.ONE_MINUTE = Date.ONE_SECOND * 60;
		Date.ONE_HOUR = Date.ONE_MINUTE * 60;
		Date.ONE_DAY = Date.ONE_HOUR * 24;
		var llNapping=false;

		function nap (liFor) {
			if(llNapping){return;}
			llNapping=true;
			var then = new Date(new Date().getTime() + liFor);
			while (new Date() < then) { /* happily destroy my processor */ }
			llNapping=false;
		}
		//************************************

		//DEPRECATED
		function newWindow(url) {
			oNewWindow=window.open(url,'newWindow','width=760,height=550','location=no, status=no, liScrolling=no, resize=yes');
			if (window.focus) {oNewWindow.focus()}
		}
		//*****************************************

		function updateTime( loElementQualifier ) {
			loHourElement=$(loElementQualifier+'-hour');
			llConstituents=(loHourElement)?(true):(false);
			loMinuteElement=$(loElementQualifier+'-minute');
			llConstituents=(loMinuteElement)?(true):(false);
			loMeridianElement=$(loElementQualifier+'-meridian');
			llConstituents=(loMeridianElement)?(true):(false);
			var loElement = $(loElementQualifier+'_time');
			llConstituents=(loElement)?(true):(false);
			if (!llConstituents) {
				return false;
			} else {
				lsHour=loHourElement.options[loHourElement.selectedIndex].value;
				lsMinute=loMinuteElement.options[loMinuteElement.selectedIndex].value;
				lsMeridian=loMeridianElement.options[loMeridianElement.selectedIndex].value;
				lsTime = lsHour + ':' + lsMinute + ' ' + lsMeridian;
				loElement.value=lsTime;
				return true;
			}
		}
		//*****************************************

		function formatThisDate(loDateField) { //pg formatted timestamp as expected input -(haxxors for datepicker weirdness)
			if (!$(loDateField)){return false;}
			lsMM_DD_YYYY = $(loDateField).value;
			lsMM_DD_YYYY = lsMM_DD_YYYY.substring(0, 10);
			lsMM_DD_YYYY = lsMM_DD_YYYY.substring(5, 7) + '-' + lsMM_DD_YYYY.substring(8, 10) + '-' + lsMM_DD_YYYY.substring(0, 4);
			$(loDateField).value=lsMM_DD_YYYY;
		}
		//*****************************************

		function PrepValue(luValue) { //interceptor - prior to sql insert, deprecated - need input formatters
			if(Number(luValue)) {
				luValue = luValue + ""; //quick assertion to string
				if(luValue.substring(0,2)=='0x') { //octals are numeric but use character fields to omit type hassle value is delivered as HTML/XML end of day so recasting to octal is trivial
					luValue='\'' + luValue + '\'';
					return luValue;
				}
				
				return luValue;
			}
			if (typeof(luValue) == 'string') {
				luValue=luValue.replace(/\'/g,"''");
				luValue=escape(luValue);
				luValue = luValue.replace(/\//g,"%2F");
				luValue = luValue.replace(/\?/g,"%3F");
				luValue = luValue.replace(/=/g,"%3D");
				luValue = luValue.replace(/&/g,"%26");
				luValue = luValue.replace(/@/g,"%40");
				luValue='\'' + luValue + '\'';
				return luValue;
			}
			return luValue;
		}
		//*****************************************


		// Old-school AJAX Holder for File Manager (will be deprecated)
			var blahdibloo = document.getElementsByTagName('body');
			var blackScreen = document.createElement('div');
			var ajaxContainer = document.createElement('div');
			var ajaxTitleBar = document.createElement('div');
			var ajaxTitle = document.createElement('div');
			var ajaxToolBar = document.createElement('div');
			var ajaxExitDiv = document.createElement('div');
			var ajaxExitBtn = document.createElement('img');
			var ajaxScroll = document.createElement('div');

		//*****************************************
		// Create AJAX Holder for CORESPIN
		function createOverlayDiv_FM(liWidth, liHeight, lsTitleElement) {
			// Alright, this son of a gun needs some updating. Positioning of window is
			// being a total punk.

			// Create Element, Apply Classes, Attach to Body
			ClassFX.addClass(blackScreen,'blackroot');
			blackScreen.setAttribute('id', 'blackscreen');
			// blackScreen.setAttribute('onclick', 'removeOverlayDiv()');
			ClassFX.addClass(ajaxContainer, 'cs_ajax_container');
			ajaxContainer.setAttribute('id', 'ajaxcontainer');

			if (lsTitleElement) {
				ClassFX.addClass(ajaxTitleBar, 'fm-title-bar');
				ClassFX.addClass(ajaxToolBar, 'fm-tools');
				ClassFX.addClass(ajaxExitDiv, 'fm-tool');
				ajaxExitBtn.setAttribute('src', '/box/icons/cross.png');
				ajaxExitBtn.setAttribute('onclick', 'removeOverlayDiv()');
				ajaxScroll.style.width = liWidth + 'px';
				ajaxScroll.style.height = liHeight - 35 + 'px';
				ajaxScroll.style.overflow = 'auto';
				ajaxExitDiv.appendChild(ajaxExitBtn);
				ajaxToolBar.appendChild(ajaxExitDiv);
				ajaxTitleBar.appendChild(ajaxToolBar);
				ajaxTitleBar.appendChild(ajaxTitle);
				ajaxTitle.innerHTML = lsTitleElement;
				ajaxContainer.appendChild(ajaxTitleBar);
				ajaxContainer.appendChild(ajaxScroll);
			}

			blahdibloo[0].appendChild(blackScreen);
			blahdibloo[0].appendChild(ajaxContainer);
			fadeControl('blackscreen', 0, 40, 440);
			fadeControl('ajaxcontainer', 0, 100, 770);
			iFullWidth = windowSize("width");
			iFullHeight = windowSize("height");
			iScreenCenter = windowSize("vpcenter");
			iLeftAdjust = Math.round((iFullWidth - liWidth) / 2);
			// iTopAdjust = Math.round((iScreenCenter - liHeight)/2);
			iTopAdjust = Math.round(window.pageYOffset + 50);
			if (iTopAdjust < 50) {
				iTopAdjust = 50;
			}


				window.onresize = function() {
					iFullWidth = windowSize("width");
					iFullHeight = windowSize("height");
					iScreenCenter = windowSize("vpcenter");
					iLeftAdjust = Math.round((iFullWidth - liWidth) / 2);
					iTopAdjust = Math.round(window.pageYOffset + 50);
					if (iTopAdjust < 0) {
						iTopAdjust = 50;
					}
					blackScreen.style.width=iFullWidth+"px";
					blackScreen.style.height=iFullHeight+"px";
					ajaxContainer.style.top=iTopAdjust+"px";
					ajaxContainer.style.left=iLeftAdjust+"px";
				}

			blackScreen.style.width=iFullWidth+"px";
			blackScreen.style.height=iFullHeight+"px";
			ajaxContainer.style.top=iTopAdjust+"px";
			ajaxContainer.style.left=iLeftAdjust+"px";
			ajaxContainer.style.width=liWidth+"px";
			ajaxContainer.style.height=liHeight+"px";

			return ajaxContainer;

		}
		//*****************************************


		//*****************************************
		function removeOverlayDiv_FM() {
			fadeControl('blackscreen', 40, 0, 300);
			fadeControl('ajaxcontainer', 94, 0, 500);
			setTimeout('ajaxContainer.innerHTML = "";', 500);
			setTimeout('blahdibloo[0].removeChild(blackScreen);', 300);
			setTimeout('blahdibloo[0].removeChild(ajaxContainer);', 300);
			blahdibloo[0].style.overflow = blahdibloo[0].style.overflow;
		}
		//*****************************************






		//*****************************************
		// Create AJAX Holder for CORESPIN
		function createOverlayDiv(liWidth,liHeight,lsTitleElement) { // Create Element, Apply Classes, Attach to Body

			loOverlayPortFactory = new cliche('ajaxcontainer', liWidth, liHeight, 'cs_ajax_container');
			loOverlayPort=loOverlayPortFactory.element;

			loBlackScreenFactory = new cliche('blackscreen', windowSize('width'), windowSize('height'), 'blackroot');
			loBlackScreen=loBlackScreenFactory.element;

			loBodyNode = $$('body');
			if (!loBodyNode) {
				loBodyNode = $('view');
				if (!loBodyNode) {
					return false;
				}
			}
			if (!loBodyNode.appendChild) {
				alert(loBodyNode);
				alert('apparently the body tag will not allow appending anymore?');
				return false;
			}
			
			//loBodyNode.appendChild(loBlackScreen);
			//loBodyNode.appendChild(loOverlayPort);

			fadeControl('blackscreen', 0, 20, 440);
			fadeControl('ajaxcontainer', 0, 94, 770);
			
			iFullWidth = windowSize("width");
			iFullHeight = windowSize("height");
			iScreenCenter = windowSize("vpcenter");
			iLeftAdjust = Math.round((iFullWidth - loOverlayPortFactory.width) / 2);
			iTopAdjust = Math.round(iScreenCenter - (loOverlayPortFactory.height/2));
			window.onresize = function() {
				iFullWidth = windowSize("width");
				iFullHeight = windowSize("height");
				iScreenCenter = windowSize("vpcenter");
				iLeftAdjust = Math.round((iFullWidth - loOverlayPortFactory.width) / 2);
				iTopAdjust = Math.round(iScreenCenter - (loOverlayPortFactory.height/2));
				loBlackScreen.style.width=iFullWidth+"px";
				loBlackScreen.style.height=iFullHeight+"px";
				loOverlayPort.style.top=iTopAdjust+"px";
				loOverlayPort.style.left=iLeftAdjust+"px";
			}
			loBlackScreen.style.width=iFullWidth+"px";
			loBlackScreen.style.height=iFullHeight+"px";
			loOverlayPort.style.top=iTopAdjust+"px";
			loOverlayPort.style.left=iLeftAdjust+"px";

			return loOverlayPort;

		}
		//*****************************************
		//*****************************************
		function removeOverlayDiv(loElement) {
			if(loElement) {
				if($(loElement)) {
					loElement.parentNode.removeChild(loElement);
					loElement = null;
				} else {
					return false;
				}
			} else {
				var loElement = null;
				loElement =	$('blackscreen');
				loElement = loElement.parentNode.removeChild(loElement);
				loElement = $('ajaxcontainer');
				loElement = loElement.parentNode.removeChild(loElement);
				loElement = null;
			}
		}
		//*****************************************

		//*****************************************
		// Returns cross-browser window dimensions, offsets liScroll position
		// lsDimension = 'width' or 'height' or 'center'
		// hopefully good enough for now....
		function windowSize(lsDimension) {
			var liClientWidth = 0;
			var liClientHeight = 0;
			if(typeof( window.innerWidth ) == 'number' ) {
				liClientWidth = window.innerWidth;
				liClientHeight = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				liClientWidth = document.documentElement.clientWidth;
				liClientHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				liClientWidth = document.body.clientWidth;
				liClientHeight = document.body.clientHeight;
			}
			var liScrollOffX = 0;
			var liScrollOffY = 0;
			var liScrollHeight = 0;
			var liScrollWidth = 0;
			if (typeof(window.pageYOffset) == 'number') {
				liScrollOffY = window.pageYOffset;
				liScrollOffX = window.pageXOffset;
				liScrollHeight = window.scrollMaxY;
				liScrollWidth = window.scrollMaxX;
			} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
				liScrollOffY = document.documentElement.scrollTop;
				liScrollOffX = document.documentElement.scrollLeft;
				liScrollHeight = document.documentElement.scrollHeight;
				liScrollWidth = document.documentElement.scrollWidth;
			} else if (document.body && (document.body.scrollHeight || document.body.scrollTop)) {
				liScrollOffY = document.body.scrollTop;
				liScrollOffX = document.body.scrollLeft;
				liScrollHeight = document.body.scrollHeight;
				liScrollWidth = document.body.scrollWidth;
			}
			liContentHeight=(document.height)?(document.height+liClientHeight):(document.documentElement.offsetHeight); //FF||IE
			liContentWidth=liClientWidth;
			liContentCenter=liContentHeight/2; //actual content center (ish ?), every browser has different values.
			//center of VIEWABLE area
			liViewPortCenter=liContentCenter;
			liViewPortCenter=(document.height)?(liViewPortCenter-liClientHeight/2):(liViewPortCenter); //subtract window height from content
			liViewPortCenter+=liScrollOffY; //oh look at that, magically works in Firefox. Thank You God for Firefox....
			// ! reset content height for IE; // if we add this above it gets thrown way off in ie
			liContentHeight=(document.height)?(liContentHeight):(document.documentElement.offsetHeight+(liClientHeight));
			if (lsDimension == 'width'|| lsDimension == 'x') {
				return liClientWidth;
			} else if (lsDimension == 'height'|| lsDimension == 'y') {
				return liContentHeight;
			} else if (lsDimension == 'center') {
				return liContentCenter;
			} else if (lsDimension == 'vpcenter') {
				return liViewPortCenter;
			} else {
				return true;
			}
		}
		//*****************************************


