//function to display or hide a given element
function showHideItems(myItem, myButton){
    //this is the ID of the hidden item
    var myItem = document.getElementById(myItem);
    //this is the ID of the plus/minus button image
    var myButton = document.getElementById(myButton);

        if (myItem.style.display != "none") {
            //items are currently displayed, so hide them
            myItem.style.display = "none";
            swapImage(myButton,"plus");
        }
        else {
            //items are currently hidden, so display them
            myItem.style.display = "block";
            swapImage(myButton,"minus");
        }
    }

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	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, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

//function to swap an image based on its current state
function swapImage(myImage, state) {
        if (state == "minus") {
            myImage.src = "/assets/images/sign_minus.png";
        }
        else {
            myImage.src = "/assets/images/sign_plus.png";
        }
}

//function to display or hide a given element
function waitLoading(myItem){

    //this is the ID of the hidden item
    var myItem = document.getElementById(myItem);

        if (myItem.style.display != "none") {
            //items are currently displayed, so hide them
            myItem.style.display = "none";
        }
        else {
            //items are currently hidden, so display them
            myItem.style.display = "block";
        }

    scroll(0,0);
}