    var oldValues = Array();
	var newTotal = 0;
	var myXYWH = Array();

	function submitForm() {
		document.getElementById('aspnetForm').submit();
	}
	
	function setTotalOverlay(inCellNum) {
		myDiv = $('totalOverlay');
		myDiv.style.left   = myXYWH[0]+'px';
		// hack for Safari
		if (window.webkit == true) {
			myDiv.style.top    = myXYWH[1] - 3 +'px';			
		} else {
			myDiv.style.top    = myXYWH[1]+'px';			
		}
		
		myDiv.style.width  = myXYWH[2] +'px';
		myDiv.style.height = myXYWH[3] +'px';
		if (inCellNum > 1) {
			myDiv.innerHTML = 'Total: '+ currencySymbol + newTotal + ' - Book Now?';
		} else {
			myDiv.innerHTML = currencySymbol + newTotal;
		}
		newTotal = 0;
		myXYWH = Array();
	}
	
	function setTotOverLink(inCell) {
		myDiv = $('totalOverlay');
		parentRow = inCell.getParent();
		var myChildren = parentRow.getChildren();
		delete parentRow;
		var myBookLink = myChildren[1].getChildren();
		myHref = myBookLink[0].href;
		delete myChildren; delete myBookLink;
		myDiv.addEvent('click',function(e) {
			location.href = myHref;
		});
	}
	
	function removeTotalOverlay() {
		myDiv.style.left   = '';
		myDiv.style.top    = '';
		myDiv.style.width  = '';
		myDiv.style.height = '';
		myDiv.innerHTML = '';
	}
	
	function combineValues(inCell) {
		parentRow = $(inCell).getParent();
		var myCells = parentRow.getChildren();
		selectedCells = Array();
		myCells.each(function(thisCell,i){
			if(thisCell.className.test("selected") == true) {
				oldValues.push(thisCell.innerHTML.replace(/\$/,''));
				selectedCells.push(thisCell);
			} 
		});
		oldValues.each(function(row,i) {
		    myCleanNums = oldValues[i].replace(/\D/,'');
		    myCleanNums = myCleanNums.replace(/\,/,'');
			newTotal += myCleanNums.toInt();
		});
		oldValues = Array();
		myXYWH[0] = selectedCells[0].getLeft();
		myXYWH[1] = selectedCells[0].getTop();
		myWidth = 0;
		selectedCells.each(function(cell,i) {
			myWidth += cell.offsetWidth;
		});
		myXYWH[2] = myWidth;
		myXYWH[3] = selectedCells[0].offsetHeight;
		delete myWidth;
		if (isNaN(newTotal) != true) {
			setTotalOverlay(selectedCells.length);
			setTotOverLink($(inCell));
		} else {
			newTotal = 0;
		}
	}
	
	function makeTotalOverlay() {
		myDiv = new Element('div', {
			'styles': {
				'position': 'absolute',
				'left': -100,
				'top': -10000,
				'width': 'auto',
				'height': 'auto'
			},
			'events': {
				'mouseout': function(){
					removeTotalOverlay();
				}
			},
			'id': 'totalOverlay',
			'title': 'This is the total for your selected nights - would you like to book?'
		});
		myDiv.injectInside(document.body);
	}
	
	function initTotOvBehaviour() {
		makeTotalOverlay();
		var soldTest = "sold";
		$$('.selected').each(function(cell,i){
			if(cell.className.indexOf(soldTest) == -1) {
				cell.addEvent('mouseenter', function(e){
					combineValues(cell);
				});
			}
		});
	}