ï»¿var host = window.location.host;
path = (host == "localhost") ? "http://" + host + "/futsal2/" : "http://" + host + "/";
if (document.images)
{
    pic1 = new Image(16,11);
    pic1.src = path + "images/ajax-loader.gif";         
}

function getXhr() 
{
	var xhr;
	if (!xhr && typeof XMLHttpRequest != 'undefined') 
	{
	   try {xhr = new XMLHttpRequest();} 
	   catch (e) {xhr = false;}
	}
	
	if(!xhr && typeof ActiveXObject != "undefined")
	{
	   try{ xhr=new ActiveXObject("MSXML2.XMLHTTP"); }
	   catch(e){xhr=false;}
	   if(!xhr)try{ xhr=new ActiveXObject("Microsoft.XMLHTTP"); }
	   catch(e){xhr=false;}
	}
	
	return xhr;
}
var detect = navigator.userAgent.toLowerCase();
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
function ajoutCommentaire(newsid, session, title, url, count, nom, prenom, club, fct, message, avatar, ne)
{
	if(session == "" || session == "false")
	{
		var pseudo = encodeURIComponent(document.getElementById('pseudo').value);
		var pseudo2 = document.getElementById('pseudo').value;
		var email = document.getElementById('email').value;
		var utf = false;
		var surv = false;
		var stephInput2 = "";
	}
	else
	{
		var pseudo = encodeURIComponent(document.getElementById('pseudo').innerHTML);
		var stephInput2 = encodeURIComponent($('#stephInput2').val());
		var pseudo2 = document.getElementById('pseudo').innerHTML;
		var email = document.getElementById('email').innerHTML;
		var surv = ($("#surveille").hasClass("active")) ? true : false;
		var utf = true;
	}
	
	var score = ($("#score").hasClass("active")) ? true : false;
	var steph = ($("#steph").hasClass("active")) ? true : false;
		
	var comm2 = document.getElementById('comm').value;
	var comm = encodeURIComponent(comm2.replace("â‚¬", "&#8364;"));	
	
	if(trim(pseudo) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoires";
	else if(trim(email) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoires";
	else if(trim(comm2) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoire";
	else
	{
		if(utf == false && Verifmail(email) == false) document.getElementById("waitinggg").innerHTML = "Adresse non-valide";
		else
		{		
			showwaiting("waitinggg");
			$("#submit").hide();
			$.ajax({
				type: "POST", url: path + "news/ajoutcommentaire.php", 
				data: "pseudo=" + pseudo + "&email=" + email + "&comm=" + comm + "&newsid=" + newsid + "&sess=" + session + "&surv=" + surv + "&title=" + title + "&url=" + url + "&utf=" + utf + "&nom=" + encodeURIComponent(nom) + "&prenom=" + encodeURIComponent(prenom) + "&club=" + encodeURIComponent(club) + "&message=" + message + "&avatar=" + encodeURIComponent(avatar) + "&fct=" + encodeURIComponent(fct) + "&score=" + score + "&steph=" + steph + "&stephInput2=" + stephInput2,
				complete: function(data)
				{	
					leselect = data.responseText;
					var tab = new Array();
					tab = leselect.split("###!!!###");
					if(tab[0] == 1)
					{
						document.getElementById("waitinggg").innerHTML = "Pseudo dÃ©jÃ  pris";
						$("#submit").fadeIn("slow");
					}
					else if(tab[0] == 2)
					{
						document.getElementById("waitinggg").innerHTML = "Adresse mail dÃ©jÃ  prise";
						$("#submit").fadeIn("slow");
					}
					else if(tab[0] == 3)
					{		
						$(tab[1]).hide().prependTo("#afficheComm").fadeIn("slow");
						$("#preview").hide();	
						$("#score").removeClass("active");	
						attente();
					}
					else
					{
						document.getElementById("waitinggg").innerHTML = "Erreur";
						$("#submit").show(500);
					}			
				}
			 });			
		}
	}
}
function attente()
{
	hidewaiting("waitinggg");
	$("#comm").val("");
	elasticTextArea("comm");
	$("#submit").show();
}
function preview(session)
{  
    if(session == "" || session == "false") var pseudo = encodeURIComponent(document.getElementById('pseudo').value);
    else var pseudo = encodeURIComponent(document.getElementById('pseudo').innerHTML);
    text = encodeURIComponent(document.getElementById("comm").value);
	var t = $("#preview").attr("innerHTML");
		
	showwaiting("waitinggg");	
	$.ajax({
		type: "POST", 
		url: path + "news/preview.php", 
		data: "text=" + text + "&pseudo=" + pseudo,
		complete: function(data)
		{	
			$("#preview").hide().html(data.responseText).fadeIn("slow");
			hidewaiting("waitinggg");			
		}
	 });	
}

function checked(id, news, userid) {
	if($("#" + id).hasClass("active")) 
	{
		$("#" + id).removeClass("active");
		document.getElementById("surveille[" + news + "]").innerHTML = "<span id='surveille[" + news + "]' class='surveille2' onclick='surveille(" + news + ", " + userid + ", 1)'>Surveiller ce sujet</span>";			
	}
	else
	{
		$("#" + id).addClass("active");
		document.getElementById("surveille[" + news + "]").innerHTML = "<span id='surveille[" + news + "]' class='surveille2' onclick='surveille(" + news + ", " + userid + ", 0)'>ArrÃªter de surveiller ce sujet</span>";
	}
}
function checked2(id) {
	if($("#" + id).hasClass("active")) 
	{
		$("#" + id).removeClass("active");
		if(id == "steph") $("#stephInput").html("");
	}
	else
	{
		$("#" + id).removeClass();
		$("#" + id).addClass("active");
		
		if(id == "steph") $("#stephInput").html("Titre : <input type='text' name='stephInput2' id='stephInput2' value='' style=' width: 300px;'/>");
	}
	
}
function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function showwaiting(div)
{
    document.getElementById(div).innerHTML = "<img src='" + path + "images/ajax-loader.gif' width='16' height='11' alt='' />";
}
function showwaitingg(div, box)
{
    document.getElementById(div).innerHTML = "<img src='" + path + "images/ajax-loader.gif' width='16' height='11' alt='' />";
    document.getElementById(box).className = "opacity";
}
function hidewaiting(div)
{
    document.getElementById(div).innerHTML = "";
}
function hidewaitingg(div, box)
{
    document.getElementById(div).innerHTML = "";
	document.getElementById(box).className = "";
}
function hidewaitinggg(box)
{
	document.getElementById(box).className = "";
}

function resultats(id, today, journee, sais)
{
    today = parseInt(today);	
    journee = parseInt(journee);	
	showwaitingg("semaine", "box1");
	$.ajax({
		type: "POST", url: path + "team/resultats2.php", 
		data: "id=" + id + "&journee=" + journee + "&today=" + today + "&sais=" + sais,
		complete: function(data)
		{	
			leselect = data.responseText;
			$("#box1").html(leselect);
			//document.getElementById("box1").innerHTML = leselect;
			document.getElementById("sem").innerHTML = journee;
			if(journee > 5)
			{
				var precedente = journee - 1;
				$("#prec").html('<a class="precc" href="' + precedente + '" class="precc"></a>');
			}
			else document.getElementById("prec").innerHTML = '&nbsp;';

			if(journee < 42)
			{
				var suivante = journee + 1;
				document.getElementById("suiv").innerHTML = '<a class="suivv" href="' + suivante + '" class="precc"></a>';
			}
			else document.getElementById("suiv").innerHTML = '&nbsp;';
			
			hidewaitingg("semaine", "box1");
			document.getElementById("semaine").innerHTML = "Semaine " + journee;
		}
	});
}
function changeClassement(sel, id, clas)
{
	var xhr = getXhr();
	xhr.onloading = showwaitingg("waiting", "box1");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			document.getElementById("box1").innerHTML =  leselect;
			xhr.oncomplete = hidewaitingg("waiting", "box1");
			document.getElementById("sem").innerHTML =  clas;
		}
	}
	xhr.open("POST", path + "team/classement2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("tri=" + sel + "&id=" + id);
}

function changeTeam(id, club, team)
{
	var xhr = getXhr();
	xhr.onloading = showwaitingg("waiting", "box1");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			document.getElementById("box1").innerHTML =  leselect;
			xhr.oncomplete = hidewaitingg("waiting", "box1");
			document.getElementById("team").innerHTML =  team;
			if(club != "") document.getElementById("changePhoto").innerHTML = "";
			else document.getElementById("changePhoto").innerHTML = "Afficher les photos d'Ã©quipes";
			maps(club);			
		}
	}
	xhr.open("POST", path + "team/effectif2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("club=" + club + "&id=" + id);
}
function maps(id)
{
	$.ajax({
		type: "POST", url: path + "team/salle.php", data: "id=" + id,
		complete: function(data)
		{	
			leselect = data.responseText;
			if(leselect != "")
			{
				tab = new Array();
				tab = leselect.split("!-!");
				
				adresse = new Array();
				adresse = tab[3].split("\n");
				
				var myLatlng = new google.maps.LatLng(tab[0],tab[1]);
				var myOptions = {
				  zoom: 17,
				  center: myLatlng,
				  mapTypeId: google.maps.MapTypeId.HYBRID
				}
				
				var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
				var t = (adresse.length == 2) ? "" : '<br />' + adresse[2];
				var contentString = '<div id="content" style="height: 80px;">'+
					'<div id="siteNotice">'+
					'</div>'+
					'<h3 id="firstHeading" class="firstHeading">' + tab[2] + '</h3>'+
					'<div id="bodyContent">'+
					'<p style="width: 250px;">' + adresse[0] + '<br />' + adresse[1] + t + '</p>'+
					'</div>'+
					'</div>';

				var infowindow = new google.maps.InfoWindow({
					content: contentString
				});

				var marker = new google.maps.Marker({
					position: myLatlng,
					map: map,
					title: tab[2],
					icon : "http://www.luxfutsal.be/images/soccer.png"
				});

				google.maps.event.addListener(marker, 'click', function() {
				  infowindow.open(map,marker);
				});
			}
		}
	});	
}
function salle()
{
	$.ajax({
		type: "POST", url: path + "salle2.php", data: "val=fdss",
		complete: function(data)
		{	
			leselect = data.responseText;			
			ligne = new Array();
			ligne = leselect.split("!!!");	
			
			tab = new Array();
			adresse = new Array();							
			locations = new Array();
			
			for (i = 0; i < ligne.length - 1; i++) { 				
				tab = ligne[i].split("!-!");
				adresse = tab[3].split("\n");
				var t = (adresse.length == 2) ? "" : '<br />' + adresse[2];
				
				var contentString = '<div id="content" style="height: 80px;">'+
					'<div id="siteNotice">'+
					'</div>'+
					'<h3 id="firstHeading" class="firstHeading">' + tab[2] + '</h3>'+
					'<div id="bodyContent">'+
					'<p style="width: 250px;">' + adresse[0] + '<br />' + adresse[1] + t + '</p>'+
					'</div>'+
					'</div>';
					
				locations[i] = [contentString, tab[0], tab[1], i, tab[2]];
			}
			
			var map = new google.maps.Map(document.getElementById('map'), {
				zoom: 9,
				center: new google.maps.LatLng(49.814949,5.589294),
				mapTypeId: google.maps.MapTypeId.ROADMAP
			});

			var infowindow = new google.maps.InfoWindow();
			var marker, i;			

			for (i = 0; i < locations.length; i++) { 
				marker = new google.maps.Marker({
					position: new google.maps.LatLng(locations[i][1], locations[i][2]),
					map: map,
					title: locations[i][4], 
					icon : "http://www.luxfutsal.be/images/soccer.png"
				});

				google.maps.event.addListener(marker, 'click', (function(marker, i) {
					return function() {
						infowindow.setContent(locations[i][0]);
						infowindow.open(map, marker);
					}
				})(marker, i));
			}
			google.maps.event.addListener(marker, 'click', function() {
			  infowindow.open(map,marker);
			});
		}
	 });	
}
function changeSalle(id)
{
	if(id == 0) salle();
	else {
		//if(wait2) showwaitingg("wait2", "map");
		$.ajax({
			type: "POST", url: path + "salle2.php", data: "id=" + id,
			complete: function(data)
			{	
				leselect = data.responseText;
				if(leselect != "")
				{
					tab = new Array();
					tab = leselect.split("!-!");
					
					adresse = new Array();
					adresse = tab[3].split("\n");

					var myLatlng = new google.maps.LatLng(tab[0],tab[1]);
					var myOptions = {
					  zoom: 17,
					  center: myLatlng,
					  mapTypeId: google.maps.MapTypeId.HYBRID
					}
					
					var map = new google.maps.Map(document.getElementById("map"), myOptions);
					var t = (adresse.length == 2) ? "" : '<br />' + adresse[2];
					var contentString = '<div id="content" style="height: 80px;">'+
						'<div id="siteNotice">'+
						'</div>'+
						'<h3 id="firstHeading" class="firstHeading">' + tab[2] + '</h3>'+
						'<div id="bodyContent">'+
						'<p style="width: 250px;">' + adresse[0] + '<br />' + adresse[1] + t + '</p>'+
						'</div>'+
						'</div>';

					var infowindow = new google.maps.InfoWindow({
						content: contentString
					});

					var marker = new google.maps.Marker({
						position: myLatlng,
						map: map,
						title: tab[2],
						icon : "http://www.luxfutsal.be/images/soccer.png"
					});

					google.maps.event.addListener(marker, 'click', function() {
					  infowindow.open(map,marker);
					});
					
					hidewaitingg("wait2", "map");
					salleEquipe(id);
				}
			}
		});
	}		
}

function changeSalle2(id)
{
	if(id == 0) salle();
	else {
		$.ajax({
			type: "POST", url: path + "salle2.php", data: "id=" + id,
			complete: function(data)
			{	
				leselect = data.responseText;
				if(leselect != "")
				{
					tab = new Array();
					tab = leselect.split("!-!");
					
					adresse = new Array();
					adresse = tab[3].split("\n");

					var myLatlng = new google.maps.LatLng(tab[0],tab[1]);
					var myOptions = {
					  zoom: 17,
					  center: myLatlng,
					  mapTypeId: google.maps.MapTypeId.HYBRID
					}
					
					var map = new google.maps.Map(document.getElementById("map"), myOptions);
					var t = (adresse.length == 2) ? "" : '<br />' + adresse[2];
					var contentString = '<div id="content" style="height: 80px;">'+
						'<div id="siteNotice">'+
						'</div>'+
						'<h3 id="firstHeading" class="firstHeading">' + tab[2] + '</h3>'+
						'<div id="bodyContent">'+
						'<p style="width: 250px;">' + adresse[0] + '<br />' + adresse[1] + t + '</p>'+
						'</div>'+
						'</div>';

					var infowindow = new google.maps.InfoWindow({
						content: contentString
					});

					var marker = new google.maps.Marker({
						position: myLatlng,
						map: map,
						title: tab[2],
						icon : "http://www.luxfutsal.be/images/soccer.png"
					});

					google.maps.event.addListener(marker, 'click', function() {
					  infowindow.open(map,marker);
					});					
				}
			}
		});
	}		
}
function salleEquipe(id)
{
	showwaitingg("wait2", "club");
	$.ajax({
		type: "POST", url: path + "salle2.php", data: "id=" + id + "&team=ok",
		complete: function(data)
		{	
			leselect = data.responseText;
			document.getElementById("club").innerHTML = leselect;
			hidewaitingg("wait2", "club");
		}
	 });
}
function changeCalendrier(idTeam)
{
	var xhr = getXhr();
	xhr.onloading = showwaitingg("waiting", "box1");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			document.getElementById("box1").innerHTML =  leselect;
			xhr.oncomplete = hidewaitingg("waiting", "box1");
		}
	}
	xhr.open("POST", path + "team/calendrier2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("idTeam=" + idTeam);
}
function contact(session)
{
	var error = "";
	if(session == "" || session == "false")
	{
		var pseudo = encodeURIComponent(document.getElementById('pseudo').value);
		var email = document.getElementById('mail').value;
		var utf = false;
	}
	else
	{
		var pseudo = encodeURIComponent(document.getElementById('pseudo').innerHTML);
		var email = document.getElementById('mail').innerHTML;
		var utf = true;
	}
	var message = encodeURIComponent(document.getElementById('message').value);
	
	if(trim(pseudo) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoires";
	else if(trim(email) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoires";
	else if(trim(message) == "") document.getElementById("waitinggg").innerHTML = "Tous les champs sont obligatoire";
	else
	{
		var xhr = getXhr();
		xhr.onloading = showwaiting("waitinggg");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById("waitinggg").innerHTML = "";
				document.getElementById("box1").innerHTML =  "<div class='envoiContact'>Email envoyÃ©</div>";
			}
		}
		xhr.open("POST", path + "contactt2.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("pseudo=" + pseudo + "&email=" + email + "&message=" + message);
	}
}
function contactPseudo(value)
{
    if(trim(value) == "")
        {
                document.getElementById("pseudoo").className = "rouge";
                return false;
        }
        else
        {
                document.getElementById("pseudoo").className = "vert";
                return true;
        }
}
function contactMessage(value)
{
    if(trim(value) == "")
        {
                document.getElementById("messagee").className = "rouge";
                return false;
        }
        else
        {
                document.getElementById("messagee").className = "vert";
                return true;
        }
}
function contactEmail(value)
{
    if(trim(value) == "") {document.getElementById("emaill").className = "rouge";return false;}
        else
        {
                if(Verifmail(value) == false)
                {
                        document.getElementById("emaill").className = "rouge";
                        document.getElementById("emailError").innerHTML = "Adresse email non-valide";
                        return false;
                }
                else
                {
                        document.getElementById("emaill").className = "vert";
                        document.getElementById("emailError").innerHTML = "";
                        return true;
                }
    }
}
function trim(aString)
{
    var regExpBeginning = /^\s+/;
    var regExpEnd       = /\s+$/;
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}
function Verifmail(adresse)
{
    var regExpr = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regExpr.test(adresse);
}


function noaccent(chaine) {
  temp = chaine.replace(/[àâä]/gi,"a")
  temp = temp.replace(/[éèêë]/gi,"e")
  temp = temp.replace(/[îï]/gi,"i")
  temp = temp.replace(/[ôö]/gi,"o")
  temp = temp.replace(/[ùûü]/gi,"u")
  return temp
}

function login(p)
{	
	var pseudo = document.getElementById("log_pseudo").value;
	var pwd = document.getElementById("log_pwd").value;
	var check = document.getElementById("check").checked;
	
	showwaiting("waitinggLogin");
	$.ajax({
		type: "POST", url:  path + "login/login_ajax.php", data: "pseudo=" + pseudo + "&pwd=" + pwd + "&check=" + check,
		complete: function(data)
		{	
			leselect = data.responseText;
			if(leselect == 1 || leselect == 2)
			{
				$("#waitinggLogin").hide();	
				$("#waitinggLogin").removeClass();				
				if(leselect == 1) $("#waitinggLogin").html("Pseudo inconnu");
				else if(leselect == 2) $("#waitinggLogin").html("IncohÃ©rence entre pseudo et mot de passe");
				$("#waitinggLogin").addClass("errorr");
				$("#waitinggLogin").show(1000);
			}
			else window.location.replace(p);
		}
	});
}
function logout(p)
{
	var xhr = getXhr();
	xhr.onloading = showwaiting("waitinggTop");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			window.location.replace(p);
		}
	}
	xhr.open("POST", path + "login/logout_ajax.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("pseudo=gfgfgf");
}

