

// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue)
{
  document.cookie = sName.replace(/ /,'') + "=" + escape(sValue) +";domain=rockresorts.com;path=/;"
}



// Retrieve the value of the cookie with the specified name.
function GetCookie(sField)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split(";");
  
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if ( 'rrDateSelections' == aCrumb[0].replace(/ /,'') ) {
		// a name/value field groupings are separated by '*'
		var aFieldList = unescape(aCrumb[1]).split("*");
		for (var x=0; x < aFieldList.length; x++)
		 {
			// a name/value pair field is separated by '##'
			var aField = aFieldList[x].split("##");
			if ( String(sField) == aField[0].replace(/ /,'') ) {
				return aField[1];
				}
		 }
	  }
  }

  // a cookie with the requested name does not exist
  return null;
}


//get refillSelections from cookie using getSelections
//added by craig mcleod 9_01_02
function refillSelections (sField, objDropDown){

	
	var userSelection

	userSelection = parseInt(GetCookie(sField))

	if (!isNaN(userSelection)){
		objDropDown.options[userSelection].selected = true;
		}
	
}
//end craig mcleod edit
	

//get getSelections from cookie
//added by craig mcleod 9_01_02
function getSelections() {

	if (document.reservation != null)
		{
		if (document.reservation.pid != null) {
			if (document.reservation.pid.type == "select-one"){
	
				refillSelections("pid",document.reservation.pid);
	
				}
			refillSelections("doa_mm",document.reservation.doa_mm);
			refillSelections("doa_dd",document.reservation.doa_dd);
			refillSelections("dod_mm",document.reservation.dod_mm);
			refillSelections("dod_dd",document.reservation.dod_dd);
			refillSelections("num_adults",document.reservation.num_adults);
			refillSelections("num_rooms",document.reservation.num_rooms);
			setTripLength()
			}
		}
}
//end craig mcleod edit



