var xmlhttp

function checkform2()
{
	if (confirm('Are you sure you want to update these users bookings?'))
	{
		dohide();
	}
	else
	{
		return false;
	}
}

function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("POST",url,true)
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  xmlhttp.send('')
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
  {
  	MM_findObj('adminUL').innerHTML = xmlhttp.responseText;
  }
  else
  {
  	alert("Problem retrieving page data:" + xmlhttp.statusText)
  }
  }
}

function InitContext()
{
    _divContext.onmouseover = function() { _mouseOverContext = true; };
    _divContext.onmouseout = function() { _mouseOverContext = false; };
    
    MM_findObj('aDisable').onclick = DisableContext;
    //MM_findObj('aEnable').onclick = EnableContext;
    
    //MM_findObj('ctable').onmousedown = ContextMouseDown;
    //MM_findObj('ctable').oncontextmenu = ContextShow;
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}

var lastclicked = null;
var bdate = null;


function doshow(el,thedate)
{            
        // hide the menu first to avoid an "up-then-over" visual effect
     _divContext.style.display = 'none';
	 _divContext.style.left = (tempX) + 'px';
	 _divContext.style.top = (tempY) + 'px';
	 _divContext.style.display = 'block';
	 lastclicked = el;
	 bdate = thedate;
}

function doshow_admin(el,thedate)
{            
	//alert('hello')
        // hide the menu first to avoid an "up-then-over" visual effect
	 //MM_findobj('adminUL')
	 loadXMLDoc('adminmenu.asp?thedate=' + thedate);
     _divContext.style.display = 'none';
	 _divContext.style.left = (tempX) + 'px';
	 _divContext.style.top = (tempY) + 'px';
	 _divContext.style.display = 'block';
	 lastclicked = el;
	 bdate = thedate;
}


function dohide()
{            
        // hide the menu first to avoid an "up-then-over" visual effect
     _divContext.style.display = 'none';
}

function calreq(num,uid)
{
	if (num == 0) { colnow = '#ffffff'}
	if (num == 1) { colnow = '#fcd94d'}
	if (num == 2) { colnow = '#f0affc'}
	if (num == 3) { colnow = '#affcba'}
	if (num == 4) { colnow = '#afb6fc'}
	//alert(lastclicked.style.backgroundColor);
	lastclicked.style.backgroundColor = colnow;
	dohide();
	url = '/bookdate.asp?uid=' + uid + '&bdate=' + bdate + '&btype=' + num;
	window.frames[0].location = url;
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.

// call from the onMouseDown event, passing the event if standards compliant
function ContextMouseDown(event)
{
	alert(event);
	
	if (event == null)
        event = window.event;
		
    if (_noContext || _mouseOverContext)
        return;

    // IE is evil and doesn't pass the event object
    
        
    // we assume we have a standards compliant browser, but check if we have IE
    var target = event.target != null ? event.target : event.srcElement;
    
    // only show the context menu if the right mouse button is pressed
    //   and a hyperlink has been clicked (the code can be made more selective)
    if (event.button == 2 && target.tagName.toLowerCase() == 'a')
        _replaceContext = true;
    else if (!_mouseOverContext)
        _divContext.style.display = 'none';
}

function CloseContext()
{
    _mouseOverContext = false;
    _divContext.style.display = 'none';
}

// call from the onContextMenu event, passing the event
// if this function returns false, the browser's context menu will not show up
function ContextShow(event)
{
    if (_noContext || _mouseOverContext)
        return;

    // IE is evil and doesn't pass the event object
    if (event == null)
        event = window.event;
        
    // we assume we have a standards compliant browser, but check if we have IE
    var target = event.target != null ? event.target : event.srcElement;
    
    if (_replaceContext) 
    {
        $('aContextNav').href = target.href;
        $('aAddWebmark').href = 'http://luke.breuer.com/webmark/?addurl=' +
            encodeURIComponent(target.href) + '&title=' +
            encodeURIComponent(target.innerHTML);
        
        // document.body.scrollTop does not work in IE
        var scrollTop = document.body.scrollTop ? document.body.scrollTop : 
            document.documentElement.scrollTop;
        var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft : 
            document.documentElement.scrollLeft;
            
        // hide the menu first to avoid an "up-then-over" visual effect
        _divContext.style.display = 'none';
        _divContext.style.left = event.clientX + scrollLeft + 'px';
        _divContext.style.top = event.clientY + scrollTop + 'px';
        _divContext.style.display = 'block';
        
        _replaceContext = false;
        
        return false;
    }
}

function DisableContext()
{
    _noContext = true;
    CloseContext();
    $('aEnable').style.display = '';
    
    return false;
}

function EnableContext()
{
    _noContext = false;
    _mouseOverContext = false; // this gets left enabled when "disable menus" is chosen
    $('aEnable').style.display = 'none';
    
    return false;
}

// comes from prototype.js; this is simply easier on the eyes and fingers
function $(id)
{
    return document.getElementById(id);
}