window.addEvent('domready', function() {

	var el = $('slider-wrapper');
	var wrapEl = $('image-wrapper');
	var fx = el.effects({duration: 1000, transition: Fx.Transitions.Quart.easeInOut});
	var elements = 0;
	
	$$('#slider-wrapper li').each(function(img) {
		elements++; 
	});
	var totalWidth = elements*705;
	el.setStyle('width', totalWidth+'px');
	
	$('right').setStyle('display', 'none');

	$('left').addEvent('click', function(e) {
		$('right').setStyle('display', 'block');
		//alert($('image-wrapper').getPosition().x)
		var current = $('current').firstChild.nodeValue;
		//alert(current);
		var absLeft = Math.abs(el.getLeft());
		if(current<elements) {
			$('current').firstChild.nodeValue=++current;
			if(fx.timer) ;
			fx.stop();
			fx.start({
			'left': -(current-1)*705//el.getLeft()-675-wrapEl.getLeft()
			});
		}
		if(current>=elements) {
			$('left').setStyle('display', 'none');
		}
		new Event(e).stop();
		
		//$('current').firstChild.nodeValue=el.getLeft()-wrapEl.getLeft()-675;
	});

	$('right').addEvent('click', function(e) {
		$('left').setStyle('display', 'block');
		var current = $('current').firstChild.nodeValue;
		if(current>0) {
			$('current').firstChild.nodeValue=(--current);
			fx.start({
				'left': -(current-1)*705 //el.getLeft()+675-wrapEl.getLeft()
			});
		}
		if(current==1) $('right').setStyle('display', 'none');
		new Event(e).stop();
		//$('current').firstChild.nodeValue=el.getLeft()-wrapEl.getLeft()-675;
	});
});

function e() 
{
	var el = $('slider-wrapper');
	var fx = el.effects({duration: 1000, transition: Fx.Transitions.Quart.easeInOut});
	var current = $('current').firstChild.nodeValue;
	var elements=0;
	$$('#slider-wrapper li').each(function(img) {
		elements++; 
	});
		var absLeft = Math.abs(el.getLeft());
		$('right').setStyle('display', 'block');$('l').setStyle('display', 'block');
		if(current<elements) {
			$('current').firstChild.nodeValue=++current;
			if(fx.timer) ;
			fx.stop();
			fx.start({
			'left': -(current-1)*705
			});
		}
		if(current>=elements) {
			$('left').setStyle('display', 'none');
			$('r').setStyle('display', 'none');
		}
}

	function f() {
	var el = $('slider-wrapper');
	var fx = el.effects({duration: 1000, transition: Fx.Transitions.Quart.easeInOut});
		var current = $('current').firstChild.nodeValue;
		$('left').setStyle('display', 'block');
		if(current>1) {
			$('current').firstChild.nodeValue=(--current);
			fx.start({
				'left': -(current-1)*705
			});
		}
		if(current==1) {$('right').setStyle('display', 'none');
		$('l').setStyle('display', 'none');
		}
		$('r').setStyle('display', 'block');
	}
	function ou(o)
	{
	o.firstChild.style.visibility = "hidden";

	}
	function ov(o)
	{
	//var current = $('current').firstChild.nodeValue;
	o.firstChild.style.visibility = "visible";

	}