// Some global vars for the timer, to hold a reference to our object, and our visibility toggle value.
var timerid;
var obj;
var visible = true;

// Toggles the fade effect on and off.
function toggleFade(objectName) {

    // Get reference to target object
    obj = document.getElementById(objectName);

    if (obj) {
        // Clear any timers currently running for fades.
        clearTimeout(timerid);
		// Toggle function modified 3/21/08 for Keith Window Company to only allow Fade In regardless of visibility
        // If we are visible, hide it otherwise show it.
        //if (visible) {
         //   hideFade(100);
        //    visible = false;
        //}
        //else {    
            showFade(50);
            visible = true;
       //}

    }
}




// Function for hiding our object with outgoing fade
function hideFade(opac) {
    if (obj) {
        // If opacity is greater than 0, decrement opacity setting by 10 every 50 milliseconds.
        if (opac > 0) {
            obj.style.opacity = (opac / 100);
            obj.style.filter = "alpha(opacity=" + opac + ")";
            timerid = setTimeout("hideFade(" + (opac - 10) + ")",50);
        }
        else {
            // Opacity is zero, so hide it and then set its opacity back to full.
            obj.style.visibility = "hidden";
            obj.style.opacity = 1;
            obj.style.filter = "alpha(opacity=100)";

            // Clear the timer that is triggering the fade to stop it.
            clearTimeout(timerid);
        }
    }
}

// Function for showing the element with incoming fade
function showFade(opac) {
    if (obj) {

        // If opacity is less than 100, make it visible and then increment its opacity.
        if (opac < 100) {
            obj.style.visibility = "visible";
            obj.style.opacity = (opac / 100);
            obj.style.filter = "alpha(opacity=" + opac + ")";
            timerid = setTimeout("showFade(" + (opac + 10) + ")",50);
        }
        else {
            // Opacity is 100, so make sure it is at full opacity.
            obj.style.opacity = 1;
            obj.style.filter = "alpha(opacity=100)";

            // Clear the timer that is triggering the fade to stop it.
            clearTimeout(timerid);
        }
    }
}

