
//--

var PATH_HTTP 				= "http://www.service-webmaster.fr";
var ID_SITE_STAT 			= 1;
var ID_MEMBRE_STAT 			= 1;
var anchorTmp 				= null;
var SettingSW = [
        {
        LoadJSAfficheurs: '0',
        LoadJSAgenda: '0',
        },
    ];

//--

document.write('<scr' + 'ipt type="text/javascript" language="javascript" src="/includes/statistiques/stats.js"><' + '/scr' + 'ipt>');

//--

$(document).ready(function ()
{

	//--
	
	$("#tabsOK").tabs();

	//-- APplicarions des tools-tip
	$('*.Tips2').qtip(
	{
		position: {
			corner: {
				target: 'topRight',
				tooltip: 'bottomLeft'
			}
		},
		style: {
			name: 'dark',
			padding: '7px 13px',
			width: {
				max: 300,
				min: 0
			},
			border: {
				width: 3,
				radius: 5,
			},
			tip: true
		}
	});

	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 15;

	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});

	//Find last image container
	var lastLi = ul.find('li:last-child');

	//When user move mouse over menu
	div.mousemove(function (e)
	{
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
		var left = (e.pageX - div.offset().left) * (ulWidth - divWidth) / divWidth;
		div.scrollLeft(left);
	});

	//-- Fenetre facebox
	
	$('a[rel*=facebox]').facebox(
	{
		loading_image: '/javascripts/facebox/loading.gif',
		close_image: '/javascripts/facebox/closelabel.gif',
	})
						   
	anchor = getAnchor();
	
	if (anchor)
		GetPage(anchor);
		
	window.setInterval("checkAnchor()", 500);
	
	convertLinks();