function creercompte()
{		
	var pseudo = encodeURIComponent(document.getElementById("log_pseudo").value);
	var email = document.getElementById("log_email").value;
	var pass1 = encodeURIComponent(document.getElementById("log_pass1").value);
	var pass2 = encodeURIComponent(document.getElementById("log_pass2").value);
	var check = document.getElementById("check2").checked;
	
	var nom = encodeURIComponent(document.getElementById("nom").value);
	var prenom = encodeURIComponent(document.getElementById("prenom").value);
	var day = document.getElementById('day').innerHTML;
	day = (day  > 10) ? day : "0" + day;
	var month = document.getElementById("month").innerHTML;
	var tab = new Array();
	tab = {"": 0, "janv": 1, "fÃ©vr": 2, "mars":3, "avril": 4, "mai":5, "juin": 6, "juill": 7, "aoÃ»t": 8, "sept": 9, "oct": 10, "nov": 11, "dÃ©c": 12};
	month = tab[month];
	month = (month  > 10) ? month : "0" + month;
	var year = document.getElementById("year").innerHTML;
	var club = encodeURIComponent(document.getElementById("club").value);
	var fct = encodeURIComponent(document.getElementById("fct").value);
	
	var serie = document.getElementById("serie").innerHTML;	
	var tab2 = new Array();
	tab2 = {"2NB": 1, "3ND": 2, "P1": 3, "2A":4, "2B": 5, "3A":6, "3B": 7, "3C": 8, "3D": 9, "VET": 1};
	serie = tab2[serie];		
	var dn = year + "-" + month + "-" + day;
		
	var error= "";

	if(trim(pseudo) == "") error = "ok";
	else if(trim(email) == "") error = "ok";
	else if(trim(pass1) == "") error = "ok";
	else if(trim(pass2) == "") error = "ok";

	if(error == "ok") 
	{	
		$("#waitinggLogin2").html("Tous les champs sont obligatoires");
		$("#waitinggLogin2").addClass("waitinggLogin2");	
		$('#waitinggLogin2').fadeIn(500, function(){
			$(this).css('filter','');
		})
	}
	else
	{
		if(Verifmail(email) == false) 
		{
			$("#waitinggLogin2").html("Adresse mail non valide");
			$("#waitinggLogin2").addClass("waitinggLogin2");
			$('#waitinggLogin2').fadeIn(500, function(){
				$(this).css('filter','');
			})		
		}
		else if(pass1 !== pass2) 
		{
			$("#waitinggLogin2").html("Mots de passe diffÃ©rents");
			$("#waitinggLogin2").addClass("waitinggLogin2");
			$('#waitinggLogin2').fadeIn(500, function(){
				$(this).css('filter','');
			})		
		}
		else
		{
			showwaiting("waitinggLogin2");
			$("#waitinggLogin2").html("");
			$.ajax({
				type: "POST", url:  path + "login/creercompte.php", data: "pseudo=" + pseudo + "&email=" + email + "&pass=" + pass1 + "&check=" + check + "&nom=" + nom + "&prenom=" + prenom + "&dn=" + dn + "&club=" + club + "&fct=" + fct + "&serie=" + serie,
				complete: function(data)
				{	
					leselect = data.responseText;
					if(leselect != 3)
					{
						if(leselect == 1) $("#waitinggLogin2").html("Pseudo dÃ©jÃ  pris");
						else if(leselect == 2) $("#waitinggLogin2").html("Adresse mail dÃ©jÃ  prise");
						else $("#waitinggLogin2").html("Erreur lors de l'exÃ©cution du script");
						$("#waitinggLogin2").addClass("errorr");
						$('#waitinggLogin2').fadeIn(500, function(){
							$(this).css('filter','');
						})					
					}
					else 
					{
						window.location.replace(path + "profile/change2/");							
					}
					
				}
			});	
		}
	}
}

