﻿/// <reference path="jquery-1.3.2.js" />
/// <reference path="jquery-ui-1.7.2.custom.min.js" />

var firstSlideIteration = true;
$(document).ready(function() {
    //centerSlideshowImages();
    $(".SlideShow:first ").cycle(
                {
                    fx: 'scrollLeft',
                    before: onBefore,
                    after: onAfter,
                    timeout: 10000,
                    sync: 0,
                    delay: -1000

                }
             );

    $(".SlideShow:first").hover(
                function() {
                    $(this).cycle('pause');
                },
                function() {
                    $(this).cycle('resume');
                });

});
//     function onBefore(curr,next,opts){ 
//                while (stack.length > 0){ 
//                if (opts.addSlide) opts.addSlide(stack.pop()); 
//          };

function onBefore(curr, next, opts) {
    if (firstSlideIteration) {
        firstSlideIteration = false;
        
        return;
    }

    var temp = $('div:first', curr);
    
    $('.SlideShowContentTrayContainer:first', curr).animate({
        top: "100%"
    }, 500);

    $('.SlideShowContentTrayContainer:first', next).animate({
        top: "100%"
    }, 0);

}
function onAfter(curr, next, opts) {
    var temp = $('.SlideShowContentTrayContainer:first', next);
    
    $('div:first', next).animate({
        top: "70%"
    }, 1000);

}
function centerSlideshowImages() {
    $('.SlideShowImage').each(
            function(intIndex) {
                var height = $(this).height();
                var width = $(this).width();
                $(this).css({ 'margin-top': (height / 2) * -1,
                    'margin-left': (width / 2) * -1
                });
            });
}
    