sfHover = function ()
{
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i = 0; i < sfEls.length; i++)
	{
		sfEls[i].onmouseover = function ()
		{
			this.className += "sfhover";
		}
		sfEls[i].onmouseout = function ()
		{
			this.className = this.className.replace(new RegExp("sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

});

function checkAnchor()
{

	anchor = getAnchor();
	if (anchor != null && anchor != anchorTmp)
		GetPage(anchor);
	
}

function getAnchor()
{
	anchor = document.location.hash;
	anchor = anchor.replace('#','');
	if (!anchor || anchor == 'undefined')
		anchor = null;
		
	return anchor;
}

function IncludeJS(sId, fileUrl, source) 
	{ 
	
	if (!document.getElementById(sId))
		{
		var oHead = document.getElementsByTagName('head').item(0);
		var oScript = document.createElement( "script" );
		oScript.language = "javascript";
		oScript.type = "text/javascript";
		oScript.id = sId;
		oScript.defer = true;
		oScript.text = source;
		oHead.appendChild( oScript );
		}
		
	} 

function convertLinks()
{

$('.link').each(function(){
	if (!$(this).hasClass('ajax'))
		{
			page = $(this).attr('href');
			page = page.replace('#','');
			$(this).click(function() {
				page = $(this).attr('href');
				page = page.replace('#','');
				ChangePage(page);
			//	return false;
			});
		$(this).addClass('ajax');
		}

	});
	//$('span.mailme').mailme();
}

//-- Fonction : Chargement d'une page Ajax pour les admins des services

function GetPage(page)
	{

	//--
	
	anchorTmp = page;
	
	//--
	
	document.getElementById('IDContentService').style.display='block';

	//--
	
	BarreChargement();
	
	//--
	
	setTimeout(function() {
		
	//--
	
	var result_html = file("/includes/pages/admin/"+page+"","GetPage");
		
	//-- 
	
	document.getElementById('IDContentService').innerHTML = result_html;	
	
	//-- Chargement du javascript du service Afficheurs
	
	if (page.match("afficheurs.php"))
		LoadJSServiceAfficheurs();
	else if (page.match("agendas.php"))
		LoadJSServiceAgendas();
	else if (page.match("commentaires.php"))
		LoadJSServiceCommentaires();
	else if (page.match("cpt_clics.php"))
		LoadJSServiceCPTClics();
	else if (page.match("cpt_visites.php"))
		LoadJSServiceCPTVisites();
	else if (page.match("cpt_live.php"))
		LoadJSServiceCPTLive();
	else if (page.match("espace_membres.php"))
		LoadJSServiceEspaceMembres();
	else if (page.match("form2mail.php"))
		LoadJSServiceForm2mail();
	else if (page.match("jukebox.php"))
		LoadJSServiceJukebox();
	else if (page.match("forum.php"))
		LoadJSServiceForum();
	else if (page.match("bannieres.php"))
		LoadJSServiceBannieres();
	else if (page.match("livredor.php"))
		LoadJSServiceLivredor();
	else if (page.match("news.php"))
		LoadJSServiceNews();
	else if (page.match("newsletter.php"))
		LoadJSServiceNewsletter();
	else if (page.match("notes.php"))
		LoadJSServiceNotes();
	else if (page.match("radios.php"))
		LoadJSServiceRadios();
	else if (page.match("recommandeur.php"))
		LoadJSServiceRecommandeur();
	else if (page.match("shoutbox.php"))
		LoadJSServiceShoutbox();
	else if (page.match("sondages.php"))
		LoadJSServiceSondages();
	else if (page.match("topsites.php"))
		LoadJSServiceTopSites();
	else if (page.match("dedicaces.php"))
		LoadJSServiceDedicaces();
	else if (page.match("annuaires.php"))
		LoadJSServiceAnnuaires();
	else if (page.match("lecteurrss.php"))
		LoadJSServiceLecteurRss();
	else if (page.match("pagerank.php"))
		LoadJSServicePagerank();
	else if (page.match("generateurs.php"))
		LoadJSServiceGenerateurs();
	else if (page.match("faq.php"))
		LoadJSServiceFaq();
	else if (page.match("petites_annonces.php"))
		LoadJSServicePetitesAnnnces();
	else if (page.match("galerie_photos.php"))
		LoadJSServiceGaleriePhotos();
	else if (page.match("eboutique.php"))
		LoadJSServiceEboutique();
	else if (page.match("statistiques.php"))
		LoadJSServiceStatistiques();
	else if (page.match("sitebuilder.php"))
		LoadJSServiceSiteBuilder();
	else if (page.match("seo.php"))
		LoadJSServiceSiteSEO();
	else if (page.match("mon_compte.php"))
		LoadJSMonCompte();
	else if (page.match("gestionnaire_contenu.php"))
		LoadJSServiceGestionnaireContenu();
	else if (page.match("help_support.php"))
		LoadJSServiceHelpSupport();

	//--
		
	convertLinks();

	//--
	
	},100);

	//-- On remonte en haut de page
	
	document.documentElement.scrollTop='0px';
	}

//-- Fonction : getParamValue

function getParamValue(param,url)
	{
	
	try
		{
		var u = url == undefined ? document.location.href : url;
		var reg = new RegExp('(\\?|&|^)'+param+'=(.*?)(&|$)');
		matches = u.match(reg);
		return matches[2] != undefined ? decodeURIComponent(matches[2]).replace(/\+/g,' ') : '';
		}
	catch(E)
		{
		return false;
		}
		
	}
	
//--

function Check_CGU()
	{
	
	if (document.getElementById('valide_cgu').checked == false)
		{
		alert('Vous devez accepter les conditions générales d\'utilisation');
		return false;
		}
	
	}

//--

function GetNbArticlePanier()
	{

	//-- On recherche le nombre de produit dans le caddie
	
	var nb_article = file("/includes/ajax/fonctions.ajax.php?action=nb_article","GetNbArticlePanier");

	if (nb_article == "") 
		nb_article = 0;

	//-- On affiche le nombre de produit sur le site
	
	if (nb_article == 0 || nb_article == 1) 
		document.getElementById('nb_article').innerHTML = nb_article + ' Article';
	else 
		document.getElementById('nb_article').innerHTML = nb_article + ' Articles';

	}

//-- Fonction : Execution d'une requete Ajax

function file(fichier,xhr_object)
	{
		
	if (window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else if (window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else return (false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if (xhr_object.readyState == 4) return (xhr_object.responseText);
	else return (false);
	}

//-- Fonction : AjaxMsgConfirmation

function AjaxMsgConfirmation(titre,texte,image)
	{
	
	//-- Message de confirmation
	
	$(document).ready(function(){
		
		var unique_id = $.gritter.add({
			title: titre,
			text: texte,
			image: 'http://www.pewiz.com/images/'+image,
			sticky: true, 
			time: '',
			class_name: 'my-sticky-class' 
		});
		
		// You can have it return a unique id, this can be used to manually remove it later using

		setTimeout(function(){
			$.gritter.remove(unique_id, { 
				fade: true,
				speed: 'slow'
			});
		}, 6000)
		
		return false;
	
		});
			
	}

//-- Fonction : iPhoneAlert

function iPhoneAlert()
	{

	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
		{
		
		var question = confirm("Souhaitez-vous naviguer sur le site optimisé pour iPhone?")

		if (question)
			window.location = "http://www.service-webmaster.mobi";
	
		}
		
	}

//-- Fonction : Ajout d'un article au panier

function SiteAddPanier(id_article, quantite, redirecton)
{

	//-- On ajout le produit dans le caddie
	var texte = file('/includes/ajax/fonctions.ajax.php?id_article=' + id_article + '&action=add_panier&quantite=' + quantite + '');

	//--
	if (texte == 1)
	{

		//-- On recherche le nombre de produit dans le caddie
		var nb_article = file('/includes/ajax/fonctions.ajax.php?action=nb_article');

		//-- On affiche le nombre de produit sur le site
		if (nb_article == 0 || nb_article == 1) document.getElementById('nb_article').innerHTML = nb_article + ' Article';
		else document.getElementById('nb_article').innerHTML = nb_article + ' Articles';

		//-- Affichage du message de confirmation
		AjaxMsgConfirmation("Informations","L'article a bien été ajouté dans votre panier.","good.png");
	
	//-- Redirection
	if (redirecton == 1) window.location = '/panier.php';

	}
	else if (texte == 2)
	{
		AjaxMsgConfirmation("Informations","Vous avez déjà une commande en attente de paiement.","error.png");
	}
	else if (texte == 3)
	{
		AjaxMsgConfirmation("Informations","Vous devez être connecté à votre espace client.","error.png");
	}
	else
	{
		AjaxMsgConfirmation("Informations","Cette article est déjà dans votre panier.","error.png");
	}

}

//-- Fonction : Cocher toutes les cases

function cochertout(formulaire)
	{
	
	if (formulaire == "" || formulaire == null) var formulaire = "form";
	
	for (var i = 0; i < document.getElementById(formulaire).elements.length; i++)
		{
		var e = document.getElementById(formulaire).elements[i];
		if ((e.name != 'coche') && (e.type == 'checkbox') && (e.disabled == false)) e.checked = document.getElementById(formulaire).coche.checked;
		}
		
	}

//-- Fonction : Verification des cases sélectionnées

function checkFormSelection(form, page)
{
	var formValid = false;
	var i = 0;
	var nbclick = 0;
	while (document.getElementById(form).elements[i])
	{
		if (document.getElementById(form).elements[i].checked)
		{
			formValid = true;
		}
		i++;
	}
	if (!formValid)
	{
		alert("Veuillez sélectionner au moins une case avant de choisir une action");
	}
	else
	{
		if (window.focus)
		{
			self.focus();
		}
		document.getElementById(form).action = page;
		document.getElementById(form).submit();
	}
	return formValid;
}

//-- Fonction : Ouverture d'une popup centrée

function PopupCentrer(page, largeur, hauteur, option)
{
	var top = (screen.height - hauteur) / 2;
	var left = (screen.width - largeur) / 2;
	window.open(page, "", "top=" + top + ",left=" + left + ",width=" + largeur + ",height=" + hauteur + "," + option);
}

//-- Fonction : Insertion des smileys dans un formulaire

function formsSmiley(smiley)
{
	textselect = document.getElementById('post').message;
	if (textselect.c)
	{
		textselect.c.text = textselect.c.text + smiley;
	}
	else
	{
		textselect.value += smiley;
	}
	textselect.focus();
}

//-- Post d'un formulaire

function envoi_form(form, page)
{
	var formValid = false;
	document.getElementById(form).target = "";
	document.getElementById(form).action = page;
	document.getElementById(form).submit();
	return formValid;
}

//-- Validation paiement d'une commande

function valide_commande_paiement(type)
{

	if (document.getElementById('panier').domaine.value == "") document.getElementById('panier').domaine.style.border = '1px solid #FF3300';

	if (document.getElementById('panier').domaine.value == "")
	{
		alert("Veuillez compléter tous les champs obligatoires !");
		erreur = false;
	}
	else
	{

		if (type == 1) 
		document.getElementById('panier').submit();
		else 
		document.location.href = "/includes/commandes/validation-commande.php?type=hawatools"

	}

}

//-- Validation d'une commande 

function valide_commande(type)
	{
	document.location.href = "/includes/commandes/valide-commande.php";
	}

//-- Fonction : Verification du formulaire de connexion

function check_login_membre()
{

	if (document.getElementById('connexion_membre').pseudo_membre.value == "") document.getElementById('connexion_membre').pseudo_membre.style.border = '1px solid #FF3300';

	if (document.getElementById('connexion_membre').passe_membre.value == "") document.getElementById('connexion_membre').passe_membre.style.border = '1px solid #FF3300';

	if (document.getElementById('connexion_membre').pseudo_membre.value == "" || document.getElementById('connexion_membre').passe_membre.value == "")
	{

		alert("Veuillez compléter tous les champs obligatoires !");

		return false;
	}
	else
		document.getElementById('connexion_membre').submit();

}

//--

function dl_script(id_script, lien)
	{
	document.location.href = lien;
	return false;
	}

//--

function arguments_cookie(offset)
	{
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}

//--

function lire_cookie(nom)
	{
	var arg = nom + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return arguments_cookie(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
	}

//--

function ChangeTypeUpload()
	{

	if (document.getElementById('type').value != 'image')
		document.getElementById('resize').disabled = true;
	else
		document.getElementById('resize').disabled = false;

	}

//--

function sack(file)
{
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;
	this.onLoading = function ()
	{
	};
	this.onLoaded = function ()
	{
	};
	this.onInteractive = function ()
	{
	};
	this.onCompletion = function ()
	{
	};
	this.createAJAX = function ()
	{
		try
		{
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (err)
			{
				this.xmlhttp = null;
			}
		}
		if (!this.xmlhttp && typeof XMLHttpRequest != "undefined") this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp)
		{
			this.failed = true;
		}
	};
	this.setVar = function (name, value)
	{
		if (this.URLString.length < 3)
		{
			this.URLString = name + "=" + value;
		}
		else
		{
			this.URLString += "&" + name + "=" + value;
		}
	}
	this.encVar = function (name, value)
	{
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
		return varString;
	}
	this.encodeURLString = function (string)
	{
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++)
		{
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1)
			{
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0], urlVars[1]);
		}
		return varArray.join('&');
	}
	this.runResponse = function ()
	{
		eval(this.response);
	}
	this.runAJAX = function (urlstring)
	{
		this.responseStatus = new Array(2);
		if (this.failed && this.AjaxFailedAlert)
		{
			alert(this.AjaxFailedAlert);
		}
		else
		{
			if (urlstring)
			{
				if (this.URLString.length)
				{
					this.URLString = this.URLString + "&" + urlstring;
				}
				else
				{
					this.URLString = urlstring;
				}
			}
			if (this.encodeURIString)
			{
				var timeval = new Date().getTime();
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element)
			{
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp)
			{
				var self = this;
				if (this.method == "GET")
				{
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				}
				else
				{
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST")
				{
					try
					{
						this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
					}
					catch (e)
					{
					}
				}
				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function ()
				{
					switch (self.xmlhttp.readyState)
					{
					case 1:
						self.onLoading();
						break;
					case 2:
						self.onLoaded();
						break;
					case 3:
						self.onInteractive();
						break;
					case 4:
						self.response = self.xmlhttp.responseText;
						self.responseXML = self.xmlhttp.responseXML;
						self.responseStatus[0] = self.xmlhttp.status;
						self.responseStatus[1] = self.xmlhttp.statusText;
						self.onCompletion();
						if (self.execute)
						{
							self.runResponse();
						}
						if (self.elementObj)
						{
							var elemNodeName = self.elementObj.nodeName;
							elemNodeName.toLowerCase();
							if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea")
							{
								self.elementObj.value = self.response;
							}
							else
							{
								self.elementObj.innerHTML = self.response;
							}
						}
						self.URLString = "";
						break;
					}
				};
			}
		}
	};
	this.createAJAX();
}


//-- Fonction : Barre de chargement

function BarreChargement()
	{
	document.getElementById('IDContentService').innerHTML = '<p>&nbsp;</p><p><img src="/images/loading.gif" width="208" height="13" /></p><p>Chargement en cours...</p>';
	}

//-- Fonction : Desactiver le service

function DesibleService(id_service,service,page)
	{
	
	//-- On demande la confirmation
	
	if(!confirm('Cela va supprimer toutes les données du service, etes-vous sur ?')) 
		{
		return false;	
		}
	else
		{
	
		//--
		
		if(file("/includes/ajax/fonctions.ajax.php?DesactiveService=1&id_service="+id_service+"&service="+service+"","DesibleService")==1)
			{		
			AjaxMsgConfirmation("Informations","Le service a bien été désactivé","good.png");
			GetPage(page);
			}
		else
			{
			AjaxMsgConfirmation("Informations","Erreur lors de la desactivation du service","error.png");
			}

		}
	
	}

//-- Fonction : Activation du service

function ActivationService(id_service,service,page)
	{
	
	//--
	
	if(file("/includes/ajax/fonctions.ajax.php?ActiveService=1&id_service="+id_service+"&service="+service+"","ActivationService")==1)
		{
		AjaxMsgConfirmation("Informations","Le service a bien été activé","good.png");
		GetPage(page);
		}
	else
		{
		AjaxMsgConfirmation("Informations","Erreur lors de l'activation du service","error.png");
		}

	}
	
//-- Ajax

function getXhr()
	{
	var xhr = null;
	if (window.XMLHttpRequest) // Firefox et autres
	xhr = new XMLHttpRequest();
	else if (window.ActiveXObject)
	{ // Internet Explorer 
		try
		{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{ // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		xhr = false;
	}
	return xhr
	}

//-- Fonction : Ajout d'un projet

function ProjetAdd()
	{
		
	//-- 
	
	var ListeChamps = "SiteAction=AddProjet";
		
	//-- On recupere tous les champs input text
	
	$("input:text").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent ( $(this).attr('value') ) + '';
		});
		
	//-- On recupere tous les champs input checked
	
	$("input:checked").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent ( $(this).attr('value') ) + '';
		});
	
	//-- On recupere tous les champs textarea
	
	$("textarea").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent( $(this).attr('value') ) + '';
		});
	
	//-- On recupere tous les champs select
	
	$("select").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent( $(this).attr('value') ) + '';
		});

	//--
	
	var xhr = getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","Votre projet a bien été enregistré.","good.png");
				}
			else if(result_html==9)
				{
				AjaxMsgConfirmation("Informations","Veuillez compèter tous les champs obligatoires.","error.png");
				}
			else
				{
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				}
				
			}

		}
		
	//--

	return false;	
	}

