//Makes an XMLHTTP request and sets the given divs content to the response.
function PostXmlHttp(functionName, divName, additionalQuery)
{
  var div = document.getElementById(divName);
  
  if (!div)
    return;
    
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  var url = "XmlHttpRequest.aspx?func=" + functionName;
  
  if (additionalQuery)
    url += "&" + additionalQuery;
    
	xmlhttp.open("GET", url, false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send();
	
	div.innerHTML = xmlhttp.responseText;
	xmlhttp = null;
}

//Toggles a table row's display and +/- image.
function ToggleDisplay(rowId, imgId)
{
  var row = document.getElementById(rowId);
  var img = document.getElementById(imgId);
  
  if (row)
  {
    var displayed = (row.style.display == 'none') ? false : true;
    row.style.display = (displayed) ? 'none' : '';
    
    if (img)
      img.src = (displayed) ? 'images/plus.gif' : 'images/minus.gif';
    
    return !displayed;
  }
  else
  {
    return false;
  }
}

function HideItems()
{
  var obj;
  
  for (var i = 0; i < arguments.length; i++)
  {
    obj = document.getElementById(arguments[i]);
    
    if (obj)
      obj.style.display = 'none';
  }
}

function OpenWindow(page, pageName, width, height, properties)
{
  var left = (screen.width - width) / 2;
  var top = (screen.height - height) / 2;
  
  properties = 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',' + properties;
    
  var win = window.open(page, pageName, properties);
}

function SetStatus(message)
{
  if (!message)
    message = '';
  
  window.status = message;
  
  return true;
}
