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;
}

function confirmation(url, msg, msg2) {
	var answer = confirm(msg)
	if (answer){
		alert(msg2);
		window.location = url;
	}
}

function confirmation2(url, msg) {
	var answer = confirm(msg)
	if (answer){
		window.location = url;
	}
}

function reportError(request) {
$F('zipResult') = "Error";
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function PrintEmbedVoucherObject( code ){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="print" align="middle">'); 
	document.write('<param name="allowScriptAccess" value="sameDomain" />'); 
	document.write('<param name="allowFullScreen" value="false" />'); 
	document.write('<param name="movie" value="/contents/printgc.swf?' + code + '" />'); 
	document.write('<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'); 
	document.write('<embed src="/contents/printgc.swf?url=' + code + '" quality="high" bgcolor="#ffffff" width="1" height="1" name="print" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
	document.write('</object>'); 
}