// JavaScript For Home Page of Dreamworkers Productions Website
$(function() {

    var stack = [];

    // preload images into an array
    for (var i=3; i<17; i++) {
        var img = new Image(760,300);
        img.src = 'graphics/banner_image_' + i + '.jpg';
        if (img.complete)
            stack.push(img);
        else 
            $(img).bind('load', function() {
                stack.push(this);
            });
    } 

    // add images to slideshow
    function onBefore(curr, next, opts) {
        if (opts.addSlide) // important!
            while(stack.length)
                opts.addSlide(stack.pop()); 
    };
	
	$('#pause').click(function() { $('#banner').cycle('pause'); return false; });
    $('#play').click(function() { $('#banner').cycle('resume'); return false; });
    
    $('#slideshow').hover(
        function() { $('#controls').fadeIn(); },
        function() { $('#controls').fadeOut(); }
    );
    
    $('#banner').cycle({
        fx:     'fade',
        speed:   3000,
        timeout: 8000,
        next:   '#next',
        prev:   '#prev',
        before:   onBefore
    });
	
	$('#ServicesMarquee').cycle({
    fx:'scrollRight',
    delay:-1000
	});
});
