
var auto_timer = null;

//jQuery(document).ready(function() {
jQuery(function ($) {
    if (typeof premium_count == 'undefined' || !premium_count) return;


    jQuery('#premium-box').mouseover(function(event) {
        if (auto_timer) clearTimeout(auto_timer);
    });

    jQuery('#premium-box').mouseout(function(event) {
        if (premium_auto) auto_timer = setTimeout(timer_func, premium_delay * 1000);
    });

    jQuery('#premium-item-1').css('display', 'block');
    jQuery('#premium-item-button-1').attr('src', '/layouts/conference/images/num1_on.gif');
    jQuery('#premium-item-button-1').css('cursor', 'auto');
    premium_pos = 1;

    for (var i = 2; i <= premium_count; i++) {
        jQuery('#premium-item-button-' + i).click(function(event) {
            showPremiumBanner(this, false);
        });
    }

    if (premium_auto) auto_timer = setTimeout(timer_func, premium_delay * 1000);
});

function showPremiumBanner(obj, auto_change) {
    if (premium_pos) {
        jQuery('#premium-item-' + premium_pos).css('display', 'none');
        //jQuery('#premium-item-' + premium_pos).fadeOut(100);
        jQuery('#premium-item-button-' + premium_pos).attr('src', '/layouts/conference/images/num' + premium_pos + '_off.gif');
        jQuery('#premium-item-button-' + premium_pos).click(function(event) {
            showPremiumBanner(this, false);
        });
        jQuery('#premium-item-button-' + premium_pos).css('cursor', 'pointer');
    }

    var pos = obj.id.replace('premium-item-button-', '');

    //jQuery('#premium-item-' + pos).css('display', 'block');
    jQuery('#premium-item-' + pos).fadeIn(500);
    //jQuery('#premium-item-' + pos).slideDown(300);
    jQuery('#premium-item-button-' + pos).attr('src', '/layouts/conference/images/num' + pos + '_on.gif');
    jQuery('#premium-item-button-' + pos).unbind('click');
    jQuery('#premium-item-button-' + pos).css('cursor', 'auto');

    premium_pos = pos;

    if (auto_timer) clearTimeout(auto_timer);
    if (auto_change) auto_timer = setTimeout(timer_func, premium_delay * 1000);
}


function timer_func() {
    var pos = 1;
    if (premium_pos) pos = (premium_pos % premium_count) + 1;

    showPremiumBanner(document.getElementById('premium-item-button-' + pos), true);
}


