// UTILITY Javascript functions

// utility function to toggle view of text
// also changes anchor wording from more to less
function toggle(a,idiv) {
    // alert("anchor="+a.innerHTML);
    var e = document.getElementById(idiv);
    var s = e.style;
    if (s.display == "none") {
        s.display = "block";
        a.innerHTML = "Read less...";
    }
    else {
        s.display = "none";
        a.innerHTML = "Read more...";
    }
}

// scrolling
// master dispatch invoked on timeout
function dispatch()
{
	// walk array of dispatchable objects
    // alert("dispo length="+dispo.length);
	for (i = 0; i < dispo.length; i++) {
        // alert("dispo["+i+"]="+dispo[i]);
		dispo[i].dispatch();
    }

	interval=setTimeout("dispatch()",speed);
}

// Lex change 1:07 pm Fri Jun  4, 2010
// must protect against null values if some controls do not exist
function startit(tscroll)
{
    var isIE = (navigator.appName == "Microsoft Internet Explorer");
    // alert("browser="+navigator.appName+", IE?="+isIE);
    var s = document.getElementById('seemore');
    if (s) {
        // hide the scroll more since no work in IE
        if (isIE)
            s.style.visibility = 'hidden';
        else
            s.style.left = 757 - s.offsetWidth;
    }

    // minimize height of schedule box
    s = document.getElementById('isched');
    if (s) {
        h = s.offsetHeight+2*s.offsetTop;
        s = document.getElementById('idivsched');
        s.style.height = h;
    }

	// find Expander menu by id
    // fix height problem with IE by conditional
	mHelp = new Expander('mHelp',isIE);

    // init popup menus
    // by traversing children of known div
    Poppers('mPop',isIE);

	// id of scrollable div, id of container, items, multi-lines
    // uses DOM to count items, minimize height
    var ndisp = 0;
    if (tscroll) {
        var d = new Scroller('scrolldisplay','scrollholder');
        if (d) dispo[ndisp++] = d;
    }

	// id, display time in sec
	// the id is that of the scrollable DIV containing all the images
	d = new Gallery('igallery',2);
	if (d) dispo[ndisp] = d;

	dispatch();
}

function stopit()
{
	clearTimeout(interval);
}

