// Menu effects
// JQuery required, Timer JQuery plugin required

var isChrome = false;
if(navigator.userAgent.indexOf("Chrome") > 0) {
    isChrome = true;
}
var timerPeriod = 1;
var timerStep = 4;
if(isChrome) {
    timerStep = 1;
    timerPeriod = 3;
}

function initMenu() {
    var menuItems = $("div#main-menu > ul > li");
    var mItemsCount = menuItems.length;
    for(var i = 0; i < mItemsCount; i++) {
        var mItem = $(menuItems[i]);
        var link = mItem.find("a");
        if(!link.hasClass("wb")) {
            mItem.hover(function() {
                var oI = $(this);
                var currentOffset = -64;
                var link = oI.find("a");
                link.addClass("hover");
                $.timer(timerPeriod, function(timer) {
                    currentOffset += timerStep;
                    oI.css({ backgroundPosition: "0px " + currentOffset + "px" });
                    if(currentOffset >= 0) { timer.stop(); }
                });
            }, function() {
                var oI = $(this);
                var currentOffset = 0;
                var link = oI.find("a");
                link.removeClass("hover");
                $.timer(timerPeriod, function(timer) {
                    currentOffset = currentOffset - timerStep;
                    oI.css({ backgroundPosition: "0px " + currentOffset + "px" });
                    if(currentOffset <= -64) { timer.stop(); }
                });
            });
        }
    }
}

function preloadDownloadButtonImages(staticPath) {
   var buttonOverImage = new Image();
   if($.browser.msie && parseFloat($.browser.version) <= 6.0) {
        buttonOverImage.src=staticPath+"/images/download-btn-a.gif"
   } else {
	buttonOverImage.src=staticPath+"/images/download-btn-a.png"
   }
}

function initDBtn(staticPath) {
    var cont = $("div#download-btn");
    cont.hover(function() {
        if($.browser.msie && parseFloat($.browser.version) <= 6.0) {
            $(this).css({
                backgroundImage: "url("+staticPath+"/images/download-btn-a.gif)"
            });
        } else {
            $(this).css({
                backgroundImage: "url("+staticPath+"/images/download-btn-a.png)"
            });
        }
    }, function() {
        if($.browser.msie && parseFloat($.browser.version) <= 6.0) {
            $(this).css({
                backgroundImage: "url("+staticPath+"/images/download-btn.gif)"
            });
        } else {
            $(this).css({
                backgroundImage: "url("+staticPath+"/images/download-btn.png)"
            });
        }
    })
}


function initScreens() {
    var sContainers = $("div.screen-container");
    for(var i = 0; i < sContainers.length; i++) {
        var sc = $(sContainers[i]);
        sc.css({ opacity: 0.7 });
        sc.hover(function() {
            $(this).animate({
                top: -4 + "px",
                opacity: 1
            }, 300);
        }, function() {
            $(this).animate({
                top: 0,
                opacity: 0.7
            }, 300);
        });
    }
}
