﻿window.faderTimeoutsContent = Array()
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style
    object.opacity = (opacity / 100)
    object.MozOpacity = (opacity / 100)
    object.KhtmlOpacity = (opacity / 100)
    object.filter = "alpha(opacity=" + opacity + ")"
}

function hide(id) {
    eval(document.getElementById(id).style.opacity = 0)
    document.getElementById(id).style.MozOpacity = 0
    document.getElementById(id).style.KhtmlOpacity = 0
    document.getElementById(id).style.filter = "alpha(opacity=" + 0 + ")"
    document.getElementById(id).setAttribute("class", "HideDiv");
    document.getElementById(id).setAttribute("className", "HideDiv");
}

function showcontent(id, millisec) {
    for (i in window.faderTimeoutsContent) {
        if (window.faderTimeoutsContent[i]) { clearTimeout(window.faderTimeoutsContent[i]); } 
    }
    if (document.getElementById(id).style.opacity == 100) {
        opacity(id, 100, 0, millisec)
    } else {
        document.getElementById(id).setAttribute("class", "ShowDiv");
        document.getElementById(id).setAttribute("className", "ShowDiv");
        opacity(id, 0, 100, millisec)
    }
    function opacity(id, opacStart, opacEnd, millisec) {
        var speed = Math.round(millisec / 100)
        var timer = 0
        if (opacStart > opacEnd) {
            for (i = opacStart; i >= opacEnd; i--) {
                window.faderTimeoutsContent.push(setTimeout("changeOpac(" + i + ",'" + id + "');;", (timer * speed)))
                timer++
            }
        } else if (opacStart < opacEnd) {
            for (i = opacStart; i <= opacEnd; i++) {
                window.faderTimeoutsContent.push(setTimeout("changeOpac(" + i + ",'" + id + "');;", (timer * speed)))
                timer++
            } 
        } 
    }
}

function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100)
    var timer = 0
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            window.faderTimeouts.push(setTimeout("changeOpac(" + i + ",'" + id + "');;", (timer * speed)))
            timer++
        }
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            window.faderTimeouts.push(setTimeout("changeOpac(" + i + ",'" + id + "');;", (timer * speed)))
            timer++
        } 
    } 
}