function ChangerStatut(Statut)
	{
	document.getElementById('SaveStatut').src='petit-loading.gif';
	setTimeout("ChangerStatut2('"+Statut+"')", 10);
	}
function ChangerStatut2(Statut,tmp)
	{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	fichier='statut_action_save.php?Statut='+Statut;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);

	document.getElementById('SaveStatut').src='OK.png';
//	alert('OK');
};
function PrevenirModo(typealerte,idobgj,msguser)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	fichier='AJAX_ModoProfil.php?Obj='+typealerte+'&Id='+idobgj+'&Msg='+msguser;
	
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	alert('OK');
};
function BOOST()
{
	document.getElementById('boutonboost').disabled=true;
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);

	if ($("#boutonboost").val()==$("#boost").val()) 
		{
    fichier='page_action_boost.php';
	  $("#boutonboost").val($("#deboost").val());
    }
  else
    {
    fichier='page_action_deboost.php';
    $("#boutonboost").val($("#boost").val());
    }	

	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	document.getElementById('boutonboost').disabled=false;
};
function Moderation(type,objet1,objet2)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	fichier='AJAX_ModerationProfil.php?type='+type+'&objet1='+objet1+'&objet2='+objet2;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
//	alert(fichier);
	$.modal.close();
	$('.mododiv').slideUp('normal');
//	location.reload(); 
};
function SPAM(id,exp)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	fichier='AJAX_SPAM.php?id='+id+'&exp='+exp;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	
	$('.spamdiv').slideUp('normal');
};
function VoteModeration(id,vote)
{
	$('#btn'+id).slideUp('normal');
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);

	fichier='AJAX_VoteModeration.php?id='+id+'&vote='+vote;
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
};
function radiovalue()
{
var radioType = document.getElementsByName("typemoderation");
var checked = false;
for (var cpt = 0 ; (cpt < radioType.length) && !checked ; cpt++) 
	if (radioType[cpt].checked) checked=radioType[cpt].value;
return(checked);
};
function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	while (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
    	theForm[z].checked = theElement.checked;
		z++;
	}
};
function insertsmiley(montag,ouInsere) {
	txtDefaut="";
	description="";

	//couleur ou boîte de dialogue :	
	msg="";

	text1=' '+montag+' '; //tag d'ouverture

//	if(!tt)
		{ // initialisation
		tt=document.getElementById(ouInsere);
		moz=tt.selectionStart || tt.selectionStart == 0 ? 1 : 0; // Moz 1.6+, Firefox
		ie= document.selection ? 1 : 0; // IEWin, Opéra
		}
	tt.focus();

	// sélection de texte :
	txt =	moz ? tt.value.substring(tt.selectionStart, tt.selectionEnd):
			ie ? document.selection.createRange().text: '';

	if (ie) {
			var sel=document.selection.createRange();
			//remplace le contenu du textarea
			sel.text = text1 + txt
			sel.select(); //place le curseur juste après text2
		}
	else if (moz) {
			debut = tt.value.substring(0,tt.selectionStart);
			fin = tt.value.substring(tt.selectionEnd, tt.value.length);
			contenuScrollTop=tt.scrollTop; //sauve le scroll
			//remplace le contenu du textarea
			tt.value = debut + text1 + txt + fin;
			//place le curseur comme IE
			tt.selectionEnd=tt.selectionStart=(debut + text1 + txt ).length;
			//empèche le scroll
			tt.scrollTop=contenuScrollTop;
			}
	else { // anciens navigateurs, curseur à la fin de la fenêtre d'édition
		tt.value=tt.value + text1 ; 
		}

text=tt.value;
};
function CheckMP()
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);

	fichier='AJAX_HasNewMP.php';

	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);

	if(xhr_object.readyState == 4) 
		mp=xhr_object.responseText;
	else 
		return(false);

	if (mp<1)
		document.getElementById('alerteNewMP').innerHTML ="";
	else		
		document.getElementById('alerteNewMP').innerHTML = "&nbsp;<a href='vue_messages_recus.php'><span class=ColorSurligne style='background:yellow;'><blink>(+"+mp+")</blink></span></a>";

	setTimeout("CheckMP()",360*1000); // a mettre en corrélation avec les autres pages chat
};
function MAJDoublons(Id)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);

	fichier='AJAX_MAJDoublons.php?Id='+Id;

	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);

	if(xhr_object.readyState == 4) 
		mesdoublons=xhr_object.responseText;
	else 
		return(false);

if (mesdoublons!='') document.getElementById('doublon').innerHTML="<option value=''>"+mesdoublons;
};
function dateChanged(calendar) {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked) {
      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth()+1;     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
      window.location = "vue_sortie_day.php?y=" + y + "&m=" + m + "&d=" + d;
    }
 };
function faitrien(){};

$(document).ready (function(){
	// JRT: POUR LE TEXTAREA
	$('textarea.expanding').autogrow();

	// JRT: POUR LE SCROLL
	//borrowed from jQuery easing plugin
	//http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
		
	//by default, the scroll is only done vertically ('y'), change it to both.
	$.scrollTo.defaults.axis = 'xy'; 			
	//this one is important, many browsers don't reset scroll on refreshes
	//$('div.pane').scrollTo( 0 );//reset all scrollable panes to (0,0)
	//$.scrollTo( 0 );//reset the screen to (0,0)
	
	//SLIDE, shows how to scroll the whole window
	$('div.jeslide a').click(function(){
		//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
//		$.scrollTo( this.hash, 8000, { easing:'elasout' });
			$.scrollTo( this.hash, 800);
		return false;
	});

	$('#jeslide a').click(function(){
		//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
//		$.scrollTo( this.hash, 8000, { easing:'elasout' });
			$.scrollTo( this.hash, 800);
		return false;
	});

	$('#affcachecomm').click(
	function()
	 {
	  if ($("#affcachecomm").val()==$("#cache").val()) 
      {
      $('.secache').hide();
		  $("#affcachecomm").val($("#affiche").val());
      }
    else
      {
      $('.secache').show();
      $("#affcachecomm").val($("#cache").val());
      }
    }   
	);
	$('.moderation').click(function (e) {
		$('#basic-modal-content').modal();
		  return false;
	});
});