﻿/* This file combines ColorChange.js, DropdownMenu.js, and FadeElement.js to one file minified */

var ColorChangeTimers = new Array(); function ColorChangeStop_timeout(element) { clearTimeout(ColorChangeTimers[element]); ColorChangeTimers[element] = false; }
function setcolor(element, step, totalsteps, incArray, to) {
    obj = document.getElementById(element); var currentColor = obj.style.backgroundColor; ColorChangeStop_timeout(element); var Color = new Array(); var ToColor = new Array(); var NewColor = new Array(); for (var i = 0; i < 3; i++) { Color[i] = parseInt(getColor(currentColor, i)); ToColor[i] = parseInt(getColor(to, i)); }
    if (step == totalsteps || (Color[0] == ToColor[0] && Color[1] == ToColor[1] && Color[2] == ToColor[2])) { obj.style.backgroundColor = to; } else {
        for (var j = 0; j < 3; j++) { if (incArray[j] >= 0 && (Color[j] + incArray[j]) >= ToColor[j]) { NewColor[j] = ToColor[j]; } else if (incArray[j] < 0 && (Color[j] + incArray[j]) < ToColor[j]) { NewColor[j] = ToColor[j]; } else { NewColor[j] = Color[j] + incArray[j]; } }
        obj.style.backgroundColor = '#' + inttohex(NewColor[0]) + inttohex(NewColor[1]) + inttohex(NewColor[2]); step++; ColorChangeTimers[element] = window.setTimeout("setcolor(\'" + element + "\'," + step + "," + totalsteps + ",[" + incArray[0] + "," + incArray[1] + "," + incArray[2] + "],\'" + to + "\')", 10);
    } 
}
function findColorChangeInc(from, to, totalsteps) {
    var returnColor = new Array(); for (var i = 0; i < 3; i++) { var tempInc = (parseInt(getColor(to, i)) - parseInt(getColor(from, i))) / totalsteps; if (tempInc > 0) { returnColor[i] = Math.ceil(tempInc); } else { returnColor[i] = Math.floor(tempInc); } }
    return returnColor;
}
function getColor(color, colorSection) { if (colorSection == 0) { if (color.substr(0, 1) == '#') { return hextoint(color.substr(1, 2)); } else if (color.substr(0, 3) == 'rgb') { return parseInt(color.split(',')[0].replace('rgb(', '')); } } else if (colorSection == 1) { if (color.substr(0, 1) == '#') { return hextoint(color.substr(3, 2)); } else if (color.substr(0, 3) == 'rgb') { return parseInt(color.split(',')[1]); } } else if (colorSection == 2) { if (color.substr(0, 1) == '#') { return hextoint(color.substr(5, 2)); } else if (color.substr(0, 3) == 'rgb') { return parseInt(color.split(',')[2].replace(')', '')); } } }
function inttohex(number) {
    var hex = parseInt(number).toString(16).toUpperCase(); if (hex.length < 2) { hex = '0' + hex; }
    return hex;
}
function hextoint(number) { return parseInt(number, 16); }
var DropDownTimers = new Array(); function openMenu(element, inc, max) { DropDownStop_timeout(element); var menuDiv = document.getElementById(element); var height = parseInt(menuDiv.style.height.replace('px', '')); if ((inc + height) >= max) { menuDiv.style.height = max + 'px'; } else { menuDiv.style.height = (inc + height) + 'px'; if ((max - height) < 25 && inc * 3 / 4 >= 1) { DropDownTimers[element] = window.setTimeout("openMenu(\'" + element + "\'," + inc * 3 / 4 + "," + max + ")", 10); } else { DropDownTimers[element] = window.setTimeout("openMenu(\'" + element + "\'," + inc + "," + max + ")", 10); } } }
function closeMenu(element, inc, min, max) { DropDownStop_timeout(element); var menuDiv = document.getElementById(element); var height = parseInt(menuDiv.style.height.replace('px', '')); if ((height - inc) < min) { menuDiv.style.height = min + 'px'; } else { menuDiv.style.height = (height - inc) + 'px'; if ((height - min) < 25 && inc >= 1) { DropDownTimers[element] = window.setTimeout("closeMenu(\'" + element + "\'," + inc * 3 / 4 + "," + min + ")", 10); } else { DropDownTimers[element] = window.setTimeout("closeMenu(\'" + element + "\'," + inc + "," + min + ")", 10); } } }
function DropDownStop_timeout(element) { clearTimeout(DropDownTimers[element]); DropDownTimers[element] = false; }
var FadeElementTimers = new Array(); var FadeDirection = new Array(); var LastElement; function setfadein(element, opacity, increment) {
    FadeDirection[element] = 1; obj = document.getElementById(element); FadeElementStop_timeout(element); if (opacity == 0) { obj.style.display = "block"; }
    if (opacity <= 100) { set_opacity(obj, opacity); opacity += increment; window.setTimeout("setfadein(\'" + element + "\'," + opacity + "," + increment + ")", 50); } 
}
function setfadeout(element, opacity, increment) {
    FadeDirection[element] = 0; obj = document.getElementById(element); if (opacity > 0) { set_opacity(obj, opacity); opacity -= increment; window.setTimeout("setfadeout(\'" + element + "\', " + opacity + ", " + increment + ")", 50); }
    if (opacity < 5) { obj.style.display = "none"; } 
}
function set_opacity(obj, opacity) { opacity = (opacity == 100) ? 99.999 : opacity; obj.style.filter = "alpha(opacity:" + opacity + ")"; obj.style.KHTMLOpacity = opacity / 100; obj.style.MozOpacity = opacity / 100; obj.style.opacity = opacity / 100; }
function fade_in(element, increment, e) { FadeElementStop_timeout(element); var obj = document.getElementById(element); if (obj.style.display == "none") { FadeElementTimers[element] = setTimeout("setfadein(\'" + element + "\', 0, " + increment + ")", 100); } else { FadeElementTimers[element] = setTimeout("setfadein(\'" + element + "\', " + obj.style.opacity * 100 + ", " + increment + ")", 50); } }
function fade_out(element, increment, e) { FadeElementStop_timeout(element); var obj = document.getElementById(element); FadeElementTimers[element] = setTimeout("setfadeout(\'" + element + "\', " + obj.style.opacity * 100 + ", " + increment + ")", 10); var relTarg; if (e.relatedTarget) { relTarg = e.relatedTarget; } else if (e.toElement) { relTarg = e.toElement; } }
function fade_toggle(element, increment, e) {
    FadeElementStop_timeout(element); var obj = document.getElementById(element); if (FadeDirection[element] == 1) { fade_out(element, increment, e); } else {
        if (LastElement != null) { FadeElementStop_timeout(LastElement); fade_out(LastElement, increment, e); }
        FadeDirection[element] = 1; fade_in(element, increment, e); LastElement = element;
    } 
}
function FadeElementStop_timeout(element) { clearTimeout(FadeElementTimers[element]); FadeElementTimers[element] = false; }