/*
 * menuExpandable3.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
	
    if (menu == null || actuator == null) return;

    actuator.parentNode.style.backgroundImage = "url(../images/plus.gif)";
    actuator.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(../images/plus.gif)" : "url(../images/minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";
        //alert('id = ' + this.id + ' nodeName = ' + this.nodeName + ' nodeType = ' + this.nodeType);
        //var sibling = this;
        //do sibling = sibling.nextSibling;
        //while (sibling && sibling.nodeType != 1);
        //alert('SIBLING! id = ' + sibling.id + ' nodeName = ' + sibling.nodeName + ' sibling = ' + this.nodeType);
        //alert('PARENT! id = ' + this.parentNode.id + ' nodeName = ' + this.parentNode.nodeName + ' nodeType = ' + this.parentNode.nodeType);
        //setSelNode(this.id.substring(1,8)); 
        //setNodeAt("m10101", "a10101");


        return false;
    }

    actuator.onKeyPress = function() {
        var display = menu.style.display;
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(../images/plus.gif)" : "url(../images/minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}

function setNodeAt(menu_Id, actuator_Id) {
	//alert(menu_Id);
	//alert(actuator_Id);
    var menu = document.getElementById(menu_Id);
    var actuator = document.getElementById(actuator_Id);

    var display = menu.style.display;
    actuator.parentNode.style.backgroundImage =
        (display == "block") ? "url(../images/plus.gif)" : "url(../images/minus.gif)";
    menu.style.display = (display == "block") ? "none" : "block";

    return false;
}

function ExpandHomePageTree(){

	var url = window.location.search.substring(1);
	if(url.length == 0){
      	initializeMenu("m101", "a101");
      	setNodeAt("m101", "a101"); 			
	}
}