addDays = function(d, j)
{
    return new Date(d.getTime() + (1000 * 60 * 60 * 24 * j));
}

function dateFR( $time )
{
   setlocale( LC_TIME, "fr" );
   return strftime( "%A %d %b %Y" , strtotime( $time ) );
}
function today(date)
{	
	showwaitingg("waiting", "box1");
	$.ajax({
		type: "POST", url: path + "team/ojd2.php", data: "date=" + date,
		complete: function(data)
		{	
			hidewaitingg("waiting", "box1");
			leselect = data.responseText;
			document.getElementById("box1").innerHTML = leselect;
			
			var j = date.split("-");
			var today = new Date(j[0], j[1]-1, j[2] , "20", "15", "00");
			
			jour = today.getDay();
			numero = today.getDate();
			if (numero < 10) numero = "0"+numero;
			mois = today.getMonth();
			TabJour = new Array("dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi");
			TabMois = new Array("janvier","fÃ©vrier","mars","avril","mai","juin","juillet","aoÃ»t","septembre","octobre","novembre","dÃ©cembre");

			document.getElementById("sem").innerHTML = "Match du " + TabJour[jour] + " " + numero + " " + TabMois[mois] + " " + j[0];

			var count = getElementsByClassName('heure2').length;
			setMatch(count);
			
			document.title = "LuxFutsal : Tous les matchs du " + TabJour[jour] + " " + numero + " " + TabMois[mois] + " " + j[0];
		}
	 });
}
function setMatch(count)
{
	if(count == 0) var quoi = "Pas de match";
	else if(count == 1) var quoi = "1 match";
	else var quoi = count + " matchs";
	document.getElementById('matchh').innerHTML = quoi;
}
function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
			current = elements[i ];
			if(testClass.test(current.className)){
					returnElements.push(current);
			}
	}
	return returnElements;
}



