	// Global Variables //
	var _isMoz = (navigator.appName == "Netscape");
	var _isIE = (navigator.appName == "Microsoft Internet Explorer");
	var _isIE6 = (navigator.appVersion.search("MSIE 6.0") != -1);
	var _isSafari = (navigator.userAgent.indexOf("Safari") != -1);
	var _isLoaded = false, _j = _numCheckboxes = _navCount = _subNavCount = _setKropLink = _paletteAngle = _width = _height = 0, _canAni = "show", _animateBy = 40, _paletteIsCPW = false;
	var dragsort, junkdrawer, _colourBoxOrder = "0|1|2|3|4", _incArrayMenu = [0,10,17,21,23], _incArrayUL = [57,47,40,36,34], _incArrayMenuH = [23,21,17,10,0], _incArrayULH = [34,36,40,47,57];
	var _currentPage = "", _timeout = {}, _mK = "";

	showHoverInfo = function(){}
	hideHoverInfo = function(){}

	getS3URL = function(_url) {
		return "http://colourlovers.com.s3.amazonaws.com" + _url;
	}

	getStaticURL = function(_url) {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//return _url;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		return "http://static.colourlovers.com" + _url;
	}

	$S = function(_elementID) {
		return ($(_elementID)) ? $(_elementID).style : false;
	}

	// init function //
	init = function() {
		addEvent(onLoad,"load");
	}

	setOpacity = function(_elementID,_opacity) {
		$S(_elementID).opacity = _opacity;
		$S(_elementID).MozOpacity = _opacity;
		$S(_elementID).filter = "alpha(opacity=" + (_opacity * 100) + ")";
	}

	within = function(_val,_low,_high) {
		return ((_val >= _low) && (_val <= _high));
	}

	dec2hex = function(_dec) {
		var _hexChars = "0123456789ABCDEF", _hex = "";
		while (_dec > 15) {
			_hex = (_hexChars.charAt((_dec - (Math.floor(_dec / 16)) * 16)) + _hex);
			_dec = Math.floor(_dec / 16);
		}
		return (_hexChars.charAt(_dec) + _hex);
	}

	hex2dec = function(_hex) {
		return parseInt(_hex,16);
	}

	// Manage events //
	addEvent = function(_function,_event) {
		if ((document.all) && (window.attachEvent)) {
			window.attachEvent("on" + _event,_function);
		} else if (window.addEventListener) {
			window.addEventListener(_event,_function,false);
		}
	}

	isHex = function(_hex) {
		return /^[a-fA-F0-9]{6}$/.test(_hex);
	}

	domEvent = function(_event) {
		_event = (_event) ? _event : window.event;

		// Opera hates this for some reason:
		if (!window.opera && _event.srcElement) {
			_event.target = _event.srcElement;
		}
		if (_event.keyCode) {
			_event.code = _event.keyCode;
		} else if (_event.which) {
			_event.code = _event.which;
		} else {
			_event.code = _event.charCode
		}
		return _event;
	}

	// onLoad //
	onLoad = function() {
		var _ypos = new Array();
		var _queryString = window.location.search;
		var _regExp = /ypos=(\d+)/;

		// If the url tells y us to scroll, then do so.
		if (_regExp.test(_queryString)) {
			_ypos = _regExp.exec(_queryString);
			_ypos = parseInt(_ypos[1]);

			if (_ypos > 0) {
				window.scroll(0,_ypos);
			}
		}
		if ($("Radio_BBCode")) {
			$("Radio_BBCode").checked = true;
		}

		try {
			initLightbox();
		} catch (_e) {}

		setNavEvents();

		_isLoaded = true;
	}

	forumPollRadioOnClick = function(_this) {
		if ($("pollAnswerOther") !== null) {
			$("pollAnswerOther").disabled = !(_this.id == "pollOptionID_1");
		}
		$("addACommentSubmitBtn").src = getStaticURL("/images/v3.5/" + _lang + "/btn/addACommentAndCastVote.png");
		$("pollOptionID_comment").value = _this.value;
		if ($S("forumCastVoteSubmitBtnDiv").display == "none") {
			Effect.BlindDown("forumCastVoteSubmitBtnDiv",{duration: 0.4});
		}
	}

	setNavEvents = function() {
		$("nav").onmouseover = function() {menuOver();};
		$("nav").onmouseout = function() {menuOut();};
		$("Nav0").onmouseover = function() {showSubNav("Nav0");};
		$("Nav1").onmouseover = function() {showSubNav("Nav1");};
		$("Nav2").onmouseover = function() {showSubNav("Nav2");};
		$("Nav3").onmouseover = function() {showSubNav("Nav3");};
		//$("Nav4").onmouseover = function() {showSubNav("Nav4");};
		//$("Nav5").onmouseover = function() {showSubNav("Nav5");};
		//$("Nav6").onmouseover = function() {showSubNav("Nav6");};
		//$("Nav7").onmouseover = function() {showSubNav("Nav7");};
		//$("Nav8").onmouseover = function() {highlightNav("Nav8"); hideSubNav();};
		//$("Nav8").onmouseout = function() {highlightNav();};
		//$("Nav9").onmouseover = function() {highlightNav("Nav9"); hideSubNav();};
		//$("Nav9").onmouseout = function() {highlightNav();};
	}

	// Init drag //
	initDD = function() {
		dragsort.makeListSortable($("ddItems"),function(_item) {
			_item.toolManDragGroup.register("dragend",clEndDrag);
		});
	}

	// End drag //
	clEndDrag = function() {
		_colourBoxOrder = "";
		var _colourBoxes = $("ddItems").getElementsByTagName("li");
		for (var _i=0;_i<_colourBoxes.length;_i++) {
			_colourBoxOrder += _colourBoxes[_i].title;
			if ((_i + 1) != _colourBoxes.length) {
				_colourBoxOrder += "|";
			}
		}
	}

	togglePollDisplay = function(_area,_element) {
		if (_area == "forums") {
			if (_element.checked) {
				$("discussionCommentRequiredSpan").hide();
				Effect.BlindDown("addPollDiv",{duration: 0.4});
			} else {
				$("discussionCommentRequiredSpan").show();
				Effect.BlindUp("addPollDiv",{duration: 0.4});
			}
			for (var _i=0;_i<10;_i++) {
				$("pollOptions_" + _i).disabled = !_element.checked;
				$("pollOptionURLs_" + _i).disabled = !_element.checked;
			}
			$("pollTitle").disabled = !_element.checked;
			$("pollEndDate_day").disabled = !_element.checked;
			$("pollEndDate_month").disabled = !_element.checked;
			$("pollEndDate_year").disabled = !_element.checked;
			$("pollDesc").disabled = !_element.checked;
			$("commentBox").disabled = _element.checked;
		}
	}

	getSpace = function(_x,_y) {
		return "<img src=\"" + getStaticURL("/images/spacer.png") + "\" style=\"width: " + _x + "px; height: " + _y + "px; border: 0px;\" alt=\" \" />";
	}

	absPos = function(_object) {
		var r = {
			x : _object.offsetLeft,
			y : _object.offsetTop
		};
		if (_object.offsetParent) {
			var v = absPos(_object.offsetParent);
			r.x += v.x;
			r.y += v.y;
		}
		return r;
	}

	patternImgDetail = function(_patternID) {
		var _pageSize = getPageSize();
		$S("clOverlayContent").background = "transparent url(" + getS3URL("/images/patterns/" + parseInt(_patternID / 1000) + "/" + _patternID + ".png?" + (new Date()).getTime().toString()) + ") center center";
		$S("clOverlayContent").width = (_pageSize[2] - 150) + "px";
		$S("clOverlayContent").height = (_pageSize[3] - 150) + "px";
		$("clOverlayContent").onclick = hideOverlay;
		showOverlay([(_pageSize[2] - 150),(_pageSize[3] - 150)]);
	}

	suggestTrend = function() {
		var _absPos = absPos($("suggestTrendBtn"));
		$S("suggestTrendDiv").top = ((_absPos.y + 21) + "px");
		$S("suggestTrendDiv").left = ((_absPos.x - 117) + "px");
		$S("suggestTrendDiv").display = "block";
	}


