	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 VaxConnect()
	{
		// check for VAX credentials
		var okToContinue = UserHasVaxCredentials();
		if(okToContinue)
		{
			// if no errors, record the one-click and then submit the form
			RecordOneClick("VAX", "welcomePage");
			if(SetUserGuid(false))
			{
				var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
				vaxForm.submit();
			}
			else
			{
				// user not logged in
				//LoadLoginFormVars();
				showLoginLayover(3, this, '', 'Welcome!', '', '', '', '');
			}
		}
		else
		{
			// user not logged in
			//LoadLoginFormVars();
			showLoginLayover(3, this, '', 'Welcome!', '', '', '', '');
		}
	}
	
	function RecordOneClick(vacationTypeID, hotDealID)
	{
		var clickAjaxCon = new AjaxConnection();
		if(clickAjaxCon)
		{
			var oneClickQueryString = "vacationTypeID=USH" + 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 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(loginUsername, 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 == "")
				{
					RecordOneClick("USH", activeDeal);
					loggedInUserID = jsonData.loggedInUserID
					if(loggedInUserID != null && loggedInUserID != "")
					{
						if(SetUserGuid(true))
						{
							var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
							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 loginForm = document.getElementById("oneClickLoginPageMaskForm");
					loginForm.Ssoguid.value = userGuid;
				}
				else
				{
					var vaxForm = document.getElementById("oneClickLoginPageMaskForm");
					vaxForm.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;
	}

