function iescroll (){
		document.getElementById("popup").style.position = "absolute";		
		window.onscroll = function()
		{
				//compatible avec certains doctypes
				var scrollTop = document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
				document.getElementById("popup").style.top = (scrollTop + hautfen) + "px";

		}
}

function Close_popup(){
	document.getElementById('popup').style.display='none';
	if (isIE == 0) document.getElementById('popup_fond').style.display='none';
}

function switcharg(rep){  
	if(document.getElementById){
        if (isIE == 1) var elt=document.getElementById('chargement');
		else var elt=document.getElementById('chargement2');
        if(rep == true){ 
                elt.style.display = "block";
        }
        else{
                elt.style.display = "none";
        }
    }
}

function popup(titre,contenu){  
	if(document.getElementById){
		var obj = document.getElementById('popup');
		obj.style.top = hautfen + "px";
		obj.style.left = leftfen + "px";
		obj.style.display = "block";
		if (isIE == 0) document.getElementById('popup_fond').style.display = "block";
		//fade(0);
		document.getElementById('popup_titre').innerHTML = titre;
		document.getElementById('popup_contenu').innerHTML = contenu;
	}
	if (isIE == 1){
		var scrollTop = document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
		document.getElementById("popup").style.top = (scrollTop + hautfen) + "px";
	}
}

var req_login = new AJAX();
req_login.setIndicatorFunction(switcharg);
req_login.setCallbackFunction(login_submit);

function login_check(){
	if(req_login.ready == true){
		document.getElementById('errlogin').style.display = "";
		req_login.getFilePost("ajax_login.php", "pseudo="+escape(document.login.pseudo.value).replace(/\+/g,"%2B")+"&mp="+escape(document.login.mp.value).replace(/\+/g,"%2B"));
	}
}

function login_submit(res_check){
	if(res_check == '0') document.login.submit();
	else {
		document.getElementById('errlogin').style.display = "block";
	}
	 
}

// Drag and drop

function $(strId){
    return document.getElementById(strId);
}

curX = 0;
curY = 0;
curScrollX = 0;
curScrollY = 0;


function getCursor(e){
  e = e || window.event;
  curX = e.clientX; 
  curY = e.clientY;
}

function getScrollCursor(e){
  e = e || window.event;
    curScrollX = (e.pageX)? e.pageX : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    curScrollY = (e.pageY)? e.pageY : e.clientY + document.body.scrollLeft + document.documentElement.scrollTop;
}

function getMove(e){
  getCursor(e);
  getScrollCursor(e);
}

function dragAndDrop(){
var toMove = $('popup');
var toDrag = $('popup_haut');
var isDragging = false;
iebug = true;
var ecartX;
var ecartY;
 
    if(toMove){
         
    document.onmousemove = function(e){
      if(iebug == true){
      getMove(e);}
      if(isDragging == true){
        toMove.style.left = (curScrollX - ecartX)+'px';
            toMove.style.top = (curScrollY - ecartY)+'px';
          }
    }

    toDrag.onmousedown= function(){
      isDragging = true;
      ecartX = curScrollX - toMove.offsetLeft;
      ecartY = curScrollY - toMove.offsetTop;
      document.onmousedown = function(e){return false};
      document.onselectstart = new Function ("return false");
    } 

    toDrag.onmouseup=function(){
      isDragging = false;
      document.onmousedown = function(e){return true};
      document.onselectstart = new Function ("return true");
    }

  }
}

function AJAX() {
	
	this.xhr_object    = null;
	this.response      = null;
	this.ready         = true;
	this.asynchronous  = true;
	this.autovalidate  = false;

	if (typeof XMLHttpRequest == "undefined")
	  XMLHttpRequest = function() {
		try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e) {};
		try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e) {};
		try { return new ActiveXObject("Msxml2.XMLHTTP"); }     catch(e) {};
		try { return new ActiveXObject("Microsoft.XMLHTTP"); }  catch(e) {};
	 
		throw alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	  };
	this.xhr_object = new XMLHttpRequest(); 

	this.indicatorFunction = null;

	this.setIndicatorFunction = function(func) {
		if(typeof(func) == "function") this.indicatorFunction = func;
	}

	this.callbackFunction = null;

	this.setCallbackFunction = function(func) {
		if(typeof(func) == "function") {
            this.callbackFunction = func;
            this.autovalidate     = true;
        }
	}

	this.setSynchronous = function() {
		this.asynchronous = false;
	}

	this.setAsynchronous = function() {
		this.asynchronous = true;
	}

	this.getFileGet = function(url, data) {
		return this.doRequest(url, "GET", data);
	}

	this.getFile = this.getFileGet;
	
	this.getFilePost = function(url, data) {
		return this.doRequest(url, "POST", data);
	}

	this.getFileHeader = function(url, header) {
		return this.doRequest(url, "HEAD", header);
	}

	this.doRequest = function(url, method, data) {

		if(!this.ready || !this.xhr_object) return false;

		function _getResponseHeader(headers, header_name) {
			var tmp = headers.split("\n");
			for(var i=0, n=tmp.length, t=[]; i<n-1; ++i) {
				t = tmp[i].split(": ");
				if(t[0].toLowerCase() == header_name.toLowerCase()) return t[1];
			}
			return "Header inconnu...";
		}

		if(this.indicatorFunction) this.indicatorFunction(true);
		this.ready = false;

		var obj = this;
		function onreadystatechangeFunction() {
			if(obj.xhr_object.readyState != 4) return;
			
			if(obj.indicatorFunction) obj.indicatorFunction(false);

			var all_headers = obj.xhr_object.getAllResponseHeaders();
			if(method == "HEAD") {
				obj.response = data ? _getResponseHeader(all_headers, data) : all_headers;
			}
			else {
				var content_type = _getResponseHeader(all_headers, "Content-Type");
				if (content_type != "Header inconnu..." && (new RegExp("^text/xml.*$", "gi")).test(content_type))
					obj.response = obj.xhr_object.responseXML;
				else {
					if(obj.xhr_object.status != 200 && obj.xhr_object.status != 304) alert("Une erreur " + obj.xhr_object.status + " est survenue, le serveur a detecté un problème dans les données transmises. Modifiez vos données ou bien contactez nous via la page contact si vous pensez que ces données sont correctes."); 
					obj.response = obj.xhr_object.responseText;
				}
				if (obj.callbackFunction) {
                    obj.callbackFunction(obj.xhr_object.responseText);
                    if (obj.autovalidate) obj.validateRequest();
                }
			}
		}

		if(method == "GET" && typeof(data) != "undefined" && data != "") url += "?"+data;
		this.xhr_object.open(method, _AJAX_addDummyData(url), this.asynchronous);

		if(this.asynchronous)
			this.xhr_object.onreadystatechange = onreadystatechangeFunction;
		
		if(data) this.xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		else     data = null;
		this.xhr_object.send(data);

		if(!this.asynchronous)
			onreadystatechangeFunction();

		return true;
	}

	this.hasResponse = function() {
		return this.response != null;
	}

	this.getResponse = function() {
		return this.response;
	}

    this.setAutoValidate = function(flag) {
        this.autovalidate = flag;
    }

	this.validateRequest = function() {
		this.ready    = true;
		this.response = null;
	}

	this.cancelRequest = function() {
		this.xhr_object.abort();
		if(this.indicatorFunction) this.indicatorFunction(false);
		this.validateRequest();
	}
}

function _AJAX_addDummyData(str) {
	var t = new Date();
    if (str.indexOf("?") == -1) str += "?ajax_dummy=";
    else                        str += "&ajax_dummy=";
	return str+t.getTime();
}