//--

function AddPropositionProjet()
	{
			
	//-- 
	
	var ListeChamps = "SiteAction=AddPropositionProjet&id_membre_projet="+document.getElementById('id_membre_projet').value+"&id_projet="+document.getElementById('id_projet').value+"";
		
	//-- On recupere tous les champs input text
	
	$("input:text").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent ( $(this).attr('value') ) + '';
		});
		
	//-- On recupere tous les champs input checked
	
	$("input:checked").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent ( $(this).attr('value') ) + '';
		});
	
	//-- On recupere tous les champs textarea
	
	$("textarea").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent( $(this).attr('value') ) + '';
		});
	
	//-- On recupere tous les champs select
	
	$("select").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent( $(this).attr('value') ) + '';
		});

	//--
	
	var xhr = getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","Votre proposition a bien été enregistré.","good.png");
				}
			else if(result_html==9)
				{
				AjaxMsgConfirmation("Informations","Veuillez compèter tous les champs obligatoires.","error.png");
				}
			else
				{
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				}
				
			}

		}
		
	//--

	return false;
	}

//-- 

function PanierRecalcul()
	{
				
	//-- 
	
	var ListeChamps = "SiteAction=RecalculPanier&id=";	
		
	//-- On recupere tous les modules cochés
	
	$(function() {$(".checked_module").each(function (){ListeChamps = ListeChamps + $(this).attr('value') + "|"})});
	
	//-- On recupere tous les champs select
	
	$("select").each(function ()
		{
		ListeChamps = ListeChamps + '&' + $(this).attr('name') + '=' + encodeURIComponent( $(this).attr('value') ) + '';
		});

	//--
	
	var xhr 		= getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","Le panier a bien été actualisé.","good.png");
				window.location.reload();
				}
			else
				{
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				}
				
			}

		}
		
	//--

	return false;
	}