function editComm(id)
{
    var xhr = getXhr();
    xhr.onloading = showwaiting("changeInfo[" + id + "]");
    xhr.onreadystatechange = function()
    {
        if(xhr.readyState == 4 && xhr.status == 200)
        {
            xhr.oncomplete = hidewaiting("changeInfo[" + id + "]");

            leselect = xhr.responseText;
            if(document.getElementById("comm[" + id + "]").className == "text")
            {
                document.getElementById("comm[" + id + "]").className = "text t";
                document.getElementById("comm[" + id + "]").innerHTML = "<textarea id='editComm[" + id + "]'>" + leselect + "</textarea>";
                document.getElementById("comm[" + id + "]").innerHTML += "<div class='submit' onclick='editComm2(" + id + ")'>Editer</div>";
				elasticTextArea("editComm[" + id + "]");
            }
            else
            {
                var reg = new RegExp("(\n)", "g");
                leselect = leselect.replace(reg, "<BR  />");

                document.getElementById("comm[" + id + "]").className = "text";
                document.getElementById("comm[" + id + "]").innerHTML = leselect;
            }
        }
    }
    xhr.open("POST", path + "news/edit.php",true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send("id=" + id);
}
function editComm2(id)
{
    var comm = encodeURIComponent(document.getElementById("editComm[" + id + "]").value);
    var com = document.getElementById("editComm[" + id + "]").value;
    var xhr = getXhr();
    xhr.onloading = showwaiting("changeInfo[" + id + "]");
    xhr.onreadystatechange = function()
    {
        if(xhr.readyState == 4 && xhr.status == 200)
        {
            document.getElementById("comm[" + id + "]").innerHTML = xhr.responseText;;
            document.getElementById("comm[" + id + "]").className = "text";
            xhr.oncomplete = hidewaiting("changeInfo[" + id + "]");
        }
    }
    xhr.open("POST", path + "news/edit2.php",true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send("id=" + id + "&comm=" + comm);
}
function deleteComm(id)
{
    if (confirm("Etes-vous sur de supprimer ce commentaire ?"))
    {
        var xhr = getXhr();
        xhr.onloading = showwaiting("changeInfo[" + id + "]");
        xhr.onreadystatechange = function()
        {
            if(xhr.readyState == 4 && xhr.status == 200)
            {
                document.getElementById("deleteComm[" + id + "]").className = "";
                document.getElementById("deleteComm[" + id + "]").innerHTML = "";
				//xhr.oncomplete = hidewaiting("changeInfo[" + id + "]");
            }
        }
        xhr.open("POST", path + "news/deletecomm.php",true);
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send("id=" + id);
    }
}

function retire(value, id)
{
    if(value == "Recherche") document.getElementById(id).value = "";
    else if(value == "") document.getElementById(id).value = "Recherche";
}

function insertAtCaret(obj, string)
{
	obj.focus();
	if (typeof(document.selection) != 'undefined')
	{
		var range = document.selection.createRange();
		if (range.parentElement() != obj)
		return;

		range.text = string;
		range.select();
	}
	else if (typeof(obj.selectionStart) != 'undefined')
	{
		var start = obj.selectionStart;

		obj.value = obj.value.substr(0, start)
              + string
              + obj.value.substr(obj.selectionEnd, obj.value.length);

		start += string.length;
		obj.setSelectionRange(start, start);

		//SelectText(string);
	}
	else obj.value += string;

	obj.focus();
}


function SelectText(text) {
    //var text = document.getElementById(element);
    if ($.browser.msie) {
        var range = document.body.createTextRange();
		alert(range);
        range.moveToElementText(text);
        range.select();
    } else if ($.browser.mozilla || $.browser.opera) {
        var selection = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(text);
        selection.removeAllRanges();
        selection.addRange(range);
    } else if ($.browser.safari) {
        var selection = window.getSelection();
        selection.setBaseAndExtent(text, 0, text, 1);
    }
}

function bbfontstyle(bbopen, bbclose)
{
	var clientPC = navigator.userAgent.toLowerCase(); // Get client info
	var clientVer = parseInt(navigator.appVersion); // Get browser version
	var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
	var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
	theSelection = false;
	var textarea = document.getElementById("comm");
	textarea.focus();
	if ((clientVer >= 4) && is_ie && is_win)
	{
		// Get text selection
		theSelection = document.selection.createRange().text;
		if (theSelection)
		{
			// Add tags around selection
			document.selection.createRange().text = bbopen + theSelection + bbclose;
			textarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (textarea.selectionEnd && (textarea.selectionEnd - textarea.selectionStart > 0))
	{
		mozWrap(textarea, bbopen, bbclose);
		textarea.focus();
		theSelection = '';
		return;
	}

	//The new position for the cursor after adding the bbcode
	var caret_pos = getCaretPosition(textarea).start;
	var new_pos = caret_pos + bbopen.length;

	// Open tag
	insert_text(bbopen + bbclose);

	// Center the cursor when we don't have a selection
	// Gecko and proper browsers
	if (!isNaN(textarea.selectionStart))
	{
		textarea.selectionStart = new_pos;
		textarea.selectionEnd = new_pos;
	}
	// IE
	else if (document.selection)
	{
		var range = textarea.createTextRange();
		range.move("character", new_pos);
		range.select();
		storeCaret(textarea);
	}

	textarea.focus();
	return;
}
function caretPosition()
{
	var start = null;
	var end = null;
}
function getCaretPosition(txtarea)
{
	var caretPos = new caretPosition();

	// simple Gecko/Opera way
	if(txtarea.selectionStart || txtarea.selectionStart == 0)
	{
		caretPos.start = txtarea.selectionStart;
		caretPos.end = txtarea.selectionEnd;
	}
	// dirty and slow IE way
	else if(document.selection)
	{

		// get current selection
		var range = document.selection.createRange();

		// a new selection of the whole textarea
		var range_all = document.body.createTextRange();
		range_all.moveToElementText(txtarea);

		// calculate selection start point by moving beginning of range_all to beginning of range
		var sel_start;
		for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++)
		{
				range_all.moveStart('character', 1);
		}

		txtarea.sel_start = sel_start;

		// we ignore the end value for IE, this is already dirty enough and we don't need it
		caretPos.start = txtarea.sel_start;
		caretPos.end = txtarea.sel_start;
	}

	return caretPos;
}
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	var scrollTop = txtarea.scrollTop;

	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;
	txtarea.selectionStart = selEnd + open.length + close.length;
	txtarea.selectionEnd = txtarea.selectionStart;
	txtarea.focus();
	txtarea.scrollTop = scrollTop;

	return;
}
function insert_text(text, spaces, popup)
{
	var textarea;

	if (!popup)
	{
		textarea = document.getElementById("comm");
	}
	else
	{
		textarea = document.getElementById("comm");;
	}
	if (spaces)
	{
		text = ' ' + text + ' ';
	}

	if (!isNaN(textarea.selectionStart))
	{
		var sel_start = textarea.selectionStart;
		var sel_end = textarea.selectionEnd;

		mozWrap(textarea, text, '')
		textarea.selectionStart = sel_start + text.length;
		textarea.selectionEnd = sel_end + text.length;
	}
	else if (textarea.createTextRange && textarea.caretPos)
	{
		if (baseHeight != textarea.caretPos.boundingHeight)
		{
			textarea.focus();
			storeCaret(textarea);
		}

		var caret_pos = textarea.caretPos;
		caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
	}
	else
	{
		textarea.value = textarea.value + text;
	}
	if (!popup)
	{
		textarea.focus();
	}
}
function changerPhoto(level, idPhoto, folder, userId, pseudo, prec, suiv)
{
	$("#photoo").fadeOut(500);
	showwaiting("waitPhoto");
	$.ajax({
		type: "POST", url: path + "album/album_photo_detail2.php", data: "idPhoto=" + idPhoto + "&folder=" + folder + "&userId=" + userId + "&pseudo=" + pseudo + "&level=" + level,
		complete: function(data)
		{	
			leselect = data.responseText;			
			$("#photoo").html(leselect);
			$("#photoo").fadeIn(500);			
			hidewaiting("waitPhoto");
			elasticTextArea("album_new_comm");
		}
	 });
}
function affichePhoto(idPhoto, folder, idAlbum, pseudo, level, user)
{
	showwaiting("waitPhoto");
	$.ajax({
		type: "POST", url: path + "album/album_photo_detail2.php", data: "idPhoto=" + idPhoto + "&idAlbum=" + idAlbum + "&folder=" + folder + "&pseudo=" + pseudo + "&level=" + level + "&userId=" + user,
		complete: function(data)
		{	
			leselect = data.responseText;			
			$("#photoo").html(leselect);
			hidewaiting("waitPhoto");
		}
	 });
}
function ajoutAlbumComm(idPhoto, idUser, pseudo)
{
	comm = encodeURIComponent(document.getElementById("album_new_comm").value);
	var reg = new RegExp("(&)", "g");
	comm = comm.replace(reg, "et");
	if(trim(comm) != "")
	{
		var xhr = getXhr();
		xhr.onloading = showwaiting("waitPhoto");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				leselect = xhr.responseText;
				document.getElementById('album_comm2').innerHTML = leselect;
				xhr.onComplete = hidewaiting("waitPhoto");
			}
		}
		xhr.open("POST", path + "album/album_ajout_comm.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("idPhoto=" + idPhoto + "&idUser=" + idUser + "&comm=" + comm + "&pseudo=" + pseudo);
	}
}

function editAlbumComm(id)
{       
    var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;                         
			if(document.getElementById("comm[" + id + "]").className == "album_text")
			{
				document.getElementById("comm[" + id + "]").className = "text t";
				document.getElementById("comm[" + id + "]").innerHTML = "<textarea id='editComm[" + id + "]' style='width: 100%; height: 80px;'>" + leselect + "</textarea>";
				document.getElementById("comm[" + id + "]").innerHTML += "<div class='editer' onclick='editAlbumComm2(" + id + ")'>Editer</div>";
			}
			else
			{
				var reg = new RegExp("(\n)", "g");
				leselect = leselect.replace(reg, "<BR  />");

				document.getElementById("comm[" + id + "]").className = "album_text";
				document.getElementById("comm[" + id + "]").innerHTML = leselect;
			}
		}
	}
	xhr.open("POST", path + "album/updateAlbumcomm.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id=" + id);
}
function editAlbumComm2(id)
{
	var comm = encodeURIComponent(document.getElementById("editComm[" + id + "]").value);
	var com = comm;
	var xhr = getXhr();

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			var reg = new RegExp("(\n)", "g");
			com = com.replace(reg, "<BR  />");
			document.getElementById("comm[" + id + "]").innerHTML = document.getElementById("editComm[" + id + "]").value;
			document.getElementById("comm[" + id + "]").className = "album_text";
		}
	}
	xhr.open("POST", path + "album/updateAlbumcomm2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id=" + id + "&comm=" + comm);
}
function deleteAlbumComm(id)
{
	if (confirm("Etes-vous sur de supprimer ce commentaire ?"))
	{
	var xhr = getXhr();
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				document.getElementById("album_comm[" + id + "]").className = "";
				document.getElementById("album_comm[" + id + "]").innerHTML = "";
			}
		}
		xhr.open("POST", path + "album/deleteAlbumcomm.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("id=" + id);
	}
}

function changebuteur(tri, id, trii)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("waiting", "box1");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			document.getElementById("sem").innerHTML = trii;
			document.getElementById("box1").innerHTML = leselect;
			xhr.oncomplete = hidewaitingg("waiting", "box1");
		}
	}
	xhr.open("POST", path + "team/buteurs2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("tri=" + tri + "&div=" + id);
}

