$(document).ready(function(){
                           
    //$('#news').hide();
    //$('#spotLight').hide();
    //$('#events').hide();  
                    
    (function($){
                                
        $.fn.wrapChildren = function(options) {
                        
            var options = $.extend({
                childElem : undefined,
                sets : 1,
                wrapper : 'div'
            }, options || {});
                                                    
            if (options.childElem === undefined) return this;
                        
                return this.each(function() {
                    var elems = $(this).children(options.childElem);
                    var arr = [];
                                
                elems.each(function(i,value) {
                    arr.push(value);
                    if (((i + 1) % options.sets === 0) || (i === elems.length -1)) {
                        var set = $(arr);
                        arr = [];
                        set.wrapAll($("<" + options.wrapper + ">"));
                    }
                });
            });
                    
        }
                    
    })(jQuery);
                    
   $.get("/scripts/userContent/filmStrip.asp", function(data){
        $('#logobottom').delay(500).html(data);     
    }); 
    $.get("/scripts/press/homefeed3x.asp", function(data){
        $('#news').delay(250).html(data);       
    });
    $.get("/scripts/calendar/calFeedJQlite2.asp", function(data){
        $('#events').delay(250).html(data);     
    });
                    
    $('#quickLinks').cycle({ 
        fx:     'scrollHorz',
        speed:  'fast',
        prev:   '#qlBack', 
        next:   '#qlForward', 
        timeout: 0 
    });
                    
    $('#banner_image').cycle({ 
        fx:     'fade', 
        timeout: 5000, 
        pager:  '#thumbs',
        speed:  'fast', 
     
        pagerAnchorBuilder: function(idx, slide) {                          
            return '#thumbs div:eq(' + idx + ') a';                         
        } 
    });
                    
    $('#overlay').cycle({ 
        fx:     'fade', 
        timeout: 5000, 
        cleartype:  false,
        speed:  'fast', 
        pager:  '#thumbs', 
     
        pagerAnchorBuilder: function(idx, slide) {                          
            return '#thumbs div:eq(' + idx + ') a';
        } 
    });                 
                     
    $('#thumbs').wrapChildren({ 
        childElem : 'div', 
        sets: 3, 
         wrapper: 'div'
    });
                    
    $('#thumbs').cycle({ 
        fx:     'scrollHorz',
        speed:  'fast',
        prev:   '#prev', 
        next:   '#next', 
        cleartype: false,
        timeout: 0 
    });             
                    
    $('#banner_proto').cycle({ 
        fx:     'scrollVert',
        speed:  'fast',
        prev:   '#quickLinksTabShow', 
        next:   '#quickLinksTabHide',
        cleartype: true,
        timeout: 0 
    }); 
                    
    $('#quickLinksTabShow').hide();
    $('#quickLinksTabHide').toggleClass('qlDown');
    $('#quickLinksTabShow').toggleClass('qlUp');
                    
    $('#quickLinksTabHide').click(function() {
        $('#quickLinksTabShow').show();
        $('#quickLinksTabHide').hide();
    });
                    
     $('#quickLinksTabShow').click(function() {
        $('#quickLinksTabShow').hide();
         $('#quickLinksTabHide').show();
    });
    
    
    //Larger thumbnail preview 

    $("#locationthumb").hover(function() {
        $(this).css({'z-index' : '50'});
        $(this).find('img').addClass("hover").stop()
            .animate({
                marginTop: '-60px', 
                marginLeft: '-3px', 
                top: '50%', 
                left: '50%', 
                width: '200px', 
                height: '185px',
                padding: '0px' 
            }, 200);
        
        } , function() {
        $(this).css({'z-index' : '0'});
        $(this).find('img').removeClass("hover").stop()
            .animate({
                marginTop: '0', 
                marginLeft: '0',
                top: '0', 
                left: '0', 
                width: '134px', 
                height: '121px', 
                padding: '0px'
            }, 400);
    });

    
});
                
$(window).load(function() {         
                    
    $('#spotLight').cycle({ 
        fx:     'scrollHorz',
        speed:  'fast',
        cleartype: 1,
        prev:   '#prevSpot', 
        next:   '#nextSpot', 
        timeout: 0 
    }); 
    
    $('#news').fadeIn();
    $('#spotLight').fadeIn();
    $('#events').fadeIn();
    $('#banner_proto').css('visibility','visible');
    $('#home_slideshow').fadeIn();

});
