/// <reference path="jQuery Source/jquery-1.3.2-vsdoc.js" />

function Queue_CGI(callforward, callback) {
	this.Queue = new Array();
	this.callforward = function(oData) { }
	if (callforward) this.callforward = callforward;
	this.callback = function(oData) { }
	if (callback) this.callback = callback;

	this.AppendToCGIQueue = function(cScript, oQueryData, callback) {
		this.Queue[this.Queue.length] = { cScript: cScript, oQueryData: oQueryData, callback: callback, Run_CGI: false };

		if (this.Queue.length == 1) {
			this.callforward();
			this.Exec_Run_CGI();
		}
	}

	this.Exec_Run_CGI = function() {
		this.Queue[0].Run_CGI = new Run_CGI(this.Queue[0].cScript, this.Queue[0].oQueryData, this.Queue[0].callback, this);
	}
}

function Run_CGI(cScript, oQueryData, callback, oQueue) {
	var my = this;
	this.script = cScript;
	var cMethod = "GET";
	if (cScript.match(/isql/)) {
		cMethod = "POST";
		if (Application.oDBKeys) {
			oQueryData = Application.oDBKeys.cCode + ";" +
							Application.oDBKeys.cPassword + ";" +
							Application.oDBKeys.cRole + ";" + String.fromCharCode(13) +
							oQueryData;
		}
	}
	if (cScript.match(/create/)) {
		cMethod = "POST";
	}
	if (cScript.match(/sql/)) {
		cMethod = "POST";	
	}
	this.query = {};
	if (oQueryData) this.query = oQueryData;
	
	this.callback = function(oData) { }
	if (callback) this.callback = callback;

	$.ajax({
		type: cMethod,
		url: "/cgi-bin/" + cScript,
		data: my.query,
		dataType: "text",
		success: function (returnedData) {
			my.callback(String2Object(returnedData));
			if (oQueue) {
				oQueue.Queue.splice(0, 1);
				if (oQueue.Queue.length > 0) {
					oQueue.Exec_Run_CGI();
				}
				else {
					oQueue.callback();
				}
			}
		}
	});
}

function String2Object(cResponseString, nSkipRows) {
	var tblSep = "<_tblSep_>";
	//tblSep = "A<_rowSep_><_tblSep_><_rowSep_>";

	var rowSep = "<_rowSep_>";
	var fieldSep = "<_fldSep_>";

	if (cResponseString.indexOf(rowSep) == -1) return cResponseString;

	var responseArrayOfRowStrings = function () {
		var aRecStrings = cResponseString.split(rowSep);
		return aRecStrings;
	}
	var responseArrayOfRowArrays = function() {
			var array_of_row_strings = responseArrayOfRowStrings();
			var array_of_row_arrays = [];
			for ( var i = 0; i < array_of_row_strings.length; i++ ) {
				array_of_row_arrays.push(array_of_row_strings[i].split(fieldSep));
			}
			return array_of_row_arrays;
	}
	var responseRows = function () {

		var array_of_row_hashes = [];

		array_of_row_hashes.castNumeric = function (cColName) {
			for (var nX = 0; nX < this.length; nX++) {
				this[nX][cColName] = Number(this[nX][cColName]);
			}
			return this
		}

		array_of_row_hashes.dataSort = function (cColName, nOrder) {
			this.sort(
			function (a, b) {
				if (!nOrder) nOrder = 1;
				if (a[cColName] < b[cColName]) return -1 * nOrder;
				if (a[cColName] > b[cColName]) return 1 * nOrder;
				return 0;
			});
			return this;
		}

		array_of_row_hashes.groupBy = function (cColName, aAggFuncs) {
			this.dataSort(cColName);

			var nX = 1;
			while (nX < this.length) {
				if (this[nX][cColName] == this[nX - 1][cColName]) {
					for (var nY = 0; nY < aAggFuncs.length; nY++) { aAggFuncs[nY](nX, this); }
					this.splice(nX, 1);
				}
				else {
					nX++;
				}
			}
			return this
		}

		array_of_row_hashes.numBinarySearch = function (nSearchVal, cSearchCol) {
			if (!this.length) return -1;

			var high = this.length - 1;
			var low = 0;

			while (low <= high) {
				mid = parseInt((low + high) / 2)
				element = this[mid];
				if (element[cSearchCol] > nSearchVal) {
					high = mid - 1;
				} else if (element[cSearchCol] < nSearchVal) {
					low = mid + 1;
				} else {
					return mid;
				}
			}

			return -1;
		};

		var array_of_row_arrays = responseArrayOfRowArrays();
		var fields = array_of_row_arrays.shift();
		while (array_of_row_arrays.length > 1) {
			var row_array = array_of_row_arrays.shift();
			if (!row_array[0].match(/(\d+ rows{0,1})/)) {
				var row_hash = {};
				for (var i = 0; i < fields.length; i++) row_hash[fields[i]] = row_array[i];
				array_of_row_hashes.push(row_hash);
			}
			else { if (array_of_row_arrays.length > 0) fields = array_of_row_arrays.shift(); }
		}
		return array_of_row_hashes;
	}

	var nTables = cResponseString.countOccurs(tblSep);
	if (nTables <= 1) {
		//erase the table seperator and return one table ( row of arrays )
		cResponseString = cResponseString.replace(tblSep, "");
		return responseRows();
	}

	var aTables = [];
	aTables = cResponseString.split(tblSep);
	aTables.length--;  //Remove Last Terminator
	for (var nX = 0; nX < nTables; nX++) {
		cResponseString = aTables[nX];
		aTables[nX] = responseRows();
	}
	return aTables;
}
function quoteSQL(cStringToQuote, cDataBase) {
	//convert to string if not already
	cStringToQuote = cStringToQuote.toString();
	
	//escape single quotes and convert line feeds to ascii equivelants
	cStringToQuote = cStringToQuote.replace(/'/g, "''");
	cStringToQuote = cStringToQuote.replace(/\n/g, "'||ASCII_CHAR(13)||ASCII_CHAR(10)||'");
	return "'"+cStringToQuote+"'";
}

function aggSum(cCol) {
	return function(nX, aResults) { aResults[nX - 1][cCol] = Number(aResults[nX - 1][cCol]) + Number(aResults[nX][cCol]); }
}

String.prototype.countOccurs = function (cStringToCount) {
	//returns a case sensative count of how many occurances of cStringToCount are in 'this' string
	var aMatches = this.match(new RegExp(cStringToCount, "gm"));
	if (aMatches == null) { return 0; }
	return aMatches.length;
}

Number.prototype.toOrdinal = function() {
	var i = this.toString();
	if (i.match(/\D/)) return i;
	if (i == 3 || i.match(/[^1]3$/)) return i + 'rd';
	if (i == 2 || i.match(/[^1]2$/)) return i + 'nd';
	if (i == 1 || i.match(/[^1]1$/)) return i + 'st';
	return i + 'th';
}


function ContactAddress(oX, cPrefix) {
	return ((oX[cPrefix + 'COMPANY'].length > 0) ? encode_HTML(oX[cPrefix + 'COMPANY']) + '<br/>' : '') +
						((oX[cPrefix + 'NAME'].length > 0) ? 'Attn: ' + encode_HTML(oX[cPrefix + 'NAME']) 
						+ '<br/>' : '') +
						((oX[cPrefix + 'ADDRESS'].length > 0) ? encode_HTML(oX[cPrefix + 'ADDRESS']) + '<br/>' : '') +
						encode_HTML(oX[cPrefix + 'CITY']) +
						((oX[cPrefix + 'CITY']=="")? ' ':', ') + 
						encode_HTML(oX[cPrefix + 'STATE']) + ' ' + oX[cPrefix + 'ZIP'];
}
function HoverClickButtons(cSelector){
	//all hover and click logic for buttons and anchors having ui-state-default
	if (!cSelector) cSelector = ""; else cSelector += " ";
	$(cSelector + "button:not(.ui-state-disabled).ui-state-default," + 
		cSelector + "a:not(.ui-state-disabled).ui-state-default," +
		cSelector + "input[type='submit']")
	.hover(
		function() {
			$(this).addClass("ui-state-hover");
		},
		function() {
			$(this).removeClass("ui-state-hover");
		}
	)
	.mousedown(function() {
		if (!$(this).hasClass('togglebutton')) {
			if ($(this).is('.ui-state-active'))
			{ $(this).removeClass("ui-state-active"); }
			else { $(this).addClass("ui-state-active"); }
		} 
	})
	.mouseup(function() {
		if (!$(this).hasClass('togglebutton')) {
			$(this).removeClass("ui-state-active");
		}
	}
	);
}


function SetRewardUnitElements(cSelector) {
	if (!cSelector) cSelector = "";
	else cSelector = cSelector + " ";

	if (Application.oUser) {
		$(cSelector + ".NumExchangeRate").text(Application.oUser.TOKENRATE);
		$(cSelector + ".textRewardUnit").text(Application.oUser.TOKENUNIT.toLowerCase());
		$(cSelector + ".textRewardUnits").text(Application.oUser.TOKENUNIT.toLowerCase() + "s");
		$(cSelector + ".TextRewardUnit").text(Application.oUser.TOKENUNIT);
		$(cSelector + ".TextRewardUnits").text(Application.oUser.TOKENUNIT + "s");
		return;
	}

	$(cSelector + ".NumExchangeRate").text(tokenrate);
	$(cSelector + ".textRewardUnit").text(strRewardUnit.toLowerCase());
	$(cSelector + ".textRewardUnits").text(strRewardUnit.toLowerCase() + "s");
	$(cSelector + ".TextRewardUnit").text(strRewardUnit);
	$(cSelector + ".TextRewardUnits").text(strRewardUnit + "s");
}
function formatCurrency(num, bHTML, bHideCents, bBlankZero) {
	var sign = false, cents = 0, cReturn = "", nNumberVal;

	if (bBlankZero && (Number(num)==0 || num==undefined || isNaN(num) || num=='' || num==0)) return "";

	if ( num==undefined || isNaN(num) || num=='') {sign = true;  num = "0"; cents = ".00"}
	else {
		num = num.toString().replace(/\$|\,/g,'');
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		nNumberValue =  Math.floor(num/100);
		num = Math.floor(num/100).toString();
		if (bHideCents) cents = "";
		else {
  		if (cents < 10) cents = "0" + cents;
  		cents = "." + cents;
		}
	  
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length - (4 * i + 3));
	}
	if (!bHTML) cReturn = (((sign) ? '' : '-') + '$' + num + cents);
	else {
		if (nNumberValue >= 1) {
			cReturn = ((sign) ? '' : '-') + '<span style="font-size:75%; vertical-align:top">$</span>' + num +
				((!bHideCents) ? '<span style="font-size:75%; vertical-align:top">' + cents + '</span>' : '');
		}
		else {
			cReturn = ((sign) ? '' : '-') + '<span style="font-size:100%;">' + String(Math.floor((Number(cents)) * 100)) + '</span>' +
				'<span style="position:relative; top:-.2em">&cent;</span>';
		}
	}
	return cReturn
}
function encode_HTML(str) {
	var cX = str.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, '<br />');
	return cX;
}
function trimNumber(s) {
	// Removes leading zero from passed string
  while (s.substr(0,1) == '0' && s.length>1)
  { s = s.substr(1,9999); }
  return s;
}
function EmptyToZero(cX) {
	if (cX == undefined || !cX || cX == '') cX = "0";
	return cX;
}
function pluralize(nAmount) {
	// returns a lower case "s" if passed amount != 1
	nAmount = Number(nAmount);
	if (nAmount == 1) return "";
  else return "s";
}