function envoiPass(p)
{
    var pseudo = document.getElementById("log_pseudo3").value;
    var mail = document.getElementById("log_email3").value;
	
	if(pseudo && mail)
	{
		showwaiting("waitinggLogin3");
		$.ajax({
			type: "POST", url: path + "login/recupmdp.php", data: "pseudo=" + pseudo + "&email=" + mail,
			complete: function(data)
			{	
				leselect = data.responseText;
				$("#waitinggLogin3").hide();	
				$("#waitinggLogin3").removeClass();				
				if(leselect == 0) $("#waitinggLogin3").html("Pseudo et mail incohÃ©rents");
				else if(leselect == 1) $("#waitinggLogin3").html("Un mail contenant les infos vous a Ã©tÃ© envoyÃ©.");
				$("#waitinggLogin3").addClass("errorr");
				$("#waitinggLogin3").show(1000);
			}
		});
	}
}
function changerPass(id)
{
    var ancien = document.getElementById("ancien").value;
    var new1 = document.getElementById("new1").value;
    var new2 = document.getElementById("new2").value;
	var error = "";

	if(trim(ancien) == "") {document.getElementById("error1").innerHTML = "Obligatoire"; error = "p";}
	else document.getElementById("error1").innerHTML = "";

	if(trim(new1) == "") {document.getElementById("error").innerHTML = "Obligatoire"; error = "p";}
	else document.getElementById("error").innerHTML = "";

	if(trim(new2) == "") {document.getElementById("error2").innerHTML = "Obligatoire"; error = "p";}
	else document.getElementById("error2").innerHTML = "";

	if(new1 != new2) {document.getElementById("error").innerHTML = "Mot de passe diffÃ©rents"; error = "p";}

	if(error == "")
	{
		var xhr = getXhr();
		xhr.onloading = showwaiting("changep");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				leselect = xhr.responseText;
				if(leselect == 0) document.getElementById("error1").innerHTML = "Mauvais mot de passe";
				else if(leselect == 1) document.getElementById("table").innerHTML = "Mot de passe changÃ© avec succÃ¨s";
				else if(leselect == 2) document.getElementById("error1").innerHTML = "Erreur, veuillez recommencer.";
				else document.getElementById("error1").innerHTML = "Erreur, veuillez recommencer.";

				if(leselect != 1) xhr.oncomplete = hidewaiting2(id, "changep");
			}
		}
		xhr.open("POST", path + "login/changerpass.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("ancien=" + ancien + "&id=" + id + "&newpass=" + new1);
	}
}
function showwaiting2(val)
{
    document.getElementById(val).innerHTML = "<img src='" + path + "images/ajax-loader.gif' width='16' height='16' alt='' />";
}
function showwaiting3(val)
{
    document.getElementById(val).innerHTML = "<img src='" + path + "images/ajax-loader.gif' width='16' height='16' alt='' style='margin-top: -6px;' />";
}
function hidewaiting2( id, val)
{
    document.getElementById(val).innerHTML = '<input id="submit" type="sumit" class="submit" name="changepass" value="Changer" style="text-align: center" onclick="changerPass(' + id + ')" />';
}
function hidewaiting3(id, val)
{
    document.getElementById(val).innerHTML = '<input id="submit" type="sumit" class="submit" name="changemail" value="Changer" style="text-align: center" onclick="changerMail(' + id + ')" />';
}
function hidewaiting4(path, id, val)
{
    document.getElementById(val).innerHTML = '<input id="submitcoord" type="submit" class="submit" name="changecoord" value="Changer" style="text-align: center" onclick="changerCoord(' + id + ')" />';
}
function hidewaiting5(val)
{
    document.getElementById(val).innerHTML = "";
}
function changeMail(id)
{
    var email = document.getElementById("newmail").value;
	alert(email);
	if(Verifmail(email) == false) document.getElementById("errormail").innerHTML = "Adresse non-valide";
	else
	{
		document.getElementById("errormail").innerHTML = "";
		var xhr = getXhr();
		xhr.onloading = showwaiting("changem");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{
				leselect = xhr.responseText;
				if(leselect == 1) document.getElementById("tablemail").innerHTML = "Adresse email changÃ©e avec succÃ¨s";
				else if(leselect == 2) document.getElementById("errormail").innerHTML = "Erreur, veuillez recommencer.";
				else document.getElementById("errormail").innerHTML = "Erreur, veuillez recommencer.";

				if(leselect != 1) xhr.oncomplete = hidewaiting3(id, "changem");
			}
		}
		xhr.open("POST", path + "login/changermail.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("email=" + email + "&id=" + id);
	}
}
function changerCoord(id)
{
    var nom = encodeURIComponent(document.getElementById("nom").value);
    var prenom = encodeURIComponent(document.getElementById("prenom").value);
    var club = encodeURIComponent(document.getElementById("club").value);
    var fct = encodeURIComponent(document.getElementById("fct").value);
    
    var day = (document.getElementById("day").value < 10) ? "0" + document.getElementById("day").value : document.getElementById("day").value;
    var month = (document.getElementById("month").value < 10) ? "0" + document.getElementById("month").value : document.getElementById("month").value;
    var year= document.getElementById("year").value;
	var serie = document.getElementById('serie').options[document.getElementById('serie').selectedIndex].value;
    var dn = year + "-" + month + "-" + day;
    
    var xhr = getXhr();
    xhr.onloading = showwaiting("changec");
    xhr.onreadystatechange = function()
    {
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			if(leselect == 1) document.getElementById("tablec").innerHTML = "CoordonnÃ©es modififiÃ©es avec succÃ¨s";
			else if(leselect == 2) document.getElementById("errorc").innerHTML = "Erreur, veuillez recommencer.";
			else document.getElementById("errorc").innerHTML = "Erreur, veuillez recommencer.";

			if(leselect != 1) xhr.oncomplete = hidewaiting("changec");
		}
    }
    xhr.open("POST", path + "login/changercoord.php",true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send("nom=" + nom + "&id=" + id + "&prenom=" + prenom + "&club=" + club + "&fct=" + fct + "&dn=" + dn + "&serie=" + serie);
}

