try{

var BrowserAPI = ( function ( ) {

	var exclude = 1;
	var agent = navigator.userAgent.toLowerCase();
	var winOS = 0; var macOS = 0; var linuxOS = 1;
	if (agent.indexOf('win') != -1) { winOS = 1; linuxOS = 0; }
	if (agent.indexOf('mac') != -1) { macOS = 1; linuxOS = 0; }

	var ice = 0;
	var ie = 0, ie4 = 0, ie5 = 0, ie6 = 0, ie7 = 0, ie8 = 0, iecompat = 0;
	var op5 = 0, op6 = 0, op7 = 0;
	var ns4 = 0, ns6 = 0, ns7 = 0, mz7 = 0;
	var kde = 0, kdeVer;
	var saf = 0;

	if (typeof navigator.vendor != "undefined" && navigator.vendor == "KDE") {
		kdeVer = parseFloat(agent.split("konqueror/")[1].split("; ")[0]);
		if (kdeVer) {
			kde = 1; ns6 = 1; exclude = 0;
		}
	} else if (agent.indexOf('webtv') != -1) {
		exclude = 1;
	} else if (typeof window.opera != "undefined") {
		exclude = 0;
		if (/opera[\/ ][5]/.test(agent)) { op5 = 1; }
		if (/opera[\/ ][6]/.test(agent)) { op6 = 1; }
		if (/opera[\/ ][7-9]/.test(agent)) { op7 = 1; }
	} else if (typeof document.all != "undefined" && !kde) {
		exclude = 0; ie = 1;
		if (typeof document.getElementById != "undefined") {
			ie5 = 1;
			if (agent.indexOf("msie 6") != -1) {
				ie6 = 1;
				if (document.compatMode != "BackCompat") { compat = 1; }
			} else 	if (agent.indexOf("msie 7") != -1) {
				ie7 = 1;
				if (document.compatMode != "BackCompat") { compat = 1; }
			} else 	if (agent.indexOf("msie 8") != -1) {
				ie8 = 1;
				if (document.compatMode != "BackCompat") { compat = 1; }
			}
		} else {
			ie4 = 1;
		}
	} else if (typeof document.getElementById != "undefined") {
		exclude = 0;
		if (agent.indexOf("netscape/6") != -1 || agent.indexOf("netscape6") != -1 ) {
			ns6 = 1;
		} else if (agent.indexOf("netscape/7") != -1 || agent.indexOf("netscape7") != -1) {
			ns6 = 1; ns7 = 1;
		} else if (agent.indexOf("gecko") != -1) {
			ns6 = 1; mz7 = 1;
		}

		if (agent.indexOf("safari") != -1 || (typeof document.childNodes != "undefined" && typeof document.all == "undefined" && typeof navigator.taintEnabled == "undefined")) {
			mz7 = 0; ns6 = 1; saf = 1;
		}
	} else if ((agent.indexOf('mozilla') != -1) && (parseInt(navigator.appVersion) >= 4)) {
		exclude = 0; ns4 = 1;
		if (typeof navigator.mimeTypes['*'] == "undefined") {
			exclude = 1; ns4 = 0;
		}
	}

	if (agent.indexOf('escape') != -1) {
		exclude = 1; ns4 = 0;
	}

	if (typeof navigator.__ice_version != "undefined"){
		exclude = 1; ie4 = 0;
	}

	return {
		agent : agent,
		exclude : exclude,
		isIE : function ( ) {
			return (ie == 1);
		},
		isGECKO : function ( ) {
			return (ns6 == 1);
		},
		isKDE : function ( ) {
			return (ns6 == 1 || kde == 1);
		},
		isKDE22 : function ( ) {
			return (kde == 1);
		},
		isMOZ : function ( ) {
			return (mz7 == 1);
		},
		isNS : function ( ) {
			return (ns4 == 1 || ns6 == 1 || ns7 == 1);
		},
		isOP : function ( ) {
			return (op5 == 1 || op6 == 1 || op7 == 1);
		},
		isSAF : function ( ) {
			return (saf == 1);
		},
		getBrowser : function ( ) {
			var br = { exclude : BrowserAPI.exclude };
			var iearray = { 4 : ie4, 5 : ie5, 6 : ie6, 7 : ie7, 8 : ie8 };
			var nsarray = { 4 : ns4, 6 : ns6, 7 : ns7 };
			if (BrowserAPI.isIE()) {
				br["type"] = "IE";
				for (v in iearray ) {
					if (iearray[v] == 1) {
						br["ver"] = v;
					}
				}
			} else if (BrowserAPI.isMOZ()) {
				br["type"] = "MOZ";
			} else if (BrowserAPI.isNS()) {
				br["type"] = "NS";
				for (v in nsarray ) {
					if (nsarray[v] == 1) {
						br["ver"] = v;
					}
				}
			} else if (BrowserAPI.isKDE() || BrowserAPI.isKDE22()) {
				br["type"] = "KDE";
				br["ver"] = kdeVer;
			} else if (BrowserAPI.isOP()) {
				br["type"] = "OP";
			} else if (BrowserAPI.isSAF()) {
				br["type"] = "SAF";
			} else {
				br = { exclude : BrowserAPI.exclude, type : "OTHER", ver : -1 };
			}

			// get OS Name
			if (navigator.appVersion.indexOf("Win") != -1) {
				br["os"] = "Windows";
			} else if (navigator.appVersion.indexOf("Mac") != -1) {
				br["os"] = "MacOS";
			} else if (navigator.appVersion.indexOf("X11") != -1) {
				br["os"] = "UNIX";
			} else if (navigator.appVersion.indexOf("Linux") != -1) {
				br["os"] = "Linux";
			}

			return br;
		}
	};

} )();

var chopTextArea = function (e, maxCharLen) {
	function setPos(e, selStart) {
		 if (e.setSelectionRange) {
		 	e.focus();
		 	e.setSelectionRange(selStart, selStart);
		 } else if (e.createTextRange) {
		 	var range = e.createTextRange();
		 	range.collapse(true);
		 	range.moveEnd('character', selStart);
		 	range.moveStart('character', selStart);
		 	range.select();
		 }

	}

	function getPos(e) {
		return e.selectionStart;
	}
	var pos = getPos(e);
	var value = e.value.trim();

	var len = value.length;
	if (maxCharLen) {
		if (len > maxCharLen) {
			len = Math.min(maxCharLen, len);
			e.value = value.substring(0, len);
			print_r(pos);
			pos = Math.min(pos, len);
			setPos(e, pos);
		}
	}

	var cntObj = $(e.id + "Count");
	if (cntObj) {
		cntObj.innerHTML = maxCharLen - len;
		if(maxCharLen <= len) {
			cntObj.innerHTML = " (No characters remaining)";
			cntObj.addClass('errorSelectClassFont');
		} else {
			cntObj.removeClass('errorSelectClassFont');
		}
	}
	return len;
}

var toJSON = ( function ( ) {

	var escape = function (value) {
		var ret = "";
		var tmp;
		for (var i = 0; i < value.length; i++) {
			tmp = value.substring(i, i+1);
			switch (tmp)
			{
				case "\"": ret += "\\\""; break;
				case "\\": ret += "\\\\"; break;
				case "\n": ret += "\\n"; break;
				case "\t": ret += "\\t"; break;
				case "\r": ret += "\\r"; break;
				default: ret += tmp;
			}
		}
		return ret;
	}

	return function ( data ) {
		switch ( $type(data) ) {
			case "number":
				return data;
				break;
			case "string":
				return '"' + escape(data) + '"';
				break;
			case "boolean":
				return data ? "true" : "false"
				break;
			case "array":
				var a = [];
				for ( var i = 0; i < data.length; i ++ ) {
					a.push ( toJSON ( data[i] ) );
				}
				return "[ " + a.join ( ", " ) + " ]";
				break;
			case "date":
				return toJSON ( data.toUTCString() );
				break;
			case "object":
				var a = [];
				for (var e in data ) {
					var line = toJSON ( e ) + " : " + toJSON ( data[e] );
					a.push ( line );
				}
				return "{ " + a.join ( ", " ) + " }";
				break;
			case "null":
			default:
				return $type(data);
				break;
		}
	}

} )();

function elogPrim(e, rd, listFunctions)
{
	var ret = "";
	var tmp = "";
	var prefix = "";
	switch ($type(e))
	{
	case "object":
		for (var i in e) {
			prefix = i + "=>";
			switch (e[i]) {
			case null: tmp = "null"; break;
			case false: tmp = "false"; break;
			case true: tmp = "true"; break;
			default:
				switch ($type(e[i])) {
				case "function": tmp = i; prefix = ""; break;
				case "object": tmp = "{\n" + elogPrim(e[i], rd + "\t") + "}\n"; break;
				case "string": tmp = "\"" + e[i] + "\"" + e[i].length; break;
				default: tmp = e[i];
				}
			}
			if (listFunctions !== true || $type(e[i]) !== "function") {
				ret += rd + $type(e[i]) + ": " + prefix + tmp + "\n";
			}
		}
	break;
	default:
		return $type(e) + ": " + e;
	}
	return ret;
}


var _____hiddenCnt__ = 0;
var _____hiddenBlocks__ = {};
var addTextSet = function (myClass, id) {
	if (!_____hiddenBlocks__[myClass]) {
		$$("div." + myClass).each(function (el2) {
			if (el2.get("class").contains("hidden")) {
				_____hiddenBlocks__[myClass] = el2;
			}
		});
	}
	var el2 = _____hiddenBlocks__[myClass].clone(true, true);
	el2.removeClass("hidden").inject(id);
	el2.getElements("textarea").each(function (el3) {
		el3.id = el2.className + "_" + el3.id;
		while ($(el3.id) != el3) {
			el3.name = el2.className + "_" + _____hiddenCnt__;
			el3.id = el2.className + "_" + _____hiddenCnt__++;
		}
	});
}

var removeTextBlockRow = function (e) {
	var className = e.parentNode.className;
	var blockElement = e.parentNode.parentNode;
	var cnt = blockElement.childNodes.length;
	if (cnt == 2) {
		addTextSet(className, blockElement.id);
	}
	if (e.parentNode.destory) {
		e.parentNode.destory();
	} else {
		e.parentNode.className = "hidden";
		e.parentNode.innerHTML = "";
	}
}

var getInputValues = function (myClass) {
	var list = {};
	$$("input." + myClass + "Input").each(function (el2) {
		var val = el2.get("value");
		if (val && val !== "") {
			list[val] = val;
		}
	});

	$$("select." + myClass + "Input").each(function (el2) {
		var val = el2.get("value");
		if (val && val !== "") {
			list[val] = val;
		}
	});

	$$("textarea." + myClass + "Input").each(function (el2) {
		var val = el2.get("value");
		if (val && val !== "") {
			list[val] = val;
		}
	});
	return list;
}

} catch(e) {
	print_r("Core.js error:");
	print_r(e);
}


