
		Date.prototype.AddDays = 		function(iDays){
											return new Date(this.getTime() + iDays*24*60*60*1000);
										};
		Date.prototype.DaysInMonth =	function(){
											return 32 - new Date(this.getYear(), this.getMonth(), 32).getDate();
										};
		Date.prototype.ToString = 		function(){
											var s = '';
											switch(this.getDate().toString().substring(this.getDate().toString().length-1)){
												case '1': s='st'; break;
												case '2': s='nd'; break;
												case '3': s='rd'; break;
												default: s='th'; 
											}
											if(this.getDate() > 10 && this.getDate() < 20){s='th';}
											
											return this.DayName() +' ' +this.getDate()+s+' '+this.MonthName()+' '+this.getFullYear();
										};
		Date.prototype.ToStringWithTime = 	function(){
											return this.ToString() + ' at ' + this.getHours() + ':' + this.getMinutes();
										};
		Date.prototype.ToISO =			function(){
											return this.getFullYear()+'-'+(this.getMonth()+1)+'-'+this.getDate();
										};
		Date.prototype.MonthName = 		function(){
											var aMonthNames = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
											return aMonthNames[this.getMonth()];
										};
		Date.prototype.DayName = 		function(){
											var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
											return days[this.getDay()];
										};
		Array.prototype.GetByID = 		function(iID){
											for(var i=0; i<this.length; i++){
												if(this[i].ID == iID){ return this[i]; }
											}
											return null;
										};
		Array.prototype.GetIndexByID = 	function(iID){
											for(var i=0; i<this.length; i++){
												if(this[i].ID == iID){ return i; }
											}
											return -1;
										};
		Array.prototype.getById = 		function(iID){
											for(var i=0; i<this.length; i++){
												if(this[i].id == iID){ return this[i]; }
											}
											return null;
										};
		Array.prototype.getIndexById = 	function(iID){
											for(var i=0; i<this.length; i++){
												if(this[i].id == iID){ return i; }
											}
											return -1;
										};
		Array.prototype.Swap = 			function(x,y) {
											var b = this[x];
											this[x] = this[y];
											this[y] = b;
											return this;
										};
		Array.prototype.Remove = 		function(i) {
											return this.splice(i,1);
										};
		Array.prototype.RemoveID = 		function(iID) {
											var index = this.GetIndexByID(iID);
											if(index > -1){
												return this.splice(this.GetIndexByID(iID),1);
											}else{
												return null;
											}
										};
		Number.prototype.Pad = 			function(length){
											var s = this;
											while (s.toString().length < length) {
												s = '0' + s;
											}
											return s;
										};
										
		function rand( n ){
			return ( Math.floor ( Math.random ( ) * n + 1 ) );
		}

		function clone(obj){
			var newObj = {};
			for(var i in obj){
				newObj[i] = obj[i];
			}
			return newObj;
		}
		
		function deepClone(dupeObj) {
			var retObj = new Object();
			if (typeof(dupeObj) == 'object') {
				if (typeof(dupeObj.length) != 'undefined')
					var retObj = new Array();
				for (var objInd in dupeObj) {	
					if (typeof(dupeObj[objInd]) == 'object') {
						retObj[objInd] = deepClone(dupeObj[objInd]);
					} else if (typeof(dupeObj[objInd]) == 'string') {
						retObj[objInd] = dupeObj[objInd];
					} else if (typeof(dupeObj[objInd]) == 'number') {
						retObj[objInd] = dupeObj[objInd];
					} else if (typeof(dupeObj[objInd]) == 'boolean') {
						((dupeObj[objInd] == true) ? retObj[objInd] = true : retObj[objInd] = false);
					}
				}
			}
			return retObj;
		}
		
		//Cookies
		function setCookie(name, value, expires, path, domain, secure) {
		  var curCookie = name + "=" + escape(value) +
			  ((expires) ? "; expires=" + expires.toGMTString() : "") +
			  ((true) ? "; path=/" : "") +
			  ((domain) ? "; domain=" + domain : "") +
			  ((secure) ? "; secure" : "");
		  document.cookie = curCookie;
		}
		
		function getCookie(name) {
		  var dc = document.cookie;
		  var prefix = name + "=";
		  var begin = dc.indexOf("; " + prefix);
		  if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return "";
		  } else
			begin += 2;
		  var end = document.cookie.indexOf(";", begin);
		  if (end == -1)
			end = dc.length;
		  return unescape(dc.substring(begin + prefix.length, end));
		}
		
		
		
		
		
		
		
		
		
		
		
		
	$(function(){
		var eEggCodes = [38,38,40,40,37,39,37,39,66,65];
		var eEggCodeIndex = 0;
		
		$(document).keydown(function(e){
			var code = (e.which || e.keyCode);

			if(eEggCodes[eEggCodeIndex] == code){ eEggCodeIndex++; }else{ eEggCodeIndex = 0; }
			if(eEggCodeIndex == eEggCodes.length){
				var curtainStyles = {
					'position':'absolute',
					'width':'50%',
					'height':'100%',
					'top':'0px',
					'background':'url(/test/curtainTest/curtain.png) left top repeat-x',
					'position':'fixed',
					'opacity':'0.9',
					'z-index':'7000'
				};
				var leftCurtain = $('<div></div>').css(
					$.extend({
						'left':'0px'
					}, curtainStyles)
				);
				var rightCurtain = $('<div></div>').css(
					$.extend({
						'right':'0px'
					}, curtainStyles)
				);
				
				$('body').append(
					$('<div></div>').css({
						'position':'absolute',
						'width':'100%',
						'height':'41%',
						'top':'0px',
						'background':'url(/test/curtainTest/pole.png) left top repeat-x',
						'position':'fixed',
						'z-index':'7000'
					})
				);
				$('body').append(leftCurtain);
				$('body').append(rightCurtain);
				
				$(window).scroll(function(){
					onScroll();
				});
				
				function onScroll(){
					var docHeight = $(document).height();
					var docWidth = $(document).width();
					var yScroll = $(window).scrollTop();
					var percentScrolled = (yScroll/docHeight);
					var left = (docWidth/1.5)*percentScrolled;
					leftCurtain.stop().animate({'left':(-left)+'px'});
					rightCurtain.stop().animate({'right':(-left)+'px'});
				}
				
				onScroll();
			}
		});
	});

