// JavaScript Document
// -----------------------------
// Netscape/Firefox Overflow:auto Fix
// By Mike Vanden Berg - 2004
// My e-mail address is myfirstname @ mylastname dot com (no spaces).
// -----------------------------

// Script changes overflow value of a div tag and adjusts the sizing 
// to prevent contents from shifting when/if scroll bars are added or removed.
// I made this because of an issue in Netscape and FireFox with some menubars dropping 
// down over a content div when overflow is set to overflow:auto, the drop down menu seems 
// to vanish when the mouse is moved over the content div.

// **Note**
// This script must also have broswer_detect.js to work.
// broswer_detect.js contains a function borrowed from Mike Hall's
// "Revenge of the Menu Bar" menu bar script at http://www.brainjar.com
// Copyright 2000-2004 by Mike Hall.

// **Use**
// setOverflow(action, LayerId)
// action - overflow value you want to set, one of them has to be "auto".
// LayerId - id tag of the layer you want the overflow value changed.

// **Example of Use**
// onMouseOver("hidden", "myContentLayer");
// onMouseOut("auto", "myContentLayer");

// **Note** - The starting overflow value of the layerId has to be set to  
// auto or this will not work in Netscpe!

// **STUPID BUG NOTICE**
// The content div that has the overflow value set (i.e. - layerId) has to have
// a set width (not a %) and it's CSS properties overflow, padding, and width 
// HAVE TO BE set in the tags HTML style="blah: blah;". I don't know why....but I will find out.

var scrollSize = null;	
var browser = new Browser();	//Get broswer version using function from browser_detect.js 

function setOverflow(action, layerId){
	if(browser.isNS){	//Make sure we only do this if we are using a Mozilla broswer...
		var obj = document.getElementById(layerId);
		
		// We need to know the scrollbar width since it can be different   
		// depending on the user's OS personal settings and/or browser type
		if(scrollSize == null){
			totalObjSize = parseInt(obj.style.width, 10) + parseInt(obj.style.paddingLeft, 10) + parseInt(obj.style.paddingRight, 10);
			scrollSize = totalObjSize - obj.clientWidth;
		}
		if(action == "auto")
			if(obj.style.overflow == action)	//we don't want to resize twice in a row by accident...!
				return false;
			else
				obj.style.width = parseInt(obj.style.width, 10) + (scrollSize) + "px";
		else{
			if(obj.style.overflow == action)	//we don't want to resize twice in a row by accident...!
				return false;
			else
				obj.style.width = parseInt(obj.style.width, 10) - (scrollSize) + "px";
		}
		obj.style.overflow = action;
	}else
		return false;
}
