
// Define global references
var tgtEle;
var optionSelected = false;
var timeoutId;


function showPage(direction) {
    if ((obj = MM_findObj("page")) != null) {
        obj.value = parseInt(obj.value) + direction;
    }
    var form = MM_findObj("qualSearchForm");
    form.submit();
}




/*
 * Starting point for the whole process of scrolling open a box with text in it
 */
function displayTitle(srcEle, tgtId) {

    // We only need to do this for IE as it is not possible to read the whole thing

    if (navigator.userAgent.indexOf("MSIE") > 0)
    {
        optionSelected = true;

        if (document.getElementById) {
            tgtEle = document.getElementById(tgtId);
        }
        else {
            tgtEle = document.all.forms[tgtId];
        }

        tgtEle.innerHTML = srcEle.options[srcEle.selectedIndex].value;
        tgtEle.style.height = "0px";

        if (tgtEle.innerHTML.length > 0)
        {
            showTitle();
            pause(3000, "hideTitle()");
        }
    }
}

/*
 * Scrolls the text block (layer) closed
 */
function hideTitle(){

    resetTimer();

    var eleHeightStr = tgtEle.style.height.substring(0, tgtEle.style.height.indexOf("px"));
    var eleHeight = parseInt(eleHeightStr);

    if (eleHeight > 1){
        tgtEle.style.height = (eleHeight - 1) + "px";
        timeoutId = window.setTimeout("hideTitle()", 5);
    }
    else {
        tgtEle.style.display = "none";
    }
}

/*
 * Scrolls the text block (layer) open
 */
function showTitle(){

    resetTimer();

    tgtEle.style.display = "block";

    var eleHeightStr = tgtEle.style.height.substring(0, tgtEle.style.height.indexOf("px"));
    var eleHeight = parseInt(eleHeightStr);

    if (eleHeight <= 45){
        tgtEle.style.height = (eleHeight + 1) + "px";
        timeoutId = window.setTimeout("showTitle()", 5);
    }
}

/*
 * Clears the timeout and sets the global variable 'optionSelected' to false.
 */
function resetTimer() {

    if (optionSelected && timeoutId) {
        window.clearTimeout(timeoutId);
        optionSelected = false;
    }

}

/*
 * Triggers a pause before
 */
function pause(timeInMillis, tgtFunc){
    window.setTimeout(tgtFunc, timeInMillis);
}


