	var openMenuId = "";
	var lastMenuTitle
	
	// Browser sniffing
	var agt=navigator.userAgent.toLowerCase();

	var isNav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));

	var isIE     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

	var coll = ""
	var styleObj = ""
	if(isIE) {
		coll = "all."
		styleObj = ".style"
	}

	if(!document.getElementById){
		if(document.all)
			document.getElementById=function(){
				if(typeof document.all[arguments[0]]!="undefined")
					return document.all[arguments[0]]
				else
					return null
				}
		else if(document.layers)
			document.getElementById=function(){
				if(typeof document[arguments[0]]!="undefined")
					return document[arguments[0]]
				else
					return null
				}
	}

	window.defaultStatus = ""
	
	function doMenu(evt) {
		// alert("In doMenu()")
		
		evt = (evt) ? evt : ((window.event) ? window.event : "")
		
		var srcElement
		if(isIE) {
			srcElement = evt.srcElement
		}
		else {
			srcElement = evt.target
		}
		
		var menuTitlePos = srcElement.id.indexOf("menuTitle_")
		if(menuTitlePos > -1) {
			var menuTitleName = srcElement.id.substr(menuTitlePos)
			if(menuTitleName.replace("menuTitle", "menu") == openMenuId) {
				return true
			}
		
			if(typeof lastMenuTitle == "object") {
				lastMenuTitle.className = "InactiveMenuItem"
				closeDropdownMenu(evt)
			}

			// 2007-April-27 RSG
			// Adding check so we don't highlight a disabled menu item
			if(srcElement.className == "DisabledMenuItem") {
				return true
			}
			
			srcElement.className = "ActiveMenuItem"
		
			lastMenuTitle = srcElement
		}
	}	
	function activateMenu(menuItem) {
		// alert("In activateMenu()")
		
		if(!(menuItem.className == "DisabledMenuItem")) {
			menuItem.className="ActiveMenuItem"
		}
		
		// closeDropdownMenu()
	}
	function deactivateMenu(menuItem) {
		// alert("In deactivateMenu()")
		
		if(!(menuItem.className == "DisabledMenuItem")) {
			menuItem.className="InactiveMenuItem"
		}
	}
	function closeDropdownMenu(evt) {
		// alert("In closeDropdownMenu()")
		
		evt = (evt) ? evt : ((window.event) ? window.event : "")
		
		var srcElement
		if(isIE) {
			srcElement = evt.srcElement
		}
		else {
			srcElement = evt.target
		}
		
		var menuTitlePos = srcElement.id.indexOf("menuTitle_")
		if(menuTitlePos > -1) {
			var menuTitleName = srcElement.id.substr(menuTitlePos)
			if(menuTitleName.replace("menuTitle", "menu") == openMenuId) {
				return true
			}						
         }
         
         if (openMenuId != "") {
				document.all[openMenuId].style.display = "none"
				openMenuId = ""
		}
    }
	function doDropdownMenu(evt, menuId) {
		// alert("In doDropdownMenu()")
				
		if (openMenuId != "") {
            document.all[openMenuId].style.display = "none"
            
            if(typeof lastMenuTitle == "object") {
				lastMenuTitle.className = "ActiveMenuItem"
			}
         }

		if(menuId == null) {
			openMenuId = ""
			
			if(typeof lastMenuTitle == "object") {
				lastMenuTitle.className = "InactiveMenuItem"
			}
			
			return false
		}
		
		evt = (evt) ? evt : ((window.event) ? window.event : "")
		
		var srcElement
		if(isIE) {
			srcElement = evt.srcElement
		}
		else {
			srcElement = evt.target
		}
		
		var menuTitlePos = srcElement.id.indexOf("menuTitle_")
		if(menuTitlePos > -1) {
			var menuTitleName = srcElement.id.substr(menuTitlePos)
			if(menuTitleName.replace("menuTitle", "menu") == openMenuId) {
				openMenuId = ""
				return false
			}
			
			var e = srcElement
			var menuTop = 0
			do {
				// alert(e.tagName + "(" + e.id + "): " + e.offsetTop)
				
				/*
				HACK ALERT!!! IE screws up the offsetTop of the TABLE element when it is 
				inside a DIV element. Instead of being 1 or 0, it ends up being the offset from the DIV's
				container, so the TABLE and containing DIV elements have the same offsetTop value. This
				ends up making the resulting offset too large. To get around this, we ignore the containing
				DIV, but it HAS to have the id "navigation".
				*/
				if(e.id != "navigation") {
					menuTop += e.offsetTop
				}
				
				// e = e.parentElement
				e = e.parentNode
			} while (e.tagName.toUpperCase() != "BODY") //BODY
			
			// var cellElement = srcElement.parentElement
			var cellElement = srcElement.parentNode
			// var rowElement = cellElement.parentElement
			var rowElement = cellElement.parentNode
			// var tableElement = rowElement.parentElement.parentElement
			var tableElement = rowElement.parentNode.parentNode
			var cellWidth = 0
			// This needs to be changed from hard-coded third cell to variable for cell that contains the source element
			for (i = 0; i < 3; i++) {
				// alert("Cell " + i + " offset: " + rowElement.cells(i).offsetWidth)
				cellWidth += rowElement.cells[i].offsetWidth
				// alert("Total Cell Width: " + cellWidth)
			}	
			
			var dropdownMenu = document.all[menuId]
			dropdownMenu.className = "OpenMenu"
			var cont = document.all['container']
			var containerOffsetLeft = 0
			if(cont) {
				containerOffsetLeft = cont.offsetLeft
			}
			dropdownMenu.style.left = tableElement.offsetLeft + cellWidth + srcElement.offsetLeft + containerOffsetLeft			
			dropdownMenu.style.top = menuTop + srcElement.offsetHeight			
			dropdownMenu.style.display = "block"
			
			var srcElementPosition = findPosition(srcElement);
			dropdownMenu.style.left = srcElementPosition[0];
			dropdownMenu.style.top = srcElementPosition[1] + srcElement.offsetHeight;
			
			openMenuId = menuId
			
			srcElement.className = "SelectedMenuTitle"
			
			if(isIE) {
				window.event.cancelBubble = true
			}
			else {
				evt.stopPropagation();
			}
		}
	}
	
	function getObjHeight(obj) {
		if(isIE) {
			return obj.clientHeight
		}
		else {
			// return obj.clip.height
			return obj.clientHeight
		}
	}
	
	function getObjWidth(obj) {
		if(isIE) {
			return obj.clientWidth
		}
		else {
			// return obj.clip.width
			return obj.clientWidth
		}
	}
	
	function getInsideWindowWidth() {
		if(isIE) {
			return document.body.clientWidth
		}
		else {
			return window.innerWidth
		}
	}
	
	function getInsideWindowHeight() {
		if(isIE) {
			return document.body.clientHeight
		}
		else {
			return window.innerHeight
		}
	}
	
	function shiftTo(obj, x, y) {
		if(isIE) {
			obj.pixelLeft = x
			obj.pixelTop = y
		}
		else {
			// obj.moveTo(x,y)
			obj.left = x
			obj.top = y
		}
	}
	
	function centerIt(elementId) {		
		// var elementStyleObj = document.all[elementId].style
		var elementStyleObj = document.getElementById(elementId).style
		// var contentObj = document.all[elementId]
		var contentObj = document.getElementById(elementId)
		
		var x = Math.round((getInsideWindowWidth() / 2)-(getObjWidth(contentObj) / 2))
		var y = Math.round((getInsideWindowHeight() / 2)-(getObjHeight(contentObj) / 2))
		shiftTo(elementStyleObj, x, y)
		elementStyleObj.visibility = "visible"
	}
	
	function findPosition( oElement ) {
		if( typeof( oElement.offsetParent ) != 'undefined' ) {
			for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
				posX += oElement.offsetLeft;
				posY += oElement.offsetTop;
			}
			return [ posX, posY ];
		} else {
			return [ oElement.x, oElement.y ];
		}
	}

	function updateWaitImage() {
		var waitImg = document.all['imgLoadingAvailability']
		waitImg.src = "images/BookTurningPages.gif"
	}
	
	function showWaitMessage(waitMessageElementId) {
		centerIt(waitMessageElementId)
		setTimeout("updateWaitImage();", 50)
	}
	
	function updateLoadingImage() {
		var loadingImg = document.all['imgLoadingResv']
		loadingImg.src = "images/progressbar20.gif"
	}
	
	function forwardToResv(pageLocation) {
		// location.href='TabbedUI.aspx'
		location.href = pageLocation
		setTimeout("updateLoadingImage();", 50)
	}
	
	function disableControls() {
		document.body.style.cursor = "wait";
		var nr = document.forms[0].all.length;
		for(i=0;i<nr;i++) {
			if(document.forms[0].all(i).tagName.toUpperCase() == "SELECT" 
				|| document.forms[0].all(i).tagName.toUpperCase() == "A"
				|| (document.forms[0].all(i).tagName.toUpperCase() == "INPUT" && (document.forms[0].all(i).type == "radio" || document.forms[0].all(i).type == "checkbox" || document.forms[0].all(i).type == "button"  || document.forms[0].all(i).type == "submit"))) {
				// alert("Disabling control " + document.forms[0].all(i).id + ": " + document.forms[0].all(i).tagName + ": " + document.forms[0].all(i).type)
				document.forms[0].all(i).href = "";
			}
		}
	}
	
	function disableCalendar(calendarId) {
		var childControls = document.all[calendarId].children
		for(i=0; i<childControls.length; i++) {
			// alert(childControls(i).tagName)
			if(childControls(i).tagName.toUpperCase() == "A") {
				childControls(i).disabled = true;
			}
		}
	}
	
	function setBrowserStatus(statusString) {
		window.status = statusString
	}
	
	function showScreenSizes() {
		alert("Screen available width x height: " + window.screen.availWidth + " x " + window.screen.availHeight)
		alert("Screen width x height: " + window.screen.width + " x " + window.screen.height)
		alert("body offset width x height: " + document.body.offsetWidth + " x " + document.body.offsetHeight)
		alert("body client width x height: " + document.body.clientWidth + " x " + document.body.clientHeight)
	}
	
	function setMinContainerWidth(size) {
		var container = document.all["container"]
		var offsetWidth = container.offsetWidth
		if(offsetWidth < size) {
			container.style.width = size
		}
	}
	
	// 2007-May-17 RSG
	// Removing the call to this function from GroupComments.aspx <BODY onunload="checkForGroupCommentsUpdate">
	// The document still unloads after the comments are saved, but the hidden field is not yet updated with
	// the results from the postback, so it looks like the comment still needs to be saved. Additionally, if
	// the user navigates to a different page, the onunload catches the changed comment, but there's no way to
	// forward the user to the requested page once the comment is saved.
	function checkForGroupCommentsUpdate() {
		var hiddenCommentsValue = document.getElementById('hiddenComments').value
		if(hiddenCommentsValue != "") {
			var groupCommentsValue = document.getElementById('tbGroupComments').value
			if(hiddenCommentsValue != groupCommentsValue) {
				var updateGroupComments = confirm('Group comments have been updated. Do you wish to save them?')
				if(updateGroupComments) {
					document.getElementById('btnEditSaveComments').click()
					document.getElementById('hiddenComments').value = "JavaScript"
				}
			}
		}
		
		return true
	}
	
	function confirmGroupShareCancellation() {
		var cancelShare = confirm('Do you wish to cancel your shared reservation and book a private room instead?\n\nPress OK to book a private room, Cancel to go back to the share request.')
		if(cancelShare) {			
			document.getElementById('btnCancelShareRequestConfirmed').click()
		}
		else {
			document.getElementById('bodyGroupShareRequest').onload = null
		}
	}