//////////////////////////////////////////// FONCTIONS /////////////////////////////////////////////////////
//************************************************** SLIDESHOW POPIN
function showDiapo(id){
	$("#"+id).removeClass("masque");
	$("#colAllCentre").css({zIndex:"10"});
}

function hideDiapo(id){
	$("#"+id).addClass("masque");
	$("#colAllCentre").css({zIndex:"2"});
}

//************************************************** SLIDESHOW PUBLICATION
function slideShowPopin(id){
	var slideShowConteneur = $("#"+id);
	if (slideShowConteneur.children(".slides_container").children(".slides_control").length ==0 ) {
		var nbrImg = slideShowConteneur.children(".slides_container").children("input").length;
		var imgHtml = "";
		for( i=0; i<nbrImg; i++){
			imgHtml += "<img src='"+slideShowConteneur.children(".slides_container").children("input:eq("+i+")").val()+"' alt='' />";
		}
		slideShowConteneur.children(".slides_container").html(imgHtml);
		$(slideShowConteneur).slides({
			preload: false,
			preloadImage: "{images_front_path}contenu/loader.gif",
			generatePagination: true,
			play: 5000,
			effect: "fade"
		});
	}
}


//************************************************** SCROLLTO
function scrollOn(id){
	window.clearTimeout(scroll);
	if ( $("#"+id).offset() ) {
		$('html,body').animate(
			{scrollTop: $("#"+id).offset().top},
			1000
		);
	}
}
//************************************************** AFFICHER / MASQUER
function showMe(id){
	$("#"+id).show();
	$('#colAllCentre').css('zIndex', 6);
}

function hideMe(id){
	$("#"+id).hide();
	$('#colAllCentre').css('zIndex', 2);
}

//************************************************** AFFICHER / MASQUER TOGGLE
function checkOpen(id,idBloc){
	$("#"+id).attr("checked") == true ? $("#"+idBloc).show() : $("#"+idBloc).hide();
}

//************************************************** AFFICHAGE ENCART S'IDENTIFIER
function toggleIdentifier(){
	if( $("#identifier").hasClass("hide") ){
		$("#identifier").removeClass("hide");
		$(".identifiezVous").addClass("on");
	}
	else{
		$("#identifier").addClass("hide")
		$(".identifiezVous").removeClass("on");
	}
}

//************************************************** AFFICHAGE ENCART FACEBOOK
function toggleFconnect(){
	var checkFconnect = $("#fConnect").css("display");
	if( checkFconnect == "none" ){
		$("#fConnect").show();
	}
	else{
		$("#fConnect").hide();
	}
}

//************************************************** RECHERCHE EXPRESS
function ajoutRechercheExpress(id, urlRecherche, compId){
	var lsText = $('#'+id).val();
	var lsVal = lsText.replace(/ /g, '_');
	lsVal = lsVal.replace(new RegExp('[\'"]', 'gi'), '--');
	if( lsVal !=  "Saisissez_un_nom_de_produit" ) {
		var xhr_object = createXMLHttpRequest();
		var url = reverse_path+"service_project/ajax/index.php?component=produit&action=ajouter_recherche_express&comp_id="+compId+"&recherche_express_libelle="+lsVal;
		xhr_object.open("GET",url,true);
		xhr_object.onreadystatechange=onreadystatechange = function() {
			if ( xhr_object.readyState == 4 && xhr_object.status == 200 ) {
				urlRecherche = xhr_object.responseText.replace('&amp;', '&');
				if(jQuery.trim($(".rechercheExpress .liste").html()) == "&nbsp;"){
					var valeur = "<span id="+lsVal+compId+"><a href='"+urlRecherche+"'>"+lsText+"</a><a href='javascript:supprimerRechercheExpress("+compId+", \""+lsVal+compId+"\")' class='fermer' title='Supprimer'>&nbsp;</a></span>";
					$(".rechercheExpress .liste").html(valeur);

				} else {
					var valeur = $(".rechercheExpress .liste").html() + "<span id="+lsVal+compId+"><a href='"+urlRecherche+"'>"+lsText+"</a><a href='javascript:supprimerRechercheExpress("+compId+", \""+lsVal+compId+"\")' class='fermer' title='Supprimer'>&nbsp;</a></span>";
					$(".rechercheExpress .liste").html(valeur);
				}
				window.location.href = urlRecherche;
			}
		}
		xhr_object.send(null);
	}
}

