	$(document).ready(function() {
	
		$('.loading').click(function() {
			$('#loader').fadeIn(20);
		});
		
		$('#saving').click(function() {
			$('#save').submit();
		});
	
		
	
	});

	function sendForm( id ) {
		$('#loader').fadeIn(20);
		$('#save_'+id).submit();
	}
	
	function enter() {
		$('#popup').fadeOut('100');
		$('#popup_layout').fadeOut('100');
		$.cookie("disclaimer", "1", { expires: 1, path: '/' });
		//$('body').css('overflow', 'auto');
	}
	
		
	function del( url, id ) {
			
		y = confirm("Souhaitez-vous supprimer cet element ?");
		
		if (y == true) {
			ajaxDelete( url, id );
		} 
		
		return;
	}
	
	function openSend( id ) {
		
		if( $('#hiddenMessage_' + id).css('height') == '30px' ) {
			
			$('#submit_' + id).slideDown(function() {
				$('#hiddenMessage_' + id).css('height', 'auto');	
			});
			
		} else {
			
			$('#submit_' + id).slideUp(function() {
				$('#hiddenMessage_' + id).css('height', '30px');	
			});
		
		}
		
	}
	
	function openReplies( id ) {
		$('#replies_' + id).toggle();
	}	
	
	function ajaxDelete( uri, id ) {
		
		$('#loader').fadeIn(20);
		jQuery.ajax({
         	type: 'GET',
            url: uri+'&request=1',
            timeout: 3000,
            error: function() {
				$('#loader').fadeOut(20);
            },
            success: function(r) {  
				$('#loader').fadeOut(20);
            	$('#item_' + id).fadeOut();
            }
		 });
	}
	
	function ajaxPosition( uri, id, mode, redirect ) {
		
		$('#loader').fadeIn(20);
		jQuery.ajax({
         	type: 'GET',
            url: uri+'&request=1&position='+mode,
            timeout: 3000,
            error: function() {
				$('#loader').fadeOut(20);
            },
            success: function(r) {  
				$('#loader').fadeOut(20);
				location.href = redirect;
            }
		 });
	}