function PageQuery(q) {
	if (q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if (q) {
		for (var i = 0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s)
	{
		for (var j = 0; j < this.keyValuePairs.length; j++) {
			if (this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function()
	{
		var a = new Array(this.getLength());
		for (var j = 0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }
}
function queryString(key) {
	var page = new PageQuery(window.location.search);
	if (!page.getValue(key))
		return false
	else
		return unescape(page.getValue(key));
}


function smallDate(cSQLDate) {
	if (cSQLDate==undefined || cSQLDate=="") {return '';};
	
	var dX = new Date(cSQLDate);
	return dX.getMonth() + 1 + "/" + dX.getDate() + "/" + String(dX.getFullYear()).substring(2, 4)
}
function smallDateTime(cSQLDate) {
	var dX = new Date(cSQLDate);
	return dX.getMonth() + 1 + "/" + dX.getDate() + "/" + String(dX.getFullYear()).substring(2, 4) + " " +
		dX.toLocaleTimeString()
}
function validateNumeric(evt) {
	var theEvent = evt || window.event;
	var key = theEvent.keyCode || theEvent.which;
	key = String.fromCharCode(key);
	var regex = /[0-9]|\./;
	if (!regex.test(key)) {
		theEvent.returnValue = false;
	}
}
function popWindow(wurl, wname, wwidth, wheight) {
	var opts = 'status=no,scrollbars=yes,resizable=yes,left=100,top=100,menubar=yes';
	if (wwidth) opts = opts + ',width=' + wwidth;
	if (wheight) opts = opts + ',height=' + wheight;
	try {
	var w = window.open(wurl, wname, opts);
	if (window.focus) w.focus();
	} catch (Error) {
		alert("We were unable to open the new window for printing, turn off any popup blockers to proceed.");
	}
}


//Other Misc jquery add-ons functions
(function($) {

	//Image Preloader
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = new Image(0,0);
      cacheImage.src = arguments[i];
    }
   }
   
  
  
	//Browser Detect
	var userAgent = navigator.userAgent.toLowerCase();

	$.browser = {
		version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1],
		safari: /webkit/.test(userAgent),
		opera: /opera/.test(userAgent),
		msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
		mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
	};





	/*
	Kwicks for jQuery (version 1.5.1)
	Copyright (c) 2008 Jeremy Martin
	http://www.jeremymartin.name/projects.php?project=kwicks
	
	Licensed under the MIT license:
	http://www.opensource.org/licenses/mit-license.php

	Any and all use of this script must be accompanied by this copyright/license notice in its present form.
	*/
	$.fn.kwicks = function (options) {
		var defaults = {
			isVertical: false,
			sticky: false,
			defaultKwick: 0,
			event: 'mouseover',
			spacing: 0,
			duration: 500
		};
		var o = $.extend(defaults, options);
		var WoH = (o.isVertical ? 'height' : 'width'); // WoH = Width or Height
		var LoT = (o.isVertical ? 'top' : 'left'); // LoT = Left or Top

		return this.each(function () {
			container = $(this);
			var kwicks = container.children('li');
			var normWoH = kwicks.eq(0).css(WoH).replace(/px/, ''); // normWoH = Normal Width or Height
			if (!o.max) {
				o.max = (normWoH * kwicks.size()) - (o.min * (kwicks.size() - 1));
			} else {
				o.min = ((normWoH * kwicks.size()) - o.max) / (kwicks.size() - 1);
			}
			// set width of container ul
			if (o.isVertical) {
				container.css({
					width: kwicks.eq(0).css('width'),
					height: (normWoH * kwicks.size()) + (o.spacing * (kwicks.size() - 1)) + 'px'
				});
			} else {
				container.css({
					width: (normWoH * kwicks.size()) + (o.spacing * (kwicks.size() - 1)) + 'px',
					height: kwicks.eq(0).css('height')
				});
			}

			// pre calculate left or top values for all kwicks but the first and last
			// i = index of currently hovered kwick, j = index of kwick we're calculating
			var preCalcLoTs = []; // preCalcLoTs = pre-calculated Left or Top's
			for (i = 0; i < kwicks.size(); i++) {
				preCalcLoTs[i] = [];
				// don't need to calculate values for first or last kwick
				for (j = 1; j < kwicks.size() - 1; j++) {
					if (i == j) {
						preCalcLoTs[i][j] = o.isVertical ? j * o.min + (j * o.spacing) : j * o.min + (j * o.spacing);
					} else {
						preCalcLoTs[i][j] = (j <= i ? (j * o.min) : (j - 1) * o.min + o.max) + (j * o.spacing);
					}
				}
			}

			// loop through all kwick elements
			kwicks.each(function (i) {
				var kwick = $(this);
				// set initial width or height and left or top values
				// set first kwick
				if (i === 0) {
					kwick.css(LoT, '0px');
				}
				// set last kwick
				else if (i == kwicks.size() - 1) {
					kwick.css(o.isVertical ? 'bottom' : 'right', '0px');
				}
				// set all other kwicks
				else {
					if (o.sticky) {
						kwick.css(LoT, preCalcLoTs[o.defaultKwick][i]);
					} else {
						kwick.css(LoT, (i * normWoH) + (i * o.spacing));
					}
				}
				// correct size in sticky mode
				if (o.sticky) {
					if (o.defaultKwick == i) {
						kwick.css(WoH, o.max + 'px');
						kwick.addClass('active');
					} else {
						kwick.css(WoH, o.min + 'px');
					}
				}
				kwick.css({
					margin: 0,
					position: 'absolute'
				});

				kwick.bind(o.event, function () {
					// calculate previous width or heights and left or top values
					var prevWoHs = []; // prevWoHs = previous Widths or Heights
					var prevLoTs = []; // prevLoTs = previous Left or Tops
					kwicks.stop().removeClass('active');
					for (j = 0; j < kwicks.size(); j++) {
						prevWoHs[j] = kwicks.eq(j).css(WoH).replace(/px/, '');
						prevLoTs[j] = kwicks.eq(j).css(LoT).replace(/px/, '');
					}
					var aniObj = {};
					aniObj[WoH] = o.max;
					var maxDif = o.max - prevWoHs[i];
					var prevWoHsMaxDifRatio = prevWoHs[i] / maxDif;
					kwick.addClass('active').animate(aniObj, {
						step: function (now) {
							// calculate animation completeness as percentage
							var percentage = maxDif != 0 ? now / maxDif - prevWoHsMaxDifRatio : 1;
							// adjsut other elements based on percentage
							kwicks.each(function (j) {
								if (j != i) {
									kwicks.eq(j).css(WoH, prevWoHs[j] - ((prevWoHs[j] - o.min) * percentage) + 'px');
								}
								if (j > 0 && j < kwicks.size() - 1) { // if not the first or last kwick
									kwicks.eq(j).css(LoT, prevLoTs[j] - ((prevLoTs[j] - preCalcLoTs[i][j]) * percentage) + 'px');
								}
							});
						},
						duration: o.duration,
						easing: o.easing
					});
				});
			});
			if (!o.sticky) {
				container.bind("mouseleave", function () {
					var prevWoHs = [];
					var prevLoTs = [];
					kwicks.removeClass('active').stop();
					for (i = 0; i < kwicks.size(); i++) {
						prevWoHs[i] = kwicks.eq(i).css(WoH).replace(/px/, '');
						prevLoTs[i] = kwicks.eq(i).css(LoT).replace(/px/, '');
					}
					var aniObj = {};
					aniObj[WoH] = normWoH;
					var normDif = normWoH - prevWoHs[0];
					kwicks.eq(0).animate(aniObj, {
						step: function (now) {
							var percentage = normDif != 0 ? (now - prevWoHs[0]) / normDif : 1;
							for (i = 1; i < kwicks.size(); i++) {
								kwicks.eq(i).css(WoH, prevWoHs[i] - ((prevWoHs[i] - normWoH) * percentage) + 'px');
								if (i < kwicks.size() - 1) {
									kwicks.eq(i).css(LoT, prevLoTs[i] - ((prevLoTs[i] - ((i * normWoH) + (i * o.spacing))) * percentage) + 'px');
								}
							}
						},
						duration: o.duration,
						easing: o.easing
					});

					if (cOldHash != "#Home") { $('.kwicks [hash_ref="' + cOldHash + '"]').mouseover(); }

				});
			}
		});
	};
})(jQuery);

//Cookie Lib
jQuery.cookie = function(name, value, options) {

/**

 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 *

 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */


    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


 // dateFormat
var dateFormat = function () {

	/*
	* Date Format 1.2.3
	* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
	* MIT license
	*
	* Includes enhancements by Scott Trenda <scott.trenda.net>
	* and Kris Kowal <cixar.com/~kris.kowal/>
	*
	* Accepts a date, a mask, or a date and a mask.
	* Returns a formatted version of the given date.
	* The date defaults to the current date/time.
	* The mask defaults to dateFormat.masks.default.
	*/

	var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;
		this.masks = {
			"default": "ddd mmm dd yyyy HH:MM:ss",
			smallDate: "m/d",
			shortDate: "m/d/yy",
			interbaseDate: "mm-dd-yy",
			mediumDate: "mmm d, yyyy",
			longDate: "mmmm d, yyyy",
			fullDate: "dddd, mmmm d, yyyy",
			shortTime: "h:MM tt",
			mediumTime: "h:MM:ss TT",
			longTime: "h:MM:ss TT Z",
			shortDateTime: "m/d/yy h:MM tt",
			isoDate: "yyyy-mm-dd",
			isoTime: "HH:MM:ss",
			isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
			isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
		};

		// Internationalization strings
		this.i18n = {
			dayNames: [
				"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
				"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
			],
			monthNames: [
				"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
				"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
			]
		};


		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(this.masks[mask] || mask || this.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var _ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d: d,
				dd: pad(d),
				ddd: this.i18n.dayNames[D],
				dddd: this.i18n.dayNames[D + 7],
				m: m + 1,
				mm: pad(m + 1),
				mmm: this.i18n.monthNames[m],
				mmmm: this.i18n.monthNames[m + 12],
				yy: String(y).slice(2),
				yyyy: y,
				h: H % 12 || 12,
				hh: pad(H % 12 || 12),
				H: H,
				HH: pad(H),
				M: M,
				MM: pad(M),
				s: s,
				ss: pad(s),
				l: pad(L, 3),
				L: pad(L > 99 ? Math.round(L / 10) : L),
				t: H < 12 ? "a" : "p",
				tt: H < 12 ? "am" : "pm",
				T: H < 12 ? "A" : "P",
				TT: H < 12 ? "AM" : "PM",
				Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
} ();

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


function doDatejs() {
	//Datejs
	/**
	* Version: 1.0 Alpha-1 
	* Build Date: 13-Nov-2007
	* Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved.
	* License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. 
	* Website: http://www.datejs.com/ or http://www.coolite.com/datejs/
	*/

	Date.CultureInfo = { name: "en-US", englishName: "English (United States)", nativeName: "English (United States)", dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"], monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], amDesignator: "AM", pmDesignator: "PM", firstDayOfWeek: 0, twoDigitYearMax: 2029, dateElementOrder: "mdy", formatPatterns: { shortDate: "M/d/yyyy", longDate: "dddd, MMMM dd, yyyy", shortTime: "h:mm tt", longTime: "h:mm:ss tt", fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", sortableDateTime: "yyyy-MM-ddTHH:mm:ss", universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT", monthDay: "MMMM dd", yearMonth: "MMMM, yyyy" }, regexPatterns: { jan: /^jan(uary)?/i, feb: /^feb(ruary)?/i, mar: /^mar(ch)?/i, apr: /^apr(il)?/i, may: /^may/i, jun: /^jun(e)?/i, jul: /^jul(y)?/i, aug: /^aug(ust)?/i, sep: /^sep(t(ember)?)?/i, oct: /^oct(ober)?/i, nov: /^nov(ember)?/i, dec: /^dec(ember)?/i, sun: /^su(n(day)?)?/i, mon: /^mo(n(day)?)?/i, tue: /^tu(e(s(day)?)?)?/i, wed: /^we(d(nesday)?)?/i, thu: /^th(u(r(s(day)?)?)?)?/i, fri: /^fr(i(day)?)?/i, sat: /^sa(t(urday)?)?/i, future: /^next/i, past: /^last|past|prev(ious)?/i, add: /^(\+|after|from)/i, subtract: /^(\-|before|ago)/i, yesterday: /^yesterday/i, today: /^t(oday)?/i, tomorrow: /^tomorrow/i, now: /^n(ow)?/i, millisecond: /^ms|milli(second)?s?/i, second: /^sec(ond)?s?/i, minute: /^min(ute)?s?/i, hour: /^h(ou)?rs?/i, week: /^w(ee)?k/i, month: /^m(o(nth)?s?)?/i, day: /^d(ays?)?/i, year: /^y((ea)?rs?)?/i, shortMeridian: /^(a|p)/i, longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i, timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i, ordinalSuffix: /^\s*(st|nd|rd|th)/i, timeContext: /^\s*(\:|a|p)/i }, abbreviatedTimeZoneStandard: { GMT: "-000", EST: "-0400", CST: "-0500", MST: "-0600", PST: "-0700" }, abbreviatedTimeZoneDST: { GMT: "-000", EDT: "-0500", CDT: "-0600", MDT: "-0700", PDT: "-0800"} };
	Date.getMonthNumberFromName = function(name) {
		var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) { return i; } }
		return -1;
	}; Date.getDayNumberFromName = function(name) {
		var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, o = Date.CultureInfo.shortestDayNames, s = name.toLowerCase(); for (var i = 0; i < n.length; i++) { if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) { return i; } }
		return -1;
	}; Date.isLeapYear = function(year) { return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)); }; Date.getDaysInMonth = function(year, month) { return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; }; Date.getTimezoneOffset = function(s, dst) { return (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST[s.toUpperCase()] : Date.CultureInfo.abbreviatedTimeZoneStandard[s.toUpperCase()]; }; Date.getTimezoneAbbreviation = function(offset, dst) {
		var n = (dst || false) ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard, p; for (p in n) { if (n[p] === offset) { return p; } }
		return null;
	}; Date.prototype.clone = function() { return new Date(this.getTime()); }; Date.prototype.compareTo = function(date) {
		if (isNaN(this)) { throw new Error(this); }
		if (date instanceof Date && !isNaN(date)) { return (this > date) ? 1 : (this < date) ? -1 : 0; } else { throw new TypeError(date); } 
	}; Date.prototype.equals = function(date) { return (this.compareTo(date) === 0); }; Date.prototype.between = function(start, end) { var t = this.getTime(); return t >= start.getTime() && t <= end.getTime(); }; Date.prototype.addMilliseconds = function(value) { this.setMilliseconds(this.getMilliseconds() + value); return this; }; Date.prototype.addSeconds = function(value) { return this.addMilliseconds(value * 1000); }; Date.prototype.addMinutes = function(value) { return this.addMilliseconds(value * 60000); }; Date.prototype.addHours = function(value) { return this.addMilliseconds(value * 3600000); }; Date.prototype.addDays = function(value) { return this.addMilliseconds(value * 86400000); }; Date.prototype.addWeeks = function(value) { return this.addMilliseconds(value * 604800000); }; Date.prototype.addMonths = function(value) { var n = this.getDate(); this.setDate(1); this.setMonth(this.getMonth() + value); this.setDate(Math.min(n, this.getDaysInMonth())); return this; }; Date.prototype.addYears = function(value) { return this.addMonths(value * 12); }; Date.prototype.add = function(config) {
		if (typeof config == "number") { this._orient = config; return this; }
		var x = config; if (x.millisecond || x.milliseconds) { this.addMilliseconds(x.millisecond || x.milliseconds); }
		if (x.second || x.seconds) { this.addSeconds(x.second || x.seconds); }
		if (x.minute || x.minutes) { this.addMinutes(x.minute || x.minutes); }
		if (x.hour || x.hours) { this.addHours(x.hour || x.hours); }
		if (x.month || x.months) { this.addMonths(x.month || x.months); }
		if (x.year || x.years) { this.addYears(x.year || x.years); }
		if (x.day || x.days) { this.addDays(x.day || x.days); }
		return this;
	}; Date._validate = function(value, min, max, name) {
		if (typeof value != "number") { throw new TypeError(value + " is not a Number."); } else if (value < min || value > max) { throw new RangeError(value + " is not a valid value for " + name + "."); }
		return true;
	}; Date.validateMillisecond = function(n) { return Date._validate(n, 0, 999, "milliseconds"); }; Date.validateSecond = function(n) { return Date._validate(n, 0, 59, "seconds"); }; Date.validateMinute = function(n) { return Date._validate(n, 0, 59, "minutes"); }; Date.validateHour = function(n) { return Date._validate(n, 0, 23, "hours"); }; Date.validateDay = function(n, year, month) { return Date._validate(n, 1, Date.getDaysInMonth(year, month), "days"); }; Date.validateMonth = function(n) { return Date._validate(n, 0, 11, "months"); }; Date.validateYear = function(n) { return Date._validate(n, 1, 9999, "seconds"); }; Date.prototype.set = function(config) {
		var x = config; if (!x.millisecond && x.millisecond !== 0) { x.millisecond = -1; }
		if (!x.second && x.second !== 0) { x.second = -1; }
		if (!x.minute && x.minute !== 0) { x.minute = -1; }
		if (!x.hour && x.hour !== 0) { x.hour = -1; }
		if (!x.day && x.day !== 0) { x.day = -1; }
		if (!x.month && x.month !== 0) { x.month = -1; }
		if (!x.year && x.year !== 0) { x.year = -1; }
		if (x.millisecond != -1 && Date.validateMillisecond(x.millisecond)) { this.addMilliseconds(x.millisecond - this.getMilliseconds()); }
		if (x.second != -1 && Date.validateSecond(x.second)) { this.addSeconds(x.second - this.getSeconds()); }
		if (x.minute != -1 && Date.validateMinute(x.minute)) { this.addMinutes(x.minute - this.getMinutes()); }
		if (x.hour != -1 && Date.validateHour(x.hour)) { this.addHours(x.hour - this.getHours()); }
		if (x.month !== -1 && Date.validateMonth(x.month)) { this.addMonths(x.month - this.getMonth()); }
		if (x.year != -1 && Date.validateYear(x.year)) { this.addYears(x.year - this.getFullYear()); }
		if (x.day != -1 && Date.validateDay(x.day, this.getFullYear(), this.getMonth())) { this.addDays(x.day - this.getDate()); }
		if (x.timezone) { this.setTimezone(x.timezone); }
		if (x.timezoneOffset) { this.setTimezoneOffset(x.timezoneOffset); }
		return this;
	}; Date.prototype.clearTime = function() { this.setHours(0); this.setMinutes(0); this.setSeconds(0); this.setMilliseconds(0); return this; }; Date.prototype.isLeapYear = function() { var y = this.getFullYear(); return (((y % 4 === 0) && (y % 100 !== 0)) || (y % 400 === 0)); }; Date.prototype.isWeekday = function() { return !(this.is().sat() || this.is().sun()); }; Date.prototype.getDaysInMonth = function() { return Date.getDaysInMonth(this.getFullYear(), this.getMonth()); }; Date.prototype.moveToFirstDayOfMonth = function() { return this.set({ day: 1 }); }; Date.prototype.moveToLastDayOfMonth = function() { return this.set({ day: this.getDaysInMonth() }); }; Date.prototype.moveToDayOfWeek = function(day, orient) { var diff = (day - this.getDay() + 7 * (orient || +1)) % 7; return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff); }; Date.prototype.moveToMonth = function(month, orient) { var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12; return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff); }; Date.prototype.getDayOfYear = function() { return Math.floor((this - new Date(this.getFullYear(), 0, 1)) / 86400000); }; Date.prototype.getWeekOfYear = function(firstDayOfWeek) {
		var y = this.getFullYear(), m = this.getMonth(), d = this.getDate(); var dow = firstDayOfWeek || Date.CultureInfo.firstDayOfWeek; var offset = 7 + 1 - new Date(y, 0, 1).getDay(); if (offset == 8) { offset = 1; }
		var daynum = ((Date.UTC(y, m, d, 0, 0, 0) - Date.UTC(y, 0, 1, 0, 0, 0)) / 86400000) + 1; var w = Math.floor((daynum - offset + 7) / 7); if (w === dow) { y--; var prevOffset = 7 + 1 - new Date(y, 0, 1).getDay(); if (prevOffset == 2 || prevOffset == 8) { w = 53; } else { w = 52; } }
		return w;
	}; Date.prototype.isDST = function() { console.log('isDST'); return this.toString().match(/(E|C|M|P)(S|D)T/)[2] == "D"; }; Date.prototype.getTimezone = function() { return Date.getTimezoneAbbreviation(this.getUTCOffset, this.isDST()); }; Date.prototype.setTimezoneOffset = function(s) { var here = this.getTimezoneOffset(), there = Number(s) * -6 / 10; this.addMinutes(there - here); return this; }; Date.prototype.setTimezone = function(s) { return this.setTimezoneOffset(Date.getTimezoneOffset(s)); }; Date.prototype.getUTCOffset = function() { var n = this.getTimezoneOffset() * -10 / 6, r; if (n < 0) { r = (n - 10000).toString(); return r[0] + r.substr(2); } else { r = (n + 10000).toString(); return "+" + r.substr(1); } }; Date.prototype.getDayName = function(abbrev) { return abbrev ? Date.CultureInfo.abbreviatedDayNames[this.getDay()] : Date.CultureInfo.dayNames[this.getDay()]; }; Date.prototype.getMonthName = function(abbrev) { return abbrev ? Date.CultureInfo.abbreviatedMonthNames[this.getMonth()] : Date.CultureInfo.monthNames[this.getMonth()]; }; Date.prototype._toString = Date.prototype.toString; Date.prototype.toString = function(format) { var self = this; var p = function p(s) { return (s.toString().length == 1) ? "0" + s : s; }; return format ? format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g, function(format) { switch (format) { case "hh": return p(self.getHours() < 13 ? self.getHours() : (self.getHours() - 12)); case "h": return self.getHours() < 13 ? self.getHours() : (self.getHours() - 12); case "HH": return p(self.getHours()); case "H": return self.getHours(); case "mm": return p(self.getMinutes()); case "m": return self.getMinutes(); case "ss": return p(self.getSeconds()); case "s": return self.getSeconds(); case "yyyy": return self.getFullYear(); case "yy": return self.getFullYear().toString().substring(2, 4); case "dddd": return self.getDayName(); case "ddd": return self.getDayName(true); case "dd": return p(self.getDate()); case "d": return self.getDate().toString(); case "MMMM": return self.getMonthName(); case "MMM": return self.getMonthName(true); case "MM": return p((self.getMonth() + 1)); case "M": return self.getMonth() + 1; case "t": return self.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); case "tt": return self.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; case "zzz": case "zz": case "z": return ""; } }) : this._toString(); };
	Date.now = function() { return new Date(); }; Date.today = function() { return Date.now().clearTime(); }; Date.prototype._orient = +1; Date.prototype.next = function() { this._orient = +1; return this; }; Date.prototype.last = Date.prototype.prev = Date.prototype.previous = function() { this._orient = -1; return this; }; Date.prototype._is = false; Date.prototype.is = function() { this._is = true; return this; }; Number.prototype._dateElement = "day"; Number.prototype.fromNow = function() { var c = {}; c[this._dateElement] = this; return Date.now().add(c); }; Number.prototype.ago = function() { var c = {}; c[this._dateElement] = this * -1; return Date.now().add(c); }; (function() {
		var $D = Date.prototype, $N = Number.prototype; var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), mx = ("january february march april may june july august september october november december").split(/\s/), px = ("Millisecond Second Minute Hour Day Week Month Year").split(/\s/), de; var df = function(n) {
			return function() {
				if (this._is) { this._is = false; return this.getDay() == n; }
				return this.moveToDayOfWeek(n, this._orient);
			};
		}; for (var i = 0; i < dx.length; i++) { $D[dx[i]] = $D[dx[i].substring(0, 3)] = df(i); }
		var mf = function(n) {
			return function() {
				if (this._is) { this._is = false; return this.getMonth() === n; }
				return this.moveToMonth(n, this._orient);
			};
		}; for (var j = 0; j < mx.length; j++) { $D[mx[j]] = $D[mx[j].substring(0, 3)] = mf(j); }
		var ef = function(j) {
			return function() {
				if (j.substring(j.length - 1) != "s") { j += "s"; }
				return this["add" + j](this._orient);
			};
		}; var nf = function(n) { return function() { this._dateElement = n; return this; }; }; for (var k = 0; k < px.length; k++) { de = px[k].toLowerCase(); $D[de] = $D[de + "s"] = ef(px[k]); $N[de] = $N[de + "s"] = nf(de); } 
	} ()); Date.prototype.toJSONString = function() { return this.toString("yyyy-MM-ddThh:mm:ssZ"); }; Date.prototype.toShortDateString = function() { return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern); }; Date.prototype.toLongDateString = function() { return this.toString(Date.CultureInfo.formatPatterns.longDatePattern); }; Date.prototype.toShortTimeString = function() { return this.toString(Date.CultureInfo.formatPatterns.shortTimePattern); }; Date.prototype.toLongTimeString = function() { return this.toString(Date.CultureInfo.formatPatterns.longTimePattern); }; Date.prototype.getOrdinal = function() { switch (this.getDate()) { case 1: case 21: case 31: return "st"; case 2: case 22: return "nd"; case 3: case 23: return "rd"; default: return "th"; } };
	(function() {
		Date.Parsing = { Exception: function(s) { this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; } }; var $P = Date.Parsing; var _ = $P.Operators = { rtoken: function(r) { return function(s) { var mx = s.match(r); if (mx) { return ([mx[0], s.substring(mx[0].length)]); } else { throw new $P.Exception(s); } }; }, token: function(s) { return function(s) { return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s); }; }, stoken: function(s) { return _.rtoken(new RegExp("^" + s)); }, until: function(p) {
			return function(s) {
				var qx = [], rx = null; while (s.length) {
					try { rx = p.call(this, s); } catch (e) { qx.push(rx[0]); s = rx[1]; continue; }
					break;
				}
				return [qx, s];
			};
		}, many: function(p) {
			return function(s) {
				var rx = [], r = null; while (s.length) {
					try { r = p.call(this, s); } catch (e) { return [rx, s]; }
					rx.push(r[0]); s = r[1];
				}
				return [rx, s];
			};
		}, optional: function(p) {
			return function(s) {
				var r = null; try { r = p.call(this, s); } catch (e) { return [null, s]; }
				return [r[0], r[1]];
			};
		}, not: function(p) {
			return function(s) {
				try { p.call(this, s); } catch (e) { return [null, s]; }
				throw new $P.Exception(s);
			};
		}, ignore: function(p) { return p ? function(s) { var r = null; r = p.call(this, s); return [null, r[1]]; } : null; }, product: function() {
			var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = []; for (var i = 0; i < px.length; i++) { rx.push(_.each(px[i], qx)); }
			return rx;
		}, cache: function(rule) {
			var cache = {}, r = null; return function(s) {
				try { r = cache[s] = (cache[s] || rule.call(this, s)); } catch (e) { r = cache[s] = e; }
				if (r instanceof $P.Exception) { throw r; } else { return r; } 
			};
		}, any: function() {
			var px = arguments; return function(s) {
				var r = null; for (var i = 0; i < px.length; i++) {
					if (px[i] == null) { continue; }
					try { r = (px[i].call(this, s)); } catch (e) { r = null; }
					if (r) { return r; } 
				}
				throw new $P.Exception(s);
			};
		}, each: function() {
			var px = arguments; return function(s) {
				var rx = [], r = null; for (var i = 0; i < px.length; i++) {
					if (px[i] == null) { continue; }
					try { r = (px[i].call(this, s)); } catch (e) { throw new $P.Exception(s); }
					rx.push(r[0]); s = r[1];
				}
				return [rx, s];
			};
		}, all: function() { var px = arguments, _ = _; return _.each(_.optional(px)); }, sequence: function(px, d, c) {
			d = d || _.rtoken(/^\s*/); c = c || null; if (px.length == 1) { return px[0]; }
			return function(s) {
				var r = null, q = null; var rx = []; for (var i = 0; i < px.length; i++) {
					try { r = px[i].call(this, s); } catch (e) { break; }
					rx.push(r[0]); try { q = d.call(this, r[1]); } catch (ex) { q = null; break; }
					s = q[1];
				}
				if (!r) { throw new $P.Exception(s); }
				if (q) { throw new $P.Exception(q[1]); }
				if (c) { try { r = c.call(this, r[1]); } catch (ey) { throw new $P.Exception(r[1]); } }
				return [rx, (r ? r[1] : s)];
			};
		}, between: function(d1, p, d2) { d2 = d2 || d1; var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); return function(s) { var rx = _fn.call(this, s); return [[rx[0][0], r[0][2]], rx[1]]; }; }, list: function(p, d, c) { d = d || _.rtoken(/^\s*/); c = c || null; return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); }, set: function(px, d, c) {
			d = d || _.rtoken(/^\s*/); c = c || null; return function(s) {
				var r = null, p = null, q = null, rx = null, best = [[], s], last = false; for (var i = 0; i < px.length; i++) {
					q = null; p = null; r = null; last = (px.length == 1); try { r = px[i].call(this, s); } catch (e) { continue; }
					rx = [[r[0]], r[1]]; if (r[1].length > 0 && !last) { try { q = d.call(this, r[1]); } catch (ex) { last = true; } } else { last = true; }
					if (!last && q[1].length === 0) { last = true; }
					if (!last) {
						var qx = []; for (var j = 0; j < px.length; j++) { if (i != j) { qx.push(px[j]); } }
						p = _.set(qx, d).call(this, q[1]); if (p[0].length > 0) { rx[0] = rx[0].concat(p[0]); rx[1] = p[1]; } 
					}
					if (rx[1].length < best[1].length) { best = rx; }
					if (best[1].length === 0) { break; } 
				}
				if (best[0].length === 0) { return best; }
				if (c) {
					try { q = c.call(this, best[1]); } catch (ey) { throw new $P.Exception(best[1]); }
					best[1] = q[1];
				}
				return best;
			};
		}, forward: function(gr, fname) { return function(s) { return gr[fname].call(this, s); }; }, replace: function(rule, repl) { return function(s) { var r = rule.call(this, s); return [repl, r[1]]; }; }, process: function(rule, fn) { return function(s) { var r = rule.call(this, s); return [fn.call(this, r[0]), r[1]]; }; }, min: function(min, rule) {
			return function(s) {
				var rx = rule.call(this, s); if (rx[0].length < min) { throw new $P.Exception(s); }
				return rx;
			};
		} 
		}; var _generator = function(op) {
			return function() {
				var args = null, rx = []; if (arguments.length > 1) { args = Array.prototype.slice.call(arguments); } else if (arguments[0] instanceof Array) { args = arguments[0]; }
				if (args) { for (var i = 0, px = args.shift(); i < px.length; i++) { args.unshift(px[i]); rx.push(op.apply(null, args)); args.shift(); return rx; } } else { return op.apply(null, arguments); } 
			};
		}; var gx = "optional not ignore cache".split(/\s/); for (var i = 0; i < gx.length; i++) { _[gx[i]] = _generator(_[gx[i]]); }
		var _vector = function(op) { return function() { if (arguments[0] instanceof Array) { return op.apply(null, arguments[0]); } else { return op.apply(null, arguments); } }; }; var vx = "each any all".split(/\s/); for (var j = 0; j < vx.length; j++) { _[vx[j]] = _vector(_[vx[j]]); } 
	} ()); (function() {
		var flattenAndCompact = function(ax) {
			var rx = []; for (var i = 0; i < ax.length; i++) { if (ax[i] instanceof Array) { rx = rx.concat(flattenAndCompact(ax[i])); } else { if (ax[i]) { rx.push(ax[i]); } } }
			return rx;
		}; Date.Grammar = {}; Date.Translator = { hour: function(s) { return function() { this.hour = Number(s); }; }, minute: function(s) { return function() { this.minute = Number(s); }; }, second: function(s) { return function() { this.second = Number(s); }; }, meridian: function(s) { return function() { this.meridian = s.slice(0, 1).toLowerCase(); }; }, timezone: function(s) { return function() { var n = s.replace(/[^\d\+\-]/g, ""); if (n.length) { this.timezoneOffset = Number(n); } else { this.timezone = s.toLowerCase(); } }; }, day: function(x) { var s = x[0]; return function() { this.day = Number(s.match(/\d+/)[0]); }; }, month: function(s) { return function() { this.month = ((s.length == 3) ? Date.getMonthNumberFromName(s) : (Number(s) - 1)); }; }, year: function(s) { return function() { var n = Number(s); this.year = ((s.length > 2) ? n : (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900))); }; }, rday: function(s) { return function() { switch (s) { case "yesterday": this.days = -1; break; case "tomorrow": this.days = 1; break; case "today": this.days = 0; break; case "now": this.days = 0; this.now = true; break; } }; }, finishExact: function(x) {
			x = (x instanceof Array) ? x : [x]; var now = new Date(); this.year = now.getFullYear(); this.month = now.getMonth(); this.day = 1; this.hour = 0; this.minute = 0; this.second = 0; for (var i = 0; i < x.length; i++) { if (x[i]) { x[i].call(this); } }
			this.hour = (this.meridian == "p" && this.hour < 13) ? this.hour + 12 : this.hour; if (this.day > Date.getDaysInMonth(this.year, this.month)) { throw new RangeError(this.day + " is not a valid value for days."); }
			var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second); if (this.timezone) { r.set({ timezone: this.timezone }); } else if (this.timezoneOffset) { r.set({ timezoneOffset: this.timezoneOffset }); }
			return r;
		}, finish: function(x) {
			x = (x instanceof Array) ? flattenAndCompact(x) : [x]; if (x.length === 0) { return null; }
			for (var i = 0; i < x.length; i++) { if (typeof x[i] == "function") { x[i].call(this); } }
			if (this.now) { return new Date(); }
			var today = Date.today(); var method = null; var expression = !!(this.days != null || this.orient || this.operator); if (expression) {
				var gap, mod, orient; orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); if (this.weekday) { this.unit = "day"; gap = (Date.getDayNumberFromName(this.weekday) - today.getDay()); mod = 7; this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); }
				if (this.month) { this.unit = "month"; gap = (this.month - today.getMonth()); mod = 12; this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); this.month = null; }
				if (!this.unit) { this.unit = "day"; }
				if (this[this.unit + "s"] == null || this.operator != null) {
					if (!this.value) { this.value = 1; }
					if (this.unit == "week") { this.unit = "day"; this.value = this.value * 7; }
					this[this.unit + "s"] = this.value * orient;
				}
				return today.add(this);
			} else {
				if (this.meridian && this.hour) { this.hour = (this.hour < 13 && this.meridian == "p") ? this.hour + 12 : this.hour; }
				if (this.weekday && !this.day) { this.day = (today.addDays((Date.getDayNumberFromName(this.weekday) - today.getDay()))).getDate(); }
				if (this.month && !this.day) { this.day = 1; }
				return today.set(this);
			} 
		} 
		}; var _ = Date.Parsing.Operators, g = Date.Grammar, t = Date.Translator, _fn; g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); g.timePartDelimiter = _.stoken(":"); g.whiteSpace = _.rtoken(/^\s*/); g.generalDelimiter = _.rtoken(/^(([\s\,]|at|on)+)/); var _C = {}; g.ctoken = function(keys) {
			var fn = _C[keys]; if (!fn) {
				var c = Date.CultureInfo.regexPatterns; var kx = keys.split(/\s+/), px = []; for (var i = 0; i < kx.length; i++) { px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); }
				fn = _C[keys] = _.any.apply(null, px);
			}
			return fn;
		}; g.ctoken2 = function(key) { return _.rtoken(Date.CultureInfo.regexPatterns[key]); }; g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour)); g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour)); g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour)); g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour)); g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute)); g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute)); g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)); g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)); g.hms = _.cache(_.sequence([g.H, g.mm, g.ss], g.timePartDelimiter)); g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)); g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)); g.z = _.cache(_.process(_.rtoken(/^(\+|\-)?\s*\d\d\d\d?/), t.timezone)); g.zz = _.cache(_.process(_.rtoken(/^(\+|\-)\s*\d\d\d\d/), t.timezone)); g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)); g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([g.tt, g.zzz])); g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function(s) { return function() { this.weekday = s; }; })); g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month)); g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month)); g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year)); g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year)); g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year)); g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year)); _fn = function() { return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); }; g.day = _fn(g.d, g.dd); g.month = _fn(g.M, g.MMM); g.year = _fn(g.yyyy, g.yy); g.orientation = _.process(g.ctoken("past future"), function(s) { return function() { this.orient = s; }; }); g.operator = _.process(g.ctoken("add subtract"), function(s) { return function() { this.operator = s; }; }); g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); g.unit = _.process(g.ctoken("minute hour day week month year"), function(s) { return function() { this.unit = s; }; }); g.value = _.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/), function(s) { return function() { this.value = s.replace(/\D/g, ""); }; }); g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM]); _fn = function() { return _.set(arguments, g.datePartDelimiter); }; g.mdy = _fn(g.ddd, g.month, g.day, g.year); g.ymd = _fn(g.ddd, g.year, g.month, g.day); g.dmy = _fn(g.ddd, g.day, g.month, g.year); g.date = function(s) { return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); }; g.format = _.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function(fmt) { if (g[fmt]) { return g[fmt]; } else { throw Date.Parsing.Exception(fmt); } }), _.process(_.rtoken(/^[^dMyhHmstz]+/), function(s) { return _.ignore(_.stoken(s)); }))), function(rules) { return _.process(_.each.apply(null, rules), t.finishExact); }); var _F = {}; var _get = function(f) { return _F[f] = (_F[f] || g.format(f)[0]); }; g.formats = function(fx) {
			if (fx instanceof Array) {
				var rx = []; for (var i = 0; i < fx.length; i++) { rx.push(_get(fx[i])); }
				return _.any.apply(null, rx);
			} else { return _get(fx); } 
		}; g._formats = g.formats(["yyyy-MM-ddTHH:mm:ss", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "d"]); g._start = _.process(_.set([g.date, g.time, g.expression], g.generalDelimiter, g.whiteSpace), t.finish); g.start = function(s) {
			try { var r = g._formats.call({}, s); if (r[1].length === 0) { return r; } } catch (e) { }
			return g._start.call({}, s);
		};
	} ()); Date._parse = Date.parse; Date.parse = function(s) {
		var r = null; if (!s) { return null; }
		try { r = Date.Grammar.start.call({}, s); } catch (e) { return null; }
		return ((r[1].length === 0) ? r[0] : null);
	}; Date.getParseFunction = function(fx) {
		var fn = Date.Grammar.formats(fx); return function(s) {
			var r = null; try { r = fn.call({}, s); } catch (e) { return null; }
			return ((r[1].length === 0) ? r[0] : null);
		};
	}; Date.parseExact = function(s, fx) { return Date.getParseFunction(fx)(s); };
}
doDatejs();