function surveille(newsid, userid, sens)
{
	var xhr = getXhr();
	xhr.onloading = showwaiting("surveille[" + newsid + "]");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			leselect = xhr.responseText;
			if(sens == 0) document.getElementById("surveille[" + newsid + "]").innerHTML = "<span id='surveille[" + newsid + "]' class='surveille2' onclick='surveille(" + newsid + ", " + userid + ", 1)'>Surveiller ce sujet</span>";
			else if(sens == 1) document.getElementById("surveille[" + newsid + "]").innerHTML = "<span id='surveille[" + newsid + "]' class='surveille2' onclick='surveille(" + newsid + ", " + userid + ", 0)'>ArrÃªter de surveiller ce sujet</span>";
			
			if(document.getElementById("surveille"))
			{
				if(sens == 1) 
				{
					$("#surveille").removeClass();
					$("#surveille").addClass("checked");
				}
				else if(sens == 0) 
				{
					$("#surveille").removeClass();
					$("#surveille").addClass("submit");
				}
			}
		}
	}
	xhr.open("POST", path + "news/surveille.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("newsid=" + newsid + "&userid=" + userid + "&sens=" + sens);
}
function changePoll(i)
{
	if($("#poll_" + i).hasClass("normal"))
	{
		$("#poll_" + i).removeClass("normal");
		$("#poll_" + i).addClass("sel");
	}
	else{
		$("#poll_" + i).addClass("normal");
		$("#poll_" + i).removeClass("sel");
	}
}
function poll(id, i, userId, nbreOption)
{
    var option = "";
    var o = 0;
    for(a = 0; a < i; a++)
    {
		if($("#poll_" + a).hasClass("sel"))
		{
			option += document.getElementById("opt[" + a + "]").innerHTML + "-";   
            o++;
		}
    }
    if(o == 0) alert("Vous n'avez selectionnÃ© aucune option ...");
    else if(o > 0 && o > nbreOption) 
    {
        var diff = o - nbreOption;
        var op = (diff > 1) ? "options" : "option";
        alert("Vous avez sÃ©lectionnÃ© " + diff + " " + op + " en trop ...");
    }
    else
    {
        var xhr = getXhr();
        xhr.onloading = showwaiting("poll[" + id + "]");
        xhr.onreadystatechange = function()
        {
            if(xhr.readyState == 4 && xhr.status == 200)
            {
                leselect = xhr.responseText;
                document.getElementById("sondage[" + id + "]").innerHTML = leselect;
            }
        }
        xhr.open("POST", path + "poll.php",true);
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send("id=" + id + "&option=" + option + "&userId=" + userId);
    }
}
function pollModif(id, userId)
{
	$.ajax({
		type: "POST", url: path + "pollModif.php", data: "id=" + id + "&userId= " + userId,
		complete: function(data)
		{	
			leselect = data.responseText;
			document.getElementById("sondage[" + id + "]").innerHTML = leselect;
		}
	});
}
function setCookie(nom, valeur, jours)
{	
	var expDate = new Date()	
	expDate.setTime(expDate.getTime() + (jours * 24 * 3600 * 1000))	
	document.cookie = nom + "=" + escape(valeur)	+ ";expires=" + expDate.toGMTString()	+ ";path=/" 
}
function setCookie2(nom, valeur) 
{	
	document.cookie = nom + "=" + escape(valeur)	+ "; path=/" 
}
function closeAvertBrowser()
{	
	document.getElementById("brows").style.display = "none";	
	if(document.getElementById("checkBrowser").checked == true) 
	setCookie("futsal_browser", "true", 365);	
	else setCookie2("futsal_browser", "true");	
}
function prono(idMatch, user, prono)
{			
	showwaiting(prono + "_" + idMatch + "");
	$.ajax({
		type: "POST", url: path + "prono/prono.php", data: "idMatch=" + idMatch + "&user=" + user + "&prono=" + prono,
		complete: function(data)
		{	
			leselect = data.responseText;
			if(leselect == "")
			{
				if(prono == "1") 	
				{		
					$("#1_" + idMatch + "").html("1");
					$("#1_" + idMatch + "").addClass("selectedd");
					$("#x_" + idMatch + "").removeClass("selectedd");
					$("#2_" + idMatch + "").removeClass("selectedd");
				}	
				else if(prono == "2") 	
				{		
					$("#2_" + idMatch + "").html("2");
					$("#1_" + idMatch + "").removeClass("selectedd");
					$("#x_" + idMatch + "").removeClass("selectedd");
					$("#2_" + idMatch + "").addClass("selectedd");
				}	
				else if(prono == "x") 	
				{		
					$("#x_" + idMatch + "").html("X");
					$("#1_" + idMatch + "").removeClass("selectedd");
					$("#x_" + idMatch + "").addClass("selectedd");
					$("#2_" + idMatch + "").removeClass("selectedd");
				}
			}
			else 
			{
				if(prono == "1") $("#1_" + idMatch + "").html("1");
				else if(prono == "2") $("#2_" + idMatch + "").html("2");
				else if(prono == "x") $("#x_" + idMatch + "").html("X");
				alert(leselect);
			}
		}
	});
}
function showStats(stats)
{		
	initStats();
	document.getElementById(stats).className = "div"; 
	document.getElementById(stats).innerHTML = "<div id='waitStat'></div>";
	var xhr = getXhr();
	xhr.onloading = showwaiting("waitStat");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			   
			var t = stats + "_2";		
			var tt = stats + "_3";	   
			leselect = xhr.responseText;
			if(stats == "usersRegister")
			{		   
				var tab = leselect.split("###");
				var count = tab[1]; 
				var phrase = (count > 1) ? count + " membres connect&eacute;s" : count + " membre connect&eacute;";
				var sel = tab[0];
                var width = "bl3";
			}
			else
			{	
				var phrase = document.getElementById(tt).innerHTML;	
				var sel = leselect;
                var width = "bl2";
			}	 
			document.getElementById(t).innerHTML = '<div class="' + width + '" onclick="initStats2(\'' + stats + '\', \'' + phrase + '\', \'' + width + '\')" id=\'' + tt + '\'>' + phrase + '</div><div id="' + stats + '" class="bll"></div>';
			document.getElementById(stats).className = "div";
			document.getElementById(stats).innerHTML = sel; 
			
			document.getElementById("body").onclick = checkwho;
		}
	}
	xhr.open("POST", path + "footer/statsAjax.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("show=" + stats);	  
}
function showStats2()
{		
	initStats();
	var stats = "comn";	 
	var val = document.getElementById("valComm").innerHTML;
	var phrase = document.getElementById("comn_3").innerHTML;	

	document.getElementById("comn_2").innerHTML = '<div class="bl4" onclick="initStats3(\'' + phrase + '\')" id=\'comn_3\'>' + phrase + '</div><div id="' + stats + '"></div>';
	document.getElementById(stats).innerHTML = val; 
	document.getElementById(stats).className = "div2";
	
	document.getElementById("body").onclick = checkwho2;
}
function checkwho(ev) {
	initStats();
}
function checkwho2(ev) {
	initStats3();
}
function initStats()
{			
	document.getElementById("LastComments").className = "bll"; 
	document.getElementById("LastComments").innerHTML = "";	
	document.getElementById("LastComments_2").innerHTML = '<div class="bl2" onclick="showStats(\'LastComments\')" id="LastComments_3">5 derniers commentaires</div><div id="LastComments" class="bll"></div>';		
	
	document.getElementById("usersRegister").className = "bll";
	document.getElementById("usersRegister").innerHTML = ""; 
	document.getElementById("usersRegister_2").innerHTML = '<div class="bl3" onclick="showStats(\'usersRegister\')" id="usersRegister_3">' + document.getElementById("usersRegister_3").innerHTML + '</div><div id="usersRegister" class="bll"></div>';		 
	
	document.getElementById("UsersMostPopular").className = "bll";
	document.getElementById("UsersMostPopular").innerHTML = "";	  
	document.getElementById("UsersMostPopular_2").innerHTML = '<div class="bl2" onclick="showStats(\'UsersMostPopular\')" id="UsersMostPopular_3">5 meilleurs posteurs</div><div id="UsersMostPopular" class="bll"></div>';		
		
	var count = document.getElementById("commCount").innerHTML;
	if(count != "no")
	{
		if(count == 0) 
		{
			var phrase = "Pas de nouveau commentaire";
			document.getElementById("comn_2").innerHTML = '<div class="bl4" id="comn_3">' + phrase + '</div><div id="comn"></div>';
		}
		else 
		{
			var phrase = (count > 1) ? count + " nouveaux commentaires" : count + " nouveau commentaire";
			document.getElementById("comn_2").innerHTML = '<div class="bl4" onclick="showStats2()" id="comn_3">' + phrase + '</div><div id="comn"></div>';
		}
	}
	function checkwho(ev) {}
	document.getElementById("body").onclick = checkwho;
}	
function initStats2(stats, phrase, width)
{				 
    if(width == undefined) width = "bl3";
	document.getElementById(stats).className = "bll"; 
	document.getElementById(stats).innerHTML = "";
    
	var t = stats + "_2";			                   
	document.getElementById(t).innerHTML = '<div class="' + width + '" onclick="showStats(\'' + stats + '\')" id="' + stats + '_3">' + phrase + '</div><div id="' + stats + '" class="bll"></div>';		
}	
function initStats3()
{				    
	var count = document.getElementById("commCount").innerHTML;
	if(count == 0) var phrase = "Pas de nouveau commentaire";
	else var phrase = (count > 1) ? count + " nouveaux commentaires" : count + " nouveau commentaire";
	document.getElementById("comn_2").innerHTML = '<div class="bl4" onclick="showStats2()" id="comn_3">' + phrase + '</div><div id="comn"></div>';
	function checkwho(ev) {}
	document.getElementById("body").onclick = checkwho;
}	
function verifMail(user, last, load, pseudo, dateSurPage)
{	 
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
			var reg = new RegExp("(#-#)", "g");
			var tab = leselect.split("#-#");
            if(tab[0] != "oooo")
            {
				var old = document.getElementById("commCount2").innerHTML;
			    document.getElementById("commCount").innerHTML = tab[1];  	 
			    document.getElementById("valComm").innerHTML = tab[2];  	 
			    document.getElementById("verifMail").innerHTML = tab[3];
				
				var reg = new RegExp("<div id='same_([0-9]+)'>true</div>", "g");
				if(tab[2].match(reg))
				{
					var id = RegExp.lastParen;					
					$("#same_" + id).html("");	
					
					tab[1]--;
					var count = tab[1];
					if(count > 0)
					{
						var commStats = (count > 1) ? "1 nouveau commentaire" : count + " nouveaux commentaires";
						$("#comn_2").html("<div class='bl4' onclick='showStats2()' id='comn_3'>" + commStats + "</div><div id='comn'></div>");
					}		
					else 
					{
						$("#comn_2").removeClass("rouge");
						$("#comn_2").removeClass("cursor");
						$("#comn_2").html("<div class='bl4' id='comn_3'><div id='comn'>Pas de nouveau commentaire</div></div>");
						$("#commCount").html(0);
						$("#valComm").html("");
					}
					verifComm(load, pseudo, dateSurPage, user, id);
				}
				else
				{
					if(document.getElementById("comn").className != "div2") document.getElementById("verifComm").innerHTML = tab[0];
					else
					{
						var count = tab[1];
						var phrase = (count > 1) ? count + " nouveaux commentaires" : count + " nouveau commentaire";
						document.getElementById("comn_3").innerHTML = phrase;
						document.getElementById("comn").innerHTML = tab[2];							
					}
				}
				if(old != tab[1] && tab[1] > 0) 
				{
					var diff = tab[1] - old;
					document.title = "LuxFutsal (" + diff + ")";
				}
            }	
			if(document.getElementById("usersRegister").className == "bll") document.getElementById("usersRegister_2").innerHTML = tab[4];  
			var date = new Date();
			var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
			setTimeout("verifMail(" + user + ", \"" + last + "\", \"" + load + "\", \"" + pseudo + "\", \"" + d + "\")", 30000);  
		}
	}
	
	if(document.getElementById("usersRegister").className == "bll") xhr.open("POST",  path + "footer/verif.php",true);  
    else xhr.open("POST",  path + "footer/verif2.php",true);	
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("verif=mail&userId=" + user + "&lastVisit=" + last + "&load=" + load + "&pseudo=" + pseudo + "&dateSurPage=" + dateSurPage);
}
function verifMail2()
{	 		  
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;  
			var tab = leselect.split("#-#");
	
			if(document.getElementById("usersRegister").className == "bll") document.getElementById("usersRegister_2").innerHTML = tab[4];  

			setTimeout("verifMail2()", 30000);  
		}
	}
	if(document.getElementById("usersRegister").className == "bll") xhr.open("POST",  path + "footer/verif.php",true);  
    else xhr.open("POST",  path + "footer/verif2.php",true);		
	
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("verif=mail");
}
function statsOjd(count)
{				 
	var stats = "usersRegister";
	var phrase = (count > 1) ? count + " membres connect&eacute;s" : count + " membre connect&eacute;";
			
	document.getElementById(stats).className = "div"; 
	document.getElementById(stats).innerHTML = "<div id='waitStat'></div>";
	
	var xhr = getXhr();
	xhr.onloading = showwaiting("waitStat");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;	 
			document.getElementById("usersRegister").innerHTML = leselect;	 			
			
			document.getElementById("usersRegister_2").innerHTML = '<div class="bl3" onclick="initStats2(\'' + stats + '\', \'' + phrase + '\')" id="usersRegister_3">' + phrase + '</div><div id="' + stats + '" class="bll"></div>';
			document.getElementById("usersRegister").className = "div";
			document.getElementById("usersRegister").innerHTML = leselect;  	 
		}
	}
	xhr.open("POST",  path + "footer/voirmembres.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("verif=mail");
}
function quote(id, poster)
{  
   	var xhr = getXhr();
	xhr.onloading = showwaiting("waitinggg");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
            var obj = document.getElementById("comm");
            var string = "[quote=" + poster + "]" + leselect + "[/quote]";	 
            obj.focus();
            if (typeof(document.selection) != 'undefined')
            {
                var range = document.selection.createRange();
            
                if (range.parentElement() != obj)
                  return;
            
                range.text = string;
                range.select();
            }
            else if (typeof(obj.selectionStart) != 'undefined')
            {
                var start = obj.selectionStart;
            
                obj.value = obj.value.substr(0, start)
                          + string
                          + obj.value.substr(obj.selectionEnd, obj.value.length);
            
                start += string.length;
                obj.setSelectionRange(start, start);
            }
            else obj.value += string;            
            obj.focus();	
            xhr.onComplete = hidewaiting("waitinggg");	 
			elasticTextArea("comm");			  
		}
	}
	xhr.open("POST",  path + "news/quote.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id=" + id);
}

