
var partners = 0;
var currentPartner = 0;

$(document).ready(
    function()
    {
        partners = $('.partnerContainer').length;
        currentPartner = 0;
        
        $('#down a').click(
            function()
            {
                setPartner(1);
                return false;
            }
        );
        
        $('#up a').click(
            function()
            {
                setPartner(-1);
                return false;
            }
        );
        
        $('[name=company]').click(
            function()
            {            
                if ($(this).is(':checked'))
                {
                    $('.registry .ifcompany').show();
                }
                else
                {
                    $('.registry .ifcompany').hide();
                }
            }
        );
        
        $('[name=othercontactaddress]').click(
            function()
            {            
                if ($(this).is(':checked'))
                {
                    $('.registry .ifothercontactaddress').show();
                }
                else
                {
                    $('.registry .ifothercontactaddress').hide();
                }
            }
        );
        
        $('.inOffer a.first').hover(
            function()
            {
                $(this).siblings().eq(0).addClass('hover');
            },
            function()
            {
                $(this).siblings().eq(0).removeClass('hover');
            }            
        );
    }
);

function setPartner(direction)
{
    if (direction < 0)
    {
        currentPartner = currentPartner -1;
        if (currentPartner < 0)
        {
            currentPartner = partners-1;
        }
    }
    else if (direction > 0)
    {
        currentPartner = (currentPartner + 1) % partners; 
    }
    
    var current = currentPartner
    for(var i = 0; i < 4; i++ )
    {
        $('.partnerFrame' + i + ' .partnerMiddle').html(
            $('.partner' + current).html() 
        );   
        
        current = (current + 1) % partners;
    }
}

