// JavaScript Document
function slideSwitch() {
    var jQueryactive = jQuery('#slideshowMain DIV.active');

    if ( jQueryactive.length == 0 ) jQueryactive = jQuery('#slideshowMain DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var jQuerynext =  jQueryactive.next().length ? jQueryactive.next()
        : jQuery('#slideshowMain DIV:first');

   
    jQueryactive.addClass('last-active');

    jQuerynext.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            jQueryactive.removeClass('active last-active');
        });
}

jQuery(function() {
    setInterval( "slideSwitch()", 5000 );
});

jQuery(function() {

	// ***
	// Scrolling background Thanks to youlove.us!!
	// ***
 
	// height of background image in pixels
	var backgroundheight = 2000;
 	var offset = 20;
 
	function scrollbackground() {
		// decrease the offset by 1, or if its less than 1 increase it by
		// the background height minus 1
   		offset = (offset < 1) ? offset + (backgroundheight - 1) : offset - 1;
		// apply the background position
   		jQuery('#outerWrapper').css("background-position", "100% " + offset + "px");
   		// call self to continue animation
   		setTimeout(function() {
			scrollbackground();
			}, 100
		);
   	}
 
	// Start the animation
	scrollbackground();
});

// Preload images function
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