//************************************************** RECHERCHE EXPRESS SUPPRIMER LISTE
function supprimerRechercheExpress(compId,id) {
	var xhr_object = createXMLHttpRequest();

	var lsVal = $("#"+id).children("a:first").html().replace(/ /g, '_');
	lsVal = lsVal.replace(new RegExp('[\'"]', 'gi'), '--');
	var url = reverse_path+"service_project/ajax/index.php?component=produit&action=supprimer_recherche_express&comp_id="+compId+"&recherche_express_libelle="+lsVal;
	xhr_object.open("GET",url,true);
	xhr_object.send(null);
	$("#"+id).remove();
	if(jQuery.trim($(".rechercheExpress .liste").html()) == "&nbsp;" || jQuery.trim($(".rechercheExpress .liste").html()) == '' ){
		$(".rechercheExpress .liste").html("&nbsp;");
	}
}


//**************************************************  MENU DEROULANT
var activeSousrub = false;

// Gestion du menu dÃ©roulant
var rubCheck = false;  // variable menu 1er niveau
var sousRubCheck = false;  // variable menu 2e niveau

//Menu
var timerDuMenu;
function timerMenu(number){ // Si les deux variables sont Ã  false alors la souris n'est pas sur le menu
	if(sousRubCheck == false && rubCheck == false){
		$("li.lienMenu div a:eq("+number+")").removeClass("Over");
		$(".sousMenu:eq("+number+")").hide();
	}
	if ( timerDuMenu ) {
		window.clearTimeout(timerDuMenu);
	}
}
function checkOutMenu(number){ // Controle de la position de la souris
	$("li.lienMenu:eq("+number+")").mouseenter(function(){ // Si sur le menu de 1er niveau
		rubCheck = true;
	});
	$(".sousMenu:eq("+number+")").mouseenter(function(){ // Si sur le sous-menu de 2e niveau
		sousRubCheck = true;
	});
	timerDuMenu = setTimeout("timerMenu("+number+")",50); // On utilise un timeOut appeler la fonction pour masquer les menu pour laisser le temps Ã  l'utilisateur d'interagir
}

// Kill tous les sous-menus ouvert, les timeout et les classes
function kill(){
	window.clearTimeout(timerDuMenu);
	// Kill toutes les classes de 1er niveau
	$("li.lienMenu div a").each(function(){
		$(this).removeClass("Over");
	});

	// Kill tous les menus de 2e niveau et 3e niveau + les classes
	$(".sousMenu").each(function(){
		$(this).hide();
	});
}

//Affichage du menu deroulant
function openMenu(number){
	var check = $(".sousMenu:eq("+number+")").css("display");
	if( check == "none" ){
		$(".sousMenu:eq("+number+")").show();
	}
}

