// function switchDiv()
//  this function takes the id of a div
//  and calls the other functions required
//  to show that div
//
function switchDiv(div_id)
{
  if (div_id=='')
  {
    hideAll();
  }
  else
  {
    var style_sheet = getStyleObject(div_id);
    if (style_sheet)
    {
	  if (style_sheet.display=='none')
	  {
	     hideAll();
      	 changeObjectDisplay(div_id,"block");
	  }
    }
    else
    {
      hideAll();
    }
  }
}

function switchDiv2(div_id)
{
  if (div_id=='')
  {
    hideSome();
  }
  else
  {
    var style_sheet = getStyleObject(div_id);
    if (style_sheet)
    {
	  if (style_sheet.display=='none')
	  {
	     hideSome();
      	 changeObjectDisplay(div_id,"block");
	  }
    }
    else
    {
      hideSome();
    }
  }
}

// function hideAll()
//  hides a bunch of divs
//
function hideAll()
{
   changeObjectDisplay("div4","none");
   changeObjectDisplay("div5","none");
   changeObjectDisplay("div6","none");
   changeObjectDisplay("div7","none");
   changeObjectDisplay("div8","none");
   changeObjectDisplay("div9","none");
   changeObjectDisplay("div10","none");
   changeObjectDisplay("div11","none");
   changeObjectDisplay("div12","none");
   changeObjectDisplay("div13","none");
   changeObjectDisplay("div14","none");
   changeObjectDisplay("div15","none");
}

function hideSome()
{
   changeObjectDisplay("div1","none");
   changeObjectDisplay("div2","none");
   changeObjectDisplay("div3","none");
}
  

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {
    setTimeout(this,1000);  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
    setTimeout(this,1000); 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function changeObjectDisplay(objectId, newVisibility) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.display = newVisibility;
    setTimeout(this,1000); 
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}
