function Slider(box, url) {
	
	var sliders = new Array();
	var count = -1;
	var current = -1;
	var box = box;
	var url = url;
	var offset = 0;
	
	function next() {
		$('#' + box).fadeOut("slow");
		if ( current == count ) {
			// $('#' + box).html('<img src="/static/images/ajax-loader.gif" border="0" />');
			// just add some offset
			number = current + 2;
			$.get(
					url, { "number": number },
					function (content) {
						if ( content == '' ) {
							// alert(number);
							current = -1;
						} else {
							count++;
							sliders[count] = content;							
						}
						show_next();							
					}
			);		
		} else {
			show_next();		
		}		
	}	
	
	function show_next() {
		if ( current < count ) {
			current++;
			setTimeout( function() { /*$('#' + box).html( '' );*/ $('#' + box).html( sliders[current] ); $('#' + box).fadeIn("slow"); }, 400);
		}
		if ( current > 0 ) {
			$('#' + box + '_previous').html('<img src="/static/images/ico-back.gif" border="0" />');
		}	
	}

	function previous() {
		if ( current > 0 ) {
			current--;
			$('#' + box).fadeOut("slow");
			setTimeout( function() { /*$('#' + box).html( '' );*/ $('#' + box).html( sliders[current] ); $('#' + box).fadeIn("slow"); }, 400);
		}
		if ( current == 0 ) {
			$('#' + box + '_previous').html('<img src="/static/images/ico-back_disabled.gif" border="0" />');			
		}
	}
	
	this.next = next;
	this.show_next = show_next;
	this.previous = previous;
	
	this.next();
}

$(document).ready(function() {
	slider = new Slider('testimonials_box', '/index.cgi?f=get_testimonial');
	setInterval(function() { slider.next(); }, 60000);
	
	slider2 = new Slider('didyouknow_box', '/index.cgi?f=get_diduknow');
	setInterval(function() { slider2.next(); }, 60000);
});

/*
Slider.prototype.next = function() {
	if ( this.current == this.count ) {
		$('#testimonials_box').html('<img src="/static/images/ajax-loader.gif" border="0" />');
		$.get(
				'/index.cgi?f=get_testimonial', {},
				this.get_content
		);		
	} else {
		this.show_next();		
	}	
}

Slider.prototype.get_content = function(content) {
	this.count++;
	this.sliders[this.count] = content;
	this.show_next();	
} */

/*
(function($) {
$.fn.slider = function(options) {
	
	if (typeof($.fn.slider.defaults) == 'undefined') {
		$.fn.slider.defaults = {
			sliders: new Array(),
			count: -1,
			current: -1,
			box: ''
		};	
		$.fn.slider.next();
	}
	
	if (options) $.extend($.fn.slider.defaults, options);
	
	return $.fn.slider;
}
$.fn.slider.next = function() {

}

$.fn.slider.show_next = function() {
	if ( $.fn.slider.defaults.current < $.fn.slider.defaults.count ) {
		$.fn.slider.defaults.current++;
		$('#testimonials_box').html( $.fn.slider.defaults.sliders[$.fn.slider.defaults.current] );		
	}	
}

$.fn.slider.previous = function() {
	if ( $.fn.slider.defaults.current > 0 ) {
		$.fn.slider.defaults.current--;
		$('#testimonials_box').html( $.fn.slider.defaults.sliders[$.fn.slider.defaults.current] );
	}
}

})(jQuery);
*/