//////////////////////////////////////////// ACTIONS ///////////////////////////////////////////////////////
$(document).ready(function() {
//************************************************** IMPRESSION ZONE
	$(".toPrint").click(function(){
		$(this).parent().parent(".magasin").printElement();
	});

//************************************************** IE7 simuler table-cell sur LI rubrique services
	if ($.browser.msie && $.browser.version == 7){
		var ulWidth = $(".rubrique").children("ul").width();
		var liWidth = 0;

		$(".rubrique li").each(function(){
			liWidth += $(this).width();
		});

		if(ulWidth > liWidth){
			var difference = Math.floor((ulWidth -liWidth)/$(".rubrique li").length);
			$(".rubrique li").each(function(){
				$(this).width($(this).width()+difference);
			});
		}
	}
//************************************************** PUBLICATION
	$(".paragraphe").children(".bloc2Col").children(".gauche").each(function(){
		var h1Height = $(this).children("h1").height();
		var heightTotal = (270 - h1Height)-20;  // -20 pour les padding
		 $(this).children(".paragrapheOverflow").height(heightTotal);
	});

//************************************************** FAQ
if($("#accordeonCenter").size()!=0) {
		$(".acc_listCenter").hide();
		$(".acc_listCenter.openPortletCenter").show();
		$(".acc_menuCenter").click(function(){
			$(this).next(".acc_listCenter").fadeToggle("normal").siblings(".acc_listCenter:visible").hide();
			$(this).toggleClass("openPortletCenter");
			$(this).siblings(".acc_menuCenter").removeClass("openPortletCenter");
		});
	}

//************************************************** IE7 simuler table-cell sur LI menu produit
	if ($.browser.msie && $.browser.version == 7){

		var menuWidth = $(".lienMenu").width();
		var rubWidth = 0;

		$("li.lienMenu").each(function(){
			var rubChildrenSize = $(this).children().width();
			$(this).width(rubChildrenSize);
		});

		$("li.lienMenu").each(function(){
			rubWidth += $(this).width();
			var rubPadding = Math.round((53-$(this).find("span").height())/2);
			var rubHeight = 53-rubPadding;
			$(this).find("span").css({ paddingTop: rubPadding+"px", height: rubHeight+"px" });
		});

		if(menuWidth > rubWidth){
			if((menuWidth - rubWidth)>=$("li.lienMenu").length){
				var rubWidthArrondi = Math.floor(menuWidth/$("li.lienMenu").length);
				var pixelRestantMenu = menuWidth - rubWidth;
				$("li.lienMenu:last").width($("li.lienMenu:last").width()+pixelRestantMenu);
			}
			else{
				var pixelRestantMenu = $("li.lienMenu:last").width() +(menuWidth - rubWidth);
				$("li.lienMenu:last").width(pixelRestantMenu);
			}
		}
	}

//************************************************** MENU DEROULANT

// Hover/out sur le menu 1er niveau
$("li.lienMenu div a").each(function(i){
	$(this).hover(function(){
		kill();  // Remet le menu Ã  zÃ©ro
		rubCheck = true;
		$(this).addClass("Over");
		openMenu(i);
	 },function(){
		rubCheck = false;
	    checkOutMenu(i);
	 });
});

// Hover/out sur le sous menu
$(".sousMenu").each(function(i){
	$(this).hover(function(){
	sousRubCheck = true;
	},function(){
		sousRubCheck = false;
		checkOutMenu(i);
	});
});


//************************************************** ONGLETS
	eval($(".ongletLien a.On").attr("href"));
	$(".ongletLien a").each(function(i){
		$(this).click(function(){
			$(".ongletLien a").removeClass('On');
			$(".ongletLien.inverse a").removeClass('On');
			$(".ongletContenu").hide();
			$(this).addClass('On');
			$(".onglet.inverse a:eq("+i+")").addClass('On');
			$(".ongletContenu:eq("+i+")").show();
		});
	});

	$(".ongletLien.inverse a").each(function(i){
		$(this).click(function(){
			$(".ongletLien a").removeClass('On');
			$(".ongletLien.inverse a").removeClass('On');
			$(".ongletContenu").hide();
			$(this).addClass('On');
			$(".ongletLien a:eq("+i+")").addClass('On');
			$(".ongletContenu:eq("+i+")").show();
		});
	});


//************************************************** CLICK OUTISDE PANIER
	var dansPanier = false;
	var dansBtnPanier = false;
	$(".nbArticle").live("mouseenter", function(){
		dansBtnPanier=true;
		if(dansBtnPanier == true) {
			$("#detailPanier").show();
			_gaq.push(['_trackEvent','Panier','DeplierPanierDepuisMenu','']);
		}
	});
	$(".nbArticle").live("mouseleave", function(){
		dansBtnPanier=false;
	});

	$("#detailPanier").live("mouseover", function(){
		dansPanier=true;
	});
	$("#detailPanier").live("mouseout", function(){
		dansPanier=false;
	});

	$("body").mouseup(function(){
		if(! dansPanier) $("#detailPanier").hide();
	});

//************************************************** CLICK OUTISDE
	$("body").click(function(){
		$("#entete #identifier").addClass("hide")
		$(".identifiezVous").removeClass("on");
	});
	 $('#entete #identifier').click(function(event){
		 event.stopPropagation();
	 });

//************************************************** CLICK OUTISDE CONNEXION FACEBOOK
	$("body").click(function(){
		$("#fConnect").hide();
	});
	 $('#fConnect').click(function(event){
		 event.stopPropagation();
	 });

//************************************************** CLICK INSIDE CONNEXION FACEBOOK
	$("#fConnect").click(function(){
		$("#fConnect").hide();
		$("#fPermission").show();

	});
 	$('#fConnect').click(function(event){
	 	event.stopPropagation();
 	});

	$("#fPermission").click(function(){
		$("#fPermission").hide();

	});
 	$('#fPermission').click(function(event){
	 	event.stopPropagation();
 	});

//************************************************** CLICK OUTISDE CONNEXION FACEBOOK
	$("body").click(function(){
		$("#fPermission").hide();
	});
	 $('#fPermission').click(function(event){
		 event.stopPropagation();
	 });

//************************************************** FILTRES PRODUIT
	$("#familles .filtreNiveau2").children("label").click(function(){
		$(".filtreNiveau3").hide().find("input:checkbox").attr("checked",false);
		$(this).next(".filtreNiveau3").show().find("input:checkbox").attr("checked",true);
	});

	$(".filtreNiveau3").each(function(){
		var filtre = $(this);
		var cases = filtre.find('input:checkbox');

		cases.click(function(){
			if( $(this).parent("label").hasClass("toutSelectionner") ){
				var valeur = $(this).attr("checked");
				cases.attr("checked",valeur);
			}
			else{
				var nombre = filtre.find("label:not(:has(.toutSelectionner))").find('input[type=checkbox]:not(:checked)').length;
				if(nombre == 0){
					filtre.find(".toutSelectionner").find("input:checkbox").attr("checked",true);
				}
				else{
					filtre.find(".toutSelectionner").find("input:checkbox").attr("checked",false);
				}
				nb = filtre.find('input[type=checkbox]:not(:checked)').length;
				var nombreFiltre3 = filtre.find("label:not(:has(.toutSelectionner))").find('input[type=checkbox]').length -1 ;

				var nombreFiltre3Checked = nombreFiltre3 - nb+1;
				if ( nombreFiltre3Checked == nombreFiltre3 ) {
					filtre.find(".toutSelectionner").find("input:checkbox").attr("checked",true);
				}
			}
		});

	});

//************************************************** AJOUT AU PANIER LISTE PRODUIT
	$(".caddie a").live("click", function(){
		$(this).parent(".caddie").hide();
		$(this).parent(".caddie").next(".quantite").show();
	});

	$(".btnPlus").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())+1;
		$(this).siblings("span").text(valeurQuantite);
	});

	$(".encartOffrePrivilege .caddie a").live("click", function(){
		$(this).parent(".caddie").hide();
		$(this).parent(".caddie").next(".quantite").hide();
		$(this).parent(".encartOffrePrivilege").addClass("desactive");
	});

	$(".encartOffrePrivilege .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("1");
			$(this).parent(".quantite").hide();
			$(this).parent(".quantite").prev(".caddie").show();
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

	$(".gauche .fondMonCompte .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("1");
			$(this).parent(".quantite").hide();
			$(this).parent(".quantite").prev(".caddie").show();
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

	$(".ficheProduit .ajoutPanier").click(function(){
		$(this).prev(".quantiteProduit").show();
		$(this).hide();
	});

	$(".ficheProduit .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("1");
			$(".ficheProduit .ajoutPanier").show();
			$(".ficheProduit .quantiteProduit").hide();
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

	$(".ficheRecette .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("0");
			$(this).parent(".quantite").hide();
			$(this).parent(".quantite").prev(".caddie").show();
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

	$(".ficheRecette .caddie").live("click", function(){
		$(this).hide();
		$(this).next(".quantite").children("span").text("1");
		$(this).next(".quantite").show();
	});

	$(".commandeRef .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("1");
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

	$(".mesFavoris .btnMoins").live("click", function(){
		var valeurQuantite = parseInt($(this).siblings("span").text())-1;
		if(valeurQuantite == 0) {
			$(this).siblings("span").text("1");
			$(this).parent(".quantite").hide();
			$(this).parent(".quantite").prev(".caddie").show();
		}
		else{
			$(this).siblings("span").text(valeurQuantite);
		}
	});

//************************************************** DESACTIVE OFFRE MARKETING
	$(".desactiveOffre").click(function(){
		$(this).parent(".encartOffrePrivilege").addClass("desactive");
	});


//************************************************** RECAP COMMANDE DETAIL OFFRE MARKETING
	$(".btnOffre").live("click", function(){
		$(this).children("img").toggleClass('moins');
		var openOffre = $(this).parent().parent().next(".detailOffre");
		if(openOffre.css("display") == "none"){
			openOffre.show();
		}
		else{
			openOffre.hide();
		}

	});
//************************************************** BANDEAU SERVICE
	//Ajoute une classe css "clickImage" à la POPIN au click du picto magasin
	$("#footer .rubriqueTransverse .rubrique ul li a").click(function(){
		$("#insertPopin").removeClass("clickImage");
		if ($(this).hasClass("clickImage")){
			$("#insertPopin").addClass("clickImage");
		}
	});
});

// Fonction qui teste si une variable est un entier
function estEntier(s) {
	return (s.toString().search(/^-?[0-9]+$/) == 0);
}

// Fonctions AJAX
function createXMLHttpRequest() {
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest n'est pas support?mettez ?our votre navigateur, merci.");
   return null;
}

function setAndExecute(divId,innerHTML){
	var div = document.getElementById(divId);
	div.innerHTML = innerHTML;
	var x = div.getElementsByTagName("script");
	for(var i=0;i<x.length;i++)   {
		eval(x[i].text);
	}
}

//Affichage des popins en Ajax
function getPublicationServices(aiArtId) {
	var xhr_object = createXMLHttpRequest();
	var url = reverse_path+"service_project/ajax/index.php?component=transverse&action=view_publication&art_id="+aiArtId;
	xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange=onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			setAndExecute('insertPopin',xhr_object.responseText);
			//On execute le contenu du href cree par le XSL afin de rendre visible  la popin
			eval( $('#insertPopin a').attr('href') );
		}
	}
	xhr_object.send(null);
}

//Traitement et affichage de la popin de rappel téléphonique
function validRappelTelephonique(asName,asTel) {
	var xhr_object = createXMLHttpRequest();
	var params =  "&pers_name="+asName+"&pers_tel="+asTel+"&posted=1";
	var url = reverse_path+"service_project/ajax/index.php?component=transverse&action=rappel_telephonique"+params;
	xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange=onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			var response = xhr_object.responseText;
			setAndExecute('rappelTelephonique',response);
		}
	}
	xhr_object.send(null);
}