/*******************************  Added from Main.js - MSimmons ********************************************/

var EFX = ( function ( ) {
    /**
     * Add an overlay to element that is passed in.
     *
     * @param {Object} el - element to put overlay on.
     * @param {Object} overlayOptions {
     *                     @param {String} background - background color of overlay. defaults to #000000
     *                     ,@param {String} position - position of overlay.  Defaults to absolute.
     *                     ,@param {String} display - display property name for overlay.  Defaults to none.
     *                     ,@param {Integer} opacity - opacity of overlay.  Defaults to 0.25.
     *                     ,@param {Integer} zIndex - z-index of overlay.  Defautls to 100.
     *                     ,@param {String} wheelColor: color of loading image.  Defaults to white. The other option is grey.
     *                     ,@param {String} size - size of loading image.  Defaults to regular size which is 50x51.  Other options are small, large, extralarge.
     *                     ,@param {Boolean} showLoadingImg - shows loading image.  Defaults to true.  Other option is false if you don't want the loading image to show.
     *                     ,@param {Object} event - event to be added to overlay.  This is an object that takes 2 parameters. {
     *                                 @param {String} attribute - the event.  ex. "click"
     *                                 @param {String} function - the function to be executed.
     *                             }
     *                }
     */
    var showOverlay = function (el2, options ) {
    	var el = (el2.id) ? $(el2.id) : el2;
    	var coords = el.getCoordinates();
        var oDivOptions = {
        	background : "#000000"
        	,display : "none"
        	,opacity : 0.25
        	,zIndex : 100
        	,wheelColor : ""
        	,size : ""
            ,showLoadingImg : true
            ,event : ""
        };
        $extend(oDivOptions, $merge(options, { width: coords.width, height: coords.height, position : "absolute" }));

        if (!el.oDivCnt) {
			el.oDivCnt = 0;
	        el.oDiv = new Element( "div", { "id" : el.id + "_overlay", "class" : "overlay", "styles" : oDivOptions });
            if (oDivOptions["showLoadingImg"]) el.oDiv.adopt(EFX.loadingImg(oDivOptions));
            if (oDivOptions["event"])  el.oDiv.addEvent(oDivOptions["event"]["attribute"], oDivOptions["event"]["function"]);
            el.oDiv.inject(document.body);
        }
        el.oDivCnt++;
        el.oDiv.setStyles(coords);
        el.oDiv.setStyle("display", "block");
	};

    /**
     * Remove the overlay on the element that is passed in.
     * @param {Object} el - element to remove overlay
     * @param {Object} options {
     *                     @param {Boolean} showMsg - replaces wheel with a msg.  Defaults to false.
     *                     ,@param {String} msg - message that you want to show.
     *                     ,@param {Integer} delayTime - time in milliseconds before overlay fades out when showMsg equals true.
     *                 }
     * @param {Object} textStyles {
     *                     @param {String} color - color of msg text.  Defaults to #000000 which is black.
     *                     @param {Integer} font-size - size of msg text.  Defaults to 18.
     *                     @param {String} font-weight - weight of msg text.  Defaults to bold.
     *                 }
     */
	var hideOverlay = function (el, options, textStyles) {
		if (el.id) el = $(el.id);

        var oDivOptions = { showMsg: false, msg: "Done!", delayTime: 2000 }
            ,oTextStyles = { color: "#000000", "font-size": 18, "font-weight": "bold" };

        $extend(oDivOptions, options);

        $extend(oTextStyles, $merge(textStyles, { "background-image": "", width: el.getStyle("width"), opacity: 1, display: "table-cell", "vertical-align": "middle" } ));
		//EFX.hideOverlay(container, { showMsg: true, msg: "On-Call dates updated successfully", delayTime: 1250 }, { color: "#7b9f01", "font-size": 23 });

		if (el && el.oDiv) {
			el.oDivCnt--;
			if (!el.oDivCnt) {
                if (oDivOptions["showMsg"]) {
					if (BrowserAPI.isIE()) {
						//el.oDiv.firstChild.addClass("sqrArea").set("html", oDivOptions["msg"]);
						el.oDiv.firstChild.setStyles({ "background-image": oTextStyles["background-image"], "vertical-align": oTextStyles["middle"], color: oTextStyles["color"], "font-size": oTextStyles["font-size"], "width": oTextStyles["width"] }).set("html", oDivOptions["msg"]);
						(function(){ el.oDiv.fade("out"); }).delay(oDivOptions["delayTime"]);
					} else {
                    	el.oDiv.firstChild.setStyles(oTextStyles).set("html", oDivOptions["msg"]);
                    	(function(){ el.oDiv.fade("out"); }).delay(oDivOptions["delayTime"]);
                    	(function(){ el.oDiv.dispose(); el.oDiv; }).delay(parseInt(oDivOptions["delayTime"]) + 1000);
					}
                } else {
                    el.oDiv.setStyle("display", "none");
                    el.oDiv.dispose();
                    if (!BrowserAPI.isIE()) {
                    	delete el.oDiv;
                    }
                }
			}
		}
	};

	var	dragContainerInit =	function ( title, container, options ) {
		var o = options || {};
		var DEFAULT_OPTIONS = {
			onStart: function () {
				if (container.preDrag) { container.preDrag(); }
			}.bind(this),
			onComplete: function () {
				if (container.postDrag) { container.postDrag(); }
			}.bind(this)
		};
		var dragContainerOptions = { handle: title }
		for ( opt in DEFAULT_OPTIONS ) {
			dragContainerOptions[opt] = o[opt] || DEFAULT_OPTIONS[opt];
		}
		title.setStyle("cursor", "move");
		container.makeDraggable(dragContainerOptions);

	}

	var fadeEffect = function ( el, options, custom ) {
		var o = options || {};
		var DEFAULT_OPTIONS = {
			duration: 250,
			wait: false,
			onComplete: function ( ) { }
		}
		var fadeOptions = { };
		for ( opt in DEFAULT_OPTIONS ) {
			fadeOptions[opt] = o[opt] || DEFAULT_OPTIONS[opt];
		}
		var fade = new Fx.Morph ( el, fadeOptions );
		if ( custom ) {
			fade.start(custom["start"], custom["end"]);
		} else {
			return fade;
		}
	}

	var fadeOut = function (el, options) {
		var o = options || {};
		var DEFAULT_OPTIONS = {
            duration : 250,
            transition : Fx.Transitions.Back.easeOut,
			onComplete : function () {
				el.dispose();
			}
		}
		var fadeOptions = {};
		for (opt in DEFAULT_OPTIONS) {
			fadeOptions[opt] = o[opt] || DEFAULT_OPTIONS[opt];
		}

		return new Fx.Morph(el, fadeOptions);
	}

    /**  Creates loading icon/wheel
     *
     * @param {Object} parms - {
     *					wheelColor: color or nothing - since we only have 2 at the moment it is either white of the default which is grey.
     *                  size: small, large or nothing.  defaults to nothing.
     *                  bgPosVertical: vertical position of loading icon. defaults to center.  options are top, center, bottom.
     *                  bgPosLeft: horizontal position of loading icon. defaults to center.  options are left, center, right.
     *					styles: styles to add to loading image.
     *					inject: element to inject this loading image into.
     *				}
     */
	var loadingImg = function (parms) {
        var p = parms || {}, options = {};

		if (p["id"]) options["id"] = p["id"];

        if (p["message"]) {
        	p["height"] = 125;
        	p["bgPosVertical"] = "55px";
			p["size"] = "large";
			p["textAlign"] = "center";
			var messageDefaultStyles = { color: "#000000", "font-size": 14, "font-weight": "bold", margin: 0, "padding": "5px 0 0 0" };
			var messageStyles = $extend(messageDefaultStyles, p["messageStyles"]);
			var message = new Element("p", { styles: messageStyles }).set("html", p["message"]);
        }

		if (!p["size"]) {
             if (p["width"] >= 150 && p["height"] >= 150) {
                var iconSize = "_large";
            } else if (p["width"] <= 16 || p["height"] <= 25) {
                    var iconSize = "_small";
            } else {
                var iconSize = "";
            }
        } else {
            var iconSize = "_" + p["size"];
        }

        var iconExt = ((p["wheelColor"]) ? "_" + p["wheelColor"] : "") + iconSize + ".gif";

        options["styles"] = {
            width: (p["width"]) ? p["width"] : "100%"
			,height: (p["height"]) ? p["height"] : 51
			,background: "transparent url(/core/images/loading" + iconExt + ") no-repeat " + (p["bgPosLeft"] || "center") + " " + (p["bgPosVertical"] || "center")
			,opacity: 1
			,"text-align": (p["textAlign"]) ? p["textAlign"] : ""
		}

		if ( p["styles"] ) {
			for ( style in p["styles"] ) {
				options["styles"][style] = p["styles"][style];
			}
		}

		var img = new Element ("div", options);

		if (p["message"]) img.adopt(message);

		if ( p["inject"] ) img.inject(p["inject"]);

		return img;

	}

	var	collapsableContainerInit = function ( el, hotspot, options ) {
		options = options || { };
		var smooth = options["smooth"] || 1;
		el.slider = new Fx.Slide(el, {duration: options["duration"] || 450 } );

		hotspot.addEvent("click", function ( e ) {

			if (smooth) {
				el.slider.toggle();

			} else {
				el.slider.toggleBlock();
			}

			if (this.getProperty("src")) {
				if (this.getProperty("src").split("_")[1]) {
					this.setProperty("src", "/images/icons/contract.png");
				} else {
					this.setProperty("src", "/images/icons/contract_r.png");
				}
			}else if (this.hasChild($(this.id + '_indicator'))) {

				var toggleImg = $(this.id + '_indicator');
				if (toggleImg.getProperty("src").split("_")[1]) {
					toggleImg.setProperty("src", "/images/icons/contract.png");
				} else {
					toggleImg.setProperty("src", "/images/icons/contract_r.png");
				}
			}
		} );

		el.getParent().setStyle("overflow", "hidden");
		if (el.hasClass("hide")) {
			el.slider.hide();
			el.removeClass("hide");
		}
	}

	var	resizeContainerInit = function ( el, options ) {
		var o = options || {};
		var DEFAULT_OPTIONS = {
			onStart : function ( el ) { },
			onDrag : function ( el ) { },
			onComplete : function ( el ) {
				el.setStyle( "height", (el.clientHeight + 2) + "px" );
			}
		};
		var resizeContainerOptions = { handle : new Element ( "Div", { styles : { bottom : 0, right : 0, width : 12, height : 12, position : "absolute", cursor : "se-resize", background: "url(/images/icons/icon_resize.gif) 99% 50% no-repeat" } } ).inject ( el ) }
		for ( opt in DEFAULT_OPTIONS ) {
			resizeContainerOptions[opt] = o[opt] || DEFAULT_OPTIONS[opt];
		}
		el.makeResizable(resizeContainerOptions);
	}

	var floatContainerInit = function ( container, options ) {
		container.setStyle("position", "absolute");
		container.floatPosition = function() {
			var sizes = window.getSize(), scroll = window.getScroll();
            if ( this.floatMove ) {
				this.floatMove.cancel();
			}
			if (container.overrideLeft) {
				var left = scroll.x + container.overrideLeft;
			} else {
				var left = (options["left"]) ? (scroll.x + options["left"]) : (scroll.x + (scroll.x - options["x"]) / 2);
			}
			if (container.overrideTop) {
				var top = scroll.y + container.overrideTop;
			} else {
				var top = (options["top"]) ? (scroll.y + options["top"]) : (scroll.y + (sizes.y - options["y"]) / 2);
			}
			this.floatMove = new Fx( { "duration": options["duration"] || 500, transition: options["transition"] || Fx.Transitions.Back.easeOut }).start(0);
		}
		container.floatPosition();
		window.addEvents( { "scroll" : container.floatPosition.bind(container), "resize" : container.floatPosition.bind(container) } );
	}

    var hasScrollBar = function ( container ) {
        var sb = ($type(container)) == "string" ? new Fx.Scroll($(container), { wait : false } ) :  new Fx.Scroll(container, { wait : false } );
        var now = sb.toBottom();
		if (now.to[0] == 0 && now.to[1] == 0) {
			return false;
		} else {
			sb.scrollTo(0, 0);
			return true;
		}
	}

    var flashOverlay = function (el, opt, repeat, interval) {
		el.flashChain = new Chain();
		var r = repeat || 5;
		for (i = 0; i < r; i++) {
			el.flashChain.chain(function ( ) { EFX.showOverlay(el, opt); });
			el.flashChain.chain(function ( ) { EFX.hideOverlay(el); });
		}
		el.runChain = function() {
			el.flashChain.callChain();
			if (el.flashChain.chains.length == 0) { el.runChain = $clear(el.flashTimer); }
		};
		el.flashTimer = el.runChain.periodical(interval || 500);
	}

	return {
		dragContainerInit : dragContainerInit
		,fadeEffect : fadeEffect
		,loadingImg : loadingImg
		,fadeOut : fadeOut
		,floatContainerInit : floatContainerInit
        ,collapsableContainerInit : collapsableContainerInit
		,resizeContainerInit : resizeContainerInit
		,hasScrollBar : hasScrollBar
		,flashOverlay : flashOverlay
        ,showOverlay : showOverlay
        ,hideOverlay : hideOverlay
	};

} ) ();

