$(document).ready(function() { 

	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
	
	$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
	
	$("#menu").lavaLamp({
		fx: "easeOutExpo",
		speed: 500,
		click: function(event, menuItem) {
			//return false;
		}
	});
	
	$("#boutLog").click(function(e) {
		e.preventDefault();
		$("#filForm").submit();
	});

	// $('.real').click(function(e) {
	// $('.real').live('click', function(e) {
	$('#realList').delegate('a','click', function(e) {
		e.preventDefault();
		var dataVar = 'id='+$(this).attr('rel');
		var urlVar = document.location+'../ajax/media.php';
		var indexVar = $("#realList a").index(this);
		$("#indice").val(indexVar);
		//alert(indexVar);
		//alert($("#indice").val());
		$.ajax({
			type: "get",
			url: urlVar,
			data: dataVar,
			success: function(msg){
				$("#realCont").hide();
				$("#realBox").hide();
				$("#realDesc").fadeOut('normal');
				$("#realBox").html(msg);
				$("#realBox").show();
			},
			complete: function(msg){
 
			},
			error: function(msg) {
				alert("Error = "+msg.responseText);
			}
		});
	});
	
	$("a.fancyBox").fancybox({
		'titleShow'     : false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'speedIn'		:	300, 
		'speedOut'		:	150
	});
	
	$("#selSuj , #selTrait").change(function(){
		var dataVar = 'idS='+$("#selSuj").val()+'&idT='+$("#selTrait").val();
		var urlVar = document.location+'../ajax/mediaList.php';
		$.ajax({
			type: "get",
			url: urlVar,
			data: dataVar,
			success: function(msg){
				$("#realList").html(msg);
				displayReal();
			},
			complete: function(msg){
				//$("#loadNew").hide(); 
			},
			error: function(msg) {
				alert("Error = "+msg.responseText);
			}
		});
	});
	
	$(".flecheG").click(function() {
		var tmp = $("#indice").val();
		tmp--;
		$("a.real:eq("+tmp+")").click();
	});
	$(".flecheD").click(function() {
		var tmp = $("#indice").val();
		tmp++;
		$("a.real:eq("+tmp+")").click();
	});
	
});
function displayReal(){
	$("a.real:first").click();
}

function changeDesc(desc){
	//$("#realDesc").hide();//alert(desc);
	$("#realDesc").html(desc);
	$("#realDesc").fadeIn('normal');
}

