// selectupdate.js

var d=document;
var ddSwitch = 0; // initializes menus set to off

function ddInit(){
    if (d.layers) { // Netscape
        d.captureEvents(Event.ONMOUSEMOVE);
        d.onmousemove=captureMousePosition;
    } else if (d.getElementById || d.all){ // IE or Mozilla
        d.onmousemove=captureMousePosition;
    }
}

function ddDisplaySelect(){
    /* grab ID names of all side-parcels with "nojs" and switch out with "js" */
    ddCount = d.getElementsByTagName('div');
    for(i=0;i<ddCount.length;i++){
        if(ddCount[i].className == 'nojs'){ ddHide(ddCount[i].id); }
        if(ddCount[i].className == 'js'){ ddShow(ddCount[i].id); }
    }
}
var yMousePos=0;
var yMousePosMin=0;
var yMousePosMax=0;
function captureMousePosition(e) {
   if (d.all) {
            yMousePos = window.event.y+document.body.scrollTop;
            yMousePosMin = d.body.scrollTop;
            yMousePosMax = d.body.clientHeight+d.body.scrollTop;
        } else if (d.getElementById || d.layers){
            // Mozilla, FF, & Netscape work the same in this regard
            yMousePos = e.pageY;
            yMousePosMin = window.pageYOffset;
            yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}
function ddShow(menu){
	d.getElementById(menu).style.display="block";
}
function ddHide(menu){
    d.getElementById(menu).style.display="none";
}
function ddHideAll(){
if(document.getElementById("selectsBox")){
    var ddFound = ddFind();
    for (i=0;i<ddFound.length;i++){
        if(d.getElementById(ddFound[i]).style.display=="block") { ddHide(ddFound[i]);}
    }
    }
}
function ddDir(menu){
        // Fixes slow computer redraw problem
            d.getElementById(menu).style.left="-10000px";
            ddShow(menu);
        /* if IE */
        if (d.all){
            ddMenuSpaceAvail=d.documentElement.clientHeight-yMousePos;
        } else {
            ddMenuSpaceAvail=yMousePosMax-yMousePos;
        }

        if ((d.getElementById(menu).offsetHeight<ddMenuSpaceAvail) || (ddMenuSpaceAvail>(yMousePos-yMousePosMin))){ /* checks if room to open down */
            d.getElementById(menu).style.top="-1px";
        } else { /* opens up */
            d.getElementById(menu).style.top = (2-(d.getElementById(menu+'Box').offsetHeight - 18))+'px';
        }
        ddHide(menu);
        d.getElementById(menu).style.left="0px";
}

function ddFind(){
    /* grab ID names of all side-parcels with selectBoxes */
    ddCount = d.getElementsByTagName("div");
    j=0;
    var ddFound = new Array();
    for(i=0;i<ddCount.length;i++){
        if(ddCount[i].className == 'selectBox' || ddCount[i].className == 'selectBox1'){
            // assuming parent div class is same as child minus 3 letter ext
            ddFound[j] = ddCount[i].id.substring(0, (ddCount[i].id.length-3));
            j++;
        }
    }
    return ddFound;
}

function ddToggle(menu, e){
    /* kill further events */
    e.cancelBubble=true;

    // assuming parent div is same as child minus 3 letter ext, set primary menu
    menu = menu.substring(0, (menu.length-3));

    if (ddSwitch==0){
        /* if menus were initially off */
        ddDir(menu);
        ddShow(menu);
        ddSwitch=1;
    } else {
        /* if the menu was open, turn that menu off */
        if (d.getElementById(menu).style.display=="block"){
            ddHide(menu);
            ddSwitch=0;
        /* otherwise confirm/turn other menus off before displaying primary menu */
        } else {
            ddHideAll();
            ddDir(menu);
            ddShow(menu);
            ddSwitch=1;
        }
    }
}

function sent_para(obj){
	if(d.getElementById || d.all || d.layers){
		var param = d.getElementById('selectsBox');
		var para_child = param.firstChild.firstChild.nodeValue;
		param.firstChild.firstChild.nodeValue = obj.firstChild.nodeValue;
		}	
}

function ddDir1(menu){
        // Fixes slow computer redraw problem
            d.getElementById(menu).style.left="-10000px";
            ddShow(menu);
        /* if IE */
        if (d.all){
            ddMenuSpaceAvail=d.documentElement.clientHeight-yMousePos;
        } else {
            ddMenuSpaceAvail=yMousePosMax-yMousePos;
        }

        if ((d.getElementById(menu).offsetHeight<ddMenuSpaceAvail) || (ddMenuSpaceAvail>(yMousePos-yMousePosMin))){ /* checks if room to open down */
            d.getElementById(menu).style.top="-1px";
        } else { /* opens up */
            d.getElementById(menu).style.top = (2-(d.getElementById(menu+'ox1').offsetHeight - 18))+'px';
        }
        ddHide(menu);
        d.getElementById(menu).style.left="0px";
}	

function ddToggle1(menu, e){
    /* kill further events */
    e.cancelBubble=true;
    if(!menu)return false;

    // assuming parent div is same as child minus 3 letter ext, set primary menu
    menu = menu.substring(0, (menu.length-3));

    if (ddSwitch==0){
        /* if menus were initially off */
        ddDir1(menu);
        ddShow(menu);
        ddSwitch=1;
    } else {
        /* if the menu was open, turn that menu off */
        if (d.getElementById(menu).style.display=="block"){
            ddHide(menu);
            ddSwitch=0;
        /* otherwise confirm/turn other menus off before displaying primary menu */
        } else {
            ddHideAll();
            ddDir1(menu);
            ddShow(menu);
            ddSwitch=1;
        }
    }
}	
function sent_para1(obj){
	if(d.getElementById || d.all || d.layers){
		var param = d.getElementById('selectsBox1');
		var para_child = param.firstChild.firstChild.nodeValue;
		param.firstChild.firstChild.nodeValue = obj.firstChild.nodeValue;
		}
}