function moveComment(article, comment)
{
    var xhr = getXhr();
	xhr.onloading = showwaiting("changeInfo[" + comment + "]");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
            document.getElementById("move[" + comment + "]").className = "text";
            document.getElementById("move[" + comment + "]").innerHTML = leselect;	
            xhr.onComplete = hidewaiting("changeInfo[" + comment + "]");	  	 
		}
	}
	xhr.open("POST",  path + "news/movecomment.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("article=" + article + "&comment=" + comment);
}
function moveComm(comment)
{
    var article = document.getElementById("moveArticleId[" + comment + "]").value;
    var xhr = getXhr();
	xhr.onloading = showwaiting("changeInfo[" + comment + "]");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
            document.getElementById("deleteComm[" + comment + "]").innerHTML = leselect;	
		}
	}
	xhr.open("POST",  path + "news/movecomment2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("article=" + article + "&comment=" + comment);
}
function fbs_click(titre, jour, mois, annee) 
{
    jour = (jour < 10) ? '0' + jour : jour;
    mois = (mois < 10) ? "0" + mois : mois;
    t = document.title;
    var haut=(screen.height-436)/2;
    var Gauche=(screen.width-626)/2;
    window.open('http://www.facebook.com/sharer.php?u=http://www.luxfutsal.be/news/' + jour + '/' + mois + '/' + annee + '/' + titre + '/&t='+encodeURIComponent(t),'sharer', 'top=' + haut + ',left=' + Gauche + ', toolbar=0,status=0,width=626,height=436');
    return false;
}
function fbs_click2(titre) 
{
    t = document.title;
    var haut=(screen.height-436)/2;
    var Gauche=(screen.width-626)/2;
    window.open('http://www.facebook.com/sharer.php?u=http://www.luxfutsal.be/prono/' + titre + '/&t='+encodeURIComponent(t),'sharer', 'top=' + haut + ',left=' + Gauche + ', toolbar=0,status=0,width=626,height=436');
    return false;
}

var essai = false;
var ajax_tooltipObj = false;
var currentTooltipObject = false;
function getButeurs(idMatch, home, away, e, inputObj, res)
{	
	if(essai == true)
	{
		$("#ajax_tooltipObj").hide();
		$("#ajax_tooltipObj").html("");
		ajax_tooltipObj.id = 'vfd';	
		contentDiv.id = 'bbfd';
		
		$('.opacity').each(function(){
			$(this).removeClass('opacity');	
		}); 		
 
		essai = false;
	}
	var currentTooltipObject = inputObj;
	if(document.all)e = event;
	
	ajax_tooltipObj = document.createElement('DIV');
	ajax_tooltipObj.id = 'ajax_tooltipObj';	
	ajax_tooltipObj.className = "buteurs";
	document.body.appendChild(ajax_tooltipObj);
		
	var contentDiv = document.createElement('DIV'); /* Create tooltip content div */
	contentDiv.className = 'body';
	ajax_tooltipObj.appendChild(contentDiv);
	contentDiv.id = 'ajax_tooltip_content';
	
	$('.resultat').each(function(){
		var flipid = $(this).attr('id');
		if(flipid != "ligne_" + idMatch) 
		{
			$("#" + flipid).addClass("opacity");	
		}
	});  
	$('.cursor').each(function(){
		$(this).removeClass('cursor');
	});	
		
	ajax_positionTooltip(e,inputObj, res);	
				
	$("#buteur2_" + idMatch).removeClass("buteur");
	showwaiting("buteur2_" + idMatch);

	if(res == "eff") var data = "id=" + idMatch + "&action=but";
	else var data = "idMatch=" + idMatch + "&home=" + home + "&away=" + away;
	
	$.ajax({
		type: "POST", url: path + "team/matchbuts.php", data: data,
		complete: function(data)
		{	
			leselect = data.responseText;
			$("#ajax_tooltipObj").hide();
			$("#ajax_tooltip_content").html(leselect);
			
			if(checkIt('msie')) $("#ajax_tooltipObj").show(500);
			else $("#ajax_tooltipObj").slideDown(500);
			
			hidewaiting("buteur2_" + idMatch);
			$("#buteur2_" + idMatch).addClass("buteur"); 
			essai = true;
			
			function checkwho(ev) {
				document.getElementById("body").onclick = checkwho2;
				$("#ajax_tooltipObj").hide();
				$("#ajax_tooltipObj").html("");
				ajax_tooltipObj.id = 'vfd';	
				contentDiv.id = 'bbfd';
				
				$('.opacity').each(function(){
					$(this).removeClass('opacity');	
				});  
				$('.foot').each(function(){
					$(this).addClass('cursor');	
				}); 
				essai = false;
			}
			function checkwho2(ev) {}
			document.getElementById("body").onclick = checkwho;
		}
	}); 	
}
function getButeursCoupe(idMatch, home, away, e, inputObj, res)
{	
	if(essai == true)
	{
		$("#ajax_tooltipObj").hide();
		$("#ajax_tooltipObj").html("");
		ajax_tooltipObj.id = 'vfd';	
		contentDiv.id = 'bbfd';
		
		$('.opacity').each(function(){
			$(this).removeClass('opacity');	
		}); 		
 
		essai = false;
	}
	var currentTooltipObject = inputObj;
	if(document.all)e = event;
	
	ajax_tooltipObj = document.createElement('DIV');
	ajax_tooltipObj.id = 'ajax_tooltipObj';	
	ajax_tooltipObj.className = "buteurs";
	document.body.appendChild(ajax_tooltipObj);
		
	var contentDiv = document.createElement('DIV'); /* Create tooltip content div */
	contentDiv.className = 'body';
	ajax_tooltipObj.appendChild(contentDiv);
	contentDiv.id = 'ajax_tooltip_content';
	
	$('.resultat').each(function(){
		var flipid = $(this).attr('id');
		if(flipid != "ligne_" + idMatch) 
		{
			$("#" + flipid).addClass("opacity");	
		}
	});  
	$('.cursor').each(function(){
		$(this).removeClass('cursor');
	});	
		
	ajax_positionTooltip(e,inputObj, res);	
				
	$("#buteur2_" + idMatch).removeClass("buteur");
	showwaiting("buteur2_" + idMatch);

	var data = "idMatch=" + idMatch + "&home=" + home + "&away=" + away;
	
	$.ajax({
		type: "POST", url: path + "team/coupebuts.php", data: data,
		complete: function(data)
		{	
			leselect = data.responseText;
			$("#ajax_tooltipObj").hide();
			$("#ajax_tooltip_content").html(leselect);
			
			if(checkIt('msie')) $("#ajax_tooltipObj").show(500);
			else $("#ajax_tooltipObj").slideDown(500);
			
			hidewaiting("buteur2_" + idMatch);
			$("#buteur2_" + idMatch).addClass("buteur"); 
			essai = true;
			
			function checkwho(ev) {
				document.getElementById("body").onclick = checkwho2;
				$("#ajax_tooltipObj").hide();
				$("#ajax_tooltipObj").html("");
				ajax_tooltipObj.id = 'vfd';	
				contentDiv.id = 'bbfd';
				
				$('.opacity').each(function(){
					$(this).removeClass('opacity');	
				});  
				$('.foot').each(function(){
					$(this).addClass('cursor');	
				}); 
				essai = false;
			}
			function checkwho2(ev) {}
			document.getElementById("body").onclick = checkwho;
		}
	}); 	
}
function ajax_positionTooltip(e,inputObj, res)
{
	if(!inputObj)inputObj = currentTooltipObject;
	if(inputObj){
		var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth);
		var topPos = ajaxTooltip_getTopPos(inputObj);
	}else{		
	   var leftPos = e.clientX;
	   var topPos = e.clientY;
	}
	
	if(res == "ojd") ajax_tooltipObj.style.left = leftPos - 679 + 'px';
	else ajax_tooltipObj.style.left = leftPos - 622 + 'px';
	
	ajax_tooltipObj.style.top = topPos + 24 + 'px';   
} 
function ajaxTooltip_getTopPos(inputObj)
{		
	var returnValue = inputObj.offsetTop;
	while((inputObj = inputObj.offsetParent) != null){
		if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
	}
	return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
	var returnValue = inputObj.offsetLeft;
	while((inputObj = inputObj.offsetParent) != null){
		if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
	}
	return returnValue;
}


function closeButeur(idMatch, home, away)
{
	document.getElementById("buteurs[" + idMatch + "]").style.display = "none";
}

function getButeurs2(i, count)
{	
	document.getElementById("buteurs[" + i + "]").style.display = "block";
	document.getElementById("buteurs[" + i + "]").onclick=checkwho;			
	function checkwho(ev) {
		closeButeur(i, count);
	}
}
function afficherPhotos()
{
	var count = getElementsByClassName("photoo", "div").length;
	var dis = document.getElementById("display").innerHTML; 

	if(dis == "none")
	{
		document.getElementById("changePhoto").innerHTML = "Cacher les photos";	
		document.getElementById("display").innerHTML = "ok";
		for(var i = 0; i < count; i++)
		{
			document.getElementById("photo[" + i + "]").style.display = "block";
		}
	}	
	else
	{
		document.getElementById("changePhoto").innerHTML = "Afficher toute les photos";	
		document.getElementById("display").innerHTML = "none";
		for(var i = 0; i < count; i++)
		{
			document.getElementById("photo[" + i + "]").style.display = "none";
		}
	}
}

function pub(id)
{	
    var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{	
		}
	}
	xhr.open("POST",  path + "sponsors.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id=" + id);
}
function showMenu(i)
{
	document.getElementById("lien[" + i + "]").className = "amenu_div";
	document.getElementById("men[" + i + "]").className = "menu_div";
}
function hiddenMenu(i)
{
	document.getElementById("lien[" + i + "]").className = "";
	document.getElementById("men[" + i + "]").className = "hidden";
}

