﻿/* 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 setClass(obj,cls) {
    var elementObj;
    if (isIE && isWin && !isOpera) elementObj = eval("document.all." + obj);
    else elementObj = eval('document.getElementById("' + obj + '")');
    elementObj.className = cls;
}

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 toggleMenu(obj,pos,dis) {
    var elementObj;
    if (isIE && isWin && !isOpera) elementObj = eval("document.all." + obj);
    else elementObj = eval('document.getElementById("' + obj + '")');
            elementObj.style.left = pos + "px";
            elementObj.style.visibility = dis;   
}

window.addEvent('domready', function() {
    SqueezeBox.assign($$('a.modal'), {
        parse: 'rel'
    });
});

function preloadImg(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
    }
}
preloadImg("images/btnDwn.gif");
preloadImg("images/SqueezeBox/bg_e.png");
preloadImg("images/SqueezeBox/bg_n.png");
preloadImg("images/SqueezeBox/bg_ne.png");
preloadImg("images/SqueezeBox/bg_nw.png");
preloadImg("images/SqueezeBox/bg_s.png");
preloadImg("images/SqueezeBox/bg_se.png");
preloadImg("images/SqueezeBox/bg_sw.png");
preloadImg("images/SqueezeBox/bg_w.png");
preloadImg("images/SqueezeBox/closebox.png");
preloadImg("images/SqueezeBox/closebox.gif");
preloadImg("images/SqueezeBox/spinner.gif");