//** Drill Down Menu v1.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/drilldownmenu.htm
//** June 8th, 2009: Script Creation date
//** June 10th, 2009: v1.01: Minor update
//* Drill Down{
//Version 1.5: June 21st, 09':
//**1) Ability to include menu from external file and added to page via Ajax
//**2) Adds support for arbitrary links to act as "back buttons" for a drill menu. Just give the link a rel="drillback-menuid" attribute
//**3) Adds drillmenuinstance.back() method, which can be called on demand to go back one level within drill menu
//**4) Fixes bug with background ULs being visible following foreground UL contents
//**5) Updated css so browsers with JS disabled will get a scrolling, fixed height UL

//Version 1.6: August 9th, 09': Adds ability to specify explicit height for main menu, instead of defaulting to top UL's natural height.


function drilldownmenu(setting){
	this.sublevelarrow={src:'right.gif', width:'8px', top:'3px', left:'6px'} //full URL to image used to indicate there's a sub level
	this.breadcrumbarrow='images/right.gif' //full URL to image separating breadcrumb links (if it's defined)
	this.loadingimage='loader.gif' //full URL to 'loading' image, if menu is loaded via Ajax
	this.homecrumbtext='All Topics' //Top level crumb text
	this.titlelength=35 //length of parent LI text to extract from to use as crumb titles
	this.backarrow='leftarrow.gif' //full URL to image added in front of back LI 

	////////// No need to edit beyond here /////////////
	this.menuid=setting.menuid
	this.$menudiv=null
	this.mainul=null
	this.$uls=null
	this.navdivs={}
	this.menuheight=setting.menuheight || 'auto'
	this.selectedul=setting.selectedul || null
	this.speed=setting.speed || 70
	this.persist=setting.persist || {enable: false, overrideselectedurl: false}
	this.$arrowimgs=null
	this.currentul=0
	this.filesetting=setting.filesetting || {url: null, targetElement: null}
	this.zIndexvalue=100
	this.arrowposx=0 //default arrow x position relative to parent LI
	var thisdrill=this
	thisdrill.init(setting)
	$(".drillmenu li a").addClass("ui-corner-all").hover(
		function() { $(this).addClass("ui-state-hover");},
		function() { $(this).removeClass("ui-state-hover");}
		);
}

