/* ================================================================================ */
/* = fonctions = */
/* ================================================================================ */

$(document).ready(function() {
	$('.rounded').prepend('<div class="tl"></div><div class="br"></div>');
	// Affichage block de navigation
	$(".content").hide();
	$(".rounded h1").each(function(){
		if ($(this).hasClass("moins")) {
			$(this).next().show();
		}else{
			$(this).addClass("plus");
		}
	});
	
	
	$(".rounded h1").click(
		function() {
			if ($(this).hasClass("moins")) {
				$(this).removeClass("moins");
				$(this).addClass("plus");
				$(this).next().slideUp("slow");
			} else {
				//symbole + ou -
				$(".rounded h1").removeClass("moins");
				$(".rounded h1").addClass("plus");
				$(this).removeClass("plus");
				$(this).addClass("moins");
				
				//affichage blocks sous menus
				$(".content").slideUp("slow");
				$(this).next().slideDown("slow");
			}
		}
	);
	
	
	
	// cyclage actualité sur la home page
	$('#defilement').cycle({
		fx:     'fade',
		speed:  'fast',
		timeout: 5000,
		next:   '#next2',
		prev:   '#prev2',
		after: onAfter,
		before: onAfter
	
	});
	
	function onAfter() { 
		$('.titre').html("<a href=\""+this.href+"\">"+this.title+"</a>");
		$('.nbre').html(str_replace('actu_',"",this.id)+"/"+str_replace('actu_',"",this.name));
		
	}
});


	/************************************************auto-completion : recherche de residence*****/
$(function(){

	$("#ville").jSuggest({
		opacity: 0.9,
		loadingImg: '/global/medias/ajax-loader.gif',
		loadingText: 'Chargement...',
		delay: 500,
		url: "/global/includes/autocompletion.php",
		type: "POST",
		data: "searchQuery",
		autoChange: true
	});

});
	/************************************************fin auto-completion : recherche de residence*****/	


function aff_demande(){
	$("#form_1056").empty();
	$("#form_1056").append('<a href="#">Remplir votre demande de logement en ligne</a><br /><a href="/pages/demande-d-informations.php">Retour</a>');
	
}