var em_user_value = "Nom d'utilisateur";
var em_pass_value = "Mot de passe";

$('#em_user').val(em_user_value);
$('#em_user').css("color", "#bbbbbb");
$('#em_pass').val(em_pass_value);
$('#em_pass').css("color", "#bbbbbb");
$('#em_user').focus(function () {
	if ($(this).val() == em_user_value) {
		$(this).val("");
		$(this).css("color", "#ffffff")
	}
});
$('#em_user').blur(function () {
	if ($(this).val() == "") {
		$(this).val(em_user_value);
		$(this).css("color", "#bbbbbb")
	}
});
$('#em_pass').focus(function () {
	if ($(this).val() == em_pass_value) {
		$(this).val("");
		$(this).css("color", "#ffffff")
	}
});
$('#em_pass').blur(function () {
	if ($(this).val() == "") {
		$(this).val(em_pass_value);
		$(this).css("color", "#bbbbbb")
	}
});
function pageLoaded() {}
function emConnect() {
	$('#emForm').submit()
}
function showSmileys() {
	$('#smiley').show(500);
	$('#colors').hide(200);
}
function showColors() {
	$('#colors').show(500);
	$('#smiley').hide(200);
}
function objectVote(objectId, objectType, showVoted) {
	if(typeof(showVoted) == 'undefined') {
    showVoted = true;
  }
  $.post("ajax.php", {
		id: objectId,
		type: objectType
	}, function(data) {
		$("#vbtn_" + objectId).html(data);
    if(showVoted) {
      $("#tbtn_" + objectId).html("a vot&eacute;")
    }
	})
}
function changePage(a, b, c) {
	page = $(a).val();
	if (!page) page = '1';
	window.location.href = b + c + page
}

var menuTimer;

function menuHide() {
  $('#jeux_cadre').hide();
  clearTimeout(menuTimer);
}

function musicPlay(id) {
  $.ajax({
		url: "loader/music-gallery," + id,
		dataType: "json",
		success: function(data) {
			startMusicGallery(data);
		}
	});
	$.ajax({
    url: "loader/music," + id,
    dataType: "html",
    success: function(data) {
      $("#music_player_container").html(data);
    },
    error: function() {
      alert("Une erreur s'est produite durant le chargement de la musique, veuillez réessayer plus tard.");
    }
  });
}

$(document).ready(function() {
  $('.menu .jeux a').bind('mouseover', function() {
    $('#jeux_cadre').show();
    clearTimeout(menuTimer);
  });
  $('#jeux_cadre').bind('mouseover', function() {
    $('#jeux_cadre').show();
    clearTimeout(menuTimer);
  });
  $('.menu .jeux a').bind('mouseout', function() {
    clearTimeout(menuTimer);
    menuTimer = setTimeout(menuHide, 400);
  });
  $('#jeux_cadre').bind('mouseout', function() {
    clearTimeout(menuTimer);
    menuTimer = setTimeout(menuHide, 400);
  });
  
  $('.music_binder').bind('click', function() {
    var id = $(this).attr('id').split('_');
    musicPlay(id[1]);
    $('.current_song').html($(this).find('.libel').html());
  });
});
