$(document).ready(function() {
	$('ul a').collapsor({speed: 500});
	
	//----- Fonction pour document - pagination
    $(".pageSuivante").click(
		function() {
		    $("#colBb").hide();
		    documentId = $(".documentId").html();
		    pageCourante = $(".pageCourante").html();
		    pageTotal = $(".pageTotal").html();
		    
		    newPage = parseInt(pageCourante) + 1;
		    
		    $.post('/global/controls/actionRequest.aspx', 
	            { action: 'getImage', id: documentId, doc: newPage }, 
	            function(result) { 
	                $("#Lb_imageElement").html(result);
	                
	                //----- Nouvelle pagination
		            $(".pageCourante").html(newPage);
		            if (newPage>=parseInt(pageTotal)){
		                $(".pageSuivante").hide();
		            }
		            if (newPage>1){
		                $(".pagePrecedente").show();
		            }
		            
		            $("#colBb").show();
		            
		            if (!$("#contentTranscription").is(":hidden")) {
                        lancementTranscription();
                    }
		            
	                return false;
	            } 
            );
            
            
            
			return false;
		});
		
	//----- Fonction pour document - pagination
    $(".pagePrecedente").click(
		function() {
		    $("#colBb").hide();
		    documentId = $(".documentId").html();
		    pageCourante = $(".pageCourante").html();
		    pageTotal = $(".pageTotal").html();
		    
		    newPage = parseInt(pageCourante) - 1;
		    
		    $.post('/global/controls/actionRequest.aspx', 
	            { action: 'getImage', id: documentId, doc: newPage }, 
	            function(result) { 
	                $("#Lb_imageElement").html(result);
	                
	                //----- Nouvelle pagination
		            $(".pageCourante").html(newPage);
		            if (newPage<parseInt(pageTotal)){
		                $(".pageSuivante").show();
		            }
		            if (newPage==1){
		                $(".pagePrecedente").hide();
		            }
		            
		            $("#colBb").show();
		            
		            if (!$("#contentTranscription").is(":hidden")) {
                        lancementTranscription();
                    }
		            
	                return false;
	            } 
            );
            
			return false;
		});
	
		    
		    
			
		
    
    $(".transcriptionFin").click(
		function() {
		    $("#contentTranscription").hide();
		    $("#contentPage").show();
		    return false;
		});			
		
    		
});

//----- Affichage transcripteur	
function lancementTranscription(){
	    
	    documentId = $(".documentId").html();
	    pageCourante = $(".pageCourante").html();
	    pageTotal = $(".pageTotal").html();
	    
	    $.post('/global/controls/actionRequest.aspx', 
            { action: 'getTranscription', id: documentId, doc: pageCourante }, 
            function(result) { 
                var monFlash = new SWFObject("/global/swf/trans.swf?" + result, "monfilm", "700", "600", "6", "#fff");
	            monFlash.addParam("quality", "high");
	            monFlash.addParam("wmode", "opaque");
	            monFlash.addParam("salign", "t");
	            monFlash.write("contentFlash");
    		    
	            $("#contentTranscription").show();
	            
                return false;
            } 
        );
		return false;
}	
