/*global Prototype,$,$A,$F,$H,Ajax,Builder,Element,Event,Form,Position */
/*global parseInt, Class */
/*jslint browser:true */
// ------------------------------------------------------------------------------------
String.prototype.trim = function() {
	// -- Skip leading and trailing whitespace and return everything in between
	return this.replace(/^\s+|\s+$/g,'');
};	
String.prototype.isEmpty = function() {
	// -- Return false if trimmed length is >0
	return this.trim().length==0;
};	
String.prototype.isEmptyOrZero = function() {
	return (this.isEmpty() || this.trim()=='0');
};	
String.prototype.equals = function(value) {
	return this == value;
};	
String.prototype.isInteger = function() {
	return this == parseInt(this,10);
};
String.prototype.getInteger = function() {
	return parseInt(this,10);
};
String.prototype.containsQuotes = function() {
	return (this.indexOf("'") != -1 || this.indexOf("\"") != -1);
};
String.prototype.commaFormatted = function() {
	var x=this;
	var delimiter = ","; 
	var a = x.split('.',2);
	var d = a[1];
	var i = parseInt(a[0],10);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = i.toString();
	a = [];
	while(n.length > 3) {
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { x = n; }
	else { x = n + '.' + d; }
	x = minus + x;
	return x;
};
String.prototype.rmvAllNonDigits = function() {
	return this.replace(/[^\d]/g, "");
};
String.prototype.acphoneFormat = function() {
	return this.replace(/^(\d{3})(\d{3})/,'($1)$2-');
};

/**
 * String.acphoneFormat2
 * Returns a formatted valid phone number.
 * If the input is '0', then the return is ''
 * If the input contains 7 digits then the output is xxx-xxxx
 * If the input contains 10 or more digits then the output is x (xxx) xxx-xxxx 
 * If the input contains 8 or 9 digits then the output is xxxx-xxxx or xxxxx-xxxx
 */
String.prototype.acphoneFormat2 = function() {
	if(this=="0")
		return '';
	var str = this.replace(/[^\d]/g, "");
	var m = str.match(/(\d*)(\d{3})(\d{4})$/);
	if(m) {
		if(m[1].length==3) {
			str="("+m[1]+") ";
		} else if(m[1].length>3) {
			str = m[1].substring(0,m[1].length-3)+" ("+m[1].substring(m[1].length-3)+") ";
		} else {
			str=m[1];
		}
		str+=m[2]+"-"+m[3];
	}
	return str;
};
/**
 * String.digitFormat
 * params:	b - digits before decimal
 * 			a - digits after decimal
 * Returns:	String containing up to b digits before a decimal, a decimal, and up to a digits after a decimal
 */
String.prototype.digitFormat = function(b,a) {
	var str = this.replace(/[^\d.]/g, "");
	var m = str.match(/^(\d*)(\.?)(\d*)/);
	if(m) {
		//uncommenting would allow entry without decimal
		//	"432".digitFormat(3,2) => 4.32
		//	"43200".digitFormat(3,2) => 432.00
		//if(m[2]==".") {
			str = m[1].substring(m[1].length-b,m[1].length)+"."+m[3].substring(0,a);
		//} else {
		//	str = m[1].substring(m[1].length-a-b,m[1].length-a)+"."+m[1].substring(m[1].length-a);
		//}
	}
	return str;
};
String.prototype.mmddyyFormat = function() {
	return this.replace(/(\d{2})(\d{2})$/,'/$1/$2');
};
/**
 * String.mmddyyFormat2
 * Input: string with up to 6 digits
 * Returns: mm/dd/yy formated string or '' if 0
 */
String.prototype.mmddyyFormat2 = function() {
	if(this.toString()=="0")
		return '';
	return this.replace(/(\d{2})(\d{2})$/,'/$1/$2');
};
// shorten a string to a given length and add ... at the end
String.prototype.shorten = function(length) {
	if (this.length==0) { return "(empty)"; }
	// if shorter than 'length' - return it back
	if (this.length <= length) { return this.toString(); }
	// if length is too short - set to minimum (equals to 4)
	if (length<=3) { length = 4; }
	// return part of the string
	return this.substring(0, length - 3) + '...';
};
String.prototype.removeDashes = function() {
	return this.replace(/-/g, "");
}

Array.prototype.getIndex = function(value) {
	var len = this.length;
	for (var i=0; i<len; i++) {
		if (this[i] == value) {
			return i;
		}
	}
	return -1;
};
Array.prototype.getIndex_ForJSON_ID = function(value) {
	var len = this.length;
	for (var i=0; i<len; i++) {
		if (this[i].id == value) {
			return i;
		}
	}
	return -1;
};
Array.prototype.getClosestIndex = function(value) {
	var len = this.length;
	for (var i=0; i<len; i++) {
		if (this[i] >= value) {
			return i;
		}
	}
	return -1;
};
Array.prototype.swap = function(i,j) {
		var tmp = this[i];
	    this[i] = this[j];
 	    this[j] = tmp;
};
Array.prototype.emptyOut = function() {
		var len = this.length;
    	for (var i=0; i<len; i++) {
    		delete this[i];
    	}
    	this.splice(0,len);
		this.length = 0;
};

Element.Methods.insertAfter = function(element,newnode,beforenode) {
	if(!element || !newnode || !beforenode) {
		return;
	}
	if($(beforenode).next()) {
		element.insertBefore(newnode,$(beforenode).next());
	} else {
		element.appendChild(newnode);
	}
};

/**
 * This adds a 'set' method to all extended elements.
 * The set method can be called in the following ways:
 * 1. $(element).set(value)
 * 2. $(element).set({options})
 * 3. $(element).set(value,{options})
 * If the element is a checkbox, then 
 * 		the checkbox is checked if value matches the checkbox value (or value is omitted)
 * 		the checkbox is unchecked if value is specified and does not match the checkbox value
 * If the element is a form field other than checkbox, then
 * 		the elements value is set to value based on the format rules (see below)
 * If the element is not a form field, then it is updated with value based on the format rules
 * If value is not specified, then the element value (form fields) or innerHTML (not form fields)
 * 		is used as the value.  (update the element, then set it to apply the format rules
 * If the element does not have a format attribute, then the format is considered open and the value is
 * 		set to the element without any modifications
 * The format attribute can have the following formats:
 * 		text[#]* - text field with a length of # characters
 * 		[+-][#]*[.][#] - numeric field
 * 			'-' optional indicates negative numbers are allowed
 * 			'+' optional indicates negative numbers are allowed and + will be shown for positive numbers
 * 			# optional before and after decimal.  if omitted, then assumed to be 0
 * Options
 * 		round	optional	blank, u, up, d, down.  Round the last digit accordingly.  Default is blank for normal rounding
 * 		zeroBlank	optional	if the number is 0, do not display it.  Default is false (display zero)
 * 		padWhole	optional	left pad the whole part of the number with zeros
 * 		padPart		optional	right pad the decimal part of the number with zeros  
 */
Element.Methods.set = function(element) {
	element = $(element);

	var optIndex=1;
	var value=null;
	if(arguments.length>1) {
		if(typeof arguments[1]=="string" || typeof arguments[1]=="number") {
			value = arguments[1];
			optIndex++;
		}
	}
	if(value===null) {
		if(element.value!==undefined) {
			value = element.value;
		} else {
			value = element.innerHTML;
		}
	}
	
	var options = Object.extend({
		round: "", //blank, U, D, up, or down for numeric formats
		zeroBlank: false, //set value to blank for a zero value in numeric formats
		padWhole: false, //left zero pad numeric formats
		padPart: false //right zero pad numeric formats
	},arguments[optIndex] || {});
	
	var format = element.readAttribute("format");
	if(options.format) {
		format = options.format;
	}
	var isNumber = false;
	if(format!==null) {
		if(format.substr(0,4).toUpperCase()=="TEXT") {
			var length = parseInt(format.substr(4));
			if(!isNaN(length)) {
				value = value.substr(0,length);
			}
		} else if(format.match(/^[+-]?\d*\.?\d*$/)) {
			isNumber = true;
			format = format.split(".");
			var m = format[0].match(/[+-]/)
			var sign="";
			if(m) {
				sign = value.toString().match(/[+-]/);
				if(!sign) {sign="";}
				if(m[0]=="-") {
					if(sign[0]!="-") {
						sign="";
					} else {
						sign="-";
					}
				} else {
					if(sign[0]!="-") {
						sign="+";
					} else {
						sign="-";
					}
				}
			}
			format[0]=parseInt(format[0].replace(/[+-]/,''));
			format[1]=parseInt(format[1]);
			if(isNaN(format[0])) {format[0]=0;}
			if(isNaN(format[1])) {format[1]=0;}
			value = parseFloat(value);
			if(isNaN(value)) {
				value = 0;
				sign="";
			}
			value = parseFloat(value.toString().replace(/[^\d.]/g,''));
			if(sign=="-") {
				value*=-1;
			}
			var round="round";
			switch(options.round.toUpperCase()[0]) {
				case "U":
					round="ceil";
					break;
				case "D":
					round="floor";
					break;
			}
			value = Math[round](value*Math.pow(10,format[1]))/Math.pow(10,format[1]);
			if(sign=="-") {
				value/=-1;
			}
			
			value = value.toString();
			var dotIndex = value.indexOf(".");
			if(dotIndex>format[0]) {
				value = value.substr(dotIndex-format[0]);
			} else if(dotIndex==-1 && value.length>format[0]) {
				value = value.substr(value.length-format[0]);
			}
			
			if(options.padWhole) {
				dotIndex = value.indexOf(".");
				if(dotIndex==-1) {dotIndex = value.length;}
				while(dotIndex<format[0]) {
					value="0"+value;
					dotIndex++;
				}
			}
			if(options.padPart && format[1]>0) {
				dotIndex = value.indexOf(".");
				if(dotIndex==-1) {
					dotIndex=value.length;
					value+=".";
				}
				while(value.length<=dotIndex+format[1]) {
					value+="0";
				}
			}
			value = sign+value;
		}
	}
	
	if(element.type=="checkbox") {
		element.checked = value==element.value;
	} else {
		if(isNumber && options.zeroBlank && parseFloat(value)==0) {
			value="";
		}
		
		if(element.value!==undefined) {
			element.value = value;
		} else {
			element.update(value);
		}
	}
	return element;
}

// --------------------------------------------------------------------------
// * Ajax.Request.abort 
// * - Extend the prototype.js Ajax.Request object so that it supports an abort method 
// --------------------------------------------------------------------------
Ajax.Request.prototype.abort = function() {
	// -- Prevent and state change callbacks from being issued    
 	this.transport.onreadystatechange = Prototype.emptyFunction;    
 	// -- Abort the XHR    
 	this.transport.abort();    
 	// -- Update the request counter    
 	Ajax.activeRequestCount--;
};

// --------------------------------------------------------------------------
// * Ajax.Request.abortCallback
// * - Extend prototype.js Ajax.Request object to allow abort with callback function processing
// --------------------------------------------------------------------------
Ajax.Request.prototype.abortCallback = function() {
	// -- Abort the XHR    
 	this.transport.abort();    
 	// -- Update the request counter    
 	Ajax.activeRequestCount--;
};


// ************************************************************************************
// * The Dancik object.	
// ************************************************************************************
var Dancik = {

		/* Dancik.alertJSONErrors */
	alertJSONErrors : function(json, titleOvr, asConfirm) {
		if (!json) { return; }
		if (!json.errors) { return; }
		var msg = "";
		var len = json.errors.length;
		for (var i=0; i<len; i++) {
			msg += "\n- " + json.errors[i];
		}
		if (titleOvr) {
			msg = titleOvr + "\n" + msg;
		} else {
			msg = "Error(s) Occurred in Response :\n" + msg;
		}
		
		if (asConfirm) {
			return confirm(msg+"\n"+asConfirm);
		} else {
			alert(msg);
		}
	},
	/* Dancik.catchAjaxError */
	catchAjaxError : function(res) {
	 	try {
	 		if (res.responseText.isEmpty() ) { 
	 			return; 
	 		} else {
				var json = res.responseText.evalJSON(true);
				if (!json) { return; }
				Dancik.alertJSONErrors(json);
			}
		} catch(e) {
			alert("Error :\n\t" + res.responseText);
		}
	},
	/* Dancik.addScript */
	addScript : function(file, location) {
		var scriptFile = "";
		if (!location) {
			scriptFile = '../../dws/' + file;
		} else {
			scriptFile = location + file;
		}
		Dancik.addScriptFile(scriptFile);
	},
	/* Dancik.addScriptFile */
	addScriptFile : function(file) {
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = file;
		document.getElementsByTagName("head")[0].appendChild(script);		
	},
	/* Dancik.addLink */
	addLink : function(file, location) {
		var link = document.createElement('link');
	 	link.setAttribute("rel", "stylesheet");
	  	link.setAttribute("type", "text/css");
	  	if (location == null) {
			link.href = '../../dws/' + file;
		} else {
			link.href = location + file;
		}
		document.getElementsByTagName("head")[0].appendChild(link);
	},
	/* Dancik.cvtToUppercase */
	// ------------------------------------------------------------------------
	// !!!! DEPRECATED - Use Dancik.cvtToUppercaseOnKeyPress() instead...
	// ------------------------------------------------------------------------
	cvtToUppercase : function (e, o) {
		if (o == null) { return; }
		
		var key  = window.event ? window.event.keyCode : e ? e.which : 0;
		// -- Avoid non-printable key strokes...
		if (key >= 32 && key < 127) {
			o.value = o.value.toUpperCase();
	  	}
	},
	/* Dancik.cvtToUppercaseOnKeyPress */
	cvtToUppercaseOnKeyPress : function (e, element) {
		if (element.readOnly) { return; }

		var key  = window.event ? window.event.keyCode : e ? e.which : 0;
		if ((key > 0x60) && (key < 0x7B)) {
			key = key - 0x20;
			if (window.event) {
				window.event.keyCode = key;
			} else if (e) {
				element.value += String.fromCharCode(key);
				Event.stop(e);
			}
		}
	},
	/* Dancik.autofocus */
	autofocus : function (from, to, evt) {
	    evt = (evt) ? evt : event;
	    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	    if (charCode > 31 && from.value.length == from.maxLength) {
	        to.focus( );
	    }
	},
	/* Dancik.getParentByTagName */
	// ** depricated : Use Prototype's : $(element).up('tr')
	getParentByTagName : function(element, tagName) {
		if (element == null) { return null; } 
		if (tagName == null) { return null; }
		var p = $(element).up(tagName);
		if(p.tagName==tagName) {
			return p;
		}
		return null;
	},
	/* Dancik.centerElementViaDocument */
	centerElementViaDocument : function(element) {
		var o2 = $(element);
		if (o2 == null) { return; }

		var o2Dim = Element.getDimensions(o2);

		var top =  Math.round((Dancik.getDocumentHeight()-o2Dim.height) / 2);
		var left = Math.round((Dancik.getDocumentWidth()-o2Dim.width) / 2);	
	
		o2.style.left = left;
		o2.style.top = top;
	},
	// ---------------------------------------------------------------------------------------------------
	// - Function    : Dancik.centerElementViaBody()
	// - Description : center passed element within browser window
	// - Parameters  : element - (req) element or id of element to center
	//				   params - (opt) 
	//				   height  : default height of element
	//				   width   : default width of element
	//				   makefit : True to resize element to fit within body if it is too big
	//				   viewtop : True to view the top of the element if it is larger than the body height
	//								(otherwise element will be centered and can't see top or bottom)
	//				   viewleft: True to view the left of the element if it is larger than the body width
	//								(otherwise element will be centered and can't see left or right)
	//										
	// --------------------------------------------------------------------------------------------------- 
	centerElementViaBody : function(element, params) {
		var o1 = document.getElementsByTagName("body")[0];
		if (o1 == null) { return; }
		var o1Dim = Element.getDimensions(o1);
		
		var o2 = $(element);
		if (o2 == null) { return; }
		if (params) {
			o2.style.height = params.height ? params.height : o2.style.height;
			o2.style.width = params.width ? params.width : o2.style.width;
		}
		var o2Dim = Element.getDimensions(o2);
		
		if(params && params.makefit) {
			o2.style.height = o2Dim.height > o1Dim.height ? o1Dim.height : o2.style.height;
			o2Dim = Element.getDimensions(o2);
		}
		
		var top =  Math.round((o1Dim.height-o2Dim.height) / 2);
		var left = Math.round((o1Dim.width-o2Dim.width) / 2);
		
		if (params && params.viewtop) {
			top = (top < 0) ? 0 : top;
		}
		if (params && params.viewleft) {
			left = (left < 0) ? 0 : left;
		}
		
		o2.style.left = left + "px";
		o2.style.top = top + "px";
	},
	/* Dancik.getDocumentHeight */
	getDocumentHeight : function() {
		if (document.all) {
			return document.body.offsetHeight;
		}
		if (document.layers) {
			return window.innerHeight;
		}
		if (document.getElementById) {
			return window.innerHeight;
		}
		return 0;
	},	
	/* Dancik.getDocumentWidth */
	getDocumentWidth : function() {
		if (document.all) {
			return document.body.offsetWidth;
		}
		if (document.layers) {
			return window.innerWidth;
		}
		if (document.getElementById) {
			return window.innerWidth;
		}
		return 0;
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.toggleReadonly  
	//	Description : Used to toggle passed element's readOnly status on/off, and set new className...
	//	Parameters 	: element	: (req) Element object
	//				  onoff	 	: (req) Boolean (true/false)... 		
	//* *********************************************************************************************
	toggleReadonly : function(element, onoff) {
		if (onoff == false) {
			Element.removeClassName(element, 'readonly');		
			element.readOnly = false;
		} else {
			Element.addClassName(element, 'readonly');
			element.readOnly = true;
		}
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.execOnEnter  
	//	Description : Use on onKeyUp method of <INPUT> fields, so to execute a passed function when the ENTER key is pressed.
	//					This is a replacement for onBlur=function, because sometimes a user just wants to clear the value.
	//	Parameters 	: e				: (req) Event
	//				  function	 	: (req) The function to execute... 		
	//* *********************************************************************************************
	execOnEnter : function (e, f) {
		if (f == null) { return false; }
		
		var key  = window.event ? window.event.keyCode : e ? e.which : 0;
		// -- Only execute on [ENTER]...
		if ( key == Event.KEY_RETURN ) {
			f();
	  	}
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.removeElements  
	//	Description : Removes all elements, by TagName, from object.
	//	Parameters 	: o				: (req) The object/element to be utilized.
	//				  rmvElements 	: An array of all tags wanting to be removed from the passed object/element.
	//									If null, then all elements are removed... 		
	//* *********************************************************************************************
	removeElements : function(o, rmvElements) {	
		if (o == null) { return; }
		
		if (rmvElements == null) {
			var kids=o.childNodes,i = kids.length;
			while (i--) {
				o.removeChild(kids[i])
			}	
		} else {
			var rmvLen = rmvElements.length;
			for (var i=0; i<rmvLen; i++) {
				var oElements = o.getElementsByTagName(rmvElements[i]);
				var oLen = oElements.length;
				for (var j=oLen; j>1; j--) {
			    	o.removeChild(oElements[j-1]);
				}
			}
		}
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.buildJSONFromElement 
	//	Description : Takes the passed in element, and builds a JSON object from it's attributes.
	//	Parameters 	: element		: (req) The element needing deconstruction.	
	//* *********************************************************************************************
	buildJSONFromElement : function(element) {
		if (element == null) { return null; }
		
			var attrs = element.attributes;
			var attrhash = $H();
			var len = attrs.length;
			for (var i=0; i<len; i++) {
				if (!attrs[i].value.isEmpty() && attrs[i].value != "null" && attrs[i].value.indexOf("function(")==-1) {
					attrhash.set(attrs[i].name, attrs[i].value);
				}
			}

			var result = new Hash( {'tag':element.tagName, 'attributes':attrhash} );

			return result.toJSON();
	 },
	//* *********************************************************************************************
	//	Function 	: Dancik.cumulativeOffset  (Copied from Prototype 1.6.0.2 (Element.Methods.cumulativeOffset(element))
	//	Description : Performs exactly how Element.Methods.cumulativeOffset(elem) works, but asks for the stopping parent to be passed in.
	//	Parameters 	: element		: (req) The element needing calculating...	
	//				: stopParent	: (req) This is the offSetParent where the calculation needs to stop at...
	//* *********************************************************************************************
	cumulativeOffset : function(element, stopParent) {
	    var valueT = 0, valueL = 0;
	    var prevParent = null;
	    do {
	      valueT += element.offsetTop  || 0;
	      valueL += element.offsetLeft || 0;
	      element = element.offsetParent;
	      
	      if (prevParent == stopParent) {
	      	break;
	      } else {
	      	prevParent = element;
	      }
	    } while (element);
	    return Element._returnOffset(valueL, valueT);
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.createImageLink (Created by John McNeirney.  Copied from Util.js, from IBDS)...
	//	Description : Create an image link.
	//  				Have to do this separately, because doesn't work when you use Builder to do it
	//  				for some reason, it adds an extra nested anonymous function...
	//	Parameters 	: srcURL		: (req) The url for the <IMG SRC>	
	//				: "title"		: Link Title / ALT...
	//				: "onclick"		: onClick function...
	//* *********************************************************************************************
	createImageLink : function(srcURL, title, onclick) {
		var options = Object.extend(
			{
				href: '#',
				title: title
			},
			arguments[3] || {}
		);
		
		// create the link
		var link = Builder.node('A', options, 
				Builder.node('IMG', {src: srcURL, border: 0})
			);

		// attach the onclick function
		if (onclick) {
			link.onclick = onclick;
		}
		return link;
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.rlSlide 
	//	Description : Moves, actually slides, an element, from Right to Left, and vise-versa....
	//	Parameters 	: o			: Object/Element to be moving...
	//				: "attributes"	: "startingPosition" 	- (req)
	//								: "endingPosition"		- (req) 
	//								: "elapsedTime"			- (req)  * - Used in transistion
	//								: "totalSlideTime"		- (opt)  dft:300  (or .3 seconds)
	//								: "speedIncrements"		- (opt)  dft:90 
	//								: "timeOutIncrements"	- (opt)  dft:50 (or .05 seconds) 
	//								: "forWidth"			- (opt)  dft:false - This replaces the use of style['left'] with style['width'];  
	//								: "forTop"				- (opt)  dft:false - This replaces the use of style['left'] with style['top'];  
	//								: "forHeight"			- (opt)  dft:false - This replaces the use of style['left'] with style['height'];  
	//								: "finalFunction"		- (opt)  dft:null - This allows user to pass a function to execute when object has completed slide... 
	//* *********************************************************************************************
	rlSlide : function(o,  attributes) {
		if (o == null) return false;
		if (attributes == null) return false;

		var totalSlideTime = (attributes.totalSlideTime == null) ? 300 : attributes.totalSlideTime;
		var speedIncrements = (attributes.speedIncrements == null) ? 90 : attributes.speedIncrements;
		var timeOutIncrements = (attributes.timeOutIncrements == null) ? 50 : attributes.timeOutIncrements;
		var forWidth = (attributes.forWidth == null) ? false : attributes.forWidth;

		var proportionSoFar = attributes.elapsedTime / totalSlideTime;
		
		var currentPos = Math.round(attributes.startingPosition + proportionSoFar * (attributes.endingPosition - attributes.startingPosition));
		o.style[attributes.forWidth ? 'width' : attributes.forTop ? 'top' : attributes.forHeight ? 'height' :'left'] = currentPos + "px";

		attributes.elapsedTime += speedIncrements;
		if (attributes.elapsedTime >= totalSlideTime) {
		  	o.style[attributes.forWidth ? 'width' : attributes.forTop ? 'top' : attributes.forHeight ? 'height' :'left'] = attributes.endingPosition + "px";;
		  	if (attributes.finalFunction != null) {
		  		attributes.finalFunction();
		  	} 
		  	return;
		}
		var nextCall = function() { 
			Dancik.rlSlide(o, attributes);
		}
		setTimeout(nextCall, timeOutIncrements);
	},
	//* *********************************************************************************************
	//	Function 	: Dancik.rlBlind 
	//	Description : Moves, actually blinds, an element, from Right to Left, and vise-versa....
	//	Parameters 	: o			: Object/Element to be moving...
	//				: "attributes"	: "startingPosition" 	- (req)
	//								: "endingPosition"		- (req) 
	//								: "elapsedTime"			- (req)  * - Used in transistion
	//								: "totalBlindTime"		- (opt)  dft:300  (or .3 seconds)
	//								: "speedIncrements"		- (opt)  dft:90 
	//								: "timeOutIncrements"	- (opt)  dft:50 (or .05 seconds) 
	//								: "forHeight"			- (opt)  dft:false - This replaces the use of style['top'] with style['height'];  
	//								: "finalFunction"		- (opt)  dft:null - This allows user to pass a function to execute when object has completed slide... 
	//* *********************************************************************************************
	rlBlind : function(o,  attributes) {
		if (o == null) return false;
		if (attributes == null) return false;

		var totalBlindTime = (attributes.totalBlindTime == null) ? 300 : attributes.totalBlindTime;
		var speedIncrements = (attributes.speedIncrements == null) ? 90 : attributes.speedIncrements;
		var timeOutIncrements = (attributes.timeOutIncrements == null) ? 50 : attributes.timeOutIncrements;
		var forHeight = (attributes.forHeight == null) ? false : attributes.forHeight;

		var proportionSoFar = attributes.elapsedTime / totalBlindTime;
		
		var currentPos = Math.round(attributes.startingPosition + proportionSoFar * (attributes.endingPosition - attributes.startingPosition));
		o.style[attributes.forHeight ? 'height' : 'top'] = currentPos + "px";
		
		attributes.elapsedTime += speedIncrements;
		if (attributes.elapsedTime >= totalBlindTime) {
		  	o.style[forHeight ? 'height' : 'top'] = attributes.endingPosition + "px";;
		  	if (attributes.finalFunction != null) {
		  		attributes.finalFunction();
		  	} 
		  	return;
		}
		var nextCall = function() { 
			Dancik.rlBlind(o, attributes);
		}
		setTimeout(nextCall, timeOutIncrements);
	},
	/* Dancik.mouseOver */
	mouseOver : function(o, extension) {
		if (o.className.indexOf("_") > 0) { return;}   // -- Exit if an extension already exists...
		var ext = !extension ? '_MouseOver' : extension;
		Dancik.addExtToClassName(o, ext);
	},
	/* Dancik.mouseOut */
	mouseOut : function(o, extension) {
		var ext = !extension ? '_MouseOver' : extension; 
		Dancik.rmvExtFromClassName(o, ext);
	},
	/* Dancik.hiLite */
	hiLite : function(o, extension) {
		if (o.className.indexOf("_") > 0) { return; }  // -- Exit if an extension already exists...
		var ext = !extension ? '_HiLite' : extension; 
		Dancik.addExtToClassName(o, ext);
	},
	/* Dancik.rmvHiLite */
	rmvHiLite : function(o, extension) {
		var ext = !extension ? '_HiLite' : extension; 
		Dancik.rmvExtFromClassName(o,  ext);
	},
	/* Dancik.addExtToClassName */
	addExtToClassName : function(o, ext) {
		if (!o) { return false; }
		if (o.className.indexOf("_") > 0) { return; }  // -- Exit if an extension already exists...
		if (ext.isEmpty()) { return false; }
		o.className += ext;
	},
	/* Dancik.rmvExtFromClassName */
	rmvExtFromClassName : function(o, ext) {
		if (!o) { return false; }
		if (ext.isEmpty()) { return false; }
		var pos = o.className.indexOf(ext);
		if (pos > 0) {
			o.className = o.className.substring(0,pos);
		}
	},
	/* Dancik.formatDate */
	formatDate : function(str, format) {
		var year = str.substr(0, 4);
		var month = str.substr(4, 2);
		var day = str.substr(6, 2);
		
		var result = format;
		var result = result.replace('y', year);
		var result = result.replace('m', month);
		var result = result.replace('d', day);
		
		return result;
	},
	/* Dancik.setSelectValue */
	setSelectValue : function(select, value) {
		for (var i=0; i<select.options.length; i++) {
			if (select.options[i].value==value) {
				select.selectedIndex = i;
				return;
			}
		}
	},
	/* Dancik.getSelectValue */
	getSelectValue : function(select) {
		return select.options[select.selectedIndex].value;
	},
	/* Dancik.isObject */
	isObject : function(o) {
		return (o && typeof(o) == "object");
	},
	/* Dancik.String */
	String : {
		/* Dancik.String.isValidTenths */
		isValidTenths : function(v) {
			if (isNaN(v)) { return false; }
			
			var a = Math.round(v * 1000000);
			var b = Math.round( a % 100000 );
			return ( b == 0 );
		},
		/* Dancik.String.isValidHundredths */
		isValidHundredths : function(v) {
			 if (isNaN(v)) { return false; }

			 var a = Math.round(v * 1000000);
			 var b = Math.round( a % 10000 );
			 return ( b == 0 );
		},
		/* Dancik.String.isValidThousandths */
		isValidThousandths : function(v) {
			if (isNaN(v)) { return false; }
			
			var a = Math.round(v * 1000000);
			var b = Math.round( a % 1000 );
			return ( b == 0 );
		},
		/* Dancik.String.isValid4Decimals */
		isValid4Decimals : function(v) {
			 if (isNaN(v)) { return false; }

			 var a = Math.round(v * 1000000);
			 var b = Math.round( a % 100 );
			 return ( b == 0 );
		},
		/* Dancik.String.isValid5Decimals */
		isValid5Decimals : function(v) {
			if (isNaN(v)) { return false; }

			var a = Math.round(v * 1000000);
			var b = Math.round( a % 10 );
			return ( b == 0 );
		},
		/* Dancik.String.isProperFileName */
		isProperFileName : function(v) {
			if (!v) { return false; }
			var regex=/[*|,\\":<>`'?\/]/;
			return !regex.test(v);
		},
		/* Dancik.String.reverse */
		reverse : function(v) {
			var splitext = v.split("");
			var revertext = splitext.reverse();
			return revertext.join("");
		},
		/* Dancik.String.lookup */
		lookup : function(v, a) {
			if (!v) { return false; }
			for (var i=0; i<a.length; i++) { 
				if ( v.equals(a[i]) ) { return true; }
			}
			return false;
		}
	},
	/* Dancik.FeetInches */
	FeetInches : {
		reFeetInches : /^(\d+)\'(\d+)\"$/,
		reFeet : /^(\d+)\'$/,
		reInches : /^(\d+)\"$/,
		reDecimal : /^(\d+)\.(\d+)$/,
		reNoDecimal : /^(\d+)$/,
		
		// ***********************************************************************************************************************************************
		// * - Function 	: Dancik.FeetInches.format
		// * - Description 	: Takes passes string, and attempts to extract out feet/inches values based on predicted formatting.
		// * - Returns 		: (null if invalid valid);
		// * -				: else { feet : 9, inches : 99, format1 : 9.99, format2 : 9'99", format3 : 9ft 99in }
		// ***********************************************************************************************************************************************
		format: function(oValue){
			// -- Ignore, if no value is passed...
			if (oValue == null) { return null; }
			// -- Strip out any blanks before,after and within...
			oValue = oValue.replace(/\s+/g,'');
			
			var rJson = null;

			try {
				// -- See if value coming in is in the (9'99") format...
				if (this.reFeetInches.exec(oValue)) {	
					rJson = { feet : RegExp.$1, inches : RegExp.$2 };
					
				// -- See if value coming in is in the (9') format...			
				} else if (this.reFeet.exec(oValue)) {	
					rJson = { feet : RegExp.$1, inches : 0 };
					
				// -- See if value coming in is in the (99") format...
				} else if (this.reInches.exec(oValue)) {
					rJson = { feet : 0, inches : RegExp.$1 };
		
				// -- See if value coming in is in the (9.99) format...
				} else if (this.reDecimal.exec(oValue)) {
					rJson = { feet : RegExp.$1, inches : RegExp.$2 };
		
				// -- See if value coming in is in the (9) format...
				} else if (this.reNoDecimal.exec(oValue)) {
					rJson = { feet : RegExp.$1, inches : 0 };
		
				} else {
					throw 'BadFormat';
				}		
				
				// -- Convert to actual numerics..
				rJson.feet = new Number(rJson.feet);
				rJson.inches = new Number(rJson.inches);
				
				
				rJson = Object.extend( rJson, { format1 : (rJson.feet + '.' + ((rJson.inches <= 9) ? "0" : "") + rJson.inches) } );
				rJson = Object.extend( rJson, { format2 : (rJson.feet + '\'' + rJson.inches) + '\"' } );
				rJson = Object.extend( rJson, { format3 : (rJson.feet + 'ft ' + rJson.inches) + 'in' } );
				rJson = Object.extend( rJson, { format4 : (rJson.feet + '.' + rJson.inches) } );

			} catch(e) {
				rJson = null;
			}
		
			return rJson;
		}
	},
	/* Dancik.Tables */
	Tables : {
		/* Dancik.Tables.hideAll */
		hideAll : function(o, tagName) {	
			if (o == null) { return; }
			if (tagName == null) { return; }
			var elements = o.getElementsByTagName(tagName);
			var len = elements.length;
			for (var i=0; i<len; i++) { 
				Element.hide(elements[i]); 
			}
		},
		/* Dancik.Tables.clearAllRows */
		clearAllRows : function(o) {	
			if (o == null) { return; }
		    while (o.hasChildNodes()) {
		    	o.removeChild(o.firstChild);
		    } 		
		},
		/* Dancik.Tables.removeElements */
		removeElements : function(o, rmvElements) {
			Dancik.removeElements(o, rmvElements);
		},
		/* Dancik.Tables.resetAllRowHiLites */
		resetAllRowHiLites : function(o) {	
			if (o == null) { return; }
			var rows = o.getElementsByTagName("tr");
			var len = rows.length;
			for (var i=0; i<len; i++) {
				var rowObj = rows[i];	
				Dancik.rmvHiLite(rowObj);
			}	
		},
		/* Dancik.Tables.hiLiteFirstRow */
		hiLiteFirstRow : function(o) {	
			Dancik.Tables.hiLiteRowX(o, 0);
		},
		/* Dancik.Tables.hiLiteRowX */
		hiLiteRowX : function(o,x) {	
			if (o == null) { return; }
			var rows = o.getElementsByTagName("tr");
			if (rows == null) { return; }
			var len = rows.length;
			for (var i=0; i<len; i++) {
				var rowObj = rows[i];
				Dancik.rmvHiLite(rowObj);
				if (i==x) {
					Dancik.hiLite(rowObj);
					Dancik.Tables.positionToRow(o, rowObj);
					break;
				}
			}	
		},
		/* Dancik.Tables.hiLiteRow */
		hiLiteRow : function(o, oRow) {	
			if (o == null) { return; }
			Dancik.Tables.resetAllRowHiLites(o);
			Dancik.hiLite(oRow);
			Dancik.Tables.positionToRow(o, oRow);
		},
		/* Dancik.Tables.getHiLitedRow */
		getHiLitedRow : function(o, hiliteSuffix) {	
			if (o == null) { return; }
			var hilite = '_HiLite';
			if (hiliteSuffix != null) { hilite = hiliteSuffix; }
			var rows = o.getElementsByTagName("tr");
			var len = rows.length;
			for (var i=0; i<len; i++) {
				if ( rows[i].className.indexOf(hilite) > 0 )  {
					return {
						element : o,
						seq : i
					};
				}
			}	
			return null;
		},
		/* Dancik.Tables.hiLiteNextRowUp */
		hiLiteNextRowUp : function(o) {	
			Dancik.Tables.hiLiteNextRow(o, 'up');
		},
		/* Dancik.Tables.hiLiteNextRowDown */
		hiLiteNextRowDown : function(o) {	
			Dancik.Tables.hiLiteNextRow(o, 'down');
		},
		/* Dancik.Tables.hiLiteNextRow */
		hiLiteNextRow : function(o, direction) {	
			if (o == null) { return; }
			var nextObj = null;
			var rows = o.getElementsByTagName("tr");
			var len = rows.length;
			for (var i=0; i<len; i++) {
				var rowObj = rows[i];
				
				if ( rowObj.className.indexOf('_HiLite') > 0 ) {
					if (direction.equals('up')) {
					 	if (i == 0) { return; }	// -- Cannot go higher than the first row...
						Dancik.rmvHiLite(rowObj);
						nextObj = rows[i-1];
					} 
					if (direction.equals('down')) {
						if (i == (len-1)) { return; }	// -- Cannot go lower than the last row...
						Dancik.rmvHiLite(rowObj);
						nextObj = rows[i+1];
					}
					// -- HiLite 'next' row...
					Dancik.hiLite(nextObj);
					Dancik.Tables.positionToRow(o, nextObj);
					return;
				}
			}	
		},
		/* Dancik.Tables.positionToX */
		positionToX : function(oTable, x) {	
			if (oTable == null) { return; }
			var row = oTable.getElementsByTagName("tr")[x];
			if (row == null) { return; }
			Dancik.Tables.positionToRow(oTable, row);
		},
		/* Dancik.Tables.positionToRow */
		positionToRow : function(oTable, oRow) {
			// -- Avoid goofy problem with IE.  (Clearing out contents in TR...	
			if (Prototype.Browser.IE) { return; }
			
			// -- Begin to check for positioning "row", if out of view...
			var oRowBottom = Position.positionedOffset(oRow)[1];

			var oRowHeight = Element.Methods.getHeight(oRow);

			var oParent = Dancik.getParentByTagName(oTable, 'DIV');
			var hParent = Element.Methods.getHeight(oParent);

			var viewableTop = oParent.scrollTop;
			var viewableBottom = hParent + oParent.scrollTop;

			// -- If Paging-Up, and ROW is out of view...
			if ((oRowBottom-oRowHeight) < viewableTop) {
				oParent.scrollTop = (oRowBottom-oRowHeight)-4; // - Addition of 4 is used for top-bottom borders of table and cell...
			// -- If Paging-Down, and ROW is out of view...
			} else if (oRowBottom > viewableBottom) {
				oParent.scrollTop = oRowBottom - hParent;
			}
		},
		/* Dancik.Tables.positionRowToTop */
		positionRowToTop : function(oTable, oRow) {	
			// -- Avoid goofy problem with IE.  (Clearing out contents in TR...	
			if (Prototype.Browser.IE) { return; }
			
			var oRowBottom = Position.positionedOffset(oRow)[1];
			var oParent = Dancik.getParentByTagName(oTable, 'DIV');
			oParent.scrollTop = oRowBottom;
		},
		/* Dancik.Tables.Cell */
		Cell : {
			/* Dancik.Tables.Cell.build */
			// ------------------------------------------------------------------------------------
			// -- Parameters : text			: Values to be loaded into cell via innerHTML...
			// -- 			 : "attributes"	: "alignment" 		- (opt) Values : left, right, center
			// --  							: "className"		- (opt) 
			// --  							: "width"			- (opt) 
			// --  							: "height"			- (opt) 
			// --  							: "bgcolor" 		- (opt) 
			// ------------------------------------------------------------------------------------
			build : function(text, attributes) {	
				var newCell = document.createElement("td");
				newCell.innerHTML = text;
				
				if (attributes != null) {
					if (attributes.alignment != null) {
						if (attributes.alignment.equals("right")) { newCell.setAttribute("align", "right"); }
						else if (attributes.alignment.equals("center")) { newCell.setAttribute("align", "center"); }
						else if (attributes.alignment.equals("left")) { newCell.setAttribute("align", "left"); }
					}
					if (attributes.width != null) { newCell.setAttribute("width", attributes.width); }
					if (attributes.height != null) { newCell.setAttribute("height", attributes.height); }
					if (attributes.className != null) { newCell.className = attributes.className; } 
					if (attributes.bgcolor != null) { newCell.setAttribute("bgColor", attributes.bgcolor); }
				}
				return newCell;
			}
		},
		/* Dancik.Tables.Row */
		Row : {
			/* Dancik.Tables.Row.toggleOptions_MouseOver */
			toggleOptions_MouseOver : function(o) {
				if (!o) { o = this; }
				if (!o.className) { return; }

				Dancik.mouseOver(o);
				var divs = o.cells[0].getElementsByTagName("div");
				if (divs.length > 0) {
					Element.hide(divs[0]);
					Element.show(divs[1]);
				}
			},
			/* Dancik.Tables.Row.toggleOptions_MouseOut */
			toggleOptions_MouseOut : function(o) {
				if (!o) { o = this; }
				if (!o.className) { return; }
				
				Dancik.mouseOut(o);
				var divs = o.cells[0].getElementsByTagName("div");
				if (divs.length > 0) {
					Element.show(divs[0]);
					Element.hide(divs[1]);
				}
			}
		}
	},
	/* Dancik.Select */
	Select : {
		// ********************************************************************************
		// ** Function : Dancik.Select.makeSelected()
		// ********************************************************************************
		makeSelected : function(o, value) {
			if (o == null) { return; }
			var selected = null;
			var len = o.length;
			for (var i=0; i<len; i++) {
				if (o.options[i].value == value) {
					o.options[i].selected = true;
					selected = o.options[i];
				} else {
					o.options[i].selected = false;
				}
			}
			return selected;
		},
		// ********************************************************************************
		// ** Function 	: Dancik.Select.resetSelected 
		// ** Description : Selects the first element of the passed in <SELECT> object.
		// ** Parameters	: 1) <SELECT> object.
		// ********************************************************************************
		resetSelected : function(o) {
			if (o == null) { return; }
			var len = o.length;
			for (var i=0; i<len; i++) {
				if (i == 0) {
					o.options[i].selected = true;
				} else {
					o.options[i].selected = false;
				}
			}
		},	
		// ********************************************************************************
		// ** Function 	: Dancik.Select.removeOptions 
		// ** Description : Removes *ALL options from the passed in <SELECT> object...
		// ** Parameters	: 1) <SELECT> object.
		// ********************************************************************************
		removeOptions : function(o) {
			if (o == null) { return; }
			var len = o.length;
		   	for (var i=len; i>=0; i--) {
				o[i] = null;
		   	}
		},
		// ********************************************************************************
		// ** Function 	: Dancik.Select.removeOption 
		// ** Description : Removes the passed in Option(Value) from the passed in <SELECT> object...
		// ** Parameters	: 1) <SELECT> object.
		// ** 				: 2) Option value.
		// ********************************************************************************
		removeOption : function(o, val) {
			if (o == null || val == null) { return; }
			for (var i=0; i<o.length; i++) {
		   		if (o[i].value == val) {
					o[i] = null;
					return;
				}
		   	}
		},
		// ********************************************************************************
		// ** Function 	: Dancik.Select.haveOptions 
		// ** Description : Asks the question, does this <SELECT> object have any options?
		// ********************************************************************************
		haveOptions : function(o) {
			if (o!=null && o.options!=null) { return true; }
			return false;
		},
		// ********************************************************************************
		// ** Function 	: Dancik.Select.sortByText 
		// ** Description : Resorts the <SELECT> object by it's TEXT value..
		// ********************************************************************************
		sortByText : function(o) {
			var i;
			var temp = [];
			if (!Dancik.Select.haveOptions(o)) { return; }
			for (i=0; i<o.options.length; i++) {
				temp[temp.length] = new Option( o.options[i].text, o.options[i].value, o.options[i].defaultSelected, o.options[i].selected) ;
				}
			if (temp.length==0) { return; }
			temp = temp.sort( function(a,b) { 
								if ((a.text.toUpperCase()+"") < (b.text.toUpperCase()+"")) { return -1; }
								if ((a.text.toUpperCase()+"") > (b.text.toUpperCase()+"")) { return 1; }
								return 0;
							} 
						);
		
			for (i=0; i<temp.length; i++) {
				o.options[i] = new Option(temp[i].text, temp[i].value, temp[i].defaultSelected, temp[i].selected);
			}
		},
		// *******************************************************************************************************************************************************
		// ** Function 	: Dancik.Select.clone
		// ** Description : Clone the contents of <SELECT> object to another. 
		// ** Parameter 	: options :		- actionObjects (opt)	: Defines other objects that should be disabled/enabled during the reload process.  [ object, object, etc ]
		// **															(This does not include the <SELECT> object itself.  That is automatic.)
		// ***************************************************************************************************************************************************** */
		clone : function(fromObject, toObject, options) {
			var i;
			if (!fromObject) { return; }
			if (!toObject) { return; }
			if (!options) { options = {}; }
		
			// -- First, Disable the <SELECT> object, any other requested object, before continuing. To avoid pre-selections...
			Form.Element.disable(fromObject);
			Form.Element.disable(toObject);
			if (options.actionObjects != null) {
				for (i=0; i<options.actionObjects.length; i++) {
					Form.Element.disable(options.actionObjects[i]);
				}
			}
			
			var len = fromObject.length;	
			for (i=0; i<len; i++) {
				toObject.options[toObject.length] = new Option(fromObject[i].text, fromObject[i].value);
			}		
			
			// -- Last, Disable the <SELECT> object, any other requested object, before continuing. To avoid pre-selections...
			Form.Element.enable(fromObject);
			Form.Element.enable(toObject);
			if (options.actionObjects != null) {
				for (i=0; i<options.actionObjects.length; i++) {
					Form.Element.enable(options.actionObjects[i]);
				}
			}			
		},
		// *******************************************************************************************************************************************************
		// ** Function 	: Dancik.Select.cloneToHash
		// ** Description : Clone the contents of <SELECT> object to a Hash object... 
		// ***************************************************************************************************************************************************** */
		cloneToHash : function(fromObject) {
			if (!fromObject) { return; }
			var h = $H();
		
			var len = fromObject.length;	
			for (var i=0; i<len; i++) {
				h.set(fromObject[i].value, fromObject[i].text);
			}		
			return h;
		},
		// *******************************************************************************************************************************************************
		// ** Function 	: Dancik.Select.reload
		// ** Description : Reloads the <SELECT> object, via passed in array, in JSON object format, ex ["id":"", "description":""] 
		// ** Parameter 	: options :		- firstOption (opt) 	: Defines what the first option of the newly reloaded <SELECT> should contain. ( id, description }
		// **								- loadEmptyOption (opt)	: Defines whether the first options should be pre-loaded [EMPTY] object... {true/false)
		// **								- actionObjects (opt)	: Defines other objects that should be disabled/enabled during the reload process.  [ object, object, etc ]
		// **															(This does not include the <SELECT> object itself.  That is automatic.)
		// ***************************************************************************************************************************************************** */
		reload : function(o, elements, options) {
			var i;
			// -- Used to catch/avoid duplicates...
			var ids = [];

			if (options == null) { options = {}; }
		
			// -- First, Disable the <SELECT> object, any other requested object, before continuing. To avoid pre-selections...
			Form.Element.disable(o);
			if (options.actionObjects != null) {
				for (i=0; i<options.actionObjects.length; i++) {
					Form.Element.disable(options.actionObjects[i]);
				}
			}

			// -- Next, remove all options...
			Dancik.Select.removeOptions(o);
			
			// -- Next, add 'firstOption' if it is passed.  (ex. <option>* SELECT ONE *</option>
			if (options.firstOption != null) {
				o.options[o.length] = new Option(options.firstOption.description, options.firstOption.id);	
				ids[ids.length] = options.firstOption.id;
			}
			// -- Or, should the first option be [EMPTY].  (ex. <option></option>
			if (options.loadEmptyOption != null  &&  options.loadEmptyOption == true) {
				o.options[o.length] = new Option('', '');
				ids[ids.length] = '';
			}

			// -- Next, Execute Loop...
			if (elements != null) {
				for (i=0; i<elements.length; i++) {
					// - Avoid Duplicates...
					if (ids.indexOf(elements[i].id) == -1) {
						o.options[o.length] = new Option(elements[i].description, elements[i].id);
						ids[ids.length] = elements[i].id;
					}	
				}
			}
			
			// -- Last, Disable the <SELECT> object, any other requested object, before continuing. To avoid pre-selections...
			Form.Element.enable(o);
			if (options.actionObjects != null) {
				for (i=0; i<options.actionObjects.length; i++) {
					Form.Element.enable(options.actionObjects[i]);
				}
			}
			
		},
		// *******************************************************************************************************************************************************
		// ** Function 	: Dancik.Select.reloadViaAJAX
		// ** Description : Reloads the <SELECT> object, via AJAX, and passed url...
		// ** Parameter 	: options :		- firstOption (opt) 	: Defines what the first option of the newly reloaded <SELECT> should contain. ( id, description }
		// **								- actionObjects (opt)	: Defines other objects that should be disabled/enabled during the reload process.  [ object, object, etc ]
		// **															(This does not include the <SELECT> object itself.  That is automatic.)
		// **								- finalFunction	(opt)	: If a function needs to be executed at the end...
		// ***************************************************************************************************************************************************** */
		reloadViaAJAX : function(o, url, params, options) {
			// -- Avoid nulls and empty values...
			if (o == null) { return; }
			if (url == null  ||  url.isEmpty() ) { return; }
			if (options == null) { options = {}; }


			// -- Use the passed URL, to retrieve results, which must be in { id, description } format...
			var ajax = new Ajax.Request( url,
				{method: 'get', 
				 parameters: params, 
				 onSuccess: function(res) {
				 	try { 
				 		if (res.responseText.isEmpty()) { throw "EmptyResult"; }
						var json = res.responseText.evalJSON(true);
						if (json == null || json.records == null) { throw "InvalidJSON"; }
						
						// -- Resulting JSON format- { records : ["id":"", "description":""]
						Dancik.Select.reload(o, json.records, options); 
						
						// -- Final Function...
						if (options.finalFunction != null) {
							options.finalFunction();
						}
						
						
					} catch(e) {
						if (e == "InvalidJSON") {
							alert("Dancik.Select.reload() - InvalidJSON : \n\n" + res.responseText);
						} else if (e == "EmptyResult") {
							// -- Still execute reload, only pass null for records...
							Dancik.Select.reload(o, null, options); 
						} else {
							alert("Dancik.Select.reload() : " + e.message);
						}
					} finally {
					}
				 }, 
				 onFailure: function(res) { alert(res.responseText); } 
				}
			);	
		}
	},
	/* Dancik.Radio */
	Radio : {
		/* Dancik.Radio.makeChecked */
		makeChecked : function(o, value) {
			if (o == null) { return; }
			for (var i=0; i<o.length; i++) {
				if (o[i].value == value) {
					o[i].checked = true;
				} else {
					o[i].checked = false;
				}
			}
		},
		/* Dancik.Radio.getChecked */
		getChecked : function(o) {
			if (o == null) { return; }
			var len = o.length;
			for (var i=0; i<len; i++) {
				if (o[i].checked == true) {
					return o[i].value;
				}
			}
			return '';
		}
	},
	/* Dancik.Build */
	Build : {
		/* Dancik.Build.KeyParam */	
		// ------------------------------------------------------------------------------------
		// -- Builds the Key-Param object used in generic popup windows...
		// -- ex. For Item# REX1119 = { dataKey : '*ITEM', key : 'REX1119', key01 : 'REX', key02 : '1119' }
		// ------------------------------------------------------------------------------------
		KeyParam : {
			/* Dancik.Build.KeyParam.forItem */
			forItem : function(val) {
				var o = { dataKey : '*ITEM', key : val };

				if (val.length > 0) { o = Object.extend(o, { key01 : val.substring(0,3) });	}
				if (val.length > 3) { o = Object.extend(o, { key02 : val.substring(3,7) });	} 
				if (val.length > 7) { o = Object.extend(o, { key03 : val.substring(7,16) });	} 
				if (val.length > 16) { o = Object.extend(o, { key04 : val.substring(16,18) }); } 
				if (val.length > 18) { o = Object.extend(o, { key05 : val.substring(18,20) }); } 
				
				return o;
			}
		}	
	},
	/* Dancik.InputMask */
	InputMask : {
		/* Dancik.InputMask.masks */
		masks: {
			date_iso: {
	         	format: '    -  -  ',
	         	regex:  /\d/
	      	},
	      	date_us: {
	      		format: '  /  /    ',
	      		regex:  /\d/
	      	},
		    time: {
	      		format: '  :  :  ',
	      		regex:  /\d/
	      	},
	      	phone: {
	      		format: '(   )   -    ',
	      		regex:  /\d/
	      	},
	      	ssn: {
	      		format: '   -  -    ',
	      		regex:  /\d/
	      	},
	      	visa: {
	      		format: '    -    -    -    ',
	      		regex:  /\d/
	      	},
	      	zipcode: {
	      		format: '     -    ',
	      		regex:  /\d/
	      	},
	      	zipcode5: {
	      		format: '     ',
	      		regex:  /\d/
	      	},
	      	zipcode4: {
	      		format: '    ',
	      		regex:  /\d/
	      	},
	      	d3_2: {
	      		format: '   .  ',
	      		regex:	/\d/
	      	}
	   	},
		// ---------------------------------------------------------------------------------------------------
		// - Function    : Dancik.InputMask.digits(event)
		// - Description :  
		// --------------------------------------------------------------------------------------------------- 
	   	digits: function(event) {
	   		var elm = Event.element(event);
	   		if(!elm.type)
	   			return;
	   		var key  = event.which || event.keyCode;
	   		if(			key == Event.KEY_BACKSPACE ||
						key == Event.KEY_TAB ||
						key == Event.KEY_RETURN ||
						key == Event.KEY_ESC ||
						key == Event.KEY_LEFT ||
						key == Event.KEY_UP ||
						key == Event.KEY_RIGHT ||
						key == Event.KEY_DOWN ||
						key == Event.KEY_DELETE ||
						key == Event.KEY_HOME ||
						key == Event.KEY_END ||
						key == Event.KEY_PAGEUP ||
						key == Event.KEY_PAGEDOWN) {
	   			return;
	   		}
	   		
	   		var ch = String.fromCharCode(key);
	   		if(!ch.match(/\d/)) {
	   			Event.stop(event);
	   		}
	   		

	   	},
		// ---------------------------------------------------------------------------------------------------
		// - Function    : Dancik.InputMask.applyForKeyPress(event, element, maskType)
		// - Description :  
		// --------------------------------------------------------------------------------------------------- 
	   	applyForKeyPress: function(e, element, maskType) {
	   		var mask = Dancik.InputMask.masks[maskType];
	        var key  = window.event ? window.event.keyCode : e ? e.which : 0;

	        if ( (key >= 32 && key < 127) ) {
				var ch = String.fromCharCode(key);
				var str = $F(element) + ch;
				var pos = str.length;
				if ( mask.regex.test(ch) && pos <= mask.format.length ) {
				   if ( mask.format.charAt(pos - 1) != ' ' ) {
				      str = $F(element) + mask.format.charAt(pos - 1) + ch;
				   }
				   element.value = str;
				   //element.focus();
				   //element.select();
				   
				}
	           Event.stop(e);
	        }
	   	},
		// ---------------------------------------------------------------------------------------------------
		// - Function    : Dancik.InputMask.applyOnly(element, maskType)
		// - Description :  
		// --------------------------------------------------------------------------------------------------- 
	   	applyOnly: function(element, maskType) {
      	}
	},
	/* Dancik.XML */
	XML : {
		/*  ************************************************************************************ 
		Function 	: Dancik.XML.BuildStringElement
		Description : Builds an XML string <tag>content</tag> 
		Parameters	: 1) Tag Name
					: 2) Content value.		
		*  ************************************************************************************ */
		BuildStringElement : function(tag, content) {
		    var xml = "";
		    if (!content ||
		    		( content instanceof String && content.isEmpty() ) ||
		    		content == " " ) {
		        xml='<' + tag + '/>';
		    } else {
		        xml='<'+ tag + '>' + content + '</' + tag + '>';
		    }
		    return xml;
		}	
	},
	/* Dancik.Time */
	Time : {
		/* Dancik.Time.format */
		format : function(h,m,s) {
			if (s == null) {
				return Dancik.Date.make2Digit(h) + ":" + Dancik.Date.make2Digit(m);
			} else {
				return Dancik.Date.make2Digit(h) + ":" + Dancik.Date.make2Digit(m) + ":" + Dancik.Date.make2Digit(s);
			}
		
		},
		/* Dancik.Time.subtractDates */
		subtractDates : function ( start, end ) {
			var hourChk = 1000*60*60;
			var minsChk = 1000*60;
			
			var timediff = end.getTime() - start.getTime();
			
			var hours = Math.floor(timediff / hourChk);
			
			var msDiffFromHours = hours * hourChk;
			
			var msRemaining = timediff - msDiffFromHours;
			
			var minutes = Math.round(msRemaining  / minsChk);
			
			if (minutes == 60) {
				hours += 1;
				minutes = 0;
			}
			
			return { 'hours' : hours, 'minutes' : minutes };
		}
	},
	/* Dancik.Date */
	Date : {
		/* Dancik.Date.cvt_MDCYStringToDate */
		cvt_MDCYStringToDate : function(mdcyDate) {
			var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
		
			if (re_date.exec(mdcyDate)) {
				return new Date (RegExp.$3, RegExp.$1-1, RegExp.$2);
			} else {
				return new Date();
			}
		},
		/* Dancik.Date.cvt_CYMDIntToDate */
		cvt_CYMDIntToDate : function(ccyymmdd) {
			var newDate = new Date();
			var ccyy = Math.round(ccyymmdd / 10000);
			var mm = Math.round( Math.round(ccyymmdd % 10000) / 100);
			var dd = Math.round( Math.round(ccyymmdd % 10000) % 100);
		
			if ( (mm+dd+ccyy) > 0 ) {
				newDate.setFullYear(ccyy, mm-1, dd);
				return newDate;
			} else {
			}
		},
		/* Dancik.Date.cvt_MDCYStringToCYMDInt */
		cvt_MDCYStringToCYMDInt : function(mdcyDate) {
			var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
		
			if (re_date.exec(mdcyDate)) {
				var m = parseInt(RegExp.$1,10);
				var d = parseInt(RegExp.$2,10);
				var y = parseInt(RegExp.$3,10);
				return (y*10000)+(m*100)+(d*1);
			} else {
				return -1;
			}
		},
		/* Dancik.Date.cvt_DateToMDCYString */
		cvt_DateToMDCYString : function(datetime) {
			if (datetime == null) { datetime = new Date(); }
			var y = datetime.getFullYear();
			var m = datetime.getMonth() + 1;
			var d = datetime.getDate();
		
			if (m<10) {
				m = '0' + m;
			}
		
			if (d<10) {
				d = '0' + d;
			}
			
			return m + "/" + d + "/" + y;
		},
		/* Dancik.Date.cvt_CYMDIntToMDCYString */
		cvt_CYMDIntToMDCYString : function(ccyymmdd) {
			return Dancik.Date.cvt_DateToMDCYString(Dancik.Date.cvt_CYMDIntToDate(ccyymmdd));
		},
		/* Dancik.Date.cvt_DateToCYMDInt */
		cvt_DateToCYMDInt : function(datetime) {
			if (datetime == null) {
				datetime = new Date();
			}
			var y = datetime.getFullYear();
			var m = datetime.getMonth() + 1;
			var d = datetime.getDate();
		
			
			return (y*10000)+(m*100)+(d*1);
		},
		/* Dancik.Date.cvt_MDCYStringToObject */
		cvt_MDCYStringToObject : function(inMDCYDate) {
			var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
		
			re_date.exec(inMDCYDate);	
			var m = RegExp.$1;
			var d = RegExp.$2;
			var y = RegExp.$3;
		
			return { month : m, day : d, year : y };
		},
		/* Dancik.Date.cvt_DateToObject */
		cvt_DateToObject : function(dateObject) {
			if (dateObject == null) { dateObject = new Date(); }
			var y = dateObject.getFullYear();
			var m = dateObject.getMonth() + 1;
			var d = dateObject.getDate();
			
			return { month : m, day : d, year : y };
		},
		/* Dancik.Date.make2Digit */
		make2Digit : function(i) {
			if (i<10) {
				return "0" + i;
			} else {
				return i;
			}
		},
		/* Dancik.Date.validate_MDCYString */
		validate_MDCYString : function(mdcyString) {
		    var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
		    if(!re_date.exec(mdcyString)){
		      return false;
		    }
		
		    var m = RegExp.$1;
		    var d = RegExp.$2;
		    var y = RegExp.$3;
		
		    if(m<1 | m>12)
		      return (false);
		
		    if (
			      (d<1)
			      || (m==2 & d>29)
			      || ((m==4 | m==6 | m==9 | m==11) & d>30)
			      || (!(m==2 | m==4 | m==6 | m==9 | m==11) & d>31)
		    ) {
		      return false;
		    }
		
		    return true;	
		}
	},
	/* Dancik.Watch */
	Watch : {
		RecordChangedIndicator : false,
		/* Dancik.Watch.MonitorKeyPress */
		MonitorKeyPress : function(e) {
			if (!Dancik.Watch.RecordChangedIndicator) {
				var elm = Event.element(e);
				var code = '';
				if (e.keyCode) {
					code = e.keyCode;
				} else if (e.which) { 
					code = e.which; 
				}
				
				if ( code != Event.KEY_BACKSPACE &&
						code != Event.KEY_TAB &&
						code != Event.KEY_RETURN &&
						code != Event.KEY_ESC &&
						code != Event.KEY_LEFT &&
						code != Event.KEY_UP &&
						code != Event.KEY_RIGHT &&
						code != Event.KEY_DOWN &&
						code != Event.KEY_DELETE &&
						code != Event.KEY_HOME &&
						code != Event.KEY_END &&
						code != Event.KEY_PAGEUP &&
						code != Event.KEY_PAGEDOWN &&
						!elm.readOnly) {
					Dancik.Watch.RecordChangedIndicator = true;
				}
			}
		},
		/* Dancik.Watch.MonitorSelectChange */
		MonitorSelectChange : function() {
			if (!Dancik.Watch.RecordChangedIndicator) {
				Dancik.Watch.RecordChangedIndicator = true;
			}
		},
		/* Dancik.Watch.Prepare */
		Prepare : function(formElement) {
			Dancik.Watch.RecordChangedIndicator = false;
			var formArr = Form.getElements(formElement);
			var len = formArr.length;
			for (var i=0; i<len; i++) {
				if (formArr[i].type == 'text' || formArr[i].type == 'textarea') {
					Event.observe($(formArr[i]).identify(), 'keyup', Dancik.Watch.MonitorKeyPress, false);
				}
				if (formArr[i].type == 'select-one' || formArr[i].type == 'checkbox') {
					Event.observe($(formArr[i]).identify(), 'change', Dancik.Watch.MonitorSelectChange, false);
				}
		   	}
		},
		/* Dancik.Watch.StopObservingElements */
		StopObservingElements : function(formElement) {
			var formArr = Form.getElements(formElement);
			var len = formArr.length;
			for (var i=0; i<len; i++) {
		   		if (formArr[i].type == 'text') {
					Event.stopObserving(formArr[i].id, 'keyup', Dancik.Watch.MonitorKeyPress, false);
				}
				if (formArr[i].type == 'select-one') {
					Event.stopObserving(formArr[i].id, 'change', Dancik.Watch.MonitorSelectChange, false);
				}
		   	}
		},
		/* Dancik.Watch.OkToContinue */
		OkToContinue : function(msg) {
			if(!msg) {
				msg="Unsaved changes were made and will be lost.  Do you wish to continue?";
			}
				
			// -- Check to make sure not records have been changed,without saving, before continuing...
			if (Dancik.Watch.RecordChangedIndicator) {
				if ( !confirm(msg) ) {
					return false;
				}
			}
			return true;
		}
	},
	/* Dancik.Blanket */
	Blanket : {
		// ------------------------------------------------------------------------------------
		// Object 		: Dancik.Blanket.OverElement
		// Parameters 	: element - Parent element... 
		//		 		: options		: (opt) - opacity (dft. .50)
		//								: (opt) - zIndex (dft. 1) 	: (number) The specific 'z-index' that you would like the 'blanket' to have.
		//								: (opt) - inProcessImgSrc
		//								: (opt) - noInProcessImg (boolean)
		// ------------------------------------------------------------------------------------
		OverElement : {
			o : null,
			prevElement : null,
			show: function(element, options) { 	
				if (!element) { return; }
				if (!options) { options = {}; }
				
				this.prevElement = element;	
	
				this.o = document.createElement("div");
				this.o.id = "blanketOverElement";
				this.o.style.position = "absolute";
				this.o.style.backgroundColor = "#CCCCCC";
				this.o.style.display = "none";
				this.o.style.zIndex = (options.zIndex == null) ? "1" : options.zIndex;
	
				this.o.style.width = Element.getDimensions(element).width;
				this.o.style.height = Element.getDimensions(element).height;
				this.o.style.left = Position.positionedOffset(element)[0];
				this.o.style.top = Position.positionedOffset(element)[1];
				
				var inProcessImg = null;
				if  (options.noInProcessImg) {
					inProcessImg = ''; 
				} else {
					inProcessImg = Builder.node('IMG', { className : 'img', src : (options.inProcessImgSrc == null) ? '../images/rotating_large.gif' : options.inProcessImgSrc }); 
				}
				
				this.o.appendChild(
					Builder.node('TABLE', { height : '100%', width : '100%' }, [
						Builder.node('TBODY', [ 
							Builder.node('TR', [ 
								Builder.node('TH', [ 
									inProcessImg 
								])
							])
						])
					])
				);
				
				element.appendChild(this.o);
				
				if (options.opacity == null) {
					Element.setOpacity(this.o, 0.50);
				} else {
					Element.setOpacity(this.o, options.opacity);
				}
				
				Element.show(this.o);
			},
			hide: function() { 	
				if (this.o != null) {
					Element.hide(this.o);
					this.prevElement.removeChild(this.o);
					this.o = null;
					this.prevElement = null;
				}
			}
		},
	
		/* **********************************************************************************************************************************************
		* - Variable : Dancik.Blanket.Full
		* - Description : Calls 'Blanket <DIV> Object' with parameters, with the 'inprocess' elements hard-coded...
		*********************************************************************************************************************************************** */
		Full : {
			show: function(options) {
				if (!options) { options = {}; }
				Object.extend(options, { ignoreImage : true } );
				Dancik.Blanket.InProcess.show(options);
			},
			hide: function() { 	
				Dancik.Blanket.InProcess.hide();
			},
			kill: function() {
				Dancik.Blanket.InProcess.kill();
			}			
		},
		
		/* **********************************************************************************************************************************************
		* - Variable : Dancik.Blanket.InProcess
		* - Description : Blanket <DIV> Object...
		* -	Parameters : "options"	: "overlayObject" 		- (opt) : (object) The object that the blanket will cover...
		* -													  (dft) : document.getElementsByTagName("body")[0]
		* -							: "appendInOverlay"		- (opt) : (boolean) If an 'overlayObject' is passed, you can append the Blanket, into the OverlayObject.
		* -													  (dft) : false, will default to appendChild of the document.getElementsByTagName("body")[0] object...
		* -	 						: "overlayDocument" 	- (opt) : (boolean) Use the browser's document size to determine the 'blankets' size.
		* -																- *NOTE* This object will override the 'overlayObject'...
		* -													  (dft) : false
		* -							: "zIndex"				- (opt) : (number) The specific 'z-index' that you would like the 'blanket' to have.
		* -												      (dft) : 1
		* -							: "imgWidth"		      (opt) : Override the Image Width
		* -												      (dft) : 500
		* -							: "imgHeight"		      (opt) : Override the Image Height
		* -												      (dft) : 500
		* -							: "opacity"		      	  (opt) : Override the Opacity level. (Hint : The lower the number, the more opacity.  1.00 indicates none)
		* -												      (dft) : .50
		* -							: "backgroundColor"	   	  (opt) : Override the blankets background color.
		* -												      (dft) : #7F9DB9
		* -							: "ignoreImage"	   	  	  (opt) : If you do not want to show the Inprocess Image, set to true... 
		* -												      (dft) : false
		* -							: "extraHTML"	   	  	  (opt) : If you would like to insert your own HTML, instead of the defaulting rotating.gif...  
		* -												      (dft) : empty
		* -							: "extraElement"	  	  (opt) : If you would like to insert your own Element/Object, instead of the defaulting rotating.gif...  
		* -												      (dft) : empty
		* -							: "message"				  (opt) : Message to display above indicator if extraElement is not specified
		* -													  (dft) : empty
		* -							: "sizeByStretch		  (opt) : Place the blanket over the entire body by using stretch (top, right, bottom, left = 0)
		* -																- *NOTE* This object will override the 'overlayObject'...
		* -													  (dft) : false
		*********************************************************************************************************************************************** */
		InProcess : {
			o : null,
			dftImgHeight : 500,
			dftImgWidth : 500, 
			overlayObject : null,
			appendInOverlay : false,
			
			build: function(options) { 	
				if (this.o != null) { return; }
				if (!options) { options = {}; } 
			
	
				this.o = document.createElement("div");
				this.o.style.position = "absolute";
				this.o.style.backgroundColor = (options.backgroundColor == null) ? "#7F9DB9" : options.backgroundColor;
				this.o.style.display = "none";
				this.o.style.zIndex = (options.zIndex == null) ? "1" : options.zIndex;
	
				this.overlayObject = (options.overlayObject != null) ? options.overlayObject : document.getElementsByTagName("body")[0];
				if (options.overlayObject == null) {
					this.appendInOverlay = false;
				} else {
					this.appendInOverlay = (options.appendInOverlay != null) ? options.appendInOverlay : false;
				}
				
				if (options.sizeByStretch) {
					this.o.style.left = 0;
					this.o.style.right = 0;
					this.o.style.top = 0;
					this.o.style.bottom = 0;
					this.appendInOverlay = false;
					this.sizeByStretch=true;
				} else if (options.overlayDocument || this.overlayObject == null) {
					var w = Dancik.getDocumentWidth()-4;
					var h = Dancik.getDocumentHeight()-4;
					this.o.style.width = w+"px;"
					this.o.style.height = h+"px";
					this.o.style.left = 0;
					this.o.style.top = 0;
				} else {
					this.o.style.width = Element.getDimensions(this.overlayObject).width+"px";
					this.o.style.height = Element.getDimensions(this.overlayObject).height+"px";
					this.o.style.left = Position.positionedOffset(this.overlayObject)[0]+"px";
					this.o.style.top = Position.positionedOffset(this.overlayObject)[1]+"px";
				}
				
				this.o.style.textAlign = 'center';
				var	opacityLvl = '0.5';
				if (options.opacity != null) {
					opacityLvl = options.opacity;
				}
				Element.setOpacity(this.o, opacityLvl);
	
				var imgWidth = (options.imgWidth != null) ? options.imgWidth : this.dftImgWidth;
				var imgHeight = (options.imgHeight != null) ? options.imgHeight : this.dftImgHeight;
				
				if (this.appendInOverlay) {
					this.overlayObject.appendChild(this.o);
				} else {
					document.getElementsByTagName("body")[0].appendChild(this.o);
				}
			},
			show: function(options) { 
				if (!options) { options = {}; } 
				
				if (this.o == null) { this.build(options); }


				
				this.o.innerHTML = ''; 
				
				Element.show(this.o);
				
				if (options.extraHTML != null) {
					this.o.innerHTML = options.extraHTML; 
				} else if (options.extraElement != null) {
					this.o.appendChild( options.extraElement );
				} else if (!options.ignoreImage) {
					if(this.sizeByStretch) {
						this.o.innerHTML = "<div style='position:absolute;top:50%;left:0;width:100%;text-align:center;'>"
												+ "<div style='position:relative;width:100%;'>"
													+ "<SPAN style='font:20pt Verdana,Arial,Sans-Serif; height:100px; color:#000;'>" 
														+ ( options.message ? options.message : "" )
													+ "</SPAN>" 
													+ "<BR>"
													+ "<img src='../images/rotating_large.gif' class='img'/>"
												+ "</div>"
											+ "</div>";
						var dim = Element.getDimensions($(this.o).down("div").down("div"));
						var h=Math.floor(dim.height/2);
						$(this.o).down("div").down("div").style.bottom=h+"px";
					} else {
						this.o.innerHTML = "<table width='100%' style='height:" + (Dancik.getDocumentHeight() - 4) + ";'>"
											+ "<tr>" 
												+ "<th style='text-align:center;'>" 
													+ "<div id='Dancik_Blanket_InProcess_Message' style='font:20pt Verdana,Arial,Sans-Serif; height:100px; color:#000; margin-bottom:25px;'>"
														+ ( options.message ? options.message : "" )
													+ "</div>" 
													+ "<img src='../images/rotating_large.gif' class='img'/>"
												+ "</th>"
											+ "</tr>"
										+ "</table>";
					}
				}
				
				
				

			},
			hide: function() { 	
				if (this.o == null) { this.build(); }	
				Element.hide(this.o);
			},
			kill: function() {
				if (this.o != null) {
					document.getElementsByTagName("body")[0].removeChild(this.o);
					this.o = null;
				}
			}
		},
	
		/* **********************************************************************************************************************************************
		* - Variable : Dancik.Blanket.InProcess_IFrame
		* - Description : Blanket <IFRAME> Object...
		* -	Parameters : "options"	: "imgWidth"		      (opt) : Override the Image Width
		* -												      (dft) : 500
		* -							: "imgHeight"		      (opt) : Override the Image Height
		* -												      (dft) : 500
		*********************************************************************************************************************************************** */
		InProcess_IFrame : {
			dftImgHeight : 500,
			dftImgWidth : 500, 
	
			build: function(options) {
				if (!options) { options = {}; } 
				var imgWidth = (options.imgWidth != null) ? options.imgWidth : this.dftImgWidth;
				var imgHeight = (options.imgHeight != null) ? options.imgHeight : this.dftImgHeight;
			
			 	return Builder.node("IFRAME", { src : '../../dws/wait/inprocess.jsp?parmWidth=' + (imgWidth-10) + '&parmHeight=' + (imgHeight-10), frameBorder : 0, style : 'overflow:none;width:' + (imgWidth) + 'px; height:' + (imgHeight) + 'px;' } );
			}
		}
	},
	/* Dancik.DSAnalysis */
	DSAnalysis : {
		// ---------------------------------------------------------------------------------------------------
		// - Function    : Dancik.DSAnalysis.getInfo()
		// - Description : Returns "get" information from the apps DataSource, in JSON format.
		// --------------------------------------------------------------------------------------------------- 
		getInfo : function(event, url) {
			var params = { output : 'JSON' };	
			var ajax = new Ajax.Request( (url == null) ? "../service/DSA_Service/get" : url,
				{method: 'get',
				 parameters : params,
				 onInteractive:  function(res) {},
				 onSuccess: function(res) {
				 	try {
					 	if (res.responseText.isEmpty() ) { return; }
						var json = res.responseText.evalJSON(true);
						if (json == null) { return; }

						var s = '';
						var keys = Object.keys(json);
						var vals = Object.values(json);
						var len = keys.length;
						for (var i=0; i<len; i++) {
							s += keys[i] + ' : ' + vals[i] + '\n';
						}
						alert(s);
					} catch(e) {
						alert("Dancik.DSAnalysis.getInfo() : " + e.message + "\n\n 'res.responseText' :\t\t\n" + res.responseText);
					}
				 }, 
				 onFailure: function(res) {}
				}
			);		
		}
	}, 
	// ******************************************************************************
	// Object 		: Dancik.Help
	// Description 	: Allows you to log information to a display, to assist with debugging.
	// ******************************************************************************
	Help : {
		// ---------------------------------------------------------------------------------------------------
		// - Function    : Dancik.Help.open()
		// - Description : Using the passed in key-code, opens a new browser window, and forwards to Dancik-Help
		// -				application. 
		// --------------------------------------------------------------------------------------------------- 
		open : function(helpkey) {
			var fullURL = "http://sal.dancik.com/help/login?key=" + Dancik.String.reverse(helpkey);
			var attr = 'width=' + Dancik.getDocumentWidth() + 
						',height=' + Dancik.getDocumentHeight() + 
						',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
			var wdw = window.open(fullURL, "HelpWindow", attr);	
		}
	},
	// ******************************************************************************
	// Object 		: Dancik.Log
	// Description 	: Allows you to log information to a display, to assist with debugging.
	// ******************************************************************************
	Log : {
		active : false,
		wdw : null,
		/* Dancik.Log.activate */
		activate: function() {
			this.active = true;
		},
		/* Dancik.Log.buildWdw */
		buildWdw: function(options) { 	
			if (this.wdw != null) { return; }
			if (!options) { options = {}; } 
			
			var o_Body = document.getElementsByTagName("body")[0];
			var left = (o_Body.getWidth()-705);
			var top = (o_Body.getHeight()-205);

			this.wdw = Builder.node('DIV', {
								id : 'Dancik_Log_View',
								style : 'position:absolute;' + 
											'overflow:auto;' +
//											'display:none;' +
											'width:700px;' +
											'height:200px;' +
											'z-index:' + ((options.zIndex == null) ? "10" : options.zIndex) + ';' +
											'left:' + left + "px;" +
											'top:' + top + "px;" +
											'background-color:#65FF45;' +
											'border:solid #666666 1px;' 
							}, [
						Builder.node('DIV', [
							Builder.node('DIV', [
								Builder.node('TABLE', {	style : 'width: 100%' }, [
									Builder.node('TBODY', [
										Builder.node('TR', [
											Builder.node('TD', { align : 'left', className : 'dws-WdwHeader' }, 'Logger' ),
											Builder.node('TD', { id : 'Dancik_Log_View_ToggleLink', align : 'center', className : 'dws-WdwHeader dws-LinkLook', width : '18px;', onclick : function(e) { Dancik.Log.close();  } }, 'X')
										] )
									] )
								] )
							] ),
							Builder.node('TABLE', { className : 'excelTableA', style:'width: 100%' }, [
								Builder.node('TBODY', {	id : 'DancikLogs_Tbody' } ) 
							] )
						] )
				]);
			o_Body.appendChild(this.wdw);
		},	
		/* Dancik.Log.close */
		close: function() {
			$('Dancik_Log_View_ToggleLink').innerHTML = 'O';
			$('Dancik_Log_View_ToggleLink').onclick =  Dancik.Log.open;
			Dancik.rlSlide( $('Dancik_Log_View'),
								{ startingPosition : (document.getElementsByTagName("body")[0].getHeight()-205),
									endingPosition : (document.getElementsByTagName("body")[0].getHeight()-25),
									   elapsedTime : 0,
									        forTop : true
								} ); 		
		},	
		/* Dancik.Log.open */
		open: function() {
			$('Dancik_Log_View_ToggleLink').innerHTML = 'X';
			$('Dancik_Log_View_ToggleLink').onclick =  Dancik.Log.close;
			Dancik.rlSlide( $('Dancik_Log_View'),
								{ startingPosition : (document.getElementsByTagName("body")[0].getHeight()-25),
									endingPosition : (document.getElementsByTagName("body")[0].getHeight()-205),
									elapsedTime : 0,
									forTop : true
								} ); 		
		},	
		/* Dancik.Log.add */
		add: function(txt) {
			if (!this.active) { return; }
			if (this.wdw == null) {
				this.buildWdw();
			} else {
				Element.show('Dancik_Log_View');
			}
			
			$('DancikLogs_Tbody').appendChild (
				Builder.node("TR", [
					Builder.node("TD", txt)
				])
			);
		}
	},
	/* Dancik.Popup */
	Popup : {
		/* Dancik.Popup.Window */
		Window : {
			o : null,
			
			width : "1000",	
			height : "650",	
			
			windowClass : 'Window',
			windowShadowClass : 'Window_Shadow_Black',
			titleClass : 'Window_Title_C',
			closeImage : '../../dws/images/close.png',
			initialURL : 'about:blank',
			
			additionalClose : null,
			confirmBeforeClose : false,
			
			/* -------------------------------------------------------------------------
			*  Dancik.Popup.Window.build 
			*   - options :	width				: 1000
			*				height				: 650
			*				windowClass			: (dft) : Window
			*				windowShadowClass	: (dft) : Window_Shadow_Black
			*				titleClass			: (dft) : Window_Title_C
			*				closeImage			: (dft) : ../../dws/images/close.png
			*				addtlClose			: (opt) 
			*				confirmBeforeClose	: (opt) : If true, throw up a 'confirm(Are you sure)' dialog, before closing window.
			*									: (dft) : false 
			*				initURL				: (dft) : about:blank 
			* 				zIndex				: (opt) : (number) The specific 'z-index' that you would like the 'windopw' to have.
			* 									  (dft) : 2
			*   ------------------------------------------------------------------------- */
			build  : function(title, options) {
				var w = (options.width == null) ? this.width : options.width;
				var h = (options.height == null) ? this.height : options.height;
				
				var wdwCls = (options.windowClass == null) ? this.windowClass : options.windowClass;
				var wdwShdwCls = (options.windowShadowClass == null) ? this.windowShadowClass : options.windowShadowClass;
				var ttlCls = (options.titleClass == null) ? this.titleClass : options.titleClass;
				var closeImg = (options.closeImage == null) ? this.closeImage : options.closeImage;
				var initURL = (options.initURL == null) ? this.initialURL : options.initURL;
				this.additionalClose = (options.addtlClose == null) ? null : options.addtlClose;
				this.confirmBeforeClose = (options.confirmBeforeClose == null) ? false : options.confirmBeforeClose;

				this.o = Builder.node("DIV", { id : 'Dancik_Popup_Window_Outer', className : wdwShdwCls, style : 'z-index:' + ((options.zIndex == null) ? "2" : options.zIndex) + '; width:' + w + 'px; height:' + h + 'px; display:none;' }, [
							Builder.node("DIV", { id : 'Dancik_Popup_Window_Inner', className : wdwCls, style : 'width:' + w + 'px; height:' + h + 'px; background-color:#FFFFFF;' }, [
								Builder.node("DIV", { className : ttlCls, style : 'height:30px; width:' + w + 'px;' }, [
									Builder.node('TABLE', {	cellpadding : '0', cellspacing : '0', style : 'width:100%' }, [
										Builder.node('TBODY', [
											Builder.node('TR', [
												Builder.node("TD", { className : ttlCls, width : '20px' }, ' ' ),
												Builder.node("TH", { className : ttlCls }, title ),
												Builder.node("TD", { className : ttlCls, width : '20px' }, [
													Dancik.createImageLink( closeImg,
																				'Close Window',
																				function(e) { 
																					if (Dancik.Popup.Window.confirmBeforeClose) {
																						if (!confirm('Are you sure you want to close this window?')) { return; }
																					} 
																					Dancik.Popup.Window.close(); 
																				  },
																				{ className : 'hand' }
																		)
												])
											])
										])
									])
								]),
								Builder.node("DIV", { style : 'height:' + (h-30) + 'px; width:' + w + 'px;' }, [
									Builder.node("IFRAME", { id : 'Dancik_Popup_Window_IFRAME', src : initURL, frameBorder : 0, style : 'width:' + w + 'px; height:' + (h-30) + 'px;' } )
								])
							])
						]);

				document.getElementsByTagName("body")[0].appendChild(this.o);
				Dancik.centerElementViaDocument(this.o);
			},
			/* Dancik.Popup.Window.open */
			open : function(url, title, options) {
				this.build(title, options);
					
				var newIFrame = $('Dancik_Popup_Window_IFRAME');
				newIFrame.src = url;
				
				Element.show(this.o);
				return  this.o;
			},
			/* Dancik.Popup.Window.close */
			close : function() {
				if (this.o === null) { return; }
				
				document.getElementsByTagName("body")[0].removeChild( Dancik.Popup.Window.o );
				this.o = null;

				if (this.additionalClose != null) { this.additionalClose(); }
			},
			/* -------------------------------------------------------------------------
			*	Function : Dancik.Popup.Window.edit() - Allows for the editing of the window objects style...
			*   ------------------------------------------------------------------------- */
			editStyle : function(options) {
				if (this.o === null) { return; }
				if (!options) { return; }
				Element.setStyle( this.o, options );
			}	
		}
	},
	/* Dancik.ToolTip */
	ToolTip : {
		o : null,
		windowClass : 'Window_Shadow',
		/* Dancik.ToolTip.Show */
		show : function(e, text, options) {
			var oSrc = Event.element(e);
			if (oSrc == null) { return false; }

			// -- Avoid nulls...
			if (options == null) { options = {}; }

			var wdwCls = (options.windowClass == null) ? this.windowClass : options.windowClass;
			var zIndx = (options.zIndex == null) ? '99999' : options.zIndex;
			var w = (options.width == null) ? ((oSrc.getWidth() > 200) ? oSrc.getWidth() : 200) : options.width; 

			// -- Build the initial object, if it doesn't exist....	
			if (this.o == null) {
				this.o = Builder.node("DIV", { id : 'Dancik_ToolTip', className : wdwCls, style : 'z-index:' + zIndx + '; width:' + w + 'px; height:20px; border:1px solid #AAA; background-color:#FFE400; font: 8pt Verdana, Arial, Sans-Serif; display:none;' }, [
							Builder.node('DIV', { id : 'Dancik_ToolTipText', style : 'width:100%' } )
						]);
				document.getElementsByTagName("body")[0].appendChild(this.o);
			}
			
			var pos = Element.viewportOffset(oSrc);
			
			this.o.style.left = pos[0];
			this.o.style.top = pos[1] + oSrc.getHeight();
			
			$('Dancik_ToolTipText').innerHTML = text;
			
			Element.show(this.o);
			
		},
		/* Dancik.ToolTip.hide */
		hide : function() {
			Element.hide(this.o);
		}
	},

	// *******************************************************************************************************************************************************
	// ** Function 		: Dancik.getDBSettings
	// ** Description 	: Retrieves the settings xml-file, from the ifs location, ../xml/db/*, and extends the passed-in toElement.
	// ** Parameter 	: (req)filename - The filename (minus the .xml) as it is defined in the system.
	// **				: (req)toElement - The element that will be extended the new settings object.
	// **				: (opt)options
	// **						- finalFunction : If a function needs to be executed at the end...
	// ***************************************************************************************************************************************************** */
	getDBSettings : function(filename, toElement, options) {
		// -- Avoid nulls and empty values...
		if (!filename) { return; }
		if (!toElement) { return; }
		if (!options) { options = {}; }

		// -- Use the passed URL, to retrieve results, which must be in { id, description } format...
		var ajax = new Ajax.Request( '../../dws/jsonservice/System_WebService/getFileSettings',
			{method: 'get', 
			 parameters: { 'parm_Filename' : filename }, 
			 onSuccess: function(res) {
			 	try { 
			 		if (res.responseText.isEmpty()) { throw "EmptyResult"; }
			 		var json = res.responseText.evalJSON(true);
			 		if (json === null) { throw "InvalidJSON"; }

					Object.extend(toElement, json );
					
					// -- If a final-function was passed, then execute..
					if (options.finalFunction != null) {
						options.finalFunction();
					}
					
					
				} catch(e) {
					if (e == "InvalidJSON") {
						toElement = { error : res.responseText };
					} else if (e == "EmptyResult") {
						toElement = { error : 'Empty Result' };
					} else {
						toElement = { error : e.message };
					}
				} finally {
				}
			 }, 
			 onFailure: function(res) { alert(res.responseText); } 
			}
		);	
	}	
};

/* ***********************************************************************
* - Full Body Blanket Object...
************************************************************************ */
var FullBlanket = {
	o : null,
	build: function(opacity, options) { 	
		if (this.o != null) { return; }
		if (!options) { options = {}; }
		
		var o_Body = document.getElementsByTagName("body")[0];

		this.o = document.createElement("div");
		this.o.id = "fullblanket";
		this.o.style.position = "absolute";
		this.o.style.backgroundColor = "#DDDDDD";
		this.o.style.display = "none";
		this.o.style.zIndex = (options.zIndex == null) ? "2" : options.zIndex;

		this.o.style.left = '0px';
		this.o.style.top = '0px';
		this.o.style.bottom = '0px';
		this.o.style.right = '0px';
		
		
		Element.setOpacity(this.o, (opacity == null) ? '0.50' : opacity);		
		
		o_Body.appendChild(this.o);
	},
	show: function(opacity, options) { 	
		if (this.o == null) { this.build(opacity, options); }

		var o_Body = document.getElementsByTagName("body")[0];
		this.o.style.width = Element.getDimensions(o_Body).width-2;
		this.o.style.height = Element.getDimensions(o_Body).height-2;
		
		Element.show(this.o);
	},
	hide: function() { 	
		if (this.o != null) {
			Element.hide(this.o);
		}
	},
	kill: function() {
		if (this.o != null) {
			document.getElementsByTagName("body")[0].removeChild(this.o);
			this.o = null;
		}
	}
};

/* **********************************************************************************************************************************************
* - Variable : FullInProcessBlanket
* - Description : Full Body Blanket Object...
* -	Parameters : "options"	: "overlayObject" 		- (opt) : (object) The object that the blanket will cover...
* -													  (dft) : document.getElementsByTagName("body")[0]
* -	 						: "overlayDocument" 	- (opt) : (boolean) Use the browser's document size to determine the 'blankets' size.
* -																- *NOTE* This object will override the 'overlayObject'...
* -													  (dft) : false
* -							: "zIndex"				- (opt) : (number) The specific 'z-index' that you would like the 'blanket' to have.
* -												      (dft) : 1
*********************************************************************************************************************************************** */
var FullInProcessBlanket = {
	o : null,
	build: function(options) { 	
		if (this.o != null) { return; }
		if (!options) { options = {}; }
	

		this.o = document.createElement("div");
		this.o.id = "fullinprocessblanket";
		this.o.style.position = "absolute";
		this.o.style.backgroundColor = "#FFFFFF";
		this.o.style.display = "none";
		this.o.style.zIndex = (options.zIndex == null) ? "1" : options.zIndex;

		var overlayObject = (options.overlayObject != null) ? options.overlayObject : document.getElementsByTagName("body")[0];
		if (options.overlayDocument || overlayObject == null) {
			this.o.style.width = Dancik.getDocumentWidth()-2;
			this.o.style.height = Dancik.getDocumentHeight()-2;
			this.o.style.left = '0px';
			this.o.style.top = '0px';
		} else {
			this.o.style.width = Element.getDimensions(overlayObject).width;
			this.o.style.height = Element.getDimensions(overlayObject).height;
			this.o.style.left = Position.positionedOffset(overlayObject)[0];
			this.o.style.top = Position.positionedOffset(overlayObject)[1];
		}
		
		this.o.style.textAlign = 'center';
		this.o.style.verticalAlign = 'middle';
		var	opacityLvl = '0.50';
		if (options.opacity != null) {
			opacityLvl = options.opacity;
		}
		Element.setOpacity(this.o, opacityLvl);
		
		this.o.innerHTML = "<table height='100%' width='100%'><tr><th style='text-align: center;'><img src='../images/rotating_large.gif' class='img'></th></tr></table>";
		
		document.getElementsByTagName("body")[0].appendChild(this.o);
		
	},
	show: function(options) { 
		if (this.o == null) { this.build(options); }
		Element.show(this.o);
	},
	hide: function() { 	
		if (this.o == null) { this.build(); }	
		Element.hide(this.o);
	},
	kill: function() {
		if (this.o != null) {
			document.getElementsByTagName("body")[0].removeChild(this.o);
			this.o = null;
		}
	}
};



// ******************************************************************************
// Class 		: Dancik_MiniBlanket
// Description 	: Allows user to build a "blanket" object, that resides over a
//					different object..
// ******************************************************************************
var Dancik_MiniBlanket = Class.create();
Dancik_MiniBlanket.prototype = {
	o : null,
	initialize : function(element, opts) {
		
		this.options = Object.extend({
			zIndex: "1",
			opacity: "0.5"
		},opts||{});
		this.element=$(element);
	
		var forObj_Dim = Element.getDimensions(element);
		var forObj_Pos = Position.cumulativeOffset(element);

		this.o = Builder.node('DIV', {
							style : 'position:absolute;' + 
										'display:none;' +
										'width:' + forObj_Dim.width + 'px;' +
										'height:' + forObj_Dim.height + 'px;' +
										'z-index:' + this.options.zIndex + ';' +
										'left:' + forObj_Pos[0] + 'px;' +
										'top:' + forObj_Pos[1] + 'px;' + 
										'background-color : #000;' 
						}
				);

		Element.setOpacity(this.o, this.options.opacity);
		document.getElementsByTagName("body")[0].appendChild(this.o);
	},
	show: function() {
		var forObj_Dim = Element.getDimensions(this.element);
		var forObj_Pos = Position.cumulativeOffset(this.element);
		this.o.style.width = forObj_Dim.width+"px";
		this.o.style.height = forObj_Dim.height+"px";
		this.o.style.left = forObj_Pos[0]+"px";
		this.o.style.top = forObj_Pos[1]+"px";
		this.o.show();
	},
	hide: function() { 	
		this.o.hide();
	}
};