NavScroll = Class.create({

	initialize: function (item) {
		
		this.item = item;
		this.id = 0;
		this.oldId = 0;
		this.previous = $$('#' + item + ' .popMenuGauche a')[0];
		this.next = $$('#' + item + ' .popMenuDroite a')[0];
		this.previous2 = $$('#' + item + ' .flecheLeft')[0];
		this.next2 = $$('#' + item + ' .flecheRight')[0];
		this.page = $$('#' + item + ' .pagination')[0];
		this.contents = $$('#' + item + ' .MenuItems');
		this.nbPages = this.page.getElementsByTagName('img').length;
		
		Event.observe(this.previous,'click',this.leftRight.bind(this,-1));
		Event.observe(this.next,'click',this.leftRight.bind(this,1));
		Event.observe(this.previous2,'click',this.leftRight.bind(this,-1));
		Event.observe(this.next2,'click',this.leftRight.bind(this,1));
			
		this.changePage(0);
		
	 },
	 
	 leftRight: function (n) {		  
		 this.id += n;		 
		 this.changePage(this.id); 
	 },
	 
	 changePage: function (id) {
		 if (this.oldId!=-1) {
			 this.contents[this.oldId].style.display = 'none';
		 }
		 this.id = id;
		 this.oldId = id;
		 this.set();
	 },
	 
	 set: function () {
		  
		 this.previous.style.display = this.previous2.style.display = (this.id == 0) ?'none' :'block';
		 this.next.style.display = this.next2.style.display = (this.id == this.nbPages-1) ?'none' :'block';
		 
		 var str = '';
		 for (var i=0;i<this.nbPages;i++) {
			 var state = (this.id==i) ?'on' :'off';
			 str += '<a href="#" class="'+state+'"><img src="static/images/menu/pagination_'+state+'.gif" alt=""/></a>&nbsp;';
		 }		 
		 this.page.innerHTML = str;
		 
		 var nodes = this.page.getElementsByTagName('a');
		 for (var i=0;i<nodes.length;i++) {
			 if (nodes[i].className!='on') {
			 	Event.observe(nodes[i],'click',this.changePage.bind(this,i));
			 }
		 }
		 
		 this.contents[this.id].style.display = 'block'; 
		 
	 }
	 
});


var scrollNodes;
Event.observe(window, 'load', function (){
	
	if ($('scContent')) {
		scrollNodes = $$('#scContent td');
	}
	
	if ($('menuTopLayers')) {
		var myNavScroll = new NavScroll('menuTopLayers');
	}
	
});