// Affiche une popup dimensionnee a la taille de l image en parametre
function popupImgAuto(url, titre) {
	w = window.open('','chargement','scrollbars=yes,toolbar=no,menubar=no,width=10,height=10');
	w.document.write( "<html><head><title>"+titre+"</title>\n" );
	w.document.write( "<script type=\"text/javascript\">\n");
	w.document.write( "function autoSize() {\n");
	w.document.write( "self.resizeTo(document.images[0].width+10,document.images[0].height+57)\n");
	w.document.write( "self.focus();\n");
	w.document.write( "}\n");
	w.document.write( "</script>\n");
	w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize()'>" );
	w.document.write( "<a href='javascript:window.close()'><img src='"+url+"' border=0 alt='"+titre+"' title='"+titre+"'></a>" );
	w.document.write( "</body></html>" );
	w.document.close();
}

// Declenche l appel ajax d insertion de la commande
function insertCommande(compId,commandeId,urlErreur) {
    var xhr_object = createXMLHttpRequest();
    var url = reverse_path+"service_project/ajax/index.php?component=commande&action=insert_commande&comp_id="+compId+"&commande_id="+commandeId;
    xhr_object.open("GET",url,true);
    xhr_object.onreadystatechange=onreadystatechange = function(){
        if ( xhr_object.readyState == 4 && xhr_object.status == 200 ) {
        	if ( xhr_object.responseText != "" ) {
        		eval('objForm = document.form_cic_'+compId);
        		objForm.submit();
        	}
        	else {
        		window.location.href = urlErreur;
        	}
        }
    }
    xhr_object.send(null);
}

