function slider (ul,lArrow,rArrow) {
		this.divBlock = ul;
		this.leftScroll = lArrow;
		this.rightScroll = rArrow;
		this.itemOnSlider = 4;
		this.itemToScroll = 1;
		this.speed = 200;
		this.navigation = "round";
		
		this.widthToScroll = 0;
		this.liCount = 0;
		this.currentPosition = 0;
		this.maxPosition = 0;
		this.difference = 0;
		
		var $this = this;
		
		$this.init = function() {
		
			
			
			$this.getLiCount(); // количество элементов li 
			
			$this.maxPosition = $this.liCount - $this.itemOnSlider; // максимальная возможная позиция для прокрутки
			
			if ($this.maxPosition < 0) $this.maxPosition = 0;
			
			jQuery($this.leftScroll).click(function() {
				$this.leftStep();
			});
		
			jQuery($this.rightScroll).click(function() {
				$this.rightStep();
			});
			
			jQuery($this.leftScroll).addClass("enabled");
			jQuery($this.rightScroll).addClass("enabled");
			
			//ajaxPage.bindClickToLi(this.divBlock); // использовать при необходимости добавить к слайдеру дополнительный функционал (например ajax загузку страниц) 
			
			$this.hideShowArrows();
			
		}
		
		$this.hideShowArrows = function() {

			if ($this.liCount <= $this.itemOnSlider) {
				jQuery($this.leftScroll + "," + $this.rightScroll).css("display","none");
			}
		}
		
		$this.calculateWidthToScroll = function(count) {
			$this.widthToScroll = count * jQuery($this.divBlock + " ul li").outerWidth(true);
			
		}
		
		$this.getLiCount = function() {
			$this.liCount = jQuery($this.divBlock + " ul li").length;
		}
		
		
		$this.scroll = function(direction) {
		
			switch(direction) {
			
				case "left":
					
					if ( $this.currentPosition < 0 ) {
						
						if ($this.navigation == "round") {
						
							$this.difference = $this.currentPosition;
				
							jQuery($this.divBlock + " ul li").slice($this.liCount - Math.abs($this.difference)).clone().prependTo(jQuery($this.divBlock + " ul"));
						
							jQuery($this.divBlock).scrollLeft( (0-$this.difference) * jQuery($this.divBlock + " ul li").outerWidth(true));
						}
					
						$this.currentPosition = 0;
					}
				
				break;
				
				case "right":
			
				   if ($this.currentPosition > $this.maxPosition) {
				   
						if ( $this.navigation == "round" ) {
							$this.difference = $this.currentPosition - $this.maxPosition;
						
							jQuery($this.divBlock + " ul li").slice(0,$this.difference).clone().appendTo(jQuery($this.divBlock + " ul"));
						} else {
							$this.currentPosition = $this.maxPosition
						}
				   } 
					
				break; 
				
				default:
				break;
			}

			$this.animate();
			
			
		}
		
		$this.animate = function () {
		
			$this.calculateWidthToScroll($this.currentPosition);
			
			jQuery($this.divBlock).animate({
				scrollLeft: $this.widthToScroll
			}, $this.speed,function() {
			
				if ($this.difference > 0) {
					jQuery($this.divBlock + " ul li").slice(0,$this.difference).remove();
					$this.currentPosition = $this.currentPosition - $this.difference;
					jQuery($this.divBlock).scrollLeft($this.currentPosition * jQuery($this.divBlock + " ul li").outerWidth(true));
					$this.difference = 0;
					
				}
				
				if ($this.difference < 0) {
					$this.getLiCount();
					jQuery($this.divBlock + " ul li").slice($this.liCount - Math.abs($this.difference)).remove();
					$this.getLiCount();
					$this.difference = 0;
				}
				
				//ajaxPage.bindClickToLi(this.divBlock);  
				jQuery($this.leftScroll + "," + $this.rightScroll).addClass("enabled");
				
				
			}); 
		}
		
		
		$this.leftStep = function() {
			if ( jQuery($this.leftScroll).hasClass("enabled") ) {
				jQuery($this.leftScroll).removeClass("enabled");
				$this.currentPosition = $this.currentPosition - $this.itemToScroll;
				$this.scroll("left");
			}

		}
		
		this.rightStep = function() {
			if ( jQuery($this.rightScroll).hasClass("enabled") ) {
				jQuery($this.rightScroll).removeClass("enabled");
				$this.currentPosition = $this.currentPosition + $this.itemToScroll;
				$this.scroll("right");
			}
		}
}


