﻿/* Script developed by Josh Squires of Structured Systems International
Please leave author credits if used */

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var currentElement = "";
var _global = this;

function openAnimation(obj, objH) {
    var elementObj;
    if (isIE && isWin && !isOpera) elementObj = eval("document.all." + obj);
    else elementObj = eval('document.getElementById("' + obj + '")');

    if (_global["closeAnimation" + obj + "ID"] != "undefined") clearTimeout(_global["closeAnimation" + obj + "ID"]);

    var cHeight = (isNaN(parseInt(elementObj.style.height))) ? 0 : parseInt(elementObj.style.height);
    var nHeight = (cHeight < parseInt(objH)) ? cHeight + 5 : cHeight;
    elementObj.style.height = nHeight + "px";
    if (nHeight != parseInt(objH)) _global["openAnimation" + obj + "ID"] = setTimeout(function() { openAnimation(obj, objH); }, 10);
}

function closeAnimation(obj, objH) {
    var elementObj;
    if (isIE && isWin && !isOpera) elementObj = eval("document.all." + obj);
    else elementObj = eval('document.getElementById("' + obj + '")');

    if (currentElement != elementObj.id) {
        if (_global["openAnimation" + obj + "ID"] != "undefined") clearTimeout(_global["openAnimation" + obj + "ID"]);
        var cHeight = (isNaN(parseInt(elementObj.style.height))) ? parseInt(objH) : parseInt(elementObj.style.height);
        var nHeight = (cHeight > 0) ? cHeight - 5 : cHeight;
        elementObj.style.height = nHeight + "px";
        if (cHeight != 0) {
            _global["closeAnimation" + obj + "ID"] = setTimeout(function() { closeAnimation(obj, objH); }, 10);
        }
    }
}

function preloadImg(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
    }
}
preloadImg("images/corporate/subMenuActive.png");
preloadImg("images/corporate/subMenuInactive.png");
preloadImg("images/corporate/subMenuPulse.gif");