
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_1_page2
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_1_page2 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_1_page2 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
/*	aniMate Stack jQuery Code 3.0.0  */
/* ***********************************************************************************
	Copyright (c) 2011, Mauricio Sabene. All rights reserved.
/* ***********************************************************************************
*/

(function($) {
  $.fn.aniMate = function(start_delay, loops) {
    var cum_delay = start_delay, $$this = this, callback;
    loops = loops ? loops : 1;
    this.each(function() {
      var $this = $(this),
          topS = $this.data('aniMate_topStart'),
          leftS = $this.data('aniMate_leftStart'),
          fadeIn = $this.data('aniMate_transition'),
          topE = $this.data('aniMate_topEnd'),
          leftE = $this.data('aniMate_leftEnd'),
          opac = $this.data('aniMate_opacity') / 100,
          holdIn = $this.data('aniMate_holdIn'),
          holdOut = $this.data('aniMate_holdOut'),
          animation = $this.data('aniMate_animation');
      $this.css({top: topS + 'px', left: leftS + 'px'});
	  $this.fadeTo(0,0);
      $this.delay(cum_delay);
	  $this.fadeTo(fadeIn,1);
      $this.delay(holdIn);
      $this.animate({top: topE + 'px', left: leftE + 'px', opacity: opac}, animation).delay(holdOut);
      cum_delay = cum_delay + fadeIn + holdIn + animation + holdOut;
    });
    callback = function(loops) {
      setTimeout(function() {
        $$this.aniMate(0);
        if (loops > 1) callback(loops - 1);
      }, cum_delay);
    }
    if (loops >= 2) callback(loops - 1);
    return this;
  };
$(window).load(function() {
    var rwId = 'stacks_in_1_page2',
        rwDelay = 0,
        rwLoops = 1,
        allLayers = $('.aniMate_slide', document.getElementById('ms_aniMate' + rwId)),
        animate_comp = $('#ms_aniMate' + rwId),
        aniMateouter = $('#aniMateouter' + rwId);
    allLayers.hide(0);
    aniMateouter.css('background-image', 'none');
    animate_comp.css('visibility', 'visible');
    allLayers.aniMate(rwDelay * 1000, rwLoops);
    aniMateouter.children('.toggleaniMate').click(function() {
      animate_comp.toggle('slow');
      return false;
    });
    aniMateouter.children('.reloadaniMate').click(function() {
      if (!allLayers.parent().children().is(':animated')) {
        animate_comp.show('slow');
        setTimeout(function() {
          allLayers.aniMate(1000);
        }, 500);
      }
      return false;
    });
  });
})(jQuery);
	return stack;
})(stacks.stacks_in_1_page2);