//-- 

function PanierVideAll()
	{
			
	//-- 
	
	var ListeChamps = "SiteAction=DeleteAllArticlePanier";	
	var xhr 		= getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","Le panier a bien été vidé.","good.png");
				window.location.reload();
				}
			else
				{
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				}
				
			}

		}
		
	//--

	return false;
	}
	
//-- 

function PanierDeleteArticle(id_article)
	{
			
	//-- 
	
	var ListeChamps = "SiteAction=DeleteArticlePanier&id_article="+id_article+"";	
	var xhr 		= getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","L'article a bien été supprimé.","good.png");
				window.location.reload();
				}
			else
				{
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				}
				
			}

		}
		
	//--

	return false;
	}

//--

function ActiveDemoAbonnement(type)
	{
				
	//-- 
	
	var ListeChamps = "SiteAction="+type+"";	
	var xhr 		= getXhr();
	xhr.open('POST', '/includes/ajax/fonctions.ajax.php', true);
	xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-15');

	var data = ListeChamps;
	xhr.send(data);

	//-- On recupere le resultat
	
	xhr.onreadystatechange = function ()
		{
	
		//-- Le code http
		
		if (xhr.readyState == 4 && xhr.status == 200)
			{
	
			//-- On recupere le resultat
			
			result_html = xhr.responseText;	

			//--
			
			if(result_html==1)
				{
				AjaxMsgConfirmation("Informations","L'abonnement a bien été activé.","good.png");
				window.location.reload();
				}
			else if(result_html==8)
				AjaxMsgConfirmation("Informations","Vous avez déja activer votre période de démonstration.","error.png");
			else
				AjaxMsgConfirmation("Informations","Erreur lors de l'enregistrement.","error.png");
				
			}

		}
		
	//--

	return false;
	}

