var slideshow;
var slideshow_options = {
        img : "http://aldf.rdsecure.org/img/rotate-",
        id:"slideshow",
        random:false,
        speed:10000,
		fadeSpeed:1000
};
$(function() {
    slideshow = donation_rotate(slideshow_options);
    slideshow.startRotate();
	$('#right-arrow').click(function(){
		slideshow.stopRotate();
		slideshow.rotateNext();
	});
	$('#left-arrow').click(function(){
		slideshow.stopRotate();
		slideshow.rotatePrev();
	});
});

var donation_rotate = function(options){
	var rotateTimer;
	var that = {};
	var rotateSize;
	var rotateStart = 1;
	var rotateId = rotateStart;
	var speed = options['speed'] || 8000;
	var fadeSpeed = options['fadeSpeed'] || 2000;
	var container_id =  "#" + (options['id'] || "rotate-container");
	var img = options['img'];

	var constructor = function(){
		rotateSize = $(".rotate").length;
   };
   that.startRotate = function(){
        $(".rotate").hide();
        $("#rotate-"+rotateStart).show();
        rotateTimer = setInterval(function(){
            that.rotateNext();
             },speed);
    };
    that.stopRotate = function(){
        clearInterval(rotateTimer);
    }
    that.rotateNext = function(){
        if (rotateId < rotateSize) {
    	    rotateId++;
       	} else {
        	rotateId=1;
       	}
        $("#rotate-"+rotateId).fadeIn(fadeSpeed).siblings().fadeOut(fadeSpeed);
	 };
     that.rotatePrev = function(){
        if (rotateId > 1) {
    	    rotateId--;
       	} else {
        	rotateId=rotateSize;
       	}
        $("#rotate-"+rotateId).fadeIn(fadeSpeed).siblings().fadeOut(fadeSpeed);
	 };
   
    constructor();
    return that;
};

