function pop(page) {
	var w = 400;
	var h = 350;
	var theURL = '/facilities/popups/' + page + '.cfm' ;
	var theFeatures = 'width=' + w + ',height=' + h;
	var newWin = window.open(theURL,'Room',theFeatures);
	newWin.focus();
}

function view_room(roomID) {
	var w = 950;
	var h = 590;
	var theURL = '/room_viewer/room_viewer.cfm?roomID=' + roomID;
	var theFeatures = 'width=' + w + ',height=' + h + ',scrollbars=yes';
	var newWin = window.open(theURL,'Room',theFeatures);
	newWin.focus();
}

function obj (id) {
	return document.getElementById (id);
}


function tintRow (theRow) {
	theRow.className = 'tinted';
}

function untintRow(theRow) {
	theRow.className = 'untinted';
}

if (typeof Behaviour != 'undefined') {

	/* in this section behaviors are registered for the behaviour.js script */
	/* begin behaviour stuff */
	var myrules = {
	
		// -----------------------------
		// any table of class "zebra" is fed to the zebratable function in zebratables.js
		
		'table.zebra' : function (element) {
			theElement = element; // needed.
			zebratable (theElement);
		},
		
		// -----------------------------
		// Create a rollover tinting effect on any tr of class .rolloverable
		
		'tr.rolloverable' : function (element) {
			theElement = element; // needed.
			element.onmouseover = function(){
				tintRow (element);
			}
			element.onmouseout = function(){
				untintRow (element);
			}
		},
		
		
		// -----------------------------
		// Scold double-clicking of submit buttons
		
		'input.button' : function (element) {
			element.ondblclick = function(){
				alert('Important:\n\n To avoid errors and duplicate data, please do not double-click buttons on this web site.');
				return false;
			}
		},
		
		
		// -----------------------------
		// Allow users to uncheck certain radio buttons
		//		Note the declaration of the supporting var radioStatus after the behaviour stuff.
		
		'input.unclickable' : function (element) {
			element.onclick = function(){
				if (radioStatus[element.name]==null) { 
					radioStatus[element.name] = element.value;
				}
				else {
					if (radioStatus[element.name] == element.value) {
						element.checked = false;
						radioStatus[element.name] = null;
					}
					else {
						radioStatus[element.name] = element.value;
					}
				}
			}
		},
		
		// -----------------------------
		// Hide pop-up messages (save confirmations, etc) after 5 seconds
		
		'div.flashmsg' : function(element) {
			setTimeout("hide(\'" + element.id + "');", 5000);
		}
		
	};
	
	
	Behaviour.register(myrules);
	
	/* end behaviour stuff */
	
	/* radioStatus is used like an array to temporarily store the state of radio buttons on a page.
			This supports the uncheckability of certain radio buttons defined in the input.unclickable
			rule above. */
	var radioStatus = new Object();
	
	function hide(id) {
		document.getElementById(id).style.display='none';
	}
	
}