// Declenche l'appel ajax de modification de la quantite d un produit dans le panier, depuis le recap commande
function modifierCommandeQte(asProduitId, aiQte) {
    var xhr_object = createXMLHttpRequest();
    var url = reverse_path+"service_project/ajax/index.php?component=commande&action=modifier_qte&produit_id="+asProduitId+"&qte="+aiQte;
    xhr_object.open("GET",url,true);
    xhr_object.onreadystatechange=onreadystatechange = function(){
        if ( xhr_object.readyState == 4 && xhr_object.status == 200 ) {
        	setAndExecute('div_commande',xhr_object.responseText);
        }
    }
    xhr_object.send(null);
}

//***************************************** Facebook connect*******************************************************/

function loginFB(aslabel) {
	//Si l'utilisateur
	FB.login(function(response) {
	  if (response.authResponse) {
	      // utilisateur logué et à donné les permissions (email), on récupère les infos
		FB.api('/me', function(response) {
			//Appel ajax
			if ( response.email ) {
				getFacebookAuth(response.email,aslabel);
			}
			//Email pas reçu, on abandonne.
			else {
		    	FB.logout(function(response) {
				});
		    }
		});
	  }
	  //Pas de jeton d'authentification
	  else {
	    // Pas logué
	  }
	}, {scope:'email'});
}