var PB = ( function ( ) {

	var ProgressBars = 0;

	var ProgressBar = new Class ( {
		initialize : function ( value, parms) {
			var vals = { id :'progressbar_' + ( ProgressBars++ ), value : $pick( value, 0 ), width : 0, height : 0, darkbg : '#67a1c4', darkfg : '#ffffff', lightbg : '#ffffff', lightfg : '#000066' };
			if ( parms && $type( parms ) == 'object' ) { $extend( vals, parms ); }
			if ( vals["height"] < 12 ) { vals["height"] = 12; }
			var pb = new Element ( "div", { id : vals["id"], 'class' : "progressbar_wrapper", styles : { border : "1px solid #bdbbbb", width : vals["width"], height : vals["height"], position : "relative" } } );
			pb.vals = vals;
			pb.appendChild( pb.vals["dark"] = new Element( "div", { id : vals["id"] + "_dark", 'class' : "progressbar_dark", styles : { width : vals["width"], height : vals["height"], background : vals["darkbg"], color : vals["darkfg"], position : "absolute", 'text-align' : "center", left : 0, top : 0, 'line-height': vals["height"] - 2 } } ) );
			pb.appendChild( pb.vals["light"] = new Element( "div", { id : vals["id"] + '_light', 'class' : 'progressbar_light', styles: { width : vals["width"], height : vals["height"], background : vals["lightbg"], color : vals["lightfg"], position : "absolute", 'text-align' : "center", left : 0, top : 0, 'line-height': vals["height"] - 2 } } ) );
			pb.setValue = function ( value ) {
				value = parseFloat( value );
				if ( isNaN( value ) || value < 0 ) {
					value = 0;
				} else {
					if ( value > 100 ) {
						value = 100;
					}
				}
				this.vals["value"] = value;
				this.vals["dark"].empty( );
				this.vals["light"].empty( );
				this.vals["dark"].appendText( value + '%' );
				this.vals["light"].appendText( value + '%' );
				var r = parseInt( this.vals["width"] * ( value / 100 ) );
				this.vals["dark"].setStyle( "clip", "rect(0," + r + "px," + this.vals["height"] + "px,0px)" );
				this.vals["light"].setStyle( "clip", "rect(0," + this.vals["width"] + "px," + this.vals["height"] + "px," + r + "px)" );
			}
			if ( vals["width"]) {
				pb.setValue( vals["value"]) ;
			} else {
				setTimeout ( 'ProgressBar_checkForParent("' + pb.id + '")', 1 );
			}
			return pb;
		}
	} );

	function ProgressBar_checkForParent ( id ) {
		var pb = $(id);
		if (!pb) { return; }
		if (!pb.parentNode) { return setTimeout( 'ProgressBar_checkForParent("' + id + '")', 1 ); }
		pb.setStyle( "width", "100%" );
		pb.vals["dark"].setStyle( "width" , pb.offsetWidth );
		pb.vals["light"].setStyle( "width" , pb.offsetWidth );
		pb.vals["width"] = pb.offsetWidth;
		pb.setValue( pb.vals["value"] );
	}

	return {
		createPB : function ( el, value, parms ) {
			if ($chk($(parms["containerID"]))) {
				$(parms["containerID"]).dispose();
			}

			var elem = parms["elem"] || "div";
			var pb = new Element (elem, { id : parms["containerID"], styles : {  "z-index" : 99 } } ).inject ( el );
			pb.headElements = Popups.createPopupHeader({
                container: pb,
                titleStyle: {
                    "padding-top": "5px",
                    background: "#a0b6cb",
                    width: (parms["width"] / 2).toInt(),
                    height: 30,
                    "float": "left"
                },
                titleAdopt: {
                    "spanText": new Element("span", {
                        styles: {
                            "text-decoration": "underline",
                            "letter-spacing": "1px",
                            "color": "#000000",
                            "font-weight": "bold",
                            "cursor": "pointer",
                            "z-index": 100
                        },
                        events: {
                            click: function(e){
                                if (pb.isPaused()) {
                                    pb.resumePB();
                                    this.set("text", "Resumed");
                                }
                                else {
                                    pb.pausePB();
                                    this.set("text", "Paused");
                                }
                            }
                        }
                    }).set("text", "Loading")
                }
            });
			if (!parms["withFloat"]) { pb.headElements["headingDiv"].setStyle("display", "none"); }
			pb.headElements["close"].setAttribute("title", "Stop Loading");
			var header = pb.headElements["headingDiv"].inject( pb );
			var sb = new ProgressBar ( value, parms ).inject( pb );
			var options = { };
			if (parms["opacity"]) { pb.setOpacity(parms["opacity"]); }
			if (parms["styles"]) { pb.setStyles(parms["styles"]); }
			pb.setStyle("font-weight", "bold");
			pb.fade = EFX.fadeOut(pb);

            if (parms["withFloat"]) {
                EFX.floatContainerInit( pb, { "left" : 5, "top" : window.getSize().y - 80, "duration" : 10 } );
                var options = { };
				if (parms["opacity"]) {
					options["oMax"] = parms["opacity"];
					options["oMin"] = parms["opacity"] / 2;
				}
				pb.postDrag = function () {
					var coords = this.getCoordinates(), sizes = window.getSize(), scrollSize = window.getScrollSize();
                    this.overrideLeft = coords.left - scrollSize.x;
					this.overrideTop = coords.top - scrollSize.y;
				};
                EFX.dragContainerInit( pb.headElements["headingDiv"], pb, options );
			}
			pb.changeStatus = parms["status_cb"] || function ( ) { };
			pb.process_id = $random(1, 1000000);
			pb.process_status = 0; // 0 => active, 1 => paused, 2 => stopped
			pb.statusText = new Element ("div", { } ).inject( pb );
			pb.statusText.setStyles( { "color" : "#000000", "font-weight" : "bold" } );
			pb.setStatusText = function ( txt ) {
				pb.statusText.set("html", txt );
			}
			pb.setValue = function ( val ) {
				sb.setValue( val );
			}
// check status
			pb.isActive = function ( ) {
				return this.process_status == 0;
			}
			pb.isPaused = function ( ) {
				return this.process_status == 1;
			}
			pb.isStopped = function ( ) {
				return this.process_status == 2;
			}
// change status
			pb.pausePB = function ( ) {
				this.process_status = 1;
				this.changeStatus();
			}
			pb.resumePB = function ( ) {
				this.process_status = 0;
				this.setStatusText("Resuming load...");
				this.changeStatus();
			}
			pb.stopPB = function ( ) {
				this.process_status = 2;
				this.setStatusText("Stopping load...");
				pb.headElements["title"].set("text", "Stopped");
				this.changeStatus();
			}
			setTimeout('try { $("' + parms["containerID"] + '").setStyle("display", "block"); } catch (ex) { }', parms["delayInterval"] || 50);
			return pb;
		}
	};

} ) ();

