/*
scripts communs
*/

$(document).ready(function() {
  $("body").append('<div id="legende"><div id="texteleg">&nbsp;</div></div>');

  $("a").each(function(){
    $(this).attr("xtitle",this.title);
//    $(this).attr("title","");
    this.title="";
  });
  var fenh = $(window).width();
  var fenv = $(window).height();
  $('#texteleg').html("&nbsp;");
  $('#legende').css("display", "none");
  $().mousemove(function(e){
    if((e.pageX + 120 >= fenh)) {
      l = e.pageX - 60;
    }
    else l = e.pageX + 10;
    $('#legende').css("left", l);
    if((e.pageY + 60 >= fenv)) h = e.pageY - 30;
    else h = e.pageY - 50;
    $('#legende').css("top", h);
  });
  $("a").mouseover(function(){
    $('#texteleg').html("&nbsp;");
    if ($(this).attr("xtitle")) {
      $('#texteleg').html($(this).attr("xtitle"));
      $('#legende').css("display", "block");
    }
  });
  $("a").mouseout(function(){
    $('#legende').css("display", "none");
    $('#texteleg').html("");
  });
});

function inscription() {
	pseudo = document.connexion.utilisateur.value;
	passe = document.connexion.motdepasse.value;
	valid = document.connexion.validation.value;
    $.get('connect.php?', {
    	action: "connex",
        pseudo: pseudo,
        passe: passe,
		valid: valid
    }, function(data) {
		if (data.substr(0,1) == 1) {
			retour = data.substring(2, data.length);
            $('#remarque').html("erreur de connection : " + retour);
		}
		else {
			$("#cnx").html(data);
			tb_remove();
		}
    });
	return;
}

function deconnexion() {
    $.get('connect.php?', {
		action: "deconex"
    }, function(data) {
		if (data.substr(0,1) == 1) {
			retour = data.substring(2, data.length);
            $('#remarque').html("erreur : " + retour);
		}
		else {
			$('#cnx').html(data);
			tb_remove();
		}
    });
	return;
}

    $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