//-- 

function PanierEtapeSuivante(etape)
	{
	document.getElementById('FormPanier').target = "";
	document.getElementById('FormPanier').action = "panier.php?etape="+etape;
	document.getElementById('FormPanier').submit();
	return false
	}


var imageTag = false;
var theSelection = false;
var clientPC = navigator.userAgent.toLowerCase();
var clientVer = parseInt(navigator.appVersion);
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
b_help = "Texte gras: [b]texte[/b]";
i_help = "Texte italique: [i]texte[/i]";
u_help = "Texte souligné: [u]texte[/u]";
q_help = "Citation: [quote]texte cité[/quote]";
c_help = "Afficher du code: [code]code[/code]";
l_help = "Liste: [list]texte[/list]";
o_help = "Liste ordonnée: [list=]texte[/list]";
p_help = "Insérer une image: [img]http://image_url/[/img]";
w_help = "Insérer un lien: [url]http://url/[/url] ou [url=http://url/]Nom[/url]";
a_help = "Fermer toutes les balises BBCode ouvertes";
s_help = "Couleur du texte: [color=red]texte[/color] Astuce: #FF0000 fonctionne aussi";
f_help = "Taille du texte: [size=x-small]texte en petit[/size]";
d_help = "Insérer une vidéo. Dailymotion : [dailymotion]codevideo[/dailymotion] ou Vidéo Youtube : [youtube]codevideo[/youtube]";
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]');
imageTag = false;
function helpline(help)
{
	document.post.helpbox.value = eval(help + "_help");
}
function getarraysize(thearray)
{
	for (i = 0; i < thearray.length; i++)
	{
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
		return i;
	}
	return thearray.length;
}
function arraypush(thearray,value)
{
	thearray[ getarraysize(thearray) ] = value;
}
function arraypop(thearray)
{
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}
function bbfontstyle(bbopen, bbclose)
{
	var txtarea = document.post.message;
	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text;
		if (!theSelection)
		{
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}
function bbstyle(bbnumber)
{
	var txtarea = document.post.message;
	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;
	if (bbnumber == -1)
	{
		while (bbcode[0])
		{
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false;
		txtarea.focus();
		return;
	}
	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text;
		if (theSelection)
		{
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}
	for (i = 0; i < bbcode.length; i++)
	{
		if (bbcode[i] == bbnumber+1)
		{
			bblast = i;
			donotinsert = true;
		}
	}
	if (donotinsert)
	{
		while (bbcode[bblast])
		{
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
			imageTag = false;
		}
		txtarea.focus();
		return;
	}
	else
	{
		if (imageTag && (bbnumber != 14))
		{
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;
			document.post.addbbcode14.value = "Img";
			imageTag = false;
		}
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1;
		arraypush(bbcode,bbnumber+1);
		eval('document.post.addbbcode'+bbnumber+'.value += "*"');
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
	selEnd = selLength;
	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}
function storeCaret(textEl)
{
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

