
$(document).ready(function() {


    function resetHomeAnimation() {
      $('.layer-bot').fadeOut(1000, function() {
          $('.layer-mid').fadeOut(1000, function() {
              $('.layer-top').fadeOut(1000, function() {
              
                // reset all the positions
                $("div.layer-mid").css('left', '160px');
                $("div.layer-top").css('left', '130px');                
                animateHome();
              });
          });
      });        
    }
    
    function animateHome() {
      // Home page animation code
      $('.layer-bot').fadeIn(2000, function() {
          $('.layer-mid').fadeIn(2000, function() {
              $('.layer-top').fadeIn(2000, function() {
              
                  // all images have been faded in, now move them.
                  $("div.layer-top").animate({
              			left: '2px',
              			opacity: 1
              		}, 660, function () {
              		
              		  $("div.layer-mid").animate({
                			left: '120px',
                			opacity: 1
                		}, 660, function() {
                		    setTimeout(resetHomeAnimation, 30000);

                		});   
              		});
              });
          });
      });    
      
    }
  
    
    // Home page headline story rotation
    
    $('#newsStories').css('visibility', 'visible');
    $('#newsStories').css('background', 'transparent');

    $('#newsStories').cycle({
  		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
  		timeout:       10000,  // milliseconds between slide transitions (0 to disable auto advance) 
  		random: true,
  		cleartype:  true,
    cleartypeNoBg:  true,
  		startingSlide: Math.floor(Math.random()*4) // the multiplier is the number of logos
    });
    
    // Home page partner logo rotation
    $('#partner_logos_home img').css('visibility', 'visible');
    $('#partner_logos_home').cycle({
  		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
  		timeout:       3000,  // milliseconds between slide transitions (0 to disable auto advance) 
  		random: true,
  		startingSlide: Math.floor(Math.random()*15) // the multiplier is the number of logos
    });
    
    // fancy lightbox image viewer
    $("a.screenshot").fancybox({
  		'transitionIn'	:	'elastic',
  		'transitionOut'	:	'elastic',
  		'speedIn'		:	600, 
  		'speedOut'		:	200, 
  		'overlayShow'	:	true,
  		'hideOnContentClick': true
  	});
  	
  	// run the animation
  	animateHome();
  	
      
	
});






