var UserPrefs = ( function ( ) {

	var prefs = { };

	var prefHash = function ( section ) {
		var hash = new Hash.Cookie ( "prefs_" + section, { duration : 30 } );
		return {
			get : function ( item ) {
				return hash.get ( MD5 ( item ) );
			},
			set : function ( item, value ) {
				return hash.set ( MD5 ( item ), value );
			},
			has : function ( item ) {
				return hash.hasKey ( MD5 ( item ) );
			},
			destroy : function ( ) {
				hash.empty();
			}
		}
	}

	return function ( section ) {
		section = MD5 ( section );
		if ( !prefs[section] ) {
			prefs[section] = new prefHash ( section );
		}
		return prefs[section];
	}

} )();


/**
 *  API for Tooltip message
 *
 *  @author Michael Simmons
 */
var ToolTipAPI = ( function() {

	return {
        /**
         * shows tooltip
         *
         * @param {Object} el - element that has event to invoke this function
         * @param {String} text - text to show in tooltip
         * @param {Integer} pixelsLeft - pixels left to move tooltip
         */
        showToolTip: function(el, text, pixelsLeft) {
            var toolTipTop = new Element("div", { "class": "toolTipTop" })
                ,toolTipMiddle = new Element("div", { "class": "toolTipMiddle" }).set("text", text)
                ,toolTipBottom = new Element("div", { "class": "toolTipBottom" })
                ,toolTipWrapper = new Element("div", { id: el.id + "_ToolTipWrappper", "class": "toolTipWrapper" }).adopt(toolTipTop, toolTipMiddle, toolTipBottom)
                ,coords = CoordinatesAPI.getCoordinates(el);

            toolTipWrapper.setStyles({ position: "absolute", top: coords.bottom, left: parseInt(coords.left - ((pixelsLeft > 0) ? pixelsLeft : 0)) }).inject($(document.body));
        },

        /**
         * hides tooltip
         *
         * @param {Object} el - element that has event to invoke this function
         */
        hideToolTip: function(el) {
            var toolTipWrapper = $(el.id + "_ToolTipWrappper");
            if (toolTipWrapper) toolTipWrapper.destroy();
        }
    }
})();