function changeHash(hash)
{
	window.location.hash = hash;
}

function displayMessage(url, width, height)
{	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(width,height);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}
function closeMessage()
{
	messageObj.close();	
}
function inputdelete(id, val)
{
	var input = document.getElementById(id).value;
	if(input == val) document.getElementById(id).value = "";	
}
function inputblur(id, val)
{
	var input = document.getElementById(id).value;
	if(input == "") document.getElementById(id).value = val;	
}
function inputdelete2(id, val)
{
	var input = document.getElementById(id).value;
	if(input == val) document.getElementById(id).value = "";	
	$("#" + id).removeClass();
	$("#" + id + "_help").removeClass("hidden");
	$("#" + id + "_help").addClass("fleche");
}
function inputblur2(id, val)
{
	var input = document.getElementById(id).value;
	if(input == "") 
	{
		document.getElementById(id).value = val;	
		$("#" + id).addClass("vide");
	}
	$("#" + id + "_help").removeClass();
	$("#" + id + "_help").addClass("hidden");
}
function indexAjax()
{
    var xhr = getXhr();
	xhr.onloading = showwaiting("mycarousel");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
			document.getElementById("mycarousel").innerHTML = leselect;
		}
	}
	xhr.open("POST",  path + "index2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("id=5");
}
function afficheResteComm(reste, newsid, url, level, date)
{
    var xhr = getXhr();
	xhr.onloading = showwaiting("resteComm");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
			document.getElementById("tnt_pagination").innerHTML = "";			
			document.getElementById("tnt_pagination").style.height = "0px";			
			document.getElementById("reste").innerHTML = leselect;
		}
	}
	xhr.open("POST",  path + "news/restecomm.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("reste=" + reste + "&newsid=" + newsid + "&url=" + url + "&level=" + level + "&date=" + date);
}
function pagination(paged, session, last, url)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("changePage", "index");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
		
			document.getElementById("index").innerHTML = leselect;		
			xhr.oncomplete = hidewaitinggg("index");

			var el = document.getElementById("index");
			el.scrollIntoView(true);				
		}
	}
	xhr.open("POST",  path + url,true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("paged=" + paged + "&session=" + session + "&last=" + last);
}
function pagination2(paged, session, last, url, word)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("changePage", "searchh");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
		
			document.getElementById("searchh").innerHTML = leselect;		
			xhr.oncomplete = hidewaitinggg("searchh");

			var el = document.getElementById("searchh");
			el.scrollIntoView(true);				
		}
	}
	xhr.open("POST",  path + "login/" + url,true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("paged=" + paged + "&session=" + session + "&last=" + last + "&word=" + word);
}
function paginationmembre(paged, total, lettre)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("changePage", "index");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
		
			document.getElementById("index").innerHTML = leselect;		
			xhr.oncomplete = hidewaitinggg("index");
			if(lettre == "" && paged == 1) document.getElementById("titre").innerHTML = 'Liste de nos ' + total + ' membres';

			var el = document.getElementById("titre");
			el.scrollIntoView(true);	
			$(".example5").colorbox();			
		}
	}
	xhr.open("POST",  path + "members2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("paged=" + paged + "&total=" + total + "&lettre=" + lettre);
}
function changeMembre(lettre)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("waitLetter", "index");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			leselect = xhr.responseText;
		
			document.getElementById("titre").innerHTML = "Liste de nos membres commencant par la lettre : " + lettre;		
			document.getElementById("index").innerHTML = leselect;		
			xhr.oncomplete = hidewaitingg("waitLetter", "index");

			var el = document.getElementById("titre");
			el.scrollIntoView(true);		
			$(".example5").colorbox();			
		}
	}
	xhr.open("POST",  path + "members2.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("lettre=" + lettre + "&paged=1");
}
function marquerSujet(user)
{
    var xhr = getXhr();
	xhr.onloading = showwaitingg("marque", "index");
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{			 
			window.location.reload();			
		}
	}
	xhr.open("POST",  path + "marquersujet.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("user=" + user);
}
function deleteMembre(user)
{
	if(confirm("Sur de supprimer ce membre et tous ses messages ?"))
	{
		var xhr = getXhr();
		xhr.onloading = showwaiting("waitt[" + user + "]");
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200)
			{			 
				document.getElementById("membre[" + user + "]").innerHTML = "";		
				document.getElementById("membre[" + user + "]").className = "";		
			}
		}
		xhr.open("POST",  path + "deletemembre.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("user=" + user);
	}
}
function readMore(id)
{	
	showwaiting("suite_" + id)
	$.ajax({
		type: "POST", url: path + "readMore.php", data: "prono=1&id=" + id,
		complete: function(data)
		{	
			leselect = data.responseText;	
			$("#suite_" + id).removeClass();
			$("#suite_" + id).html(leselect);
			if (checkIt('msie')) $("#suite_" + id).show(1000);
			else $("#suite_" + id).slideDown(1000);
			document.getElementById("suite_" + id).onclick = "";
		}
	 });
}
function readMoreProno(id, user)
{	
	showwaiting("suiteProno_" + id)
	$.ajax({
		type: "POST", url: path + "readMore.php", data: "prono=11&id=" + id + "&user=" + user,
		complete: function(data)
		{	
			leselect = data.responseText;	
			$("#suiteProno_" + id).removeClass();
			$("#suiteProno_" + id).html(leselect);
			if (checkIt('msie')) $("#suiteProno_" + id).show(1000);
			else $("#suiteProno_" + id).slideDown(1000);
			//$("#suiteProno_" + id).click = alert('yy');
			document.getElementById("suiteProno_" + id).onclick = "";
		}
	 });
}
function index()
{
	$.ajax({
		type: "POST", url: path + "index2.php", data: "",
		complete: function(data)
		{	
			leselect = data.responseText;
			if(leselect.substr(-4) != "--no")
			{				
				$("#news1").html(leselect);
				var count = eval(document.getElementById("counttDiv").innerHTML);
				jQuery('#mycarousel').jcarousel({
					start: count, 
					scroll : 5
				});			
			}
			else
			{
				$("#news2").fadeOut();
			}
		}
	 });
}
function annif(page, el)
{
	showwaitingg("waitingAnnif", "anniff");
	$.ajax({
		type: "POST", url: path + "statsannif.php", data: "page=" + page,
		complete: function(data)
		{	
			leselect = data.responseText;
			hidewaitingg("waitingAnnif", "anniff");
			$("#anniff").hide();
			$("#anniff").html(leselect);
			$("#anniff").show();
		}
	 });	
	if(el != "") 
	{
		var el = document.getElementById(el);
		el.scrollIntoView(true);
	}
}

function resume(idNews, id)
{
	$('.rep').each(function(){
		$(".rep").html("");
	});
	document.getElementById("res2["+ idNews + "]["+ id + "]").innerHTML = "<input type='text' value='' id='resume["+ idNews + "][" + id + "]' onBlur='resume2(" + idNews + ", this.value, " + id + ")' onKeyPress='if (event.keyCode == 13) resume2(" + idNews + ", this.value, " + id + ")' />";	
	document.getElementById("resume["+ idNews + "]["+ id + "]").focus()
}
function resume2(idNews, val, id)
{
	$.ajax({
		type: "POST", 
		url: "resumeajax.php", 
		data: "val=" + val + "&id= " + id + "&idNews= " + idNews,
		complete: function(data)
		{	
			leselect = data.responseText;
			document.getElementById("rr").innerHTML = leselect;
			//document.getElementById("res2["+ idNews + "]["+ id + "]").innerHTML = "<span class='resume' href='http://www.luxfutsal.be/resume.php?idComm=" + val + "'>(RÃ©sumÃ©)</span>";
		}
	 });
}

function verifComm(load, pseudo, dateSurPage, user, id)
{	
	tab = new Array();
	tab = load.split("/");
	count = tab.length;
	var datee = tab[count-3] + "-" + tab[count-4] + "-" + tab[count-5];
	var sujet = tab[count-2];
	showwaiting("waitinggg");
	$.ajax({
		type: "POST", 
		url: path + "news/verifComm.php", 
		data: "sujet=" + sujet + "&datee=" + datee + "&last=" + dateSurPage + "&pseudo=" + pseudo + "&user=" + user + "&id=" + id,
		complete: function(data)
		{	
			leselect = data.responseText;
			tab = new Array();
			tab = leselect.split("###");
			if(tab[0] > 0)
			{
				/*var ne = document.getElementById("cou").innerHTML;
				var nee = eval(ne) + 1;	
				document.getElementById("new_" + ne).innerHTML = "<div id='new_" + nee + "'></div>";
				document.getElementById("cou").innerHTML = nee;			

				$("#new_" + ne).hide();
				document.getElementById("new_" + ne).innerHTML += tab[1]; 
				
				if (checkIt('msie')) $("#new_" + ne).show(500);
				else $("#new_" + ne).slideDown(500);*/

				$(tab[1]).hide().prependTo("#afficheComm").fadeIn("slow");				
				
				hidewaiting("waitinggg");

				if(tab[0] == 1)
				{
					var unique_id = $.gritter.add({
						title: 'Nouveau message',
						text: 'Un nouveau commentaire vient d\'Ãªtre postÃ© sur le sujet que vous Ãªtes en cours de lecture.',
						sticky: false
						//time: 10000
					});
				}
				else
				{
					var unique_id = $.gritter.add({
						title: 'Nouveaux messages',
						text: tab[0] + ' nouveaux commentaires viennent d\'Ãªtre postÃ©s sur le sujet que vous Ãªtes en cours de lecture.',
						sticky: false
						//time: 10000
					});
				}				
				//var el = document.getElementById("new_0");
				//el.scrollIntoView(true);	
			}			
		}
	});	
}




