var HelpWindow;
var CurrDiv;

//
function switchDiv(div_id,visibility)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    changeObjectVisibility(div_id, visibility);
    return false;
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
  
} 

//get object style
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)) {  
        return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
        return document.layers[objectId];
   } else {
        return false;
   }
} 

//get object id
function getObjectId(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
        return document.getElementById(objectId);
   }
   else if (document.all && document.all(objectId)) {  
        return document.all(objectId);
   } 
   else if (document.layers && document.layers[objectId]) { 
        return document.layers[objectId];
   } else {
        return false;
   }
} 


//changes object visibility
function changeObjectVisibility(objectId, newVisibility) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    if (styleObject) {
        styleObject.visibility = newVisibility;
        return true;
    } else {
        return false;
    }
} 


function toggleDivDisplay(div_id)
{
  var styleObject = getStyleObject(div_id);
  var div_idnum;
  
  if (styleObject)
    {
    getStyleObject("line" + div_id.replace(/\D/g, '')).backgroundColor = ((styleObject.display == 'none') ?   '#dddddd' : ((parseInt(div_id.replace(/\D/g, '')) % 2) ? 'white' : '#dddddd') );
    getObjectId("navimg" + div_id.replace(/\D/g, '')).src = (styleObject.display == 'none') ? "/graphics/triangle-d.gif" : "/graphics/triangle-r.gif";
    styleObject.display = (styleObject.display == 'none') ? '' : 'none';
//    if ((CurrDiv != div_id) && (CurrDiv != null)) {
//        getStyleObject(CurrDiv).display = 'none';
//        getObjectId("navimg" + CurrDiv.replace(/\D/g, '')).src = "/graphics/triangle-r.gif";
//        }
    CurrDiv = div_id;
        return false;
    }
  else 
    {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
  
} 

//open a window
function PopWinText(url,name,options,text) {
  HelpWindow = window.open(url,name,options);
  HelpWindow.document.write(text);
  HelpWindow.focus();
  return false;
}


//open a window
function PopWin(url,name,winWidth,winHeight,options) {
  var sx = parseInt((screen.availWidth-winWidth)/2);
  var sy = parseInt((screen.availHeight-winHeight)/2);
  options += ",left=" + sx + ",top=" + sy;
  options += ",screenX=" + sx + ",screenY=" + sy;
  options += ",Height=" + winHeight + ",Width=" + winWidth;   
  HelpWindow = window.open(url,name,options);
  HelpWindow.focus();
  return false;
}

