function showDetails(elemId, inId, e, inType, inQty, inDate, inNotes)
{
	var elem = document.getElementById(elemId);
	var viewportBuffer = 50;
	var cursorOffset = 5;
	
	if (getCursorPosition(e)[0] + parseInt(elem.style.width) + viewportBuffer - getScrollingPosition()[0] >= getViewportSize()[0])
	{
		elemHOffset = -(parseInt(elem.style.width)) - cursorOffset;
	}
	else
	{
		elemHOffset = 5;
	}
	
	if (getCursorPosition(e)[1] + parseInt(elem.style.height) + viewportBuffer - getScrollingPosition()[1] >= getViewportSize()[1])
	{
		elemVOffset = -(parseInt(elem.style.height)) - cursorOffset;
	}
	else
	{
		elemVOffset = 5;
	}
	
	if (inType != null && inQty != null && inDate != null && inNotes != null)		// only update content when new data comes in...
	{
		var elemContent = "<table style=\"width:100%;\"><tr class=\"bold\"><td colspan=\"2\">TITLE</td></tr><tr><!--<td class=\"nonBreaking\">Currently Available : AVAILABLE_HIDE</td>--><td class=\"right\" style=\"width:33%;\">DATE</td></tr><tr><td colspan=\"2\">NOTES</td></tr></table>";
		var newContent;
		
		rExp1 = /TITLE/;
		rExp2 = /AVAILABLE/;
		rExp3 = /DATE/;
		rExp4 = /NOTES/;
		
		newContent = elemContent.replace(rExp1, inType);
		newContent = newContent.replace(rExp2, inQty);
		newContent = newContent.replace(rExp3, inDate);
		newContent = newContent.replace(rExp4, inNotes);
		
		elem.innerHTML = newContent;
	}
	
	elem.style.left = getCursorPosition(e)[0] + elemHOffset + "px";
	elem.style.top = getCursorPosition(e)[1] + elemVOffset + "px";
	elem.style.display = "block";
}

function hideDetails(elemId)
{
	var elem = document.getElementById(elemId);
	elem.style.display = "none";
	elem.style.top = "-5000px";
	elem.style.left = "-5000px";
}

function initCalendar(elemId)
{
	var elem = document.getElementById(elemId);
	elem.style.width = getViewportSize()[0] - 280 + "px";
}

function locid_OnChange(elemId)
{
	var elem = document.getElementById(elemId);
	elem.submit();
}

function editItem(inId)
{
	var editWin = window.open("editItem.asp?ltiid=" + inId, "editWindow", "width=700, height=400, scrollbars, resizable");
	editWin.focus();
}

function editDay(inDate)
{
	var editWin = window.open("editDay.asp?ltidate=" + inDate, "editWindow", "width=900, height=600, scrollbars, resizable");
	editWin.focus();
}

function startBooking(inId)
{
	window.location = "bookings.asp?ltiid=" + inId;
}

function getIndex(c, inKey)
{
	for (i = 0; i != c.options.length; i++)
	{
		if (c.options[i].value == inKey)
		{
			return i;
		}
	}
	
	return 0;
}

function alterBackground(cell, newImage)
{
	cell.style.backgroundImage = "url('" + newImage + "')";
}
