function URLEncode()
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = document.newpurchaseform.newitemfield.value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	document.newpurchaseform.newitemfield.value = encoded;
	return false;
};

function URLEncodeTags()
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = document.AddTags.Tags.value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	document.AddTags.Tags.value = encoded;
	return false;
};

function URLDecode(encodedvalue)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = encodedvalue;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};

function ShowListAndHideList(i){
        nav=document.getElementById('div'+i).style;
        con=document.getElementById('ul'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

function popup(url, title, width, height) {
	window.open(url, title, "width=" + width + ",height=" + height + ",scrollbars=yes,toolbar=no;locationbar=no,statusbar=no,resizable=yes,status=0,status=no");
	return false;
}

function popupNoScroll(url, title, width, height) {
	window.open(url, title, "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no;locationbar=no,statusbar=no,resizable=yes,status=0,status=no");
	return false;
}

function popupNoScrollNoResize(url, title, width, height) {
	window.open(url, title, "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no;locationbar=no,statusbar=no,resizable=no,status=0,status=no");
	return false;
}

function couponPop(url, title, width, height) {
	window.open(url, "couponpopup", "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no;locationbar=no,statusbar=no,resizable=no,status=0,status=no");
	return false;
}
function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}
function printClose(returnLink) {
	window.print();
	window.opener.location.href = returnLink;
	setTimeout('window.close()', 1500);
}
function printPage(t) {
	setTimeout('window.print()', t);
}
function closeWindowAndRefresh(returnLink,t) {
	window.opener.location.href = returnLink;
	setTimeout('window.close()', t);
}
function pageRedirect(redirectLink,t) {
	setTimeout('window.location(redirectLink)', t);
}

function URLEncodePromocode(){
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = document.promocodeform.promocode.value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	document.promocodeform.promocode.value = encoded;
	return false;
};
function selectResorts() {
	document.search.name.checked = true;
	document.search.description.checked = false;
	document.search.address.checked = false;
	document.search.city.checked = true;
	document.search.state.checked = false;
	document.search.zip.checked = false;
	document.search.phone.checked = false;
	document.search.location.checked = false;
	document.search.resort.checked = true;
	document.search.urlstring.checked = false;
	document.search.keywords.checked = false;
	document.search.coupons.checked = false;
	document.search.categories.checked = false;
}
function selectCities() {
	document.search.name.checked = false;
	document.search.description.checked = false;
	document.search.address.checked = false;
	document.search.city.checked = true;
	document.search.state.checked = false;
	document.search.zip.checked = false;
	document.search.phone.checked = false;
	document.search.location.checked = true;
	document.search.resort.checked = true;
	document.search.urlstring.checked = false;
	document.search.keywords.checked = false;
	document.search.coupons.checked = false;
	document.search.categories.checked = false;
}
function selectActivities() {
	document.search.name.checked = false;
	document.search.description.checked = false;
	document.search.address.checked = false;
	document.search.city.checked = false;
	document.search.state.checked = false;
	document.search.zip.checked = false;
	document.search.phone.checked = false;
	document.search.location.checked = false;
	document.search.resort.checked = false;
	document.search.urlstring.checked = false;
	document.search.keywords.checked = true;
	document.search.coupons.checked = false;
	document.search.categories.checked = true;
}
function selectAll() {
	document.search.name.checked = false;
	document.search.description.checked = false;
	document.search.address.checked = false;
	document.search.city.checked = false;
	document.search.state.checked = false;
	document.search.zip.checked = false;
	document.search.phone.checked = false;
	document.search.location.checked = false;
	document.search.resort.checked = false;
	document.search.urlstring.checked = false;
	document.search.keywords.checked = false;
	document.search.coupons.checked = false;
	document.search.categories.checked = false;
}