﻿/*
	File:    jQuery_RotatingContent.js
	Version: 1.0
	Date:    18 May 2009
	Author:  Adrian Graham
	         RA Creative - www.raonline.co.uk
	--------------------------------------------------------------
	Fades through all <div> areas inside the designated container.
	Building upon Karl Swedberg's fading banner script, adding
	the ability to jump to a specific banner by calling
	feature_jump and passing it the relevant div id.
	--------------------------------------------------------------
*/
var RAimage_count;
var RAcurrent_image=0;
var new_image = 0;
var old_image = 0;

$(document).ready(function(){
  RAimage_count = $("#rotatingarea div").hide().size();
  $("#rotatingarea div:eq("+RAcurrent_image+")").show();
  rotateID = setInterval(feature_rotate,8000);
});
function feature_rotate() {
  old_image = RAcurrent_image%RAimage_count;
  new_image = ++RAcurrent_image%RAimage_count;
  $("#rotatingarea div:eq(" + new_image + ")").fadeIn("slow", function() {
    $("#rotatingarea div:eq(" + old_image + ")").fadeOut("slow");
  });
}
function feature_jump(jumpid) {
		clearInterval(rotateID);
		RAcurrent_image = jumpid;
		$("#rotatingarea div:eq(" + jumpid + ")").fadeIn("fast", function () {
			$("#rotatingarea > div:not(div:eq(" + jumpid + "))").fadeOut("fast");
		});
		rotateID = setInterval(feature_rotate,8000);
}