jQuery.noConflict();

// Put all your code in your document ready area
jQuery(document).ready(function($){
    setup_sliders($);
    setup_cycle($);
    setup_gallery_lightboxes($);
});




function setup_sliders($) {
    // layers animation
    lastBlock = $("#Layout");
    maxWidth = 839;
    minWidth = 50;
    if ($("#About .layer-inner").length) {

        // replace the tab anchor with a div
        tab_content = $('#About a.tab').text();
        $('#About a.tab').replaceWith('<div class="tab">' + tab_content + '</div>');

        // load up the page
        $("#About .layer-inner").load("/about-us/AjaxContent",null, function () {
            // callback
            // setup About lightboxes
            $('#About .Sidebar .BioPage a').each( function() {
                $(this).colorbox({opacity: .5, width: '894px', height: '550px', close: 'close window'});
            });
        });
    }

    if ($("#Contact .layer-inner").length) {
        // replace the tab anchor with a div
        tab_content = $('#Contact a.tab').text();
        $('#Contact a.tab').replaceWith('<div class="tab">' + tab_content + '</div>');

        // load up the page
        $("#Contact .layer-inner").load("/contact-us/AjaxContent",null, function () {
            // callback
            // setup Creative Brief lightbox
            $('#Contact a.colorbox').each( function() {
                $(this).colorbox({opacity: .5, width: '894px', height: '90%', close: 'close window', iframe: true});
            });
        });
    }

    $("#Layout").css('cursor', 'auto');

    $("#Layout, #Contact, #About").click(
        function(){
            $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
            $(this).animate({width: maxWidth+"px"}, { queue:false, duration:400 });
            if ( $(this).attr('id') != $(lastBlock).attr('id') ) {
                $(lastBlock).addClass('hidden').css('cursor', 'pointer');
                $(this).removeClass('hidden').css('cursor', 'auto');
            }
            lastBlock = this;
        }
    );

}


function setup_cycle($) {
    $('#spotlight-items').cycle({timeout: 5000});
}

function setup_gallery_lightboxes($) {
    $('#gallery-items a').each( function() {
        var title = $(this).attr('title');
        var note = $(this).attr('rev');
        var message = '<h1>' + title + ' <span>|</span></h1>' + '<p>' + note + '</p>';
        $(this).colorbox({opacity: .5, width: '894px', title: message, close: 'close window'});
    });
    // $('#gallery-items a').colorbox({opacity: .5, width: '894px'});
}
