/* segments.js (Cross-browser)
* Copyright (c) 1998 Mecklermedia Corp. To receive the right to license
* this code to use on your site the original code must be copied from
* Webreference.com. License is granted if and only if this entire copyright 
* notice is included, and you link from the page on which the code is used 
* to Webreference at http://webreference.com/dhtml/ for the latest version.
* By Peter Belesis. v1.1 980312 - column 16.
*/


maxHeight = 0;
hasFooter = (footerEl != null);
arSegments = new Array();

function initIt(){
if (NS4) {

  
  for (i=0; i<document.layers.length; i++) {
    tempEl = document.layers[i];
    eval(tempEl.id + "= tempEl");
    tempEl.showIt = showIt;    
    if (tempEl.id.indexOf(prefix)!=-1) arSegments[arSegments.length] = tempEl;
  }

  for (i=0; i<arSegments.length; i++) {
    tempSeg = arSegments[i];
    
    if (topPos != null) tempSeg.top = topPos;  
    if (leftPos != null) tempSeg.left = leftPos;  

    tempSeg.arrangeIt = arrangeIt;
    if (maxHeight < tempSeg.document.height) {maxHeight = tempSeg.document.height; longest=tempSeg;}
  }  

  if (hasFooter) eval(footerEl + ".pageY = topPos + maxHeight + footerElSpace");
  
}
else {
  allDIVs = document.all.tags("DIV");
  for (i=0; i<allDIVs.length; i++) {
    if (allDIVs(i).className=="segment") arSegments[arSegments.length] = allDIVs[i];
    allDIVs(i).showIt = showIt;
  }
  for (i=0; i<arSegments.length; i++) {
    tempSeg = arSegments[i]; 
    if (leftPos!=null) tempSeg.style.pixelLeft = leftPos;
    if (topPos!=null) tempSeg.style.pixelTop = topPos;
    tempSeg.style.width = document.body.clientWidth - leftPos - margRight;
    tempSeg.arrangeIt = arrangeIt;
  }
}

  if (hasFooter) footerEl = eval(footerEl);

  fullHash = location.hash;
  if (fullHash.length > 0 )
    firstSeg = fullHash.substr(1)

	currentSeg = eval(prefix + firstSeg)
	showSegment(firstSeg);

 setTimeout("window.onresize=reDo",1000);
}

function arrangeIt() {
    if (NS4) {
      footerEl.top = this.pageY + this.document.height + footerElSpace;
    }
    else {
      footerEl.style.pixelTop = this.style.pixelTop + this.offsetHeight + footerElSpace;
    }

	footerEl.showIt(true);
	
}


function showIt(on) {
  if (NS4) {this.visibility = (on) ? "show" : "hide"}
  else {this.style.visibility = (on) ? "visible" : "hidden"}
}

function showSegment(el){
  whichSeg = eval(prefix+el);
  currentSeg.showIt(false);
  if (hasFooter) footerEl.showIt(false);
  whichSeg.showIt(true);
  currentSeg = whichSeg;
  
  whichSeg.arrangeIt()
  
  if (hasFooter)  setTimeout("whichSeg.arrangeIt();",50);
  
  document.body.scrollTop = 0;
  document.body.scrollLeft = 0;
  
  
  
}

function reDo(){window.location.reload()}
