var rotator = function(){};
	
rotator.prototype = {
	
	url: "/banner/rotate",
	selector: ".side-banner",
	type: "sidebanner",
	
	current: 0,
	
	rotate: function(){
		
		var this1 = this;
		
		$.ajax(this1.url, {
			data: "lastbanner=" + this.current,
			dataType: 'json',
			type: 'post',
			success: function(object){
				
				//set the current
				this1.current = object.id;
				
				var newimage = $("<a titel=\""+object.title+"\" href=\"" + object.url + "\"><img alt=\""+object.old+"\" src=\"" + object.src + "\"/></a>");
				
				newimage.hide();
				$(this1.selector).append(newimage);
				newimage.fadeIn(1000, function(){
					//remove first child
					
					$(this1.selector + ' > div:first, ' + this1.selector + ' > a:first').remove();
					setTimeout(function(){this1.rotate();}, 30000)
				});
			}
		});
	}
};


$(function(){
	if(typeof rotator !== "undefined" && !$.isFunction(rotator)){
		setTimeout(function(){rotator.rotate();}, 30000);
	}
	
	if(typeof rotator2 !== "undefined" && !$.isFunction(rotator2)){
		setTimeout(function(){
			rotator2.rotate();
		}, 30000);
	}
	
	if( typeof rotator3 !== "undefined" && !$.isFunction(rotator3)){
		setTimeout(function(){rotator3.rotate();}, 30000);
	}
});