/**
 * API to get coordinates of elements
 *
 * @author Michael Simmons <msimmons@guidepointglobal.com>
 */
var CoordinatesAPI = ( function(){
    /**
     * get coordinates of passed in element
     *
     * @param {Object} obj - object to get coordinates for
     */
	var getCoordinates = function(obj) {
		if (BrowserAPI.isIE()) {
			var top = right = bottom = left = 0
				,objWidth = obj.offsetWidth
				,objHeight = obj.offsetHeight;

			if (obj.offsetParent) {
				do {
					left += obj.offsetLeft;
					top += obj.offsetTop;
				} while (obj = obj.offsetParent);
			}

			return { top: top, right: left + objWidth, bottom: top + objHeight, left: left };
		} else {
			return obj.getCoordinates();
    	}
	};

    /**
     * gets position/coordinates of mouse pointer
     *
     * @param {Object} e - event object
     */
	var getMouseCoordinates = function(e) {
		var posx = posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) {
			posx = e.pageX;
			posy = e.pageY;
		} else if (e.clientX || e.clientY) {
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		return { top: posy, left: posx };
	};
	
	var getViewportWidth = function() {
       if (window.innerWidth)        {
           return window.innerWidth;
       } else if (document.body && document.body.offsetWidth) {
           return document.body.offsetWidth;
       } else {
    	   return 0;
       }
	};

	var getViewportHeight = function() {
       if (window.innerHeight) {
    	   return window.innerHeight;
       } else if (document.body && document.body.offsetHeight) {
    	   return document.body.offsetHeight;
       } else {
    	   return 0;
       }
	};

	var getViewPointCoordinates = function() {
		return { width: getViewportWidth, height: getViewportHeight };
	};
	
	return {
		getCoordinates: getCoordinates
		,getMouseCoordinates: getMouseCoordinates
		,getViewportWidth: getViewportWidth
		,getViewportHeight: getViewportHeight
		,getViewPointCoordinates: getViewPointCoordinates
	};
})();