//Fonction Ajax associée
function getFacebookAuth(asEmail,aslabel) {
	var xhr_object = createXMLHttpRequest();
	var params = "&emailfb="+asEmail;
	var url = reverse_path+"service_project/ajax/index.php?component=login_front&module=login&action=facebook_connect"+params;
	xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange=onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			var response = xhr_object.responseText;
			//Utilisateur connecté, on recharge la page
			if ( response == true ) {
				location.reload();
				_gaq.push(['_trackEvent','MonCompte','ConnexionFacebook',aslabel]);
			}
			else if ( response == false ){
				//Utilisateur déjà logué
				return;
			}
			else {
				//pers_facebook_connect  different de 1, on se delogue
				FB.logout(function(response) {
					});
				setAndExecute('insertPopin',response);
				showMe('modifCompte');showMe('fondRappel');
			}


		}
	}
	xhr_object.send(null);
}

//Récupération de l'adresse des cgv ou reglement fidelite
function getUrlPublication(aiPublication) {
	var xhr_object = createXMLHttpRequest();
	var url = reverse_path+"service_project/ajax/index.php?component=dossier_service&action=get_url&publication="+aiPublication;
	xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange=onreadystatechange = function(){
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText!='' ) {
				window.location.href =  xhr_object.responseText;
			}
		}
	}
	xhr_object.send(null);
}

//Appel AJAX : Affichage des avis d'un produit + formulaire
function refreshEncartCentre() {
	var xhr_object = createXMLHttpRequest();
	var url = reverse_path+"service_project/ajax/index.php?module=dossier&component=dossier_centre&action=view_encart";
	xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange=onreadystatechange = function(){
		if ( xhr_object.readyState == 4 && xhr_object.status == 200 ) {
			setAndExecute('encartDossier',xhr_object.responseText);
		}
	}
	xhr_object.send(null);
}
