$(document).ready(function() {

   navTwitter = $('#nav-twitter').html();

   
   $("#twitter").children("ul").children('li').each(function() {
	   $(this).append(navTwitter);
	   $(this).hide();
   });

   firstLI = $("#twitter").children("ul").children('li:first');
   lastLI = $("#twitter").children("ul").children('li:last');

   firstLI.children(".left-twitter").css("border", "1px solid #79b6d1");
   firstLI.children(".left-twitter").css("color", "#79b6d1");
   
   lastLI.children(".right-twitter").css("border", "1px solid #79b6d1");
   lastLI.children(".right-twitter").css("color", "#79b6d1");
   
   $("#twitter").children("ul").children('li:first-child').show();
   $('#nav-twitter').hide();

   $('.right-twitter').click(function() {
	   eltLiShowed = $("#twitter").children("ul").children('li:visible');

	   nextElt = $(eltLiShowed).next("li");
	   if(nextElt.html() != null) {
		   	nextElt.show(300);
	   		$(eltLiShowed).hide();
	   }	
   });

   $('.left-twitter').click(function() {
	   eltLiShowed = $("#twitter").children("ul").children('li:visible');

	   prevElt = $(eltLiShowed).prev("li");
	   	   
	   if(prevElt.html() != null) {
		   	prevElt.show(300);
	 	   	$(eltLiShowed).hide();
	   }
   });  
   

});

// Pop up search
var showresult = function(nbResult) {
   if(eval(nbResult) == 0 || nbResult != '') {
       $('#popup-search').remove();

       var popup = "<div id='popup-search'>";
       popup += "<strong id='resultPopup'>"+nbResult+"</strong> annonce";
       if(nbResult > 0) popup += "s";
       popup += " !";
       popup += "<img onclick='javascript:closePopupSearch();' src='/images/design/recherche/close.png' alt='fermer la popup' id='img-close-popup'/>";
       popup += "</div>";
       popup = $(popup).hide();
       $('#completeSearch').append(popup);
       popup.fadeIn(150);
   }
}
var closePopupSearch = function() {
    $('#popup-search').remove();
}

