//<![CDATA[
/* [## makeJSBetter 0.8 - Joshua Jarman (redesigned.com) ##] */
//$ = function() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') { element = document.getElementById(element); }; if (arguments.length == 1) { return element; }; 	elements.push(element); }; 	return elements; };
$Ajax = function(i, u, m, r, p, d) { m=m||'get';p=p||{};d=d||{onComplete: function(){}, onSuccess: function(){}, onFailure: function(){}};r=r||Element.update;if(r=='update'){r=Element.update};if(r=='replace'){r=Element.replace};d=new Hash({method: m, evalScripts: true, insertion: r}).merge(d);new Ajax.Updater(arguments[0], arguments[1], d);};
$Any = function() { var elements = new Array(); for (var i=0,len=arguments.length;i<len;i++) { var element = arguments[i]; if (typeof element == 'string') { var matched = document.getElementById(element); if (matched) { 	elements.push(matched); } else { var allels = (document.all) ? document.all : document.getElementsByTagName('*'); var regexp = new RegExp('(^| )'+element+'( |$)'); for (var i=0,len=allels.length;i<len;i++) { if (regexp.test(allels[i].className)) { elements.push(allels[i]); }; }; }; if (!elements.length) { elements = document.getElementsByTagName(element); }; if (!elements.length) { elements = new Array(); var allels = (document.all) ? document.all : document.getElementsByTagName('*'); 	for (var i=0,len=allels.length;i<len;i++) if (allels[i].getAttribute(element)) elements.push(allels[i]); }; if (!elements.length) { var allels = (document.all) ? document.all : document.getElementsByTagName('*'); for (var i=0,len=allels.length;i<len;i++) if (allels[i].attributes) for (var j=0,lenn=allels[i].attributes.length;j<lenn;j++) if (allels[i].attributes[j].specified) if (allels[i].attributes[j].nodeValue == element) elements.push(allels[i]); }; } else { elements.push(element); }; }; if (elements.length == 1) { return elements[0]; } else { return elements; }; };
$AjaxEveryXSeconds = function(i, u, x, m, r, p, d) { x=x||15;m=m||'get';p=p||{};d=d||{onComplete: function(){}, onSuccess: function(){}, onFailure: function(){}};r=r||Element.update;if(r=='update'){r=Element.update};if(r=='replace'){r=Element.replace};d=new Hash({method: m, frequency: x, decay: 1, evalScripts: true, insertion: r}).merge(d);new Ajax.PeriodicalUpdater(arguments[0], arguments[1], d);};
addEvent = function(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; }; };
createCookie = function(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); } document.cookie = name+"="+value+expires+"; path=/"; };
eraseCookie = function(name) { createCookie(name,"",-1); };
readCookie = function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') { c = c.substring(1,c.length); }; if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); }; }; return null; };
Math.mod = function(val,mod) { if (val < 0) { while(val<0) { val += mod; }; return val; } else { return val%mod; }; };
Number.max = function(a,b) { return a<b?b:a; };
Number.min = function(a,b) { return a>b?b:a; };
Number.isNumeric = function(str) { var ValidChars = "0123456789."; for (i = 0; i < str.length; i++) { if (ValidChars.indexOf(str.charAt(i)) == -1) { return false; }; }; return true; };
Number.prototype.toBool = function () { if (this == '1') { return true; } else { return false; }; };
Number.prototype.approxFraction = function(maxDenominator) { x = parseFloat(this); maxDenominator = parseInt(maxDenominator); var approx = 0; var error = 0; var best = 0; var besterror = 0; for (var i=1; i <= maxDenominator; i++) { approx = Math.round(x/(1/i)); error = (x - (approx/i)); if (i==1) { best = i; besterror = error; }; if (Math.abs(error) < Math.abs(besterror)) { best = i; besterror = error; }; }; return (Math.round(x/(1/best)) + "/" + best); };
Number.prototype.fancy = function() { var full = new String(this); var last = full.right(1); var last2 = full.right(2); var ext = 'th'; if (last == '1') { ext = 'st'; } else if (last == '2') { ext = 'nd'; } else if (last == '3') { ext = 'rd'; }; if (last2 == '11' || last2 == '12' || last2 == '13') { ext = 'th'; }; return new String(full+ext); };
Number.prototype.numFormat = function(decPlaces, prefix, seperator) { decPlaces = decPlaces || ''; prefix = prefix || ''; seperator = seperator || ''; var i = parseFloat(this); if (i < 0) { var p = '-'; i = i * -1; } else { var p = ''; };  if (decPlaces != '' && decPlaces > 0) { i = i.toFixed(decPlaces); }; if (seperator != '') { var splitStr = String(i).split('.'); var splitLeft = splitStr[0]; var splitRight = (splitStr.length > 1) ? '.'+splitStr[1] : ''; var regx = /(\d+)(\d{3})/; 	while (regx.test(splitLeft)) { splitLeft = splitLeft.replace(regx, '$1'+seperator+'$2'); }; i = splitLeft+splitRight; }; return String(prefix+p+i); };
String.prototype.numUnformat = function() { return Number(this.replace(/([^0-9\.\-])/g,'')*1); };
String.prototype.left = function(count) { if (this.length>count) { return this.substring(0, count); } else { return this; }; };
String.prototype.right = function(count) { if (this.length>count) { return this.substring(this.length-count, this.length); } else { return this; }; };
String.prototype.contains = function(t) { return this.indexOf(t) >= 0 ? true : false; };
String.prototype.beginsWith = function(value) { if (this.length<value.length) { return false; } else { return this.substring(0, value.length)===value; }; };
String.prototype.endsWith = function(value) { if (this.length<value.length) { return false; } else { return this.substring(this.length-value.length, this.length)===value; }; };
String.prototype.shorten = function(maxLength) { if (!this) { result = null; } else if (this.length>maxLength) { preferredSize = maxLength-'...'.length; if (preferredSize>0) { result = this.left(preferredSize) + '...'; } else {  result = this.left(maxLength); }; } else { result = this; }; return result; };
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); };
String.prototype.lTrim = function() { return this.replace(/^\s+/g,""); };
String.prototype.rTrim = function() { return this.replace(/\s+$/g,""); };
String.prototype.lPad = function (n,c) {var i; var a = this.split(''); for (i=0; i < n - this.length; i++) { a.unshift(c) }; return a.join(''); };
String.prototype.rPad = function (n,c) {var i; var a = this.split(''); for (i=0; i < n - this.length; i++) { a.push(c) }; return a.join(''); };
String.prototype.Reverse = function() { var s = ""; var i = this.length; while (i>0) { s += this.substring(i-1,i); i--; }; return s; };
String.prototype.repeat = function(n) { var ret = ""; for (var i = 0; i < n; ++i) { ret += this; }; return ret; };
String.prototype.htmlEncode = function() { var i,e={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'},t=this; for(i in e) t=t.replace(new RegExp(i,'g'),e[i]); return t; };
String.prototype.htmlDecode = function() { var i,e={'&lt;':'<','&gt;':'>','&amp;':'&','&quot;':'"'},t=this; for(i in e) t=t.replace(new RegExp(i,'g'),e[i]); return t; };
String.prototype.urlEncode = function() { return encodeURIComponent(this); };
String.prototype.urlDecode = function() { return decodeURIComponent(this); };
//String.prototype.stripTags = String.prototype.stripTags.wrap(function(){ var args = $A(arguments), proceed = args.shift(); if (args.length > 0) { return this.replace(new RegExp('<\/?(' + args.join('|') + ')[^>]*>', 'gi'), ''); }; return proceed(); });
String.prototype.clickableURLS = function() { var str = this; str = str.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim, '<a href="$&" target="_blank">$&</a>').replace(/([^\/])(www[\S]+(\b|$))/gim, '$1<a href="http://$2" target="_blank">$2</a>').replace(/([^\/])(ftp[\S]+(\b|$))/gim, '$1<a href="ftp://$2" target="_blank">$2</a>').replace(/\s([^\s]*@[^\s]*)/gi,' <a href=mailto:$1>$1</a>'); return str; };
String.prototype.listOfLinks = function() { var arrAllLinks; arrAllLinks = this.match(/(https:\/\/|http:\/\/|ftp:\/\/|www.|ftp.|[^\s]*@)([^\s]*)/gi ); return String(arrAllLinks.join(',')).replace(/,,/gim, ','); };
String.prototype.arrayOfLinks = function() { var arrAllLinks; arrAllLinks = this.match(/(https:\/\/|http:\/\/|ftp:\/\/|www.|ftp.|[^\s]*@)([^\s]*)/gi ); return Array('"'+String(arrAllLinks.join('","')).replace(/,,/gim, ',')+'"'); };
String.prototype.collapseSpaces = function() { return this.trim().replace(/\s{2,}/g, " ").replace(/{(Keyword):\s*(.*?)\s*}/gi, "{$1:$2}"); };
String.prototype.capitalize = function() { return this.toUpperCase() };
String.prototype.lowercase = function() { return this.toLowerCase() };
String.prototype.capWords = function() { str = this; str = str.toLowerCase(); str = str.substr(0, 1).toUpperCase() + str.substring(1, str.length); var i = 0; var j = 0; while((j = this.indexOf(" ", i)) && (j != -1)) { str = str.substring(0, j + 1) + str.substr(j + 1, 1).toUpperCase() + str.substring(j + 2, str.length); i = j+1; }; return str; };
String.prototype.capSentences = function() { var m; var cStr = ""; var str = this; if (str.match(/([^a-z]{1,})/) != null) { str = str.toLowerCase(); str = str.substr(0,1).toUpperCase() + str.substring(1, str.length); while (m = RegExp("([\\.\\?!\\r\\n]+[\\s]*)([a-z]{1,1})").exec(str)) { str = str.substr(0, m.index)+m[1]+m[2].toUpperCase()+str.substr(m.index + m[0].length); }; while (m = RegExp("([^\\w]i([^\\w]|'))").exec(str)) { cStr += str.substr(0, m.index) + m[1].toUpperCase(); str = str.substr(m.index + m[1].length); }; }; return cStr+str; };
String.prototype.replaceTokensWith = function() { if (!arguments.length) { throw "String.format() failed, no arguments passed, this = "+this; }; var tokens = this.split("?"); if (arguments.length != (tokens.length - 1)) { throw "String.format() failed, tokens != arguments, this = "+this; }; var s = tokens[0]; for (var i = 0; i < arguments.length; ++i) { s += (arguments[i] + tokens[i + 1]); }; return s; };
String.prototype.isValidEmail = function () { var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); var matches = rx.exec(this); return (matches != null && this == matches[0]); };
String.prototype.isValidURL = function () { var rx = new RegExp("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-\\+ ./?%:&=#\\[\\]]*)?"); var matches = rx.exec(this); return (matches != null && this == matches[0]); };
String.prototype.isMatch = function(validChr) { for( i = 0; i < this.length; i++ ) { if (validChr.indexOf(this.substring(i,i+1)) == -1) { return false; }; }; return true; };
String.prototype.isNumeric = function() { return this.isMatch("1234567890,."); };
String.prototype.isAlpha = function() { return this.isMatch("abcdefghijklmnopqrstuvwxyzåäöæøüABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖÆØÜ "); };
String.prototype.isAlphaNumeric = function() { return this.isMatch("abcdefghijklmnopqrstuvwxyzåäöæøüABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖÆØÜ 1234567890,."); };
String.prototype.isoDate = function () { var a = this.split('-'); var d = new Date(a[1]+"/"+a[2]+"/"+a[0]); return new Date(d); };
String.prototype.toDate = function () { return new Date(this); };
String.prototype.toInt = function () { return parseInt(this); };
String.prototype.toFloat = function () { return parseFloat(this); };
String.prototype.toNumber = function () { return new Number(this); };
String.prototype.toBool = function () { var x = this.lowercase(); if (x == 'true' || x == '1') { return true; } else { return false; }; };
String.prototype.toArray = function () { return this.split(','); };
Array.prototype.sortNum = function() { return this.sort( function (a,b) { return a-b; } ); };
//Array.prototype.map = function(f) { var returnArray=[]; for (i=0; i<this.length; i++) { returnArray.push(f(this[i])); }; return returnArray; };
Array.prototype.filter = function(fnc) { var a = new Array(); for (var i = 0; i < this.length; i++) { if (fnc(this[i])) { a.push(this[i]); }; }; return a; };
Array.prototype.random = function() { return this[Math.floor((Math.random()*this.length))]; };
Array.prototype.sum = function() { for (var i=0, sum=0; i < this.length; sum += this[i++]); return sum; };
Array.prototype.max = function() { return Math.max.apply({},this); };
Array.prototype.min = function() { return Math.min.apply({},this); };
Array.prototype.remove = function(s) { for (i=0; i < this.length; i++) { if (s == this[i]) {this.splice(i, 1); }; }; };
Array.prototype.unique = function() { 	var a = [], l = this.length; for (i=0; i<l; i++) { if( a.indexOf(this[i], 0, false) < 0 ) { a.push(this[i]); }; }; return a; };
Array.prototype.shuffle = function() { var Arr2 = new Array(); while (this.length > 0) { Arr2.push(this.splice(Math.round((this.length-1)*Math.random()),1)); }; return Arr2; };
Array.prototype.find = function(lookFor) { for(i = 0; i<this.length; i++) { if (this[i] == lookFor) { return i; }; }; return -1; };
Date.prototype.shortDaysOfWeek = function(x) { var DaysOfWeek = new Array('sun', 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun'); DaysOfWeek['mon'] = 1; DaysOfWeek['tues'] = 2; DaysOfWeek['wed'] = 3; DaysOfWeek['thurs'] = 4; DaysOfWeek['fri'] = 5; DaysOfWeek['sat'] = 6; DaysOfWeek['sun'] = 7; return DaysOfWeek[x]; };
Date.prototype.longDaysOfWeek = function(x) { var DaysOfWeek = new Array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); DaysOfWeek['monday'] = 1; DaysOfWeek['tuesday'] = 2; DaysOfWeek['wednesday'] = 3; DaysOfWeek['thursday'] = 4; DaysOfWeek['friday'] = 5; DaysOfWeek['saturday'] = 6; DaysOfWeek['sunday'] = 7; return DaysOfWeek[x]; };
Date.prototype.shortMonthsOfYear = function(x) { var MonthsOfYear = new Array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); MonthsOfYear['jan'] = 0; MonthsOfYear['feb'] = 1; MonthsOfYear['mar'] = 2; MonthsOfYear['apr'] = 3; MonthsOfYear['may'] = 4; MonthsOfYear['jun'] = 5; MonthsOfYear['jul'] = 6; MonthsOfYear['aug'] = 7; MonthsOfYear['sep'] = 8; MonthsOfYear['oct'] = 9; MonthsOfYear['nov'] = 10; MonthsOfYear['dec'] = 11; return MonthsOfYear[x]; };
Date.prototype.longMonthsOfYear = function(x) { var MonthsOfYear = new Array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'); MonthsOfYear['january'] = 0; MonthsOfYear['february'] = 1; MonthsOfYear['march'] = 2; MonthsOfYear['april'] = 3; MonthsOfYear['may'] = 4; MonthsOfYear['june'] = 5; MonthsOfYear['july'] = 6; MonthsOfYear['august'] = 7; MonthsOfYear['september'] = 8; MonthsOfYear['october'] = 9; MonthsOfYear['november'] = 10; MonthsOfYear['december'] = 11; return MonthsOfYear[x]; };
Date.prototype.firstDayOfMonth = function() { D = new Date(this); D.setDate(1); return new Date(D); };
Date.prototype.lastDayOfMonth = function() { D = new Date(this); D.setMonth(D.getMonth() + 1); D.setDate(0); return new Date(D); };
Date.prototype.lastXDayOfMonth = function(x) { var D = new Date(this); D = new Date(D.firstDayOfMonth()); D = new Date(D.setMonth(D.getMonth() + 1)); D = new Date(D.setDate(7 * 1 - 6 + (7 + D.shortDaysOfWeek(x) - D.getDay()) % 7)); D = new Date(D.setDate(D.getDate() - 7)); return new Date(D); };
Date.prototype.nthXDayOfMonth = function(n, x) { var D = new Date(this); D = new Date(D.firstDayOfMonth()); D = new Date(D.setDate(7 * n - 6 + (7 + D.shortDaysOfWeek(x) - D.getDay()) % 7)); if (D > this.lastXDayOfMonth(x)) { D = this.lastXDayOfMonth(x) }; return new Date(D); };
Date.prototype.arrayOfMonthsUntil = function(endDate) { var Months = new Array(); var StartDate = new Date(this); StartDate = new Date(StartDate.firstDayOfMonth()); var EndDate = new Date(endDate); EndDate = new Date(EndDate.lastDayOfMonth()); while (StartDate <= EndDate) { Months.push(new Date(StartDate)); StartDate.setMonth(StartDate.getMonth() + 1); }; return Months; };
Date.prototype.nthDayUntil = function(n, endDate) { var thisDate = new Date(this); var Dates = new Array(); while (thisDate <= endDate) { Dates.push(new Date(thisDate)); thisDate = new Date(thisDate.setDate(thisDate.getDate() + n)); }; return Dates; };
Date.prototype.nthWeekUntil = function(n, endDate) { var thisDate = new Date(this); var Dates = new Array(); while (thisDate <= endDate) { Dates.push(new Date(thisDate)); thisDate = new Date(thisDate.setDate(thisDate.getDate() + (7*n))); }; return Dates; };
Date.prototype.nthMonthUntil = function(n, endDate) { 	var thisDate = new Date(this); var thisDay = thisDate.getDate(); var Dates = new Array(); this.arrayOfMonthsUntil(endDate).each(function(item) { var LastDay = new Date(item.lastDayOfMonth()); var ThisDate = new Date(item); ThisDate = new Date(ThisDate.setDate(thisDay)); if (LastDay.getMonth() != ThisDate.getMonth()) { ThisDate = new Date(LastDay); }; Dates.push(new Date(ThisDate)); }); var NewDates = new Array(); for (i=0; i<=Dates.length; i=i+n) { if (Dates[i] >= this && Dates[i] <= endDate) { NewDates.push(new Date(Dates[i])); }; }; return NewDates; };
Date.prototype.nthYearUntil = function(n, endDate) { var thisDate = new Date(this); var Dates = new Array(); while (thisDate <= endDate) { Dates.push(new Date(thisDate)); thisDate = new Date(thisDate.setYear(thisDate.getYear() + n + 1900)); }; return Dates; };
Date.prototype.countDaysUntil = function(endDate) { return this.nthDayUntil(1, endDate).length - 1; };
Date.prototype.countWeeksUntil = function(endDate) { return new Number((this.nthDayUntil(1, endDate).length - 1) / 7).numFormat(1); };
Date.prototype.countMonthsUntil = function(endDate) { return this.nthMonthUntil(1, endDate).length - 1; };
Date.prototype.countYearsUntil = function(endDate) { return this.nthYearUntil(1, endDate).length - 1; };
Date.prototype.closestXAfter = function(x) { if (this.isXWeekday(x)) { return new Date(this); } else { var D = new Date(this); var TargetDay = D.shortDaysOfWeek(x); var CurrentDay = D.getDay(); var ShiftDays = TargetDay - CurrentDay; if (ShiftDays < 0) { ShiftDays = 7 + ShiftDays; }; D = new Date(D.setDate(D.getDate() + ShiftDays)); return new Date(D); }; };
Date.prototype.closestXBefore = function(x) { if (this.isXWeekday(x)) { return new Date(this); } else { var D = new Date(this); var TargetDay = D.shortDaysOfWeek(x); var CurrentDay = D.getDay(); var ShiftDays = CurrentDay - TargetDay; if (ShiftDays < 0) { ShiftDays = 7 + ShiftDays; }; D = new Date(D.setDate(D.getDate() - ShiftDays)); return new Date(D); }; };
Date.prototype.lastXOfMonthUntil = function(x, endDate) { var Months = new Array(); var thisDate = new Date(this); this.arrayOfMonthsUntil(endDate).each(function(item) { var currentDate = new Date(item.lastXDayOfMonth(x)); if (currentDate <= endDate && currentDate >= thisDate) { Months.push(item.lastXDayOfMonth(x)); }; }); return Months; };
Date.prototype.nthXOfMonthUntil = function(n, x, endDate) { var Months = new Array(); var thisDate = new Date(this); this.arrayOfMonthsUntil(endDate).each(function(item) { var currentDate = new Date(item.nthXDayOfMonth(n, x)); if (currentDate <= endDate && currentDate >= thisDate) { Months.push(new Date(currentDate)); }; }); return Months; };
Date.prototype.weekdayShort = function() { return this.shortDaysOfWeek(this.getDay()); };
Date.prototype.weekdayLong = function() { return this.longDaysOfWeek(this.getDay()); };
Date.prototype.monthNameShort = function() { return this.shortMonthsOfYear(this.getMonth()); };
Date.prototype.monthNameLong = function() { return this.longMonthsOfYear(this.getMonth()); };
Date.prototype.dayShort = function() { return this.format('d'); };
Date.prototype.dayLong = function() { return this.format('dd'); };
Date.prototype.dayFancy = function() { return new String(new Number(this.format('d')).fancy()); };
Date.prototype.monthShort = function() { return this.format('m'); };
Date.prototype.monthLong = function() { return this.format('mm'); };
Date.prototype.yearShort = function() { return this.format('yy'); };
Date.prototype.yearLong = function() { return this.format('yyyy'); };
Date.prototype.isoDate = function() { return this.format('yyyy-mm-dd'); };
Date.prototype.humanShort = function() { return this.format('mm/dd/yy'); };
Date.prototype.humanMed = function() { return new String(this.monthNameShort().capWords()+'. '+this.dayFancy()+', '+this.yearLong()); };
Date.prototype.humanLong = function() { return new String(this.monthNameLong().capWords()+' '+this.dayFancy()+', '+this.yearLong()); };
Date.prototype.humanMedWithWeek = function() { return new String(this.weekdayShort().capWords()+'., '+this.monthNameShort().capWords()+'. '+this.dayFancy()+', '+this.yearLong()); };
Date.prototype.humanLongWithWeek = function() { return new String(this.weekdayLong().capWords()+', '+this.monthNameLong().capWords()+' '+this.dayFancy()+', '+this.yearLong()); };
Date.prototype.isXWeekday = function(x) { return (this.weekdayShort() == x || this.weekdayLong() == x); };
Date.prototype.addXDays = function(x) { var D = new Date(this); D = new Date(D.setDate(D.getDate() + x)); return new Date(D); };
Date.prototype.addXWeeks = function(x) { var D = new Date(this); D = new Date(D.setDate(D.getDate() + (x*7))); return new Date(D); };
Date.prototype.addXMonths = function(x) { var D = new Date(this); var DDay = D.dayShort(); var DLast = new Date(D.firstDayOfMonth()); DLast = new Date(DLast.setMonth(DLast.getMonth() + x)); var N = new Date(DLast); DLast = new Date(DLast.lastDayOfMonth()); 	N = new Date(N.setDate(DDay)); if (N > DLast) { N = new Date(DLast); }; return new Date(N); };
Date.prototype.addXYears = function(x) { var D = new Date(this); D = new Date(D.setYear(D.yearLong().toInt() + x)); return new Date(D); };
Date.prototype.weekStarts = function() { return new Date(this.closestXBefore('sun')); };
Date.prototype.weekEnds = function() { return new Date(this.closestXAfter('sat')); };
Date.prototype.workWeekStarts = function() { if (this.isXWeekday('sun')) { return new Date(this.closestXAfter('mon')); } else { return new Date(this.closestXBefore('mon')); }; };
Date.prototype.workWeekEnds = function() { if (this.isXWeekday('sat')) { return new Date(this.closestXBefore('fri')); } else { return new Date(this.closestXAfter('fri')); }; };
Date.prototype.firstFullWeek = function() { return new Date(this.nthXDayOfMonth(1, 'sun')); };
Date.prototype.firstFullWorkWeek = function() { return new Date(this.nthXDayOfMonth(1, 'mon')); };
Date.prototype.firstFullWeekend = function() { return new Date(this.nthXDayOfMonth(1, 'sat')); };
Date.prototype.firstFullDayGroup = function(x1, x2) { return new Date(this.nthXDayOfMonth(1, x1)); };
Date.prototype.lastFullWeek = function() { return new Date(this.lastXDayOfMonth('sat').closestXBefore('sun')); };
Date.prototype.lastFullWorkWeek = function() { return new Date(this.lastXDayOfMonth('fri').closestXBefore('mon')); };
Date.prototype.lastFullWeekend = function() { return new Date(this.lastXDayOfMonth('sun').closestXBefore('sat')); };
Date.prototype.lastFullDayGroup = function(x1, x2) { return new Date(this.lastXDayOfMonth(x2).closestXBefore(x1)); };
Date.prototype.nthFullWeekend = function(n) { var D = new Date(this.firstFullWeekend()); D = new Date(D.addXDays((n - 1) * 7)); if (D > this.lastFullWeekend()) { D = new Date(this.lastFullWeekend()); }; return new Date(D); };
Date.prototype.nthXDayOfFullWeekInMonth = function(n, x) { var D = new Date(this.firstFullWeek()); D = new Date(D.addXDays((n - 1) * 7).closestXAfter(x)); if (D > this.lastFullWeek().closestXAfter(x)) { D = new Date(this.lastFullWeek().closestXAfter(x)); }; return new Date(D); };
Date.prototype.lastXDayOfFullWeekInMonth = function(x) { return new Date(this.nthXDayOfFullWeekInMonth(99, x)); };
Date.prototype.nthXDayOfFullWorkWeekInMonth = function(n, x) { var D = new Date(this.firstFullWorkWeek()); D = new Date(D.addXDays((n - 1) * 7).closestXAfter(x)); if (D > this.lastFullWorkWeek().closestXAfter(x)) { D = new Date(this.lastFullWorkWeek().closestXAfter(x)); }; return new Date(D); };
Date.prototype.lastXDayOfFullWorkWeekInMonth = function(x) { return new Date(this.nthXDayOfFullWeekInMonth(99, x)); };
Date.prototype.nthXDayOfDayGroupInMonth = function(n, x, x1, x2) { var D = new Date(this.firstFullDayGroup(x1, x2)); D = new Date(D.addXDays((n - 1) * 7).closestXAfter(x)); if (D > this.lastFullDayGroup(x1, x2).closestXAfter(x)) { D = new Date(this.lastFullDayGroup(x1, x2).closestXAfter(x)); }; return new Date(D); };
Date.prototype.lastXDayOfDayGroupInMonth = function(x, x1, x2) { return new Date(this.nthXDayOfDayGroupInMonth(99, x, x1, x2)); };
Date.prototype.format = function() { 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; }; return function (date, mask, utc) { var dF = Date.prototype.format; if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) { mask = date; date = undefined; }; date = date ? new Date(date) : new Date(this); if (isNaN(date)) throw new SyntaxError("invalid date"); mask = String(dF.masks[mask] || mask || dF.masks["default"]); 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: dF.i18n.dayNames[D], dddd: dF.i18n.dayNames[D + 7], m: m + 1, mm: pad(m + 1), mmm: dF.i18n.monthNames[m], mmmm: dF.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); }); }; }();
Date.prototype.format.masks = { "default": "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/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", 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'" };
Date.prototype.format.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"] };
window.Bookmark = function() {}; Bookmark = window.Bookmark;
window.Bookmark.Page = function(title, url) { if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if ( window.external ) { window.external.AddFavorite( url, title); } else if (window.opera && window.print) { return true; }; };
window.Bookmark.ThisPage = function() { Bookmark.Page(document.title, window.location.href); };
if ("HTMLElement" in window) { /* el.outerHTML */ extendElements = function() { if (document.body.__defineGetter__) { if (HTMLElement) { var element = HTMLElement.prototype; if (element.__defineGetter__) { element.__defineGetter__("outerHTML", function() { var parent = this.parentNode; var el = document.createElement(parent.tagName); el.appendChild(this); var shtml = el.innerHTML; parent.appendChild(this); return shtml; }); }; }; }; if (document.body.__defineSetter__) { if (HTMLElement) {	var element = HTMLElement.prototype; if (element.__defineSetter__) { element.__defineSetter__("outerHTML", function(shtml) { Element.replace(this.id, shtml); }); }; }; }; }; addEvent(window,'load',extendElements,false); };
//]]>
