// rollovers for buttons ... uses class="imgover" to invoke
function initRollovers() {
	//check for incompatible browser
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	
	// declare image and input element variables
	var aInputs = document.getElementsByTagName("input");
	var aImg = document.getElementsByTagName('img');
	var aImages = new Array();
	
	// loop that finds the input elements
	for(var i = 0; i < aInputs.length; i++)
	{
		aImages[i] = aInputs.item(i);
	}
	// loop that finds all image elements and adds to 
	// inputs for total images that need swapping
	for(var i = 0; i < aImg.length; i++)
	{
		aImages[i + aInputs.length] = aImg.item(i);
	}

	// looks for images or inputs that have the imgover class and runs the following methods
	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			// adds the mouseover event
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			// adds the mouseout event
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

// popup window for 100% satisfaction
var win = null;
function NewWindow(url,name,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; // this
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0; // and this is for centering the popup on your screen
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=false'

win = window.open(url,name,settings)
}

function on(id){
	document.getElementById('arrow'+id).src = 'img/buttons/greenArrow-over.gif';
}
function off(id){
	document.getElementById('arrow'+id).src = 'img/buttons/greenArrow.gif';
}




function adjustWidth(element, container, widthWithScrollbar, widthWithoutScrollbar) {
if (element.offsetHeight != 0) {
if (element.offsetHeight > container.offsetHeight) {
//scrolling; use width with scrollbar
element.style.width = widthWithScrollbar;
} else {
//not scrolling; use width without scrollbar
element.style.width = widthWithoutScrollbar;
}
}
}

