

//	AFFICHER LE DOS DE LA POCHETTE DANS LE LABEL
	
	function labelOtherFace( _id_img, _face ){
		document.getElementById( 'pochette_bloc' ).innerHTML = 'chargement....';
		
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				//document.getElementById( 'pochette_bloc' ).innerHTML = xhr.responseText;
				if( _face == 'img0pochette_dos' ){
					document.getElementById( 'pochette_bloc' ).innerHTML = xhr.responseText+'<div id="pochette_view_back"><span class="btn_js" onclick="labelOtherFace( '+_id_img+', \'pochette_face\' )">Verso</span></div>';
					document.getElementById( 'pochette_view_back' ).innerHTML = '<span class="btn_js" onclick="labelOtherFace( '+_id_img+', \'img0pochette_face\' )">Recto</span>';
				}else{
					document.getElementById( 'pochette_bloc' ).innerHTML = xhr.responseText+'<div id="pochette_view_back"><span class="btn_js" onclick="labelOtherFace( '+_id_img+', \'img0pochette_dos\' )">Verso</span></div>';
					document.getElementById( 'pochette_view_back' ).innerHTML = '<span class="btn_js" onclick="labelOtherFace( '+_id_img+', \'img0pochette_dos\' )">Verso</span>';
				}
			}
		}
				
		xhr.open( "GET", URL_AJAX+'ajax_req.php?label_back='+_id_img+'&face='+_face+'', true );
		xhr.send(null);
		
	}
	

	function replierPresent(){
		$('#presentation_invisible').hide();
		$('#informations_visibles').show();
	}
	
	function depliePresent(){
		$('#presentation_invisible').show();
		$('#informations_visibles').hide();
	}

//	CONTACT 

	function add_musicien(){
		var nb = $("#nb_accompagnants").val();
		nb = parseInt( nb );
		$("#nb_accompagnants").val( ( nb + 1 ) );
		//alert( $("#nb_accompagnants").val() );
		
		$("#place_mus").after('<label id="lab_mus_'+nb+'"><input class="long_input" type="text" name="mus_acc_'+nb+'" id="mus_acc_'+nb+'" value="" /></label><input class="long_input" type="text" name="instr_acc_'+nb+'" id="instr_acc_'+nb+'" value="" /> <span id="span_del_'+nb+'" class="btn_js" onclick="del_musicien('+nb+');">-</span>');
	}
	
	function del_musicien( _id ){
		$("#lab_mus_"+_id+"").remove();
		$("#span_del_"+_id+"").remove();
		$("#mus_acc_"+_id+"").remove();
		$("#instr_acc_"+_id+"").remove();
	}

//	DIAPORAMA ACCUEIL

	function get_photo( _index ){
		$("#bloc_diapo").remove();
		$("#diaporama").load( URL_AJAX+'ajax_req.php?diapo_suite='+_index+'', function(){
				//get_photo( ( _index + 1 ) );
				$("#bloc_diapo").fadeIn( 'slow', function(){
					$("#bloc_diapo").animate({ top:0 }, 2000, function(){
								$("#bloc_diapo").fadeOut( 'slow', function(){
										get_photo( ( _index + 1 ) );
									}
								)
							}
						)
					}
				);
			}
		);
	}

//	AFFICHER LA SUITE D'UNE GALERIE
	
	function getGalerySuite( _id_gal, _depart ){

		$("#sample_gal").children().fadeOut("slow",function(){
			$("#sample_gal").load( URL_AJAX+'ajax_req.php?galerie_suite='+_id_gal+'&depart='+_depart+'' );
		});
		
		/*
		$("#sample_gal").ajaxComplete(function(request, settings){
		$(this).children().fadeIn("slow");
		});
		*/
				
	}


//	AFFICHER LE DOS DE LA POCHETTE
	
	function albumOtherFace( _id_img, _face ){
		document.getElementById( 'pochette_bloc' ).innerHTML = 'chargement....';
		
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById( 'pochette_bloc' ).innerHTML = xhr.responseText;
				if( _face == 'pochette_dos' ){
					document.getElementById( 'pochette_view_back' ).innerHTML = '<span class="btn_js" onclick="albumOtherFace( '+_id_img+', \'pochette_front\' )">Recto</span>';
				}else{
					document.getElementById( 'pochette_view_back' ).innerHTML = '<span class="btn_js" onclick="albumOtherFace( '+_id_img+', \'pochette_dos\' )">Verso</span>';
				}
			}
		}
		
		xhr.open( "GET", URL_AJAX+'ajax_req.php?pochette_back='+_id_img+'&face='+_face+'', true );
		xhr.send(null);
		
	}
	
	
	
//	AFFICHER UNE PHOTO DE LA GALERIE EN GRAND
	function viewBigPhoto( _id_photo ){
		
		$("#detail_view_photo").html( ' ' );
		
		var avant = '';
		var apres = '<div class="clear"></div>';
		
		var id_prev = $("#bloc_photo_"+_id_photo ).prev().attr( 'id' );
		if( id_prev == '' ){
			
		}else if( id_prev  != undefined ){
			id_prev = id_prev.substring( 11 )
			avant = '<div style="float:left;margin-top:20px;" class="btn_js" onclick="viewBigPhoto('+id_prev+')"><img src="/front/img/img_fle_prec.png" alt="image precedente" title="image precedente" /></div>';
		}
		var id_next = $("#bloc_photo_"+_id_photo ).next().attr( 'id' );
		if( id_next == '' ){
			var next_limite = $("#next_limite").val();
			apres = '<div style="float:right;margin-top:20px;" class="btn_js" onclick="getGalerySuite(2, '+next_limite+' )"><img src="/front/img/img_fle_suiv.png" alt="image suivante" title="image suivante" /></div>'+apres;
		}else if(  id_next != undefined ){
			id_next = id_next.substring( 11 )
			apres = '<div style="float:right;margin-top:20px;" class="btn_js" onclick="viewBigPhoto('+id_next+')"><img src="/front/img/img_fle_suiv.png" alt="image suivante" title="image suivante" /></div>'+apres;
		}
	
		$("#detail_view_photo").fadeOut("slow",function(){
			$("#detail_view_photo").load( URL_AJAX+'ajax_req.php?view_big_photo='+_id_photo+'' );
		});
		
		
		
		$("#detail_view_photo").ajaxComplete(function(request, settings){
		$(this).fadeIn("slow", function(){
				
			});
		$(this).prepend( avant );
		$(this).append( apres );
		
		avant = '';
		apres = '';
		});
	
	
	/*
	
		$("#bloc_view_photo").html( 'chargement...' );
	
		$("#bloc_view_photo").load( URL_AJAX+'ajax_req.php?view_big_photo='+_id_photo+'' );

		$("#bloc_view_photo").ajaxComplete(function(request, settings){
		  // $(this).append("<li>Request Complete.</li>");
		   //$(this).animate({height:"200px"},1000);
		 });
*/
	
	}
	
	
	
	

/*	*******************************************************************************************************	*/
/*	************************************************	AJAX	***************************************	*/
/*	*******************************************************************************************************	*/
	function getXhr(){
		var xhr = null; 
		if(window.XMLHttpRequest) // Firefox et autres
			xhr = new XMLHttpRequest(); 
		else if(window.ActiveXObject){ // Internet Explorer 
			try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}else {
				window.alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				xhr = false; 
		} 
		return xhr
	}