// JavaScript Document
window.addEvent('domready', function() {
	
	var buton = $('slide_button');
	var slider = $('slider');
	var sliderp = slider.getPosition();
	var sliders= slider.getSize();
    var butons = buton.getSize();
	buton.style.left='-5px';
	
	$$('div.item').each(function(item,index) {
								 item.id='item_'+index;
								   });
	var itms=$('item_0').getSize();
	var total = itms.x*$$('div.item').length;
	$('ads_place').style.width=total+'px';
	var total2 = total - itms.x;
	slider.addEvent(
				   'mousedown' , function() {
					  	
										 slider.addEvent('mousemove', function(event) {
										var x = -(sliderp.x-event.client.x+30);
										$('body').onselectstart =  function() { return false;}
										$('body').ondragstart =  function() { return false;}
										
										
										if (x>=sliders.x-butons.x+5) {} 
										else if(x<=-5) {}
										else  { 
										var xproc = 100 - (((sliders.x-butons.x)-x)/(sliders.x-butons.x))*100;
										xproc = xproc.round();
										$('ads_place').style.left=-(xproc*total2)/100+'px';
										buton.style.left=x+'px'; }
										 })	;
										
										 });
				slider.addEvent('mouseup', function () {
						slider.removeEvents('mousemove');
						$('body').onselectstart =  function() { return true;}
						$('body').ondragstart =  function() { return true;}
										
						});
				   
	
});