/**********************************************
**************** PROTOTYPES *******************
**********************************************/

// Prototypes
Date.monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
Date.monthDays = [ 31, "l", 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
Date.isValid = function ( date ) {
	if ( date instanceof Date ) {
		return true;
	} else {
		return !isNaN ( Date.parse ( date ) );
	}
}
Date.create = function ( date ) {
	if ( date instanceof Date ) {
		return date;
	} else {
		var d = new Date();
		var p = Date.parse ( date );
		if ( !isNaN ( p ) ) {
			d.setTime ( p );
		}
		return d;
	}
}
Date.prototype.getMonthAsString = function ( ) {
	return Date.monthNames[this.getMonth()];
}
Date.prototype.getMonthAsStringShort = function ( ) {
	return this.getMonthAsString().substr(0,3);
}
Date.dayNames = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
Date.prototype.getDayAsString = function ( ) {
	return Date.dayNames[this.getDay()];
}
Date.prototype.getDayAsStringShort = function ( ) {
	return this.getDayAsString().substr(0,3);
}
Date.prototype.equals = function ( date ) {
	if ( !(date instanceof Date ) ) return false;
	return this.getFullYear() == date.getFullYear() && this.getMonth() == date.getMonth() && this.getDate() == date.getDate();
}
Date.prototype.isWeekend = function ( ) {
	return this.getISODay() >= 6;
}
Date.prototype.getISODay = function ( ) {
	var d = this.getDay();
	if ( d < 1 ) return 7;
	return d;
}
Date.prototype.getSuffix = function ( ) {
	var x = ("" + this.getDate()).substr(-1);
	var y = ("" + this.getDate()).substr(-2);
	if ( x == 1 && y != 11 ) return "st";
	if ( x == 2 && y != 12 ) return "nd";
	if ( x == 3 && y != 13 ) return "rd";
	return "th";
}
Date.prototype.getDaysInMonth = function ( ) {
	var d = Date.monthDays[this.getMonth()];
	return ( isNaN ( d ) ? ( this.isLeapYear() ? 29 : 28 ) : d );
}
Date.prototype.isLeapYear = function ( ) {
	var y = this.getFullYear();
	if ( y % 4 == 0 ) {
		if ( y % 100 == 0 ) {
			return ( y % 400 == 0 );
		} else {
			return true;
		}
	} else {
		return false;
	}
}
Date.prototype.getAMPM = function ( ) {
	return this.isMorning() ? "AM" : "PM";
}
Date.prototype.isMorning = function ( ) {
	return this.getHours() < 12;
}
Date.prototype.getHours12Hr = function ( ) {
	return this.getHours() % 12;
}
/*Date.prototype.format = function ( format ) {
	while ( format.match ( /(^|[^\\])[dDjlNSwzWFmMntLoYyaABgGhHisueIOPZcrU]/ ) ) {
		format = format
			// d - Day of the month, 2 digits with leading zeros
			.replace ( /(^|[^\\])d/g, "$1" + (""+this.getDate()).lpad(2,"0") )
			// D - A textual representation of a day, three letters
			.replace ( /(^|[^\\])D/g, "$1" + this.getDayAsStringShort().replace(/(\w)/g,"\\$1") )
			// j - Day of the month without leading zeros
			.replace ( /(^|[^\\])j/g, "$1" + this.getDate() )
			// l - A full textual representation of the day of the week
			.replace ( /(^|[^\\])l/g, "$1" + this.getDayAsString().replace(/(\w)/g,"\\$1") )
			// N - ISO-8601 numeric representation of the day of the week
			.replace ( /(^|[^\\])N/g, "$1" + this.getISODay() )
			// S - English ordinal suffix for the day of the month, 2 characters
			.replace ( /(^|[^\\])S/g, "$1" + this.getSuffix().replace(/(\w)/g,"\\$1") )
			// w - Numeric representation of the day of the week
			.replace ( /(^|[^\\])w/g, "$1" + this.getDay() )
			// z - The day of the year (starting from 0) [not implemented]
			.replace ( /(^|[^\\])z/g, "$1" + "\\z" )

			// W - ISO-8601 week number of year, weeks starting on Monday
			.replace ( /(^|[^\\])W/g, "$1" + "\\W" )

			// F - A full textual representation of a month, such as January or March
			.replace ( /(^|[^\\])F/g, "$1" + this.getMonthAsString().replace(/(\w)/g,"\\$1") )
			// m - Numeric representation of a month, with leading zeros
			.replace ( /(^|[^\\])m/g, "$1" + (""+(this.getMonth()+1)).lpad(2,"0") )
			// M - A short textual representation of a month, three letters
			.replace ( /(^|[^\\])M/g, "$1" + this.getMonthAsStringShort().replace(/(\w)/g,"\\$1") )
			// n - Numeric representation of a month, without leading zeros
			.replace ( /(^|[^\\])n/g, "$1" + ( this.getMonth() + 1 ) )
			// t - Number of days in the given month
			.replace ( /(^|[^\\])t/g, "$1" + this.getDaysInMonth() )

			// L - Whether it's a leap year
			.replace ( /(^|[^\\])L/g, "$1" + ( this.isLeapYear() ? 1 : 0 ) )
			// o - [Not implemented]
			.replace ( /(^|[^\\])o/g, "$1" + "\\o" )
			// Y - A full numeric representation of a year, 4 digits
			.replace ( /(^|[^\\])Y/g, "$1" + this.getFullYear() )
			// y - A two digit representation of a year
			.replace ( /(^|[^\\])y/g, "$1" + (""+this.getFullYear()).substr(2,2) )

			// a - Lowercase Ante meridiem and Post meridiem
			.replace ( /(^|[^\\])a/g, "$1" + this.getAMPM().toLowerCase().replace(/(\w)/g,"\\$1") )
			// A - Uppercase Ante meridiem and Post meridiem
			.replace ( /(^|[^\\])A/g, "$1" + this.getAMPM().replace(/(\w)/g,"\\$1") )
			// B - Swatch Internet time [not implemented]
			.replace ( /(^|[^\\])B/g, "$1" + "\\B" )
			// g - 12-hour format of an hour without leading zeros
			.replace ( /(^|[^\\])g/g, "$1" + this.getHours12Hr() )
			// G - 24-hour format of an hour without leading zeros
			.replace ( /(^|[^\\])G/g, "$1" + this.getHours() )
			// h - 12-hour format of an hour with leading zeros
			.replace ( /(^|[^\\])h/g, "$1" + (""+this.getHours12Hr()).lpad(2,"0") )
			// H - 24-hour format of an hour with leading zeros
			.replace ( /(^|[^\\])H/g, "$1" + (""+this.getHours()).lpad(2,"0") )
			// i - Minutes with leading zeros
			.replace ( /(^|[^\\])i/g, "$1" + (""+this.getMinutes()).lpad(2,"0") )
			// s - Seconds, with leading zeros
			.replace ( /(^|[^\\])s/g, "$1" + (""+this.getSeconds()).lpad(2,"0") )
			// u - Milliseconds
			.replace ( /(^|[^\\])u/g, "$1" + this.getMilliseconds() )

			// e - Timezone identifier [not implemented]
			.replace ( /(^|[^\\])e/g, "$1" + "\\e" )
			// I - Whether or not the date is in daylight saving time [not implemented]
			.replace ( /(^|[^\\])I/g, "$1" + "\\I" )
			// O - Difference to Greenwich time (GMT) in hours
			.replace ( /(^|[^\\])O/g, "$1" + ( (o=this.getTimezoneOffset()/60) > 0 ? "-" : "+" ) + ( parseInt(o) + "" + 60 * ( o - parseInt(o) ) ).rpad(3,"0").lpad(4,"0") )
			// P - Difference to Greenwich time (GMT) with colon between hours and minutes
			.replace ( /(^|[^\\])P/g, "$1" + ( (o=this.getTimezoneOffset()/60) > 0 ? "-" : "+" ) + ( parseInt(o) + ":" + 60 * ( o - parseInt(o) ) ).rpad(4,"0").lpad(5,"0") )
			// T - Timezone abbreviation [not implemented]
			.replace ( /(^|[^\\])T/g, "$1" + "\\T" )
			// Z - Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive
			.replace ( /(^|[^\\])Z/g, "$1" + ( this.getTimezoneOffset() * -60 ) )

			// c - ISO 8601 date
			.replace ( /(^|[^\\])c/g, "$1" + "Y-m-d\\TG:i:sP" )
			// r - RFC 2822 formatted date
			.replace ( /(^|[^\\])r/g, "$1" + "D, j M Y G:i:s O" )
			// U - Seconds since the Unix Epoch
			.replace ( /(^|[^\\])U/g, "$1" + this.getTime() / 100 );
	}
	return format.replace ( /\\(\w)/g, "$1" );
}*/

/************* String prototype ************************/
String.prototype.lpad = function ( length, pad ) {
	var x = this;
	while ( x.length < length ) x = (pad||" ") + x;
	return x;
}
String.prototype.rpad = function ( length, pad ) {
	var x = this;
	while ( x.length < length ) x += (pad||" ");
	return x;
}
String.prototype.ucWords = function ( ) {
	return this.replace ( /\b(\w)/g, function ( c ) {
		return c.toUpperCase();
	} );
}
String.prototype.stripCarriageReturns = function ( ) {
	return this.replace( /\\r/g, '' );
}
String.prototype.stripTags = function ( ) {
	return this.replace( /<([^>]+)>/g, '' );
}
String.prototype.addSlashes = function ( ) {
	return this.replace( /['"]/g, function( match ) {
			return ( '\\' + match.charAt( 0 ) + match.charAt ( 1 ) );
	} );
}
String.prototype.nl2br = function ( ) {
	return this.replace( /\n/g, '<br />' );
}
String.prototype.br2nl = function ( ) {
	return this.replace( /<br\/>/gi, "\n" );
}
String.prototype.stripSlashes = function ( ) {
	return this.replace(/\\['"]{1,}/g, function ( match ) {
		return ( match.charAt ( 1 ) );
	} );
}
String.prototype.htmlEntities = function ( ) {
	return this.replace( /&/g, '&amp;' ).replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
}
String.prototype.ltrim = function ( ) {
	return this.replace( /^\s+/g, '' );
}
String.prototype.rtrim = function( ) {
	return this.replace ( /\s+$/g, '' );
}
String.prototype.strtoupper = function ( ) {
	return this.toUpperCase ( );
}
String.prototype.strtolower = function ( ) {
 		return this.toLowerCase ( );
}
String.prototype.firstChar = function ( n ) {
	return ( this.charAt ( 0 ) == n );
}
String.prototype.hasChar = function ( n ) {
	for (var i = 0; i <= this.length; i++ ) {
		if ( this.charAt(i) == n ) { return true; }
	}
	return false;
}
String.prototype.lastChar = function ( n ) {
	return ( this.charAt( this.length - 1 ) == n );
}
String.prototype.globalReplace = function( val, repl, regexAttr ) {
	return this.replace( new RegExp( val, regexAttr || 'gi'), repl );
}
String.prototype.posOf = function ( n ) {
	var positions = [];
	for ( var i = 0; i < this.length; i++ ) {
		if ( this.charAt( i ) == n ) {
			positions.push( i );
		}
	}
	return ( positions.length == 0 ) ? false : positions;
}
String.prototype.getFirstChar = function ( ) {
	return this.charAt( 0 );
}
String.prototype.getLastChar = function ( ) {
	return this.charAt( this.length - 1 );
}
String.prototype.ucFirst = function ( ) {
	return this.replace( this.charAt( 0 ), this.charAt( 0 ).strtoupper());
}
String.prototype.lcFirst = function ( ) {
	return this.replace( this.charAt( 0 ), this.charAt( 0 ).strtolower());
}
String.prototype.isInt = function () {
	var i = value.indexOf(".");
	if (isNaN(this) || (i > -1 && i < this.length-1)) {
		return false;
	}
	return true;
}
String.prototype.isFloat = function () {
	if (isNaN(this)) {
		return false;
	}
	return true;
}
String.prototype.parseUSCurrency = function () {
	var ret = this.replace(/[,$]/g, "");
	return ret.isFloat() ? ret : "";
}
String.prototype.toUSCurrency = function () {
	var i;
	var val = this.parseUSCurrency();
	var tmp = val.split(".");
	if(tmp.length == 1 && tmp[0].length == 0) { return "";}
	if (tmp.length > 1 && tmp[1].length > 2) {
		if (tmp[1].charAt(2) >= 5) {
			val -= -.01;
			val += "";
		}
		val = val.substr(0, tmp[0].length + 3);
		tmp = val.split(".");

	}
	var t = tmp[0].length % 3;
	var ret = "$";
	for (i = 0; i < val.length; i++) {
		if((i - t + 3) % 3 == 0 && i > 0 && i < tmp[0].length - 1) {
			ret += ",";
		}
		ret += val.charAt(i);
	}
	if (tmp.length == 1) {
		ret += ".00";
	} else if (tmp[1].length == 0) {
		ret += "00";
	} else if (tmp[1].length == 1) {
		ret += "0";
	}
	return ret;
}

String.prototype.isValidName = function () {
	return true;
	/*if (this.length > 80) {
		return false;
	}

	if (this.split(/[a-zA-Z ,"]/).join("").length == 0) {
		return true;
	}
	return false;*/
}

String.prototype.isValidZip = function () {
	if (this.length > 20) {
		return false;
	}
	if (this.split(/[a-zA-Z0-9]/).join("").length == 0) {
		return true;
	}
	return false;
}

String.prototype.isCurrency = function () {
	return (this.parseUSCurrency().length !== "") ? true : false;
}
String.prototype.isValidEmail = function () {
	if (this.search(/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-][a-zA-Z0-9.-]+$/) > -1) {
		return true;
	}
	return false;
}
String.prototype.isValidKey = function () {
	if (this.isFloat()) {
		if (this >= 0) {
			var a = this.split('.');
			if (a.length == 1 || parseInt(a[1]) == 0) {
				return true;
			}
		}
	}
	return false;
}
String.prototype.isValidFloat = function () {
	return this.isFloat();
}

