function extend(Child, Parent) {
    var F = function() { };
    F.prototype = Parent.prototype;
    Child.prototype = new F();
    Child.prototype.constructor = Child;
    Child.superclass = Parent.prototype;
}
function Slider() {
	this.items=[];
	this.items_count=0;
	this.cur_index=0;
	this.display_count=3;
};
Slider.prototype.AddItem = function(id,url,name,img) {
	this.items[this.items_count++] = {id:id,url:url,name:name,img:img}; 
};
Slider.prototype.MoveLeft = function() {
	//console.log('MoveLeft');
	if (this.cur_index ==0) {
		this.cur_index=this.items_count-1;
	} else {
		this.cur_index--;
	}
	this.Paint();
};
Slider.prototype.MoveRight = function() {
	//console.log('MoveRight');
	this.cur_index++;
	if (this.cur_index >= this.items_count) {
		this.cur_index=0;
	}
	this.Paint();
};
Slider.prototype.Paint = function() {
	//console.log('Slider.prototype.Paint');
};

function NOSlider () {
	NOSlider.superclass.constructor.call(this);
}
extend(NOSlider, Slider)
NOSlider.prototype.Paint = function() {
	//console.log('NOSlider.prototype.Paint');
	var index = this.cur_index;
	var total = this.items_count;
	var items = this.items;
	$('.links a').each(function(){
		//console.log(index);
		//console.log(this);
		if (items[index].img) {
			$(this).find('span').attr('style','background: url('+items[index].img+') no-repeat');
		} else {
			//Place for NOPHOTO
		}
		    $(this).attr('href','/remont/i/'+items[index].url+'.html');
		    $(this).find('div').text('Ремонт '+items[index].name);
		    
		index++;
		if (index >=total) {
			index=0;
		}
	});
};
NOSlider.prototype.AddItem = function(id,url,name,img) {
	this.items[this.items_count++] = {id:id,url:url,name:name,img:img}; 
	//console.log(this.items_count);
	//console.log(this.items);
};
