
jQuery.fn.rotate = function(elements,interval,timeout) {
	var rotation = this;
	elements = elements.split(',');
	for(i=0;i<elements.length;i++){
		this.append('<img src="' + elements[i] + '" alt="" />');
	}
	this.children('img:not(:first)').hide(0);
	$(window).load(function()
	{
		var current = rotation.children('img:first');
		function changeImage() {
			if (globalBooleanRotate == true) {
				current.fadeOut(1000);
				current.removeClass('active');
				if (current.next().length!=0) {
					current.next().fadeIn(1000);
					current.next().addClass('active');
					current = current.next();
				} else {
					rotation.children('img:first').fadeIn(1000);
					rotation.children('img:first').addClass('active');
					current = rotation.children('img:first');
				}
			}
		}
		function initInterval() {
			setInterval(changeImage,interval);
		}
		if (timeout!='') setTimeout(initInterval,timeout);
		else initInterval();
	});
}
