function bannerFade(){
	
	if ($('.last_image').is(':visible')){
		$(".current_image").delay(2000).fadeOut(400, function() {
			$(".first_image").addClass("current_image");
			$(this).removeClass("current_image");
			$(".first_image").fadeIn(300, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				bannerFade();
			});
		});
	} else {
		$(".current_image").delay(2000).fadeOut(400, function() {
			$(this).next().addClass("current_image");
			$(this).removeClass("current_image").next().fadeIn(300, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				bannerFade();
			});
		});
	};
};

$(document).ready(function(){
	
	$("#stampede_banner a img, #western_banner a img").first().addClass("current_image first_image");
	$("#stampede_banner a img, #western_banner a img").last().addClass("last_image");
	
	bannerFade();
	
});

(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)

jQuery.preLoadImages('images/sce/stampede_banner1.jpg','images/sce/stampede_banner2.jpg','images/sce/stampede_banner3.jpg','images/sce/western_banner1.jpg','images/sce/western_banner2.jpg','images/sce/western_banner3.jpg');


/**************************************************************************

					HEADER BANNER Slider

***************************************************************************/

function bannerFade2(){
	
	if ($('.last_image').is(':visible')){
		$(".current_image").delay(3000).fadeOut(400, function() {
			$(".first_image").addClass("current_image");
			$(this).removeClass("current_image");
			$(".first_image").fadeIn(300, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				bannerFade2();
			});
		});
	} else {
		$(".current_image").delay(3000).fadeOut(400, function() {
			$(this).next().addClass("current_image");
			$(this).removeClass("current_image").next().fadeIn(300, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				bannerFade2();
			});
		});
	};
};

$(document).ready(function(){
	
	$("#header_banner a").first().addClass("current_image first_image");
	$("#header_banner a").last().addClass("last_image");
	
	bannerFade2();
	
});

(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)

jQuery.preLoadImages('images/sce/header_banner1.jpg','images/sce/header_banner2.jpg','images/sce/header_banner3.jpg','images/sce/header_banner4.jpg');

/**************************************************************************

					     NEW TEMPLATE Slider

***************************************************************************/
function slideshow(){
	
	if ($(".last_slide").is(":visible")){
		$(".current_slide").delay(3000).fadeOut(500, function() {
			$(".first_slide").addClass("current_slide");
			$(this).removeClass("current_slide");
			$(".first_slide").fadeIn(500, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				slideshow();
			});
		});
	} else {
		$(".current_slide").delay(3000).fadeOut(500, function() {
			$(this).next().addClass("current_slide");
			$(this).removeClass("current_slide").next().fadeIn(500, function() {
				//Fixes IE's clear-type issue on animated fonts
				if(jQuery.browser.msie) this.style.removeAttribute('filter');
				slideshow();
			});
		});
	};
};

$(document).ready(function(){
	
	$(".banner_slides").first().addClass("current_slide first_slide");
	$(".banner_slides").last().addClass("last_slide");
	
	slideshow();
	
	/***Buttons beside home page slider***/
	$("#slider_buttons a").hover(

        function () {
            $(this).children("img").animate({
                top: '-=120px',
                left: '-=0px',
                marginLeft: '-=0px',
                marginRight: '-=0px',
                paddingLeft: '-=0px',
                paddingRight: '-=0px'
            }, 150, function() {
                // Animation complete.
            });
        }, 
        function () {
            $(this).children("img").animate({
                top: '+=120px',
                left: '+=0px',
                marginLeft: '+=0px',
                marginRight: '+=0px',
                paddingLeft: '+=0px',
                paddingRight: '+=0px'
            }, 150, function() {
                // Animation complete.
            });
        }

	);        
	
});

(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)

jQuery.preLoadImages('images/new/home_slider1.jpg','images/new/home_slider2.jpg','images/new/home_slider3.jpg');