drilldownmenu.prototype.init = function(setting) {
	var thisdrill = this;
	//relative position main DIV
	var $maindiv = $('#' + setting.menuid).css({ position: 'relative' });
	//$maindiv.find("a").addclass("ui-state-default ui-corner-all");
	var $uls = $maindiv.find('ul')
	//absolutely position ULs
	$uls.css({ position: 'absolute', left: 0, top: 0, visibility: 'hidden' });
	this.$maindiv = $maindiv;
	this.$uls = $uls;
	this.navdivs.$crumb = $('#' + setting.breadcrumbid);
	this.navdivs.$backbuttons = $('a[rel^="drillback-' + setting.menuid + '"]').css({ outline: 'none' })
		.click(function(e) {
			thisdrill.back();
			e.preventDefault();
		})
	this.buildmenu();
	$(window).bind('unload', function() {
		thisdrill.uninit();
	})
	setting = null;
}

drilldownmenu.prototype.buildmenu = function() {
	var thisdrill = this;
	//loop through each UL

	this.$uls.each(function(i) {
		var $thisul = $(this);
		if (i == 0) { //if topmost UL
			$('<li class="backcontroltitle ui-corner-all ui-state-default">Select a Topic:</li>').prependTo($thisul)
				.click(function(e) { e.preventDefault() });
			//set main menu DIV's height to top level UL's height
			thisdrill.$maindiv
				.css({ height: (thisdrill.menuheight == 'auto') ? $thisul.outerHeight() : parseInt(thisdrill.menuheight), overflow: 'hidden' })
				.data('h', parseInt(thisdrill.$maindiv.css('height')));
		}
		else { //if this isn't the topmost UL
			var $parentul = $thisul.parents('ul:eq(0)');
			var $parentli = $thisul.parents('li:eq(0)');
			//add back LI item
			$('<li class="backcontrol ui-corner-all ui-state-default">' +
					$parentli[0].firstChild.innerHTML +'</li>')
				.click(function(e) { thisdrill.back(); e.preventDefault() })
				.prependTo($thisul);
			//remove outline from anchor links
			var $anchorlink = $parentli.children('a:eq(0)').data('control', { order: i })
				.append('<span class="DDMenu-SubMenuIndicator ui-icon ui-icon-triangle-1-e"/>');
			//assign click behavior to anchor link
			$anchorlink.click(function(e) {
				thisdrill.slidemenu(jQuery(this).data('control').order);
				e.preventDefault();
			});
		}
		var ulheight = ($thisul.outerHeight() < thisdrill.$maindiv.data('h')) ? thisdrill.$maindiv.data('h') : 'auto';
		$thisul.css({ visibility: 'visible', width: '100%', height: ulheight, left: (i == 0) ? 'auto' : $parentli.outerWidth(), top: 0 });
		$thisul.data('specs', {
			w: $thisul.outerWidth(),
			h: $thisul.outerHeight(),
			order: i,
			parentorder: (i == 0) ? -1 : $anchorlink.parents('ul:eq(0)').data('specs').order,
			x: (i == 0) ? $thisul.position().left : $parentul.data('specs').x + $parentul.data('specs').w,
			title: (i == 0) ? thisdrill.homecrumbtext : $parentli.find('a:eq(0)').text().substring(0, thisdrill.titlelength)
		});
	}) //end UL loop
	//check if "selectedul" defined, plus if actual element exists
	var selectedulcheck = this.selectedul && document.getElementById(this.selectedul)
	this.$arrowimgs = this.$maindiv.find('img.arrowclass')
	this.arrowposx = parseInt(this.$arrowimgs.eq(0).css('left')) //get default x position of arrow
	if (window.opera)
		this.$uls.eq(0).css({ zIndex: this.zIndexvalue }) //Opera seems to require this in order for top level arrows to show
	if (this.persist.enable && (this.persist.overrideselectedul || !this.persist.overrideselectedul && !selectedulcheck) && drilldownmenu.routines.getCookie(this.menuid)) { //go to last persisted UL?
		var ulorder = parseInt(drilldownmenu.routines.getCookie(this.menuid))
		this.slidemenu(ulorder, true)
	}
	else if (selectedulcheck) { //if "selectedul" setting defined, slide to that UL by default
		var ulorder = $('#' + this.selectedul).data('specs').order;
		this.slidemenu(ulorder, true);
	}
	else {
		this.slidemenu(0, true);
	}
	//assign click behavior to breadcrumb div
	this.navdivs.$crumb.click(function(e) {
		if (e.target.tagName == "A") {
			var order = parseInt(e.target.getAttribute('rel'));
			//check link contains a valid rel attribute int value (is anchor link)
			if (!isNaN(order)) {
				thisdrill.slidemenu(order);
				e.preventDefault();
			}
		}
	})
}

