$(document).ready(function() {
    $('#page-header').supersleight(); 
    $('.box .header').corner("cc:#fff round tl tr 10px");
    $('.box').corner("round all 10px");
    $('.reserve').corner("round all 10px");
    $('.side-menu').corner("round all 10px");
    $('.side-menu .header').corner("round tl tr 10px");

    $('div.border-box').wrapInner('<div class="border-inner"></div>');
    $('div.border-inner').corner("round 8px").parent().css('padding','2px').corner("round 8px");
    $('.border-box .header').corner("cc:#fff round tl tr 10px");
    $('.border-box').corner("round all 10px");

    $('div.column-set').each(
        function() { 
            setEqualHeight($(this).find('div.border-box > div.border-inner')); 
            setEqualHeight($(this).find('div.box')); 
        }
    );

    $('.button').corner("round all 10px");
    $('.nav-menu').bgiframe();
    $("#nav-bar li").hover(
        function() {
            buttonOffset = $(this).offset();
            buttonOffset.left += parseInt($("body").css("borderLeftWidth"));
            buttonOffset.top += $(this).height();
            submenu = $(this).find(".nav-menu");
            submenu.css(buttonOffset);
            $(this).addClass("hovering");
        },
        function () {
            $(this).removeClass("hovering");
        }
    );
});
function setEqualHeight(columns) {  
    var tallestcolumn = 0;  
    columns.each(  
        function() {  
            currentHeight = $(this).height();  
            if(currentHeight > tallestcolumn)  
                tallestcolumn  = currentHeight;  
        }  
    );  
    columns.height(tallestcolumn);  
}

function updateBannerImage(delay, imageIndex) {
    var imageSets = $('.image-set');
    if (imageSets.length > 1)
    {
        if (!imageIndex)
            imageIndex = 0;
        var firstIndex = imageIndex;
        var foundImage = false;

        do
        {
            var nextIndex = imageIndex + 2;
            if (nextIndex >= imageSets.length)
                nextIndex = (nextIndex % 2 == 0) ? 1 : 0;

            var currentSet = imageSets.eq(imageIndex);
            if (currentSet.children('img').length > 1)
            {
                var label = currentSet.children('span.title').first();
                currentSet.children('.active').each(function() {
                    var container = $(this).parent();
                    var nextImage = ($(this).next('img').length > 0) ? $(this).next('img') : container.children('img').first();
                    $(this).fadeOut('fast', function(){
                        $(this).removeClass('active');
                        var title =  nextImage.attr("alt");
                        if (label && title)
                            label.html(title);
                        nextImage.fadeIn('fast').addClass('active');
                    });
                });
                foundImage = true;
                break;
            }
            imageIndex = nextIndex;
        } while (nextIndex != firstIndex);

        if (foundImage)
            setTimeout('updateBannerImage('+delay+','+nextIndex+')', delay);
    }
}

