Event.observe(window, 'load', function(){
	if ($('consultAnnonce')){
		$('consultAnnonce').select('tr.menu').each(function(tr){
			Event.observe(tr, 'mouseover', function(event){
				Event.element(event).up().addClassName('over');
				
			});
			
			Event.observe(tr, 'mouseout', function(event){
				Event.element(event).up().removeClassName('over');
			});
			
			Event.observe(tr, 'click', function(event){
				
				var formulaire = document.createElement("form");
				formulaire.setAttribute("method", "POST");
				formulaire.setAttribute("name", "frmAnnonceConsult");
				formulaire.setAttribute("id", "frmAnnonceConsult");
				
				var page = document.createElement("input");
				page.setAttribute("type", "hidden");
				page.setAttribute("id", "page");
				page.setAttribute("name", "page");
				page.setAttribute("value", "CarrieresAnnoncesDetails");

				var action = document.createElement("input");
				action.setAttribute("type", "hidden");
				action.setAttribute("id", "action");
				action.setAttribute("name", "action");
				action.setAttribute("value", "onClickButton");
				
				var idAnnonce = document.createElement("input");
				idAnnonce.setAttribute("type", "hidden");
				idAnnonce.setAttribute("id", "idAnnonce");
				idAnnonce.setAttribute("name", "idAnnonce");
				idAnnonce.setAttribute("value", Event.element(event).previous('td.hidden').getAttribute('name')); 
				
				//alert (arrayBckAnnuaireConsultation.getAttribute("value") );
				formulaire.appendChild(page);
				formulaire.appendChild(action);
				formulaire.appendChild(idAnnonce);
				//formulaire.appendChild(arrayBckAnnuaireConsultation);
				document.body.appendChild(formulaire);
				formulaire.submit();
				
			});
			
		});
	}
	
	if($('numeroPage')){
		 $('numeroPage').select('[attr="otherPage"]').each(function(td){
			Event.observe(td, 'click', function(event){
			
				//alert(Event.element(event).getAttribute('value'));
				var formChangePage = document.createElement("form");
				formChangePage.setAttribute("method", "POST");
				formChangePage.setAttribute("name", "formChangePage");
				formChangePage.setAttribute("id", "formChangePage");
				
				var page = document.createElement("input");
				page.setAttribute("type", "hidden");
				page.setAttribute("id", "page");
				page.setAttribute("name", "page");
				page.setAttribute("value", "CarrieresAnnonces");

				var action = document.createElement("input");
				action.setAttribute("type", "hidden");
				action.setAttribute("id", "action");
				action.setAttribute("name", "action");
				action.setAttribute("value", "onClickOtherPageAnnonces");
				
				var numeroPage = document.createElement("input");
				numeroPage.setAttribute("type", "hidden");
				numeroPage.setAttribute("id", "numeroPage");
				numeroPage.setAttribute("name", "numeroPage");
				numeroPage.setAttribute("value", Event.element(event).getAttribute('value')); 
				
				//alert (arrayBckAnnuaireConsultation.getAttribute("value") );
				formChangePage.appendChild(page);
				formChangePage.appendChild(action);
				formChangePage.appendChild(numeroPage);
				document.body.appendChild(formChangePage);
				formChangePage.submit();
		  });
	   });
	};
});