drilldownmenu.prototype.slidemenu=function(order, disableanimate){
	var order=isNaN(order)? 0 : order
	this.$uls.css({display: 'none'})
	var $targetul=this.$uls.eq(order).css({zIndex: this.zIndexvalue++})
	$targetul.parents('ul').andSelf().css({display: 'block'})
	this.currentul=order
	if ($targetul.data('specs').h > this.$maindiv.data('h')){
		this.$maindiv.css({overflowY:'auto'}).scrollTop(0)
		this.$arrowimgs.css('left', this.arrowposx-15) //adjust arrow position if scrollbar is added
	}
	else{
		this.$maindiv.css({overflowY: 'hidden'}).scrollTop(0)
		this.$arrowimgs.css('left', this.arrowposx)
	}
	this.updatenav(order)
	this.$uls.eq(0).animate({left:-$targetul.data('specs').x}, typeof disableanimate!="undefined"? 0 : this.speed)
}

drilldownmenu.prototype.back=function(){
	if (this.currentul>0){
		var order=this.$uls.eq(this.currentul).parents('ul:eq(0)').data('specs').order
		this.slidemenu(order)
	}
}

drilldownmenu.prototype.updatenav = function(endorder) {
	var $currentul = this.$uls.eq(endorder)
	if (this.navdivs.$crumb.length == 1) { //if breadcrumb div defined
		var $crumb = this.navdivs.$crumb.empty()
		if (endorder > 0) { //if this isn't the topmost UL (no point in showing crumbs if it is)
			var crumbhtml = ''
			while ($currentul && $currentul.data('specs').order >= 0) {
				crumbhtml = ' <img src="' + this.breadcrumbarrow + '" /> <a href="#nav" rel="' + $currentul.data('specs').order + '">' + $currentul.data('specs').title + '</a>' + crumbhtml
				$currentul = ($currentul.data('specs').order > 0) ? this.$uls.eq($currentul.data('specs').parentorder) : null
			}
			$crumb.append(crumbhtml).find('img:eq(0)').remove().end().find('a:last').replaceWith(this.$uls.eq(endorder).data('specs').title) //remove link from very last crumb trail
		}
		else {
			$crumb.append(this.homecrumbtext)
		}
	}
	if (this.navdivs.$backbuttons.length > 0) { //if back buttons found
		if (!/Safari/i.test(navigator.userAgent)) //exclude Safari from button state toggling due to bug when the button is an image link
			this.navdivs.$backbuttons.css((endorder > 0) ? { opacity: 1, cursor: 'pointer'} : { opacity: 0.5, cursor: 'default' })
	}
	if (endorder > 0) { $("#TipsMenuBackButton").show(); } else { $("#TipsMenuBackButton").hide(); }
}

