var speed = 30;
var wMin = 10;
var wMax = 32;
var wInc = 8;

if ((navigator.userAgent).indexOf("Opera")!=-1) {
	wInc = 12;
	speed = 5;
}
else if (navigator.appName=="Netscape") {
}
else if ((navigator.appName).indexOf("Microsoft") != -1) {
	if (navigator.appVersion.indexOf("5.0") == 0) {
		wMin = 12;
		wMax = 34;
	}
}

var widths = new Array();
var objRef = new Array();
var expanding = new Array();
var scheduleClose = new Array();
var isInside = new Array();

function initRef(boxId)
{
  if (document.getElementById) {
    objRef[boxId] = document.getElementById(boxId);
  }
  else if (document.all) {
    objRef[boxId] = document.all[boxId];
  }
  else if (document.layers) {
    objRef[boxId] = document.layers[boxId];
  }	
}

// Set width on object
function setWidth(id, w)
{
  var ref = objRef[id];
  if (document.getElementById) {
    ref.style.width = w + 'px';
  }
  else if (document.all) {
    ref.style.width = w;
  }
  else if (document.layers) {
    ref.width = w;
  }
}

// Mouse entered box
function expand(boxId) {

	// initial values
	if (!widths[boxId]) 
	{
		initRef(boxId);
		widths[boxId] = wMin;
		expanding[boxId] = false;
		scheduleClose[boxId] = false;
		isInside[boxId] = true;
	}

	isInside[boxId] = true;
	
	scheduleClose[boxId] = false;
	doExpand(boxId);
}

// Mouse left box (onmouseout event)
function contract(boxId) {

	// initial values
	if (!widths[boxId])
	{
		initRef(boxId);
		widths[boxId] = wMin;
		expanding[boxId] = false;
		scheduleClose[boxId] = false;
		isInside[boxId] = false;
	}

	isInside[boxId] = false;
	
	if (expanding[boxId]) 
	{
		scheduleClose[boxId] = true;
		if (expanding[boxId]) 
		{
			return;
		}
	}

	doContract(boxId);
}

// Function called repeatedly until box fully expanded
function doExpand(boxId) 
{		
	expanding[boxId] = true;
    
	w = widths[boxId];
	w += wInc;
  	if (w > wMax) {
    	w = wMax;
  	}
  	
  	setWidth(boxId, w);
 
  	if (w < wMax) {
    	setTimeout('doExpand("' + boxId + '")', speed);
  	}
	else {
		if (scheduleClose[boxId]) {
			setTimeout('contract("' + boxId + '")', speed);
		}
		expanding[boxId] = false;
	}
  
  widths[boxId] = w;
}

// Function called repeatedly until box fully contracted
function doContract(boxId) {

	if (expanding[boxId])
			return;
			
	scheduleClose[boxId] = false;
	
	if (isInside[boxId])
		return;
		
  w = widths[boxId];

  w -= wInc;
  if (w < wMin) {
    w = wMin;
  }
  
  setWidth(boxId, w);

  if (w > wMin) {
    setTimeout('doContract("' + boxId + '")', speed);
  }

  widths[boxId] = w;
}

/* Activate box */
function flashOn(boxId) {
  if (document.layers) {
    document.layers[boxId].bgColor = "White";
  }
  else if (document.all) {
    document.all(boxId).style.backgroundColor = "White";
  }
  else if (document.getElementById) {
    document.getElementById(boxId).style.backgroundColor = "White";
  }
}

/* Deactivate box */
function flashOff(boxId) {
  if (document.layers) {
    document.layers[boxId].bgColor = "transparent";
  }
  else if (document.all) {
    document.all(boxId).style.backgroundColor = "transparent";
  }
  else if (document.getElementById) {
    document.getElementById(boxId).style.backgroundColor = "transparent";
  }
}

/* NNresizeFix Reloads the page to workaround a Netscape Bug */
if (document.layers) {
    origWidth = innerWidth;
    origHeight = innerHeight;
}

function NNresizeFix() {
    if (innerWidth != origWidth || innerHeight != origHeight)
    location.reload();
}

if (document.layers) {
    onresize = NNresizeFix;
}
