﻿    /// <reference path="/jquery-1.4.4-vsdoc.js" />


/* Settings */
var theSpeed = 100; // Seconds for complete loop


theSpeed = theSpeed * 100;
var totalWidth = 0;

jQuery(window).load(function () {

    if (getInternetExplorerVersion() > 6 || getInternetExplorerVersion() == -1) {

        theSpeed = theSpeed * 10;

        // Get the width of all the images together
        jQuery("#sponsors-container").children().children().each(function () {
            var itemWidth;

            // If the image is inside an <a> tag
            if (this.tagName == "A" && jQuery(this).children("img").exists()) {
                itemWidth = jQuery(this).outerWidth();
            } else {
                // Else it's just an image or link alone
                itemWidth = jQuery(this).outerWidth();
            }

            totalWidth += itemWidth;

        });

        // Copy the div so we have a continuous flow
        var theHTML = jQuery("#sponsors-container").children().html();
        jQuery("#sponsors-container").children().children(':last-child').after(theHTML);

        // Set the width and start the animation
        jQuery("#sponsors-container").children().width(totalWidth * 2 + 20);

        animatePanel();
    }
});

function animatePanel() {
    jQuery("#sponsors-container").children().animate({
        left: -(totalWidth + 20) // container padding
    }, theSpeed,
        "linear",
        function () {
            jQuery(this).css("left", -20);
            animatePanel();
        }
    );
}

jQuery.fn.exists = function () { return jQuery(this).length > 0; }

/* IE Detection */
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}