drilldownmenu.prototype.uninit = function() {
	if (this.persist.enable)
		drilldownmenu.routines.setCookie(this.menuid, this.currentul);
}

drilldownmenu.routines={

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]*", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name+"="+value+"; path=/"
	}

}

// }  Drill down close


// Content hider
jQuery.fn.extend({
	/*
		image : '',
		color : '#fff',
		opacity : 65,
		func : function,
		text : ''
		text_style : {
			color : '#fff'
			'font-size' : '16px'
		}
	*/
	elapsor :
	function (a) {
		this.w = [this.innerWidth(),this.innerHeight()];
		this.s = [this.scrollLeft(),this.scrollTop()];
		a.opacity = a.opacity ? '0.'+a.opacity.toString() : .65;
		a.color = a.color ? a.color : '#000';
		a.text_style = a.text_style ? a.text_style : {
			color : '#fff',
			'font-size' : '16px'
		}
		this.mask = this.find('.ternMask').get(0);
		if(!this.mask) {
			this.mask = document.createElement('div');
			jQuery(this.mask).css({
				'display'	: 'none',
				'position'	: 'fixed',
				'clear'		: 'both',
				'overflow'	: 'hidden',
				'z-index'	: 50,
				'top'		: 0,
				'left'		: 0,
				'width'		: this.innerWidth()+this.get(0).scrollWidth,
				'height'	: this.innerHeight()+this.get(0).scrollHeight
			});
			if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
				jQuery(this.mask).css({'position':'absolute'});
			}
			this.prepend(this.mask);
			jQuery(this.mask).addClass('ternMask');
		}
		if(a.image || a.text) {
			this.createElapsor(a);
		}
		else if(this.elap) {
			jQuery(this.elap).css('display','none');
		}
		jQuery(this.mask).css({
			'opacity'			: a.opacity,
			'background-color'	: a.color,
			'display'			: 'block'
		});
		if(a.func) { a.func(); }
	},
	createElapsor :
	function (a) {
		this.elap = this.find('.ternElapsor').get(0);
		if(this.elap) {
			var i = $(this.elap).find('img').get(0);
			if(i) {
				i.src = a.image;
			}
			if(a.text) {
				this.elapsorText(a.text);
			}
		}
		else {
			this.elap = document.createElement('div');
			if(a.image) {
				this.image = document.createElement('img');
				this.image.src = a.image;
				this.elap.appendChild(this.image);
				this.elap.appendChild(document.createElement('br'));
			}
			if(a.text) {
				this.text = document.createElement('span');
				this.text.appendChild(document.createTextNode(a.text));
				this.elap.appendChild(this.text);
			}
			this.mask.appendChild(this.elap);
			jQuery(this.elap).addClass('ternElapsor').css({
				'position' : 'absolute',
				'width' : 300,
				'z-index' : 50,
				'text-align' : 'center'
			}).css(a.text_style);
		}
		jQuery(this.elap).css({
			'top' : (this.s[1]+((this.w[1])/2)),
			'left' : (this.s[0]+((this.w[0]-300)/2)),
			'display' : 'block'
		});
		return this.elap;
	},
	elapsorText :
	function (t) {
		$(this.elap).find('span').html = t;
	},
	hideElapsor :
	function () {
		this.mask = this.find('.ternMask').get();
		if(this.mask) {
			jQuery(this.mask).css({
				'display' : 'none'
			})
		}
	}
});


