	function fixButton(div) 
	{
		var obj = document.getElementById(div);
		var cw = document.body.clientWidth;
		var ch = document.body.clientHeight;
		var x = document.body.scrollLeft;
		var y = document.body.scrollTop;
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;
		obj.style.left = x + (cw - w);
		obj.style.top = y;
	}
	
	function OneClickSubmit(formObj, numTravelersWarningDivName, dateWarningDivName)
	{
		activeForm = formObj;
		if(ValidateOneClick(formObj, numTravelersWarningDivName, dateWarningDivName))
		{
			// if the form target is blank, then we're headed of to VAX: check for VAX credentials
			var okToContinue = formObj.target == "_blank" ? UserHasVaxCredentials() : false;
			if(okToContinue)
			{
				// if no errors, record the one-click and then submit the form
				RecordOneClick(formObj.gsvacationtype.value, formObj.gsprefhotelcode.value);
				if(SetUserGuid(false))
				{
					formObj.submit();
				}
				else
				{
					// user not logged in
					LoadLoginFormVars(formObj);
					showLoginLayover(3, this, '', 'Welcome!', '', '', '', '');
				}
			}
			else
			{
				// user not logged in
				LoadLoginFormVars(formObj);
				showLoginLayover(3, this, '', 'Welcome!', '', '', '', '');
			}
		}
	}
	
	function ValidateOneClick(formObj, numTravelersWarningDivName, dateWarningDivName)
	{
		// clear any warnings that may be set
		var jsNumTravWarning = document.getElementById(numTravelersWarningDivName);
		var jsDateWarning = document.getElementById(dateWarningDivName);
		jsNumTravWarning.style.display = "none";
		jsDateWarning.style.display = "none";
		
		// calculate return date
		var lengthofstay = formObj.gslengthofstay.value;
		var departuredate = formObj.gsdeparturedate.value;
		var rdate = new Date(departuredate);
		if((departuredate == "") || (rdate < globalStartDate)) 
		{
			jsDateWarning.style.display = "block";
			return false;
		}
	
		rdate.setDate(rdate.getDate() + parseInt(lengthofstay))
		var rm = rdate.getMonth()+1;
		var rd = rdate.getDate();
		var ry = rdate.getFullYear();
		var returndate = rm + "/" + rd + "/" + ry;
		formObj.gsreturndate.value = returndate;
			
		// calculate total number of travelers
		var nadults = formObj.gsNumOfAdults.value;
		var a1 = formObj.gsAge1.value;
		var a2 = formObj.gsAge2.value;
		var a3 = formObj.gsAge3.value;
		var a4 = formObj.gsAge4.value;
		var nchildren = 0;
		if (a1 != "") nchildren++;
		if (a2 != "") nchildren++;
		if (a3 != "") nchildren++;
		if (a4 != "") nchildren++;
		var ntravelers = parseInt(nadults) + parseInt(nchildren);
		if (ntravelers > 8) 
		{
			jsNumTravWarning.style.display = "block";
			return false;
		}
		formObj.gsnumberoftravelers.value = ntravelers;
		return true;
	}
	
	function RecordOneClick(vacationTypeID, hotDealID)
	{
		var clickAjaxCon = new AjaxConnection();
		if(clickAjaxCon)
		{
			var oneClickQueryString = "vacationTypeID=" + vacationTypeID + "&hotDealID=" + hotDealID + "&sessionID=" + aspSessionID;
			var requestUrl = "/common/ajax/includes/one-click-tracker.asp";
			clickAjaxCon.open("POST", requestUrl,  false);
			clickAjaxCon.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			clickAjaxCon.send(oneClickQueryString);
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function LoadLoginFormVars(oneClickForm)
	{
		var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
		vaxForm.Ssoguid.value = oneClickForm.Ssoguid.value;
		vaxForm.RedirectToCheckout.value = oneClickForm.RedirectToCheckout.value;
		vaxForm.gsvendor.value = oneClickForm.gsvendor.value;
		vaxForm.gsvacationtype.value = oneClickForm.gsvacationtype.value;
		vaxForm.gsorigin.value = oneClickForm.gsorigin.value;
		vaxForm.gsdeparturedate.value = oneClickForm.gsdeparturedate.value;
		vaxForm.gsdestination.value = oneClickForm.gsdestination.value;
		vaxForm.gsnumberoftravelers.value = oneClickForm.gsnumberoftravelers.value;
		vaxForm.gslengthofstay.value = oneClickForm.gslengthofstay.value;
		vaxForm.gsreturndate.value = oneClickForm.gsreturndate.value;
		vaxForm.gsprefhotelcode.value = oneClickForm.gsprefhotelcode.value;
		vaxForm.gsNumOfAdults.value = oneClickForm.gsNumOfAdults.value;
		vaxForm.gsAge1.value = oneClickForm.gsAge1.value;
		vaxForm.gsAge2.value = oneClickForm.gsAge2.value;
		vaxForm.gsAge3.value = oneClickForm.gsAge3.value;
		vaxForm.gsAge4.value = oneClickForm.gsAge4.value;
		vaxForm.gsAge5.value = oneClickForm.gsAge5.value;
	}
	
	function ValidateLogin()
	{
		var loginForm = document.getElementById("popupLoginForm");
		var loginUsername = loginForm.oneClickLoginUsername.value;
		var loginPassword = loginForm.oneClickLoginPassword.value;
		var loginRememberMe = loginForm.oneClickLoginRememberMe.value;
		var loginErrors = "";
		if(loginUsername == "")
		{
			loginErrors += "Please enter your username.<br/>";
		}
		if(loginPassword == "")
		{
			loginErrors += "Please enter your password.<br/>";
		}
		if(loginErrors != "")
		{
			document.getElementById('loginLayover_errorMessage').innerHTML = loginErrors;
		}
		else
		{
			ValidateUserPassCombo(encodeURI(loginUsername), encodeURI(loginPassword), loginRememberMe);
		}
	}
	
	var ajaxConOneClick;
	function ValidateUserPassCombo(loginUsername, loginPassword, loginRememberMe)
	{
		var requestUrl = "/common/ajax/includes/validate-user-pass-get-vax-user-info.asp";
		ajaxConOneClick = new AjaxConnection();
		if(ajaxConOneClick)
		{
			//Setting the event handler for the response
			ajaxConOneClick.onreadystatechange = ValidateUserPassCombo_HandleResponse;
				
			//Initializes the request object with GET (METHOD of posting),
			//Request URL and sets the request as asynchronous.
			var formData = "username=" + loginUsername + "&password=" + loginPassword + "&rememberme=" + loginRememberMe;
			ajaxConOneClick.open("POST", requestUrl,  true);
			ajaxConOneClick.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			ajaxConOneClick.send(formData);
		}
	}
	
	function ValidateUserPassCombo_HandleResponse()
	{
		// To make sure receiving response data from server is completed
		if(ajaxConOneClick.readyState == 4)
		{
			// To make sure valid response is received from the server, 200 means response received is OK
			if(ajaxConOneClick.status == 200)
			{
				var jsonData = eval('(' + ajaxConOneClick.responseText + ')');
				if(jsonData.ERROR == "")
				{
					HandleOneClickSpecifics(jsonData.consortiumID);
					var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
					RecordOneClick(vaxForm.gsvacationtype.value, vaxForm.gsprefhotelcode.value);
					loggedInUserID = jsonData.loggedInUserID
					if(loggedInUserID != null && loggedInUserID != "")
					{
						if(SetUserGuid(true))
						{
							vaxForm.submit();
						}
						else
						{
							alert("Error preparing handoff to VAX login process.");
						}
					}
					else
					{
						alert("Login successful.  However, this account does not have VAX Login Info stored.");
					}
				}
				else
				{
					alert("The VAX login process experienced an error:\n\n" + jsonData.ERROR);
				}
			}
			else
			{
				alert("There was a problem communicating with the server.  Please try again.");
				return false;
			}
		}
	}

	function UserHasVaxCredentials()
	{
		var ajaxCon = new AjaxConnection();
		if(ajaxCon)
		{
			var requestUrl = "/common/ajax/includes/vax-user-credential-check.asp";
			ajaxCon.open("POST", requestUrl,  false);
			ajaxCon.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajaxCon.send(requestUrl);
			var jsonData = eval('(' + ajaxCon.responseText + ')');
			if(jsonData.userHasVaxCredentials)
			{
				loggedInUserID = jsonData.loggedInUserID;
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}

	function SetUserGuid(isLoginForm)
	{
		var ajaxCon = new AjaxConnection();
		if(ajaxCon)
		{
			if(!isNaN(parseInt(loggedInUserID)))
			{
				var requestUrl = "/common/ajax/dotnet/getguid.aspx";
				ajaxCon.open("POST", requestUrl, false);
				ajaxCon.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				ajaxCon.send("loggedInUserID=" + loggedInUserID);
				var userGuid =  ajaxCon.responseText;
				if(isLoginForm)
				{
					var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
					vaxForm.Ssoguid.value = userGuid;
				}
				else
				{
					activeForm.Ssoguid.value = userGuid;
				}
				return (userGuid.match("^Error") != "Error");
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}

	function VAXAccountPopup(formID)
	{
		alert("Your account does not have VAX VacationAccess account information associated with it.\n\nIf you would like to update your account, go to http://www.universaltravelagents.com/registration/edit_profile.asp.\n\nIf you need to create a VAX account, please visit http://www.vaxvacationaccess.com/Registration/MCYRegStep1.asp.");
		objID = formID + "VaxRegistration";
		ToggleObjectVisibility(objID, true);
	}
	
	function ToggleObjectVisibility(objID, toggle)
	{
		jsObject = document.getElementById(objID);
		jsDisplay = toggle?"":"none"; //display if toggle is true, hide if false
		jsObject.style.display = jsDisplay;
	}