String.prototype.isSSN = function () {
	if (this.isInt() && this > 0 && this.length == 9) {
		return true;
	}
	return false;
}
String.prototype.isEIN = function () {
	if (this.isInt() && value > 0 && this.length == 10) {
		return true;
	}
	return false;
}
String.prototype.isSSNOrEIN = function () {
	if (this.isInt() && this > 0 && this.length >= 9 && this.length <= 10) {
		return true;
	}
	return false;
}
/*
String.prototype.isValidSSN = function () {
	return this.isSSNOrEIN();
}*/

String.prototype.isValidPhoneNumber = function () {
	if (this.search(/.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*/) > -1) {
		return true;
	}
	return false;
}

String.prototype.numberFormat = function () {
	nStr = this;
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
/*String.prototype.isValidAdvisorEmail = function (cbFunction) {
	if (this.isValidEmail()) {
		$
	}
	return true;
}*/


// Number prototype
Number.prototype.numberFormat = function () {

	nStr = this.toString();
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

Element.Events.extend({
    "wheelup": {
        type: Element.Events.mousewheel.type,
        map: function(event){
            event = new Event(event);
            if (event.wheel >= 0) {
                this.fireEvent('wheelup', event);
            }
        }
    },
    "wheeldown": {
        type: Element.Events.mousewheel.type,
        map: function(event){
            event = new Event(event);
            if (event.wheel <= 0) {
                this.fireEvent('wheeldown', event);
            }
        }
    }
});

Fx.Slide.extend({
    toggleBlock: function(mode){
        if (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) {
            return this.show(mode);
        }
        else {
            return this.hide(mode);
        }
    }
});


var array_unique = function (arr) {
	var tmp = [];
	for (var i = 0; i < arr.length; i++) {
		if (!tmp.contains(arr[i])) {
			tmp.push(arr[i]);
		}
	}
	return tmp;
};

var isset = function(objName){
    var set;
    try {
        eval("set = $defined(" + objName + ")");
    }
    catch (ex) {
        set = false;
    }

    return set;
}

var updateNoteCountA = function (elID, cnt) {
	$(elID).set('text', cnt > 0 ? cnt : "");

	var iconTypes = {PMNoteCountSpan : 'AdvNote', CltNoteCountSpan : 'CltNote', pmnspan : 'pmnimg', clncntspan : 'clnimg' };
	var lines = elID.split('_');
	for (var i in iconTypes) {
		if (lines[0] == i) {
			$(iconTypes[i] + '_' + lines[1]).src= (cnt > 0) ? "/images/icons/icon_note.gif" : "/images/icons/icon_add_note.gif";
		}
	}
}


var call_user_func = function (cb, parameters) {
    // Call a user function which is the first parameter
    //
    // version: 909.322
    // discuss at: http://phpjs.org/functions/call_user_func    // +   original by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: call_user_func('isNaN', 'a');
    // *     returns 1: true
    var func;
     if (typeof cb == 'string') {
        if (typeof this[cb] == 'function') {
            func = this[cb];
        } else {
            func = (new Function(null, 'return ' + cb))();        }
    } else if (cb instanceof Array) {
        func = eval(cb[0]+"['"+cb[1]+"']");
    }
        if (typeof func != 'function') {
        throw new Error(func + ' is not a valid function');
    }

    return func.apply(null, Array.prototype.slice.call(arguments, 1));
}

var sectorCheckboxFunc = function(checkbox) {
	checkbox.checked = (checkbox.checked) ? false : true;
}