// BGIFRAME
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
 (function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);




var aEasings = 
 [ "easeInQuad",
	"easeOutQuad",
	"easeInOutQuad",
	"easeInCubic",
	"easeOutCubic",
	"easeInOutCubic",
	"easeInQuart",
	"easeOutQuart",
	"easeInOutQuart",
	"easeInQuint",
	"easeOutQuint",
	"easeInOutQuint",
	"easeInSine",
	"easeOutSine",
	"easeInOutSine",
	"easeInExpo",
	"easeOutExpo",
	"easeInOutExpo",
	"easeInCirc",
	"easeOutCirc",
	"easeInOutCirc",
	"easeInElastic",
	"easeOutElastic",
	"easeInOutElastic",
	"easeInBack",
	"easeOutBack",
	"easeInOutBack",
	"easeInBounce",
	"easeOutBounce",
	"easeInOutBounce"];
	

jQuery.fn.constrainNumeric = function(options, callback) {
/*
 * Allows only valid characters to be entered into input boxes.
 * Note: does not validate that the final text is a valid number
 * (that could be done by another script, or server-side)
 *
 * @name     numeric
 * @param    decimal      Decimal separator (e.g. '.' or ',' - default is '.')
 * @param    callback     A function that runs if the number is not valid (fires onblur)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $(".numeric").numeric();
 * @example  $(".numeric").numeric(",");
 * @example  $(".numeric").numeric(null, callback);
 *
 */
	var defaults = {
		decimal: ".",
		absolute: false,
		integer: false
	};
	var o = $.extend(defaults, options);
	decimal = o.decimal;
	callback = typeof callback == "function" ? callback : function(){};
	
	this.keypress(
		function(e)
		{
			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
			// allow enter/return key (only when in an input box)
			if(key == 13 && this.nodeName.toLowerCase() == "input")
			{
				return true;
			}
			else if(key == 13)
			{
				return false;
			}
			var allow = false;
			// allow ctrl+a
			if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
			// allow ctrl+x (cut)
			if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
			// allow ctrl+c (copy)
			if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
			// allow ctrl+z (undo)
			if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
			// allow or deny ctrl+v (paste), shift+ins
			if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
			|| (e.shiftkey && key == 45)) return true;
			
			// if a number was not pressed
			if(key < 48 || key > 57)
			{
				if (!o.absolute) {
					/* '-' only allowed at start */
					if(key == 45 && this.value.length == 0) return true;
				}

				if (o.integer && key==46) return false;

				if (!o.integer) {
					/* only one decimal separator allowed */
					if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
					{
						allow = false;
					}
				}

				// check for other keys that have special purposes
				if(
					key != 8 /* backspace */ &&
					key != 9 /* tab */ &&
					key != 13 /* enter */ &&
					key != 35 /* end */ &&
					key != 36 /* home */ &&
					key != 37 /* left */ &&
					key != 39 /* right */ &&
					key != 46 /* del */
				)
				{
					allow = false;
				}
				else
				{
					// for detecting special keys (listed above)
					// ie does not support 'charCode' and ignores them in keypress anyway
					if(typeof e.charCode != "undefined")
					{
						// special keys have 'keyCode' and 'which' the same (e.g. backspace)
						if(e.keyCode == e.which && e.which != 0)
						{
							allow = true;
						}
						// or keyCode != 0 and 'charCode'/'which' = 0
						else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
						{
							allow = true;
						}
					}
				}
				// if key pressed is the decimal and it is not already in the field
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) == -1)
				{
					allow = true;
				}
			}
			else
			{
				allow = true;
			}
			return allow;
		}
	)
	.blur(
		function()
		{
			var val = jQuery(this).val();
			if(val != "")
			{
				var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
				if(!re.exec(val))
				{
					callback.apply(this);
				}
			}
		}
	);
	return this;
}