MySlider = function (slider, toLeft, toRight, handler, settings) 
{	
	settings = jQuery.extend({
		sliderCount : 5,
		speed : 500,
		animation : "swing"
	}, settings);
	
	var handler = handler ? $(handler) : null;
	var container = jQuery(slider);
	var slider = container.find("ul");		
	var countItems =  slider.find("li").size();
		
	var width = parseInt(slider.find("li")[0].clientWidth);	
	var height = parseInt(slider.find("li").css("height"));	
	
	container.css("width",  width*settings.sliderCount);	
	container.css("height", height);	
	slider.css("width", width*countItems);
	
	idx = Math.abs(parseInt(slider.css("left")) / width) + 1;

	init();

	function buttons() {
		$(toRight).hide();
		$(toLeft).hide();
		if (idx > 1) $(toLeft).show();				
		if (idx <= countItems-settings.sliderCount) $(toRight).show();
	}
	
	function setHandler()
	{		
		handler.find("li a").removeClass("act");	
		year = slider.find("li:eq("+(idx-1)+")").attr("class");	
		
		handler.find("li.y"+year+" a").addClass("act");	
	}
	
	function init()
	{
		if (handler) { setHandler(); }
		buttons();
		
		busy = false;
	}
	
	function scroll(width) {		
		if (busy) {
			return false;
		}
		busy = true;
		
		var left = parseInt(slider.css("left")) + parseInt(width);
	
		if (width > 0) {
			idx--;
		} else {
			idx++;
		}
			
		slider.animate({left: left + "px"}, settings.speed, settings.animation, init);	
	}
	
	function setPosition(i) {	
		if (busy) {
			return false;
		}
		busy = true;
				
		var left = parseInt(-i*width);
		idx = i+1;	
		slider.animate({left: left + "px"}, settings.speed, settings.animation, init);	
				
	}

	$(toLeft).click(function() {			
		if (!busy) scroll(width);
		return false;
	})

	$(toRight).click(function() {		
		if (!busy) scroll(-width);
		return false;
	})
	
	if (handler) {		
		handler.find("li a").click(function(){			
			y = $(this).parent().attr('class');
			y = y.substr(1);			
			var i = 0;
			slider.find("li").each(function(ps){			
				if ($(this).attr("class") > y){			
					i++;				
				} else {
					return;
				}
			})	
	
			setPosition(i);	
		})
	}
}

MyVerticalSliderPortfolio = function (slider, toLeft, toRight, settings) 
{	
	settings = jQuery.extend({
		sliderCount : 2,
		speed : 500,
		animation : "swing"
	}, settings);
	
	
	var container = jQuery(slider);
	var slider = container.find("ul");		
	var countItems =  slider.find("li").size();
		
	var width = parseInt(slider.find("li")[0].clientWidth);	
	var height = parseInt(slider.find("li")[0].clientHeight);	

	container.css("width",  width);	
	container.css("height", height*settings.sliderCount);	
	slider.css("height", height*countItems);
	
	idx = Math.abs(parseInt(slider.css("top")) / height) + 1;	
	init();

	function buttons() {
		
		//$(toRight).hide();
		//$(toLeft).hide();
		
		if (idx > 1) $(toLeft).show();
		if (idx <= countItems-settings.sliderCount) $(toRight).show();	
	}
	
	function init()
	{	
		buttons();
		
		busy = false;
	}
	
	function scroll(height) {		
		if (busy) {
			return false;
		}
		busy = true;
		
		var top = parseInt(slider.css("top")) + parseInt(height);
	
		if (height > 0) {
			idx--;
		} else {
			idx++;
		}
			
		slider.animate({top: top + "px"}, settings.speed, settings.animation, init);	
	}
	
	function setPosition(i) {	
		if (busy) {
			return false;
		}
		busy = true;
				
		var top = parseInt(-i*height);
		idx = i+1;	
		slider.animate({top: top + "px"}, settings.speed, settings.animation, init);	
				
	}

	$(toLeft).click(function() {			
		if (!busy) scroll(height);
		return false;
	})

	$(toRight).click(function() {		
		if (!busy) scroll(-height);
		return false;
	})
		
}

MyVerticalSlider = function (slider, toLeft, toRight, settings) 
{	
	settings = jQuery.extend({
		sliderCount : 4,
		speed : 500,
		animation : "swing"
	}, settings);
	
	
	var container = jQuery(slider);
	var slider = container.find("ul");		
	var countItems =  slider.find("li").size();
		
	var width = parseInt(slider.find("li")[0].clientWidth);	
	var height = parseInt(slider.find("li")[0].clientHeight);	

	container.css("width",  width);	
	container.css("height", height*settings.sliderCount);	
	slider.css("height", height*countItems);
	
	idx = Math.abs(parseInt(slider.css("top")) / height) + 1;	
	init();

	function buttons() {
		
		$(toRight).hide();
		$(toLeft).hide();
		
		if (idx > 1) $(toLeft).show();
		if (idx <= countItems-settings.sliderCount) $(toRight).show();	
	}
	
	function init()
	{	
		buttons();
		
		busy = false;
	}
	
	function scroll(height) {		
		if (busy) {
			return false;
		}
		busy = true;
		
		var top = parseInt(slider.css("top")) + parseInt(height);
	
		if (height > 0) {
			idx--;
		} else {
			idx++;
		}
			
		slider.animate({top: top + "px"}, settings.speed, settings.animation, init);	
	}
	
	function setPosition(i) {	
		if (busy) {
			return false;
		}
		busy = true;
				
		var top = parseInt(-i*height);
		idx = i+1;	
		slider.animate({top: top + "px"}, settings.speed, settings.animation, init);	
				
	}

	$(toLeft).click(function() {			
		if (!busy) scroll(height);
		return false;
	})

	$(toRight).click(function() {		
		if (!busy) scroll(-height);
		return false;
	})
		
}
