
	/* opens the faq. */
	function jPopFAQ(sURL, iWidth, iHeight) {
		jNewWindow("http://www.ideablender.com/cdn/faq/challenge-packages.faq.php#" + sURL, iWidth, iHeight);
	}
	
	/* opens a new window. */
	function jNewWindow(sURL, iWidth, iHeight) {
		var iDate = new Date(); var iTime = iDate.getTime();
		eval("oPage" + iTime + " = window.open(sURL, '" + iTime + "', 'toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=0, width=" + iWidth + ", height=" + iHeight + ", left=100, top=100');");
	 }
	
	/* redirects the browser. */
	function jRedirect(sDestination) {
		window.location = sDestination;
	}
	
	/* triggered when the search input receives focus. */
	function eSearchFocus(oElement, sDefault) {
		oElement.value = oElement.value == sDefault ? "" : sDefault;
	}
	
	/* triggered when the search input loses focus. */
	function eSearchBlur(oElement, sDefault) {
		oElement.value = oElement.value == "" ? sDefault : oElement.value;
	}
	
	/* triggered when the search form is submitted. */
	function jDoSearch(oForm) {
		window.location = "{RelativePath}/challenges/browse/?s=" + escape(oForm["Query"].value);
		return false;
	}
	
	/* gets the current scroll offset. */
	function jGetScrollOffset() {
		if (window.pageYOffset) return window.pageYOffset;
		if (document.documentElement) return document.documentElement.scrollTop;
		if (document.body) return document.body.scrollTop;
	}
	
	/* sets the current scroll offset. */
	function jSetScrollOffset(iValue) {
		if (window.pageYOffset) window.pageYOffset = parseInt(iValue);
		if (document.documentElement) document.documentElement.scrollTop = parseInt(iValue);
		if (document.body) document.body.scrollTop = parseInt(iValue);
	}
	
	/* gets the value of a cookie. */
	function jGetCookie(sName) {
		
		var iStart = document.cookie.indexOf(sName + "=");
		var iLength = iStart + sName.length + 1;
		
		if ((!iStart) && (sName != document.cookie.substring(0, sName.length))) {
			return null;
		}
		
		if (iStart == -1) return null;
		
		var iEnd = document.cookie.indexOf(";", iLength);
		
		if (iEnd == -1) {
			iEnd = document.cookie.length;
		}
		
		return unescape(document.cookie.substring(iLength, iEnd));
	
	}
	
	/* handles focus and blur events for input. */
	function eFocusInput(oElement, sDefault, bIsFocus) {
		
		if (bIsFocus && oElement.value == sDefault) {
			oElement.value = "";
		} else if (!bIsFocus && oElement.value == "") {
			oElement.value = sDefault;
		}
	
	}
	
	/* gets the value of the selected radio in a radio group. */
	function jGetSelectedRadio(oForm, sElement) {
		
		var sReturnValue = "";
		
		for (i = 0; i < oForm[sElement].length; i++) {
			if (oForm[sElement][i].checked == true) {
				sReturnValue = oForm[sElement][i].value;
			}
		}
		
		return sReturnValue;
	
	}
	
	function jFormatCurrency(strValue) {
		if (strValue.length > 0) {
			strValue = strValue.toString().replace(/\$|\,/g,'');
			dblValue = parseFloat(strValue);
			
			blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
			dblValue = Math.floor(dblValue*100+0.50000000001);
			intCents = dblValue%100;
			strCents = intCents.toString();
			dblValue = Math.floor(dblValue/100).toString();
			if(intCents<10)
				strCents = "0" + strCents;
			for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
				dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
				dblValue.substring(dblValue.length-(4*i+3));
			return ((blnSign)?'':'-') + dblValue;
		} else {
			return "";
		}
	}
	
	function eCheckCharLimit(oElement, iLimit, oIndicator) {
		
		var sValue = oElement.value;
		
		if (oElement.value.length > iLimit) {
			oElement.value = sValue.substring(0, iLimit);
		} else {
			oIndicator.innerHTML = jFormatCurrency(new String(iLimit - sValue.length));
		}
	
	}
	
	function jHighlightMissingFields(oForm, aFields) {
		
		for (var i = 0; i < aFields.length; i++) {
			var oElement = oForm[aFields[i]];
			
			if (oElement.value == "") {
				jHighlightMissingInputField(oElement); // oElement.style.backgroundColor = "#ffff99";
			} else {
				jResetInputField(oElement); // oElement.style.backgroundColor = "#ffffff";
			}
		}
		
	}
	
	function jResetMissingFields(oForm, aFields) {
		
		for (var i = 0; i < aFields.length; i++) {
			jResetInputField(oForm[aFields[i]]); // oElement.style.backgroundColor = "#ffffff";
		}
	
	}
	
	function jHighlightMissingInputField(oElement) {
		oElement.style.backgroundColor = "#ffff99";
	}
	
	function jResetInputField(oElement) {
		oElement.style.backgroundColor = "#fff";
	}
	
	function jForceNumeric(oEvent) {
		
		var iChar = (oEvent.which) ? oEvent.which : event.keyCode;
		
		if (iChar == 8 || iChar == 44) {
			return true;
		}
		
		if ((iChar < 48 || iChar > 57)) {
			return false;
		}
		
		return true;
		
	}
	