// Overlay //
	showOverlay = function(_overlayContentDimensions) {
		var _pageSize = getPageSize();
		_lastOverlayDimensions = _overlayContentDimensions;
		$S("clOverlay").height = (_pageSize[1] + "px");
		$S("clOverlay").display = "block";

		var _overlayContentTop = (getPageScroll()[1] + ((_pageSize[3] - _overlayContentDimensions[1] - 20) / 2)); // -20 for border
		var _overlayContentLeft = ((_pageSize[0] - _overlayContentDimensions[0] - 20) / 2); // -20 for border

		$S("clOverlayContent").top = (_overlayContentTop < 0) ? "0px" : _overlayContentTop + "px";
		$S("clOverlayContent").left = (_overlayContentLeft < 0) ? "0px" : _overlayContentLeft + "px";
		$S("clOverlayContent").display = "block";
		$S("clOverlay").height = (getPageSize()[1] + "px");
	}

	hideOverlay = function() {
		$S("clOverlay").display = "none";
		$S("clOverlayContent").display = "none";
	}

	modComment = function(_commentType,_commentID,_commentI) {
		if (_isLoaded) {
			var _modDiv = $(_commentType + "_cm_" + _commentID);
			var _comment = _modDiv.innerHTML.replace(/__CL_LESSTHAN__/g,"<").replace(/__CL_GREATERTHAN__/g,">");
			var _textareaID = ("comments" + _commentType + _commentID + _commentI);
			_modDiv.innerHTML = "";

			var _modCommentForm = document.createElement("form");
			if (_mK !== undefined) {
				_modCommentForm.setAttribute("action","/op/modComment/" + _mK);
			} else {
				_modCommentForm.setAttribute("action","/op/modComment");
			}
			_modCommentForm.setAttribute("method","post");
			_modDiv.insertBefore(_modCommentForm,_modDiv.firstChild);

			var _submitBtn = document.createElement("input");
			_submitBtn.setAttribute("type","image");
			_submitBtn.setAttribute("class","outline");
			_submitBtn.setAttribute("src",getStaticURL("/images/v3.5/" + _lang + "/btn/submit.png"));
			_modCommentForm.insertBefore(_submitBtn,_modCommentForm.firstChild);

			var _commentTextarea = document.createElement("textarea");
			_commentTextarea.setAttribute("name","comments");
			_commentTextarea.setAttribute("id",_textareaID);
			_commentTextarea.onselect = new Function("storeCaret($('" + _textareaID + "'));");
			_commentTextarea.onclick = new Function("storeCaret($('" + _textareaID + "'));");
			_commentTextarea.onkeyup = new Function("storeCaret($('" + _textareaID + "'));");
			_commentTextarea.onchange = new Function("storeCaret($('" + _textareaID + "'));");
			_commentTextarea.className = "formElement";
			if (_commentType == "for") {
				_commentTextarea.style.width = "403px";
			} else if (_commentType == "gro") {
				_commentTextarea.style.width = "405px";
			} else if ((_commentType == "tc") || (_commentType == "wtc") || (_commentType == "ccc") || (_commentType == "bpc")) {
				_commentTextarea.style.width = "404px";
			} else if ((_commentType == "cfc") || (_commentType == "pfc") || (_commentType == "lfc") || (_commentType == "nfc") || (_commentType == "pic")) {
				_commentTextarea.style.width = "305px";
			}
			_commentTextarea.style.height = "120px";
			_commentTextarea.style.marginBottom = "10px";
			_modCommentForm.insertBefore(_commentTextarea,_modCommentForm.firstChild);
			_commentTextarea.value = _comment;

			var _bbDiv = document.createElement("div");
			_bbDiv.style.marginBottom = "5px";
			_bbDiv.className = "htmlBar";
			_bbDiv.innerHTML = "<a onclick=\"fmtTxt('" + _textareaID + "','<strong>','</strong>');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/bold.png") + "\" alt=\"Bold\" title=\"Bold\" /></a>";
			_bbDiv.innerHTML += "<a onclick=\"fmtTxt('" + _textareaID + "','<em>','</em>');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/italic.png") + "\" alt=\"Italic\" title=\"Italic\" /></a>";
			_bbDiv.innerHTML += "<a onclick=\"fmtTxtUnderline('" + _textareaID + "');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/underline.png") + "\" alt=\"Underline\" title=\"Underline\" /></a>";
			_bbDiv.innerHTML += "<a onclick=\"fmtTxtImage('" + _textareaID + "');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/image.png") + "\" alt=\"Insert Image\" title=\"Insert Image\" /></a>";
			_bbDiv.innerHTML += "<a onclick=\"fmtTxtURL('" + _textareaID + "');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/url.png") + "\" alt=\"Insert Link\" title=\"Insert Link\" /></a>";
			_bbDiv.innerHTML += "<a onclick=\"fmtTxt('" + _textareaID + "','<blockquote>','</blockquote>');\"><img src=\"" + getStaticURL("/images/v3.5/_/btn/html/blockquote.png") + "\" alt=\"Quote\" title=\"Quote\" /></a>";
			_bbDiv.innerHTML += "<div style=\"display: inline; margin-left: 10px; vertical-align: 50%; color: #aaaaaa;\">Some HTML OK</div>\n";
			_modCommentForm.insertBefore(_bbDiv,_modCommentForm.firstChild);

			var _commentIDInput = document.createElement("input");
			_commentIDInput.setAttribute("type","hidden");
			_commentIDInput.setAttribute("name","commentID");
			_commentIDInput.setAttribute("value",_commentID);
			_modCommentForm.insertBefore(_commentIDInput,_modCommentForm.firstChild);

			var _commentTypeInput = document.createElement("input");
			_commentTypeInput.setAttribute("type","hidden");
			_commentTypeInput.setAttribute("name","commentType");
			_commentTypeInput.setAttribute("value",_commentType);
			_modCommentForm.insertBefore(_commentTypeInput,_modCommentForm.firstChild);

			$(_commentType + "_mc_" + _commentID).style.display = "none";
			$(_commentI).style.display = "none";
			_modDiv.style.display = "block";
			_commentTextarea.focus();
			goToAnchor(_commentI);
		}
	}

	getLoadingFlash = function() {
		var _str = "<div style=\"text-align: center;\">";
			_str += "<!--[if !IE]> -->";
				_str += "<object type=\"application/x-shockwave-flash\" data=\"" + getStaticURL("/images/v3.5/_/loading.swf") + "\" width=\"50\" height=\"50\">";
			_str += "<!-- <![endif]-->";

			_str += "<!--[if IE]>";
				_str += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"50\" height=\"50\">";
				_str += "<param name=\"movie\" value=\"" + getStaticURL("/images/v3.5/_/loading.swf") + "\" />";
				_str += "<!--><!--dgx-->";
			_str += "<param name=\"loop\" value=\"true\" />";
			_str += "<param name=\"wmode\" value=\"transparent\" />";
			_str += "<param name=\"menu\" value=\"false\" />";
			_str += "</object>";
			_str += "<!-- <![endif]-->";
		return _str += "</div>\n";
	}

	httpPost = function() {
		var _httpPostSocket;
		// Send request //
		this.sendRequest = function(_contentElement,_args) {
			var _url = ("/ajax/" + _contentElement), _postArgs = "";

			if (window.XMLHttpRequest) {
				_httpPostSocket = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				try {
					_httpPostSocket = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(_e) {
					_httpPostSocket = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}

			if (_contentElement == "addComment") {
				// commentsID, contextType, contextID, comments
				var _comments = _args[3];
				_postArgs += "commentsID=" + _args[0] + "&contextType=" + _args[1] + "&contextID=" + _args[2] + "&comments=" + _args[3];
			} else if (_contentElement == "saveCopaso") {
				// copasoMeta, paletteMeta, copasoPaletteID, paletteID
				_url += "?copasoMeta=" + _args[0] + "&paletteMeta=" + _args[1] + "&copasoPaletteID=" + _args[2] + "&paletteID=" + _args[3];
			} else if (_contentElement == "publishCopaso") {
				// copasoMeta, paletteMeta, copasoPaletteID, _paletteID, _nonExistentColorNamesList, _nonExistentColorHexsList
				_url += "?copasoMeta=" + _args[0] + "&paletteMeta=" + _args[1] + "&copasoPaletteID=" + _args[2] + "&paletteID=" + _args[3] + "&nonExistentColorNamesList=" + _args[4] + "&nonExistentColorHexsList=" + _args[5];
			}

			// Tell Google that we have another page view //
			try {
				urchinTracker(_url);
			} catch (_e) {}
			if (window.XMLHttpRequest) {
				_httpPostSocket.onreadystatechange = this.xmlhttpChange;
				_httpPostSocket.open("POST",_url,true);
				_httpPostSocket.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
				_httpPostSocket.send(_postArgs);
			} else if (window.ActiveXObject) {
				if (_httpPostSocket) {
					_httpPostSocket.onreadystatechange = this.xmlhttpChange;
					_httpPostSocket.open("POST",_url,true);
					_httpPostSocket.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
					_httpPostSocket.send(_postArgs);
				}
			}
		}

		// AJAX Listener //
		this.xmlhttpChange = function() {
			if (_httpPostSocket.readyState == 4) {
				var _responseArray = [];
				var _responseText = _httpPostSocket.responseText;
				var _PFSResponseType = _httpPostSocket.getResponseHeader("PFSResponseType");

				// IE seems to think this is a static object, I think not //
				if (_isIE) {
					_httpPostSocket.abort();
				}

				if (_PFSResponseType == "addComment") {
					_responseArray = _responseText.split("|");

					if (_responseArray[0] == "login") {
						window.location.href = "/login?referer=" + _responseArray[1];
					} else {
						(new httpRequest()).sendRequest(_responseArray[0],eval(_responseArray[1]),false);
					}
				} else if (_PFSResponseType == "saveCopaso") {
					saveCopasoResponse(_responseText);
				} else if (_PFSResponseType == "publishCopaso") {
					publishCopasoResponse(_responseText);
				}
			}
		}
	}

	// AJAX //
	httpRequest = function() {
		var _httpSocket;

		// Send request //
		this.sendRequest = function(_contentElement,_args,_registerNewPageView) {
			var _url = "";
			_registerNewPageView = (_registerNewPageView != "undefined") ? _registerNewPageView : false;

			if ((_contentElement == "loversBlog1") || (_contentElement == "loversBlog2") || (_contentElement == "loversBlog3") || (_contentElement == "loversBlog4")) {
				_url = "/ajax/loversBlog";
			} else if ((_contentElement == "loversFeaturedPCN1") || (_contentElement == "loversFeaturedPCN2") || (_contentElement == "loversFeaturedPCN3")) {
				_url = "/ajax/loversFeaturedPCN";
			} else {
				_url = ("/ajax/" + _contentElement);
			}

			if (window.XMLHttpRequest) {
				_httpSocket = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				try {
					_httpSocket = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (_e) {
					_httpSocket = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}

			if (_contentElement == "loversFriendsComments") {
				// userID, page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "loversFlickr") {
				// flickrID, howMany
				_url += "?flickrID=" + _args[0] + "&howMany=" + _args[1];
			} else if (_contentElement == "loversWhoLoves") {
				// id [user], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "loversWhoILove") {
				// id [user], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "tagCloud") {
				// page
				_url += "?page=" + _args[0];
			} else if (_contentElement == "indexRandColours") {
				// howMany, hue, lover [id], groupID
				_url += "?howMany=" + _args[0] + "&hue=" + _args[1] + "&lover=" + _args[2] + "&groupID=" + _args[3];
			} else if (_contentElement == "similarColours") {
				// howMany, hue
				_url += "?howMany=" + _args[0] + "&hue=" + _args[1];
			} else if (_contentElement == "indexRandPalettes") {
				// howMany, lover [id], groupID
				_url += "?howMany=" + _args[0] + "&lover=" + _args[1] + "&groupID=" + _args[2];
			} else if (_contentElement == "indexRandPatterns") {
				// howMany, lover [id], groupID
				_url += "?howMany=" + _args[0] + "&lover=" + _args[1] + "&groupID=" + _args[2];
			} else if (_contentElement == "loversGroups") {
				// userID, page
				_url += "?userID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "indexTopColours") {
				// howMany, page
				_url += "?howMany=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "newPalettes") {
				// howMany
				_url += "?howMany=" + _args[0];
			} else if (_contentElement == "coloursInPalettes") {
				// id [colour], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "loversFavouritePalettes") {
				// id [user], howMany
				_url += "?id=" + _args[0] + "&howMany=" + _args[1];
			} else if (_contentElement == "loversFavouriteColours") {
				// id [user], howMany
				_url += "?id=" + _args[0] + "&howMany=" + _args[1];
			} else if (_contentElement == "coloursFriendsComments") {
				// id [colour], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "myComments") {
				// id [user], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "coloursWhoLoves") {
				// id [colour], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "groupMembers") {
				// groupID, page
				_url += "?groupID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "palettesInColours") {
				// id [palette], howMany
				_url += "?id=" + _args[0] + "&howMany=" + _args[1];
			} else if (_contentElement == "palettesWhoLoves") {
				// id [palette], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "patternsInColours") {
				// patternID, howMany
				_url += "?patternID=" + _args[0] + "&howMany=" + _args[1];
			} else if (_contentElement == "patternsWhoLoves") {
				// patternID, page
				_url += "?patternID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "patternComments") {
				// patternID, page
				_url += "?patternID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "patternCategorySearchResponse") {
				// patternCategoryID, patternCategoryOrderBy, page
				_url += "?patternCategoryID=" + _args[0] + "&patternCategoryOrderBy=" + _args[1] + "&page=" + _args[2];
			} else if (_contentElement == "searchPatterns") {
				// sortType, sortBy, query, hsb, lover, hex, hueOption0, hueOption1, hueOption2, f, patternDefinitionID, publishedBeginDate, publishedEndDate, page
				_url += "?sortType=" + _args[0] + "&sortBy=" + _args[1] + "&query=" + _args[2] + "&hsb=" + _args[3] + "&lover=" + _args[4] + "&hex=" + _args[5] + "&hueOption0=" + _args[6] + "&hueOption1=" + _args[7] + "&hueOption2=" + _args[8] + "&f=" + _args[9] + "&patternDefinitionID=" + _args[10] + "&publishedBeginDate=" + _args[11] +  "&publishedEndDate=" + _args[12] + "&page=" + _args[13];
			} else if (_contentElement == "palettesFriendsComments") {
				// id [palette], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "indexTopPalettes") {
				// howMany
				_url += "?howMany=" + _args[0];
			} else if (_contentElement == "loversColours") {
				// section, id [user], howMany
				_url += "?section=" + _args[0] + "&id=" + _args[1] + "&howMany=" + _args[2];
			} else if (_contentElement == "rate") {
				// contextType, contextID, score
				_url += "?contextType=" + _args[0] + "&contextID=" + _args[1] + "&score=" + _args[2];
			} else if (_contentElement == "loversPalettes") {
				// section, id [user], howMany
				_url += "?section=" + _args[0] + "&id=" + _args[1] + "&howMany=" + _args[2];
			} else if (_contentElement == "loversPatterns") {
				// section, id [user], howMany
				_url += "?section=" + _args[0] + "&id=" + _args[1] + "&howMany=" + _args[2];
			} else if (_contentElement == "loversFavouriteLovers") {
				// userName, id [user], page
				_url += "?userName=" + _args[0] + "&id=" + _args[1] + "&page=" + _args[2];
			} else if (_contentElement == "searchColours") {
				// sortType, sortBy, query, hsv, lover, hex, f, publishedBeginDate, publishedEndDate, page
				_url += "?sortType=" + _args[0] + "&sortBy=" + _args[1] + "&query=" + _args[2] + "&hsv=" + _args[3] + "&lover=" + _args[4] + "&f=" + _args[6] + "&publishedBeginDate=" + _args[7] +  "&publishedEndDate=" + _args[8] + "&page=" + _args[9];
			} else if (_contentElement == "searchPalettes") {
				// sortType, sortBy, query, hsv, lover, hex, hueOption0, hueOption1, hueOption2, f, publishedBeginDate, publishedEndDate, page
				_url += "?sortType=" + _args[0] + "&sortBy=" + _args[1] + "&query=" + _args[2] + "&hsv=" + _args[3] + "&lover=" + _args[4] + "&hex=" + _args[5] + "&hueOption0=" + _args[6] + "&hueOption1=" + _args[7] + "&hueOption2=" + _args[8] + "&f=" + _args[9] + "&publishedBeginDate=" + _args[10] +  "&publishedEndDate=" + _args[11] + "&page=" + _args[12];
			} else if (_contentElement == "searchLovers") {
				// sortType, sortBy, query, location, lover, page
				_url += "?sortType=" + _args[0] + "&sortBy=" + _args[1] + "&query=" + _args[2] + "&location=" + _args[3] + "&lover=" + _args[4] + "&page=" + _args[5];
			} else if (_contentElement == "recentLovers") {
				// NULL, page
				_url += "?page=" + _args[1];
			} else if (_contentElement == "recentComments") {
				// contextType, page
				_url += "?contextType=" + _args[0] + "&page=" + _args[1];
			} else if ((_contentElement == "loversBlog1") || (_contentElement == "loversBlog2") || (_contentElement == "loversBlog3") || (_contentElement == "loversBlog4")) {
				// data, howMany
				_url += "?data=" + _args[0] + "&howMany=" + _args[1] + "&contentElement=" + _contentElement;
			} else if ((_contentElement == "loversFeaturedPCN1") || (_contentElement == "loversFeaturedPCN2") || (_contentElement == "loversFeaturedPCN3")) {
				// section, userID, howMany
				_url += "?section=" + _args[0] + "&userID=" + _args[1] + "&howMany=" + _args[2] + "&contentElement=" + _contentElement;
			} else if (_contentElement == "checkIfColoursExist") {
				// paletteColours, pickerType, overwrite
				_url += "?paletteColours=" + _args[0] + "&pickerType=" + _args[1] + "&overwrite=" + _args[2];
			} else if (_contentElement == "trendsTrends") {
				// year, month, query, hsv, trendType, page
				_url += "?year=" + _args[0] + "&month=" + _args[1] + "&query=" + _args[2] + "&hsv=" + _args[3] + "&trendType=" + _args[4] + "&page=" + _args[5];
			} else if (_contentElement == "websiteTrendsTrends") {
				// year, month, query, hex, url, hueOption0, hueOption1, hueOption2
				_url += "?year=" + _args[0] + "&month=" + _args[1] + "&query=" + _args[2] + "&hex=" + _args[3] + "&url=" + _args[4] + "&hueOption0=" + _args[5] + "&hueOption1=" + _args[6] + "&hueOption2=" + _args[7] + "&page=" + _args[8];
			} else if (_contentElement == "prevCoverColours") {
				// howMany, id [trend]
				_url += "?howMany=" + _args[0] + "&id=" + _args[1];
			} else if (_contentElement == "websiteTrendsComments") {
				// websiteTrendID, page
				_url += "?websiteTrendID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "trendsComments") {
				// id [trend], page
				_url += "?id=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "newsNews") {
				// NULL, page
				_url += "?page=" + _args[1];
			} else if (_contentElement == "blogBlog") {
				// NULL, page
				_url += "?page=" + _args[1];
			} else if (_contentElement == "addColourReference") {
				// hex
				_url += "?hex=" + _args[0];
			} else if ((_contentElement == "loverUnsubscribeAll") || (_contentElement == "loverSubscribeAll")) {
				// subscriptionContextType
				_url += "?subscriptionContextType=" + _args[0];
			} else if (_contentElement == "picturePaletteInspiration") {
				// url
				_url += "?url=" + _args[0];
			} else if (_contentElement == "copasoPixelatedImageOnClick") {
				// url, x, y
				_url += "?url=" + _args[0] + "&x=" + _args[1] + "&y=" + _args[2];
			} else if (_contentElement == "copasoPixelatedImgPreview") {
				// url, x, y
				_url += "?url=" + _args[0] + "&x=" + _args[1] + "&y=" + _args[2];
			} else if ((_contentElement == "copasoSearchColors") || (_contentElement == "copasoSearchPalettes")) {
				// SO - Search Options
				_url += "?SO=" + _args[0];
			} else if (_contentElement == "copasoInfoTooltip") {
				// elementID, hexOrPaletteID
				_url += "?elementID=" + _args[0] + "&hexOrPaletteID=" + _args[1];
			} else if (_contentElement == "remComment") {
				// contextType, commentID, reffererArgs
				_url += "?contextType=" + _args[0] + "&commentID=" + _args[1] + "&reffererArgs=" + _args[2];
				_url += (_mK !== undefined) ? "&mK=" + _mK : "";
			} else if (_contentElement == "loversModTopUsers") {
				// excludedUserIDs, recordCount, page
				_url += "?excludedUserIDs=" + _args[0] + "&recordCount=" + _args[1] + "&page=" + _args[2];
			} else if (_contentElement == "loversModTopUsersPaging") {
				// recordCount, page
				_url += "?recordCount=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "echo") {
				// N/A
			} else if (_contentElement == "recentlyActiveSponsors") {
				// N/A
			} else if (_contentElement == "colorCodeComments") {
				// colorCodeID, page
				_url += "?colorCodeID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "rmCopasoImg") {
				// path
				_url += "?path=" + _args[0];
			} else if (_contentElement == "photocopaImageWhoLoves") {
				// photocopaImageID, page
				_url += "?photocopaImageID=" + _args[0] + "&page=" + _args[1];
			} else if (_contentElement == "photocopaImageComments") {
				// photocopaImageID, page
				_url += "?photocopaImageID=" + _args[0] + "&page=" + _args[1];
			}

			if (!["rate","checkIfColoursExist","loverUnsubscribeAll","loverSubscribeAll","picturePaletteInspiration","copasoPixelatedImageOnClick","copasoPixelatedImgPreview","copasoSearchPalettes","copasoSearchColors","copasoInfoTooltip","remComment","echo","rmCopasoImg"].in_array(_contentElement)) {
				$(_contentElement).innerHTML = getLoadingFlash();
			}

			if ((_contentElement == "loverUnsubscribeAll") || (_contentElement == "loverSubscribeAll")) {
				var _subscriptionAction = (_contentElement == "loverUnsubscribeAll") ? "u" : "s";
				var _text = (_contentElement == "loverUnsubscribeAll") ? "Unsubscribing" : "Subscribing";
				$("d" + _args[0] + "s_" + _subscriptionAction + "a").innerHTML = (_text + " ...");
			}

			if (_registerNewPageView) {
				// Tell Google that we have another page view //
				try {
					urchinTracker(_url);
				} catch (_e) {}
			}
			if (window.XMLHttpRequest) {
				_httpSocket.onreadystatechange = this.xmlhttpChange;
				_httpSocket.open("GET",_url,true);
				_httpSocket.setRequestHeader("Content-Type","text/plain; charset=UTF-8");
				_httpSocket.send(null);
			} else if (window.ActiveXObject) {
				if (_httpSocket) {
					_httpSocket.onreadystatechange = this.xmlhttpChange;
					_httpSocket.open("GET",_url,true);
					_httpSocket.setRequestHeader("Content-Type","text/plain; charset=UTF-8");
					_httpSocket.send();
				}
			}
		}

		// AJAX Listener //
		this.xmlhttpChange = function() {
			if (_httpSocket.readyState == 4) {
				var _responseArray = [], _alertText, _ns = [];
				var _responseText = _httpSocket.responseText;
				var _PFSResponseType = _httpSocket.getResponseHeader("PFSResponseType");

				// IE seems to think this is a static object, I think not //
				if (_isIE) {
					_httpSocket.abort();
				}

				if (_PFSResponseType == "rate") {
					_responseArray = _responseText.split("|");

					if (_responseArray[0] == "login") {
						window.location.href = "/login?referer=" + _responseArray[1];
					} else if (_responseArray[0] == "alert") {
						if (_responseArray[1] == "priorVote") {
							_alertText = "You have already voted for this Palette / Color.\nYou can vote again next month.";
						} else if (_responseArray[1] == "noCP") {
							_alertText = "ERROR => Color / Palette does not exist!";
						} else if (_responseArray[1] == "invalidScore") {
							_alertText = "Score was out of range!";
						} else if (_responseArray[1] == "invalidContextType") {
							_alertText = "ERROR => Bad `contextType`.";
						}
						alert(_alertText);
					} else if (_responseArray[0] == "success") {
						_ns = eval(_responseArray[1]);
						$("rateNumVotes").innerHTML = _ns[0];
						$("rateScore").innerHTML = _ns[1];
					}
				} else if ((_PFSResponseType == "loverUnsubscribeAll") || (_PFSResponseType == "loverSubscribeAll")) {
					if (_responseText == "login") {
						window.location.href = "/login"; // Just in case their session times out //
					} else if (_responseText != "") {
						_responseArray = _responseText.split("|");
						if (_responseArray[0]) {
							var _subscriptionAction = (_PFSResponseType == "loverUnsubscribeAll") ? "u" : "s";
							var _text = (_PFSResponseType == "loverUnsubscribeAll") ? "Unsubscribed!" : "Subscrition[s] Confirmed";
							$("d" + _responseArray[1] + "s_" + _subscriptionAction + "a").innerHTML = _text;
						}
					} else {
						alert("Bad subscriptionContextType");
					}
				} else if (_PFSResponseType == "checkIfColoursExistN") {
					_patternObject.checkIfColorsExistRequestResponse(_responseText);
				} else if (_PFSResponseType == "checkIfColoursExistP") {
					_coloursChecked = true;
					_newColours = _responseText;
					addPalette();
				} else if (_PFSResponseType == "checkIfColoursExistC") {
					_coloursChecked = true;
					_colourExists = true;

					if (_responseText == "cdne") {
						_colourExists = false;
					}
					addColour();
				} else if (_PFSResponseType == "picturePaletteInspiration") {
					if (_responseText == "badimg") {
						$("picturePaletteInspirationInnerDiv").innerHTML = "<div style=\"color: #d40000; margin-top: 50px;\"><strong>ERROR:</strong> The URL you provided is invalid.</div>";
					} else {
						_responseText = _responseText.split("|");

						$("picturePaletteInspirationInnerDiv").innerHTML = "";
						for (var _i=0;_i<_responseText.length;_i++) {
							$("picturePaletteInspirationInnerDiv").innerHTML += "<a href=\"JavaScript:updateHexDiv('" + _responseText[_i] + "');%20setHex(_currentColourDiv);\" style=\"background-color: #" + _responseText[_i] + ";\" title=\"#" + _responseText[_i] + "\"></a>";
						}
					}
				} else if (_PFSResponseType == "copasoPixelatedImageOnClick") {
					copasoPixelatedImageHex(_responseText);
				} else if (_PFSResponseType == "copasoPixelatedImgPreview") {
					copasoPixelatedImgPreview(_responseText);
				} else if (_PFSResponseType == "copasoSearchPalettes") {
					searchPaletteResults(_responseText);
				} else if (_PFSResponseType == "copasoSearchColors") {
					searchColorResults(_responseText);
				} else if (_PFSResponseType == "checkIfColoursExistCopaso") {
					checkIfCopasoColorsExistResponse(_responseText);
				} else if (_PFSResponseType == "copasoInfoTooltip") {
					showInfoTooltipResponse(_responseText);
				} else if (_PFSResponseType == "remComment") {
					_responseTextArray = _responseText.split("|");
					if (_responseTextArray[0] == "redirect") {
						window.location.href = _responseTextArray[1];
					} else {
						buildRequest(_responseTextArray[0],[_responseTextArray[1],_responseTextArray[2]]);
					}
				} else if (_PFSResponseType == "loversModTopUsers") {
					var _responseObject = _responseText.evalJSON(true);
					var _recordCount = parseInt(_responseObject["recordCount"]);
					var _numRows = parseInt(_responseObject["rows"]);
					var _responsePage = parseInt(_responseObject["page"]);
					var _innerHTML = "<ul id=\"topFriends\" class=\"topFriendsUL whoLoves\" style=\"height: 330px;\">\n";

					for (var _i=0;_i<_numRows;_i++) {
						_innerHTML += "<li class=\"d dragCursor\" id=\"topFriends_" + _responseObject[_i]["userID"].toString() + "\" style=\"margin-bottom: 4px;\">";
							_innerHTML += (_responseObject[_i]["showSponsoredBadge"]) ? "<div class=\"s\" style=\"margin: -5px 0 -13px -5px;\" title=\"Sponsor\"></div>" : "";
							_innerHTML += "<img src=\"" + _responseObject[_i]["thumbpath"] + "\" class=\"i\" style=\"width: 63px; height: 50px;\" alt=\"" + _responseObject[_i]["loverUserNameLong"].toString() + "\" />" + _responseObject[_i]["loverUserName"].toString() + "\n";
						_innerHTML += "</li>\n";
					}
					$("loversModTopUsers").innerHTML = (_innerHTML + "</ul>\n\n");

					if (_isSponsored) {
						loversModTopUsers_updateSequence = function() {
							var _i = 0, _id = "";
							Sortable.sequence("topFriends").each(function(_userID) {
								_id = ("topFriends_" + _userID); // Seriously, WTF, IE?
								$S(_id).marginBottom = (_i++ < 5) ? "14px" : "4px";
							});
						}

						Sortable.destroy("topFriends");
						Sortable.create("topFriends",{
							overlap: "horizontal",
							constraint: true,
							onChange: loversModTopUsers_updateSequence
						});
						loversModTopUsers_updateSequence();
						// Account for the 5 record accumulative offset on each page:
						_recordCount += (Math.ceil(((_recordCount - 5) * 5) / 15) - 5);

						if (_recordCount > _numRows) {
							buildRequest("loversModTopUsersPaging",[_recordCount,_responsePage]);
						}
					}
				} else if (_PFSResponseType == "echo") {
					// Do Nothing
				} else {
					$(_PFSResponseType).innerHTML = _responseText;
				}
			}
		}
	}

	buildPost = function(_contentElement,_args) {
		(new httpPost()).sendRequest(_contentElement,_args,true);
	}

	buildRequest = function(_contentElement,_args,_registerNewPageView) {
		(new httpRequest()).sendRequest(_contentElement,_args,_registerNewPageView);
	}

	goToAnchor = function(_anchor) {
		if (_anchor) {
			window.location.href = ((/^([^#]+)#?(.*)?$/.exec(window.location.href))[1] + "#" + _anchor);
		}
	}

	rotatePalette = function(_args,_cPW) {
		_paletteAngle++;
		if (_paletteAngle == 4) {
			_paletteAngle = 0;
		}
		$("paletteImg").src = ("/paletteImg/" + _args + "?angle=" + _paletteAngle + "&cPW=" + _cPW);
	}

	indexStatsOnClick = function(_thisID,_subElementID) {
		["indexStatsTM","indexStatsTW","indexStatsT"].each(function(_elementID) {
			$(_elementID).className = "";
			$S(_elementID + "Div").display = "none";
		});
		$(_thisID).className = "on";
		$S(_thisID + "Div").display = "block";

		["c","p","n","u"].each(function(_tmpID) {
			$(_thisID + "Div" + _tmpID).className = "";
			$S(_thisID + "Div" + _tmpID + "Div").display = "none";
		});

		if (_subElementID) {
			$S(_thisID + "Div" + _subElementID + "Div").display = "block";
			$(_thisID + "Div" + _subElementID).className = "on";
		} else {
			$S(_thisID + "DivcDiv").display = "block";
			$(_thisID + "Divc").className = "on";
		}
	}

	getPicturePaletteInspirationColors = function() {
		var _url = $("picturePaletteInspiration").value;
		if (_url == "http://") {
			return false;
		}
		if ((_url.indexOf("http://") != -1) || (_url.indexOf("https://") != -1)) {
			$("picturePaletteInspirationImg").src = ("/srcImg/" + _url.base64_encode());
			$("picturePaletteInspirationInnerDiv").innerHTML = getLoadingFlash();
			$("picturePaletteInspirationTable").style.display = "block";
			buildRequest("picturePaletteInspiration",[_url]);
		} else {
			alert("Please enter a valid URL!\n\nFor Example:") + " http://www.colourlovers.com/images/logo.png";
			$("picturePaletteInspiration").focus();
		}
	}

	rmLoveNoteConf = function(_amt) {
		var _go = false;
		if (_amt == 1) {
			_go = confirm("Are you sure you want to Delete this Love Note?");
		} else {
			_go = confirm("Are you sure you want to Delete these Love Notes?");
		}
		if (_go) {
			$("remLoveNotesForm").submit();
		}
	}

	toggleAll = function(_checked) {
		if (_isLoaded) {
			for (var _i=0;_i<_numCheckboxes;_i++) {
				$("cb" + _i).checked = _checked;
			}
		}
	}

	setCaret = function(_elementID,_position) {
		if ($(_elementID).createTextRange) {
			var _range = $(_elementID).createTextRange();
			_range.move("character",_position);
			_range.select();
		} else if ($(_elementID).selectionStart) {
			$(_elementID).setSelectionRange(_position,_position);
		}
	}

	clearRadios = function(_groupName) {
		var _radios = document.getElementsByName(_groupName);
		for (var _i=0;_i<_radios.length;_i++) {
			_radios[_i].checked = false;
		}
	}

	// Build search request //
	submitComment = function (_commentsID,_contextType,_contextID) {
		// Get comments //
		var _comments = $("ajaxComments").value.replace(/\n/g,"__CL_NEWLINE_CHAR_0192837465__");
		_comments = _comments.replace(/&/g,"__CL_AMPERASAND_CHAR_0192837465__");
		_comments = _comments.replace(/#/g,"__CL_POUND_SIGN_CHAR_0192837465__");
		_comments = _comments.replace(/\+/g,"__CL_PLUSSIGN_CHAR_0192837465__");

		if (_comments != "") {
			// Clear comments //
			$("ajaxComments").value = "";
			// Send request //
			(new httpPost()).sendRequest("addComment",[_commentsID,_contextType,_contextID,_comments],true);
		}
		return false;
	}


	// Rating object //
	rateObject = function(_rateName,_contextType,_contextID) {
		this._rateName = _rateName;
		this._heartTimer = null;
		this._numHearts = 0;
		this._canAni = true;
		this._contextType = _contextType;
		this._contextID = _contextID;
		this._heartPath = "";

		this.showHearts = function(_heartNum) {
			this.clearHeartTimer();
			this.greyHearts();
			this.colorHearts(_heartNum);
		}

		this.colorHearts = function(_heartNum) {
			var _hURL = "";
			if (this._canAni) {
				for (var _i=0;_i<_heartNum;_i++) {
					if ((_heartNum + 1) > _i) {
						_hURL = (_heartNum == (_i + 0.5)) ? "half.png" : "full.png";
					} else {
						_hURL = "empty.png";
					}

					$("heart" + (_i + 1)).src = getStaticURL("/images/v3.5/_/hearts/" + this._heartPath + _hURL);
				}
			}
		}

		this.greyHearts = function() {
			if (this._canAni) {
				for (var _i=0;_i<5;_i++) {
					$("heart" + (_i + 1)).src = getStaticURL("/images/v3.5/_/hearts/" + this._heartPath + "empty.png");
				}
			}
		}

		this.setHearts = function(_heartNum) {
			this._numHearts = _heartNum;
			this.drawHearts(_heartNum);
			this._canAni = false;
			this.setHearts = function(){};
			buildRequest("rate",[this._contextType,this._contextID,((_heartNum * 2) - 1)])
		}

		this.drawHearts = function(_heartNum) {
			this._numHearts = _heartNum;
			this.showHearts(_heartNum);
		}

		this.clearHearts = function() {
			this._heartTimer = setTimeout(this._rateName + ".resetHearts()",200);
		}

		this.resetHearts = function() {
			this.clearHeartTimer();

			if (this._numHearts) {
				this.drawHearts(this._numHearts);
			} else {
				this.greyHearts();
			}
		}

		this.clearHeartTimer = function() {
			if (this._heartTimer) {
				clearTimeout(this._heartTimer);
				this._heartTimer = null;
			}
		}
	}

	showDatePicker = function(_elementID,_date) {
		var _days = [], _daysClasses = [], _dates = [];
		_date = new Date((_date === undefined) ? Date.parse($(_elementID).value) : Date.parse(_date));
		_date = (isNaN(_date)) ? new Date() : _date;

		var _numDaysInThisMonth = parseInt(32 - (new Date(_date.getFullYear(),_date.getMonth(),32).getDate()),10);
		var _firstDayOffset = (new Date(_date.getFullYear(),_date.getMonth(),1)).getDay();
		var _numDaysInLastMonth = parseInt(32 - (new Date(_date.getFullYear(),_date.getMonth() - 1,32).getDate()),10);
		var _numWeeksInThisMonth = Math.ceil((_numDaysInThisMonth + _firstDayOffset) / 7);
		var _numDaysTrailing = parseInt((_numWeeksInThisMonth * 7) - _numDaysInThisMonth - _firstDayOffset);
		var _offset = absPos($(_elementID));
		var _lastMonth = new Date(_date.getFullYear(),_date.getMonth() - 1,_date.getDate());
		var _nextMonth = new Date(_date.getFullYear(),_date.getMonth() + 1,_date.getDate());
		var _lastMonthURL = (_lastMonth.getMonth() + 1).toString() + "/" + _lastMonth.getDate().toString() + "/" + _lastMonth.getFullYear().toString();
		var _nextMonthURL = (_nextMonth.getMonth() + 1).toString() + "/" + _nextMonth.getDate().toString() + "/" + _nextMonth.getFullYear().toString();
		_lastMonth = _monthNames[_lastMonth.getMonth()] + " " + _lastMonth.getFullYear().toString();
		_nextMonth = _monthNames[_nextMonth.getMonth()] + " " + _nextMonth.getFullYear().toString();

		if (_firstDayOffset !== 0) {
			_days = _days.concat($A($R(_numDaysInLastMonth - _firstDayOffset + 1,_numDaysInLastMonth)));
			_daysClasses = _daysClasses.concat([].fill(0,_firstDayOffset," class=\"darkTD\""));

			for (var _i=_firstDayOffset - 1;_i>=0;_i--) {
				_dates.push(new Date(_date.getFullYear(),_date.getMonth() - 1,_numDaysInLastMonth - _i));
			}
		}

		_days = _days.concat($A($R(1,_numDaysInThisMonth)));
		_daysClasses = _daysClasses.concat([].fill(0,_numDaysInThisMonth,""));
		for (var _i=1;_i<=_numDaysInThisMonth;_i++) {
			_dates.push(new Date(_date.getFullYear(),_date.getMonth(),_i));
		}

		if (_numDaysTrailing !== 0) {
			_days = _days.concat($A($R(1,_numDaysTrailing)));
			_daysClasses = _daysClasses.concat([].fill(0,_numDaysTrailing," class=\"darkTD\""));
			for (var _i=1;_i<=_numDaysTrailing;_i++) {
				_dates.push(new Date(_date.getFullYear(),_date.getMonth() + 1,_i));
			}
		}

		var _buffer = "";
		_buffer += "<div class=\"calendarDiv\">\n";
			_buffer += "<form action=\"#\" method=\"get\" onsubmit=\"showDatePicker('" + _elementID + "',new Date($('datePicker_year').value,$('datePicker_month').value,$('datePicker_day').value)); return false;\">\n";
				_buffer += "<input type=\"hidden\" id=\"datePicker_day\" value=\"" + _date.getDate() + "\" />\n";
				_buffer += "<select id=\"datePicker_month\" class=\"formElement\" style=\"width: 100px;\">\n"; // In JS's 0-based format
					for (var _i=0;_i<_monthNames.length;_i++) {
						_buffer += "<option value=\"" + _i + "\"" + ((_date.getMonth() === _i) ? " selected=\"selected\"" : "") + ">" + _monthNames[_i] + "</option>";
					}
				_buffer += "</select>";
				_buffer += "<select id=\"datePicker_year\" class=\"formElement\" style=\"margin: 0 8px; width: 55px;\">\n";
					for (var _i=2004;_i<(new Date()).getFullYear() + 1;_i++) {
						_buffer += "<option value=\"" + _i + "\"" + ((_date.getFullYear() === _i) ? " selected=\"selected\"" : "") + ">" + _i + "</option>";
					}
				_buffer += "</select>";
				_buffer += "<input type=\"submit\" class=\"formBtn\" style=\"padding: 0;\" value=\"GO\" />";
			_buffer += "</form>\n";

			_buffer += "<a href=\"#\" onclick=\"showDatePicker('" + _elementID + "','" + _lastMonthURL + "'); return false;\" class=\"block left\" style=\"margin: 5px 0;\">&lt;&lt; " + _lastMonth + "</a>\n";
			_buffer += "<a href=\"#\" onclick=\"showDatePicker('" + _elementID + "','" + _nextMonthURL + "'); return false;\" class=\"block right\" style=\"margin: 5px 0;\">" + _nextMonth + " &gt;&gt;</a>\n";
			_buffer += "<div class=\"clear\"></div>\n";

			_buffer += "<table cellpadding=\"0\" cellspacing=\"1\">\n";
				_buffer += "<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></td>\n";
			_buffer += "</table>\n";

			_buffer += "<table cellpadding=\"0\" cellspacing=\"1\" class=\"calendarTable\">\n";
				var _l = 0, _dateStr = "";
				for (var _i=0;_i<_numWeeksInThisMonth;_i++) {
					_buffer += "<tr>\n";
						for (var _j=0;_j<7;_j++) {
							_dateStr = _dates[_l].getDate() + "," + _dates[_l].getMonth() + "," + _dates[_l].getFullYear();
							_buffer += "<td" + _daysClasses[_l] + "" + ((_date.valueOf() == _dates[_l].valueOf()) ? " style=\"background-color: #aaaaaa;\"" : "") + "><a href=\"#\" onclick=\"datePickerSetDate('" + _elementID + "'," + _dateStr + ");\">" + _days[_l] + "</a></td>\n";
							_l++;
						}
					_buffer += "</tr>\n";
				}
			_buffer += "</table>\n";
		_buffer += "</div>\n";

		if (!$("datePickerDiv")) {
			$$("body")[0].appendChild(Builder.node("div",{id: "datePickerDiv",style: "display: none; position: absolute; top: 0; left: 0; zindex: 10;"}));
		}

		$("datePickerDiv").innerHTML = _buffer;
		$S("datePickerDiv").left = (_offset.x + 1).toString() + "px";
		$S("datePickerDiv").top = (_offset.y + 19).toString() + "px";
		$("datePickerDiv").show();
	}

	datePickerSetDate = function(_elementID,_day,_month,_year) {
		var _date = new Date(_year,_month,_day);
		var _month = (_date.getMonth() + 1).toString();
		var _day = _date.getDate().toString();

		$(_elementID).value = ((_month.length === 1) ? ("0" + _month) : _month) + "/" + ((_day.length === 1) ? "0" + _day : _day) + "/" + _date.getFullYear();
		$("datePickerDiv").fade({duration: 0.2});
	}

	getHearts = function(_score) {
		return (_score == 0) ? 0 : ((Math.floor(_score) / 2) + 0.5);
	}

	hsvSearchOnSubmit = function() {
		if ($("hsv")) {
			$("hsv").value = (_hSliders.values.toString() + "|" + _bSliders.values.toString());
		}
	}

	hSliderOnSlide = function(_val,_leftSliderID,_rightSliderID) {
		_leftSliderID = (_leftSliderID == undefined) ? "hue1O" : _leftSliderID;
		_rightSliderID = (_rightSliderID == undefined) ? "hue2O" : _rightSliderID;

		$S(_leftSliderID).width = (parseInt((_val[0] * 390) / 360) + 1) + "px";
		$S(_rightSliderID).width = ((390 - parseInt((_val[1] * 390) / 360)) - 1) + "px";
	}

	bSliderOnSlide = function(_val,_leftSliderID,_rightSliderID) {
		_leftSliderID = (_leftSliderID == undefined) ? "bri1O" : _leftSliderID;
		_rightSliderID = (_rightSliderID == undefined) ? "bri2O" : _rightSliderID;

		$S(_leftSliderID).width = (parseInt((_val[0] * 390) / 100) + 1) + "px";
		$S(_rightSliderID).width = ((390 - parseInt((_val[1] * 390) / 100)) - 1) + "px";
	}

	replyTo = function(_divID,_inputID,_userName) {
		var _regEx = /<br( \/)?>/g;
		if ($(_inputID).value == "") {
			$(_inputID).value = (_userName.base64_decode() + " wrote:\n<blockquote>" + $(_divID).innerHTML.replace(_regEx,"") + "</blockquote>");
		} else {
			$(_inputID).value += (_userName.base64_decode() + " wrote:\n<blockquote>" + $(_divID).innerHTML.replace(_regEx,"") + "</blockquote>");
		}
		$(_inputID).focus();
	}

	confRemAvatar = function() {
		if (confirm("Are you sure you want to Delete your Avatar?")) {
			window.location.href = "/op/remAvatar";
		}
	}

	confRemPicture = function() {
		if (confirm("Are you sure you want to Delete your Picture?")) {
			window.location.href = "/op/remPicture";
		}
	}

	// Show subNav //
	showSubNav = function(_elementID) {
		_wait = 0;
		if (_canAni == "show") {
			$S("navUL").marginBottom = 0;
			if ($("subNavContainer").style.height != (_incArrayMenuH[0] + "px")) {
				// If subNavContainer is closed...
				_canAni = "";
				for (var _i=0;_i<_incArrayMenu.length;_i++) {
					setTimeout("aniSubNav(" + _incArrayMenu[_i] + "," + _incArrayUL[_i] + ")",(_animateBy * _i));
				}
				$S("subNavContainer").display = "block";
			}
			_wait = (_incArrayMenu.length * _animateBy);
			setTimeout("menuAniStop('hide')",(_wait + 19));
		}

		fadeElement("sub" + _elementID,0);
		for (var _i=1;_i<=10;_i++) {
			setTimeout("fadeElement('sub" + _elementID + "'," + _i + ")",(_wait + (_animateBy * _i)));
		}
		highlightNav(_elementID);

		// Close any SubNavs we have open //
		for (var _i=0;_i<=_subNavCount;_i++) {
			$S("subNav" + _i).display = "none";
		}
		$S("sub" + _elementID).display = "block";
	}

	aniSubNav = function(_howMuchMenu,_howMuchUL) {
		$S("subNavContainer").height = (_howMuchMenu + "px");
		$S("navUL").marginTop = (_howMuchUL + "px");
	}

	// Hide subNav //
	hideSubNav = function() {
		_wait = 0;
		if (_canAni == "hide") {
			if ($S("subNavContainer").height == (_incArrayMenuH[0] + "px")) {
				_canAni = "";
				for (var _i=0;_i<_incArrayMenu.length;_i++) {
					setTimeout("aniSubNav(" + _incArrayMenuH[_i] + "," + _incArrayULH[_i] + ")",(_animateBy * _i));
				}
				_wait = (_incArrayMenu.length * _animateBy);
				setTimeout("menuAniStop('show')",(_wait + 19));
			}
		}
	}

	menuOver = function() {
		try {
			clearTimeout(_timeOut);
		} catch(_e) {}
	}

	menuOut = function() {
		_timeOut = setTimeout("hideSubNav(); highlightNav();",750);
	}

	// Called when the menu is done animating [either up or down]
	menuAniStop = function(_showHide) {
		_canAni = _showHide;
	}

	// Highlight whatever _elementID is passed //
	highlightNav = function(_elementID) {
		// Clear any Nav Anchors we have higlighted //
		for (var _i=0;_i<=_navCount;_i++) {
			// See .nav li a in ./global.css for values //
			$S("Nav" + _i).background = "";
			$S("Nav" + _i).color = "#515151";
		}
		if (_elementID) {
			// See .nav li a:hover in ./global.css for values //
			$S(_elementID).background = "transparent url(http://colourlovers.com.s3.amazonaws.com/images/v3/header/nav/bgOver.png) top right no-repeat";
			$S(_elementID).color = "#ffffff";
		}
	}

	// Fades _elementID to _opacity, called from timeouts //
	fadeElement = function(_elementID,_opacity) {
		// Safari seems to think it's funny to throw a moueover event when you move your mouse, so this will flicker: //
		if (_isIE) {
			$(_elementID).style.filter = "alpha(opacity=" + (_opacity * 10) + ")";
		} else if (_isMoz) {
			$(_elementID).style.MozOpacity = (_opacity / 10);
			$(_elementID).style.opacity = (_opacity / 10);
		}
	}

	swapImage = function(_elementID,_src) {
		var _element = "";
		if (_element = _src.match(/(.+)_off\.png$/)) {
			$(_elementID).src = _element[1] + "_on.png";
		} else {
			$(_elementID).src = _src.match(/(.+)_on\.png$/)[1] + "_off.png";
		}
	}

	toggleDisplay = function(_elementIDs,_flow) {
		if (_elementIDs.constructor != Array) {
			_elementIDs = [_elementIDs];
		}
		for (var _i=0;_i<_elementIDs.length;_i++) {
			$(_elementIDs[_i]).style.display = (_flow) ? _flow : "none";
		}
	}


	// Verify object //
	objectVerify = function() {
		this._elements = new Array;
		this._i = 0;

		this.addElement = function(_elementID,_vType,_errMsg) {
			this._elements[this._i] = [_elementID,_vType,_errMsg];
			this._i++;
		}

		this.getElement = function(_elementID) {
			return this._elements[_elementID];
		}
	}

	// Prototypes //
	Array.prototype.implode = function(_char) {
		return this.toString().replace(/,/g,_char);
	}

	Array.prototype.in_array = function(_needle) {
		for (var _i=0;_i<=this.length;_i++ ) {
			if (this[_i] == _needle) {
				return true;
			}
		}
		return false;
	}

	Array.prototype.fill = function(_beginIndex,_end,_value) {
		var _array = [];
		for (var _i=_beginIndex;_i<_end;_i++ ) {
			_array[_i] = _value;
		}
		return _array;
	}

	Array.prototype.sum = function() {
		var _sum = 0.0, _length = this.length;

		if (_length === 0) {
			return false;
		}

		for (var _i=0;_i<_length;_i++ ) {
			if (isNaN(this[_i]) === true) {
				return false;
			}
			_sum += this[_i];
		}
		return _sum;
	}

	String.prototype.stripLowerASCII = function() {
		return this.replace(/([\x00-\x08\x0b-\x0c\x0e-\x19])/g,"");
	}

	String.prototype.padHex = function() {
		var _str = ("000000".toString() + this.toString());
		return _str.substring((_str.length - 6),_str.length); // THANKS IE!!!!
	}

	String.prototype.padLeft = function(_padStr,_amount) {
		var _finalPadStr = "", _str = "";
		_amount++;

		for (var _i=0;_i<_amount;_i++) {
			_finalPadStr += _padStr.toString();
		}
		_str = (_finalPadStr + this.toString());
		return _str.substring((_str.length - _amount),_str.length); // THANKS IE!!!!
	}



	// Custom //
	addEngine = function() {
		if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
			window.sidebar.addSearchEngine("http://www.COLOURlovers.com/firefox/COLOURlovers.src",getStaticURL("/firefox/COLOURlovers.png"),"COLOURlovers","COLOURlovers Palette Search");
		} else {
			alert("The Firefox browser is required to install this plugin.");
		}
	}

	addEngine2 = function() {
		if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
			window.sidebar.addSearchEngine("http://www.COLOURlovers.com/firefox/COLOURlovers_hex.src",getStaticURL("/firefox/COLOURlovers.png"),"COLOURlovers hex","COLOURlovers Palette HEX Search");
		} else {
			alert("The Firefox browser is required to install this plugin.");
		}
	}

	init();