$(document).ready(function()
{
    // DOM is ready


    $(function()
    {
        var items = $('.billboard ul li').size();
        var opacity = $.support.opacity;
        //var opacity = true;
        for (i=1;i<=items;i++)
        {
            $('.billboard ul li:nth-child(' + i + ')').hide();
            if (opacity === true)
            {
                $('.billboard ul li:nth-child(' + i + ')').animate({ opacity: 0, paddingLeft: '20px' }, { "duration": 0 });
            } else {
                $('.billboard ul li:nth-child(' + i + ')').fadeOut();
            }
        }
        var timer;
        var billboardItem = 0;
		var donext = function (x)
		{
            if (billboardItem != 0)
            {
                //hide previous billboard item
                if (opacity === true)
                {
                    $('.billboard ul li:nth-child(' + billboardItem + ')').animate({ opacity: 0, paddingLeft: '20px' }, { "duration": "slow" });
                } else {
                    $('.billboard ul li:nth-child(' + billboardItem + ')').fadeOut();
                }
                $('.billboard ul li:nth-child(' + billboardItem + ')').hide();
            }
            billboardItem++;
            if (billboardItem > items)
            {
                billboardItem = 1;
            }
            //show next billboard item
            
            $('.billboard ul li:nth-child(' + billboardItem + ')').show();
            if (opacity === true)
            {
                $('.billboard ul li:nth-child(' + billboardItem + ')').animate({ opacity: 1, paddingLeft: '40px' }, { "duration": "slow" });
            } else {
                $('.billboard ul li:nth-child(' + billboardItem + ')').fadeIn();
            }

            

			if(timer != null)
			{
                clearInterval(timer);
            }
			timer = setInterval(function() { donext(); }, 5000);
		}
		donext();

        //check the current url and update the navigation if it matches
        $(".menu ul li a[href='" + window.location.pathname + "']").parent('li').addClass('selected');
        //swap the border outline on focus and blur
        $('.content input,.content textarea').focus(function() { $(this).addClass('selected'); });
        $('.content input,.content textarea').blur(function() { $(this).removeClass('selected'); });
        switch (window.location.pathname)
        {
            case "/login.asp":
            case "/password-reminder.asp":
                $('#txtemail').focus();
                break;
            case "/password-change.asp":
                $('#txtoldpassword').focus();
                break;
            default:
                $('#txtfirstname').focus();
        }
        
        if($.browser.msie)
        {
            $('td input:checkbox').css({padding:'0px', marginLeft:'0px', marginRight:'0px', border:'none', backgroundImage:'none' });
        }


    });
});

