
$(function(){

	// segment du travail : liens dans le sommaire
	$('#sommaire a').each(function() {
		// Ajout d'un travail ˆ un evenement
		$(this).click(function(event) {
        	if ( $(this).attr("rel").length>0 ) {
        		var linkHref = '#'+$(this).attr("rel");
        		$(this).attr('href', linkHref );
        		$(this).href="#"+$(this).attr("rel"); // on assign un nouveau lien
        	}
		});
	});

    $('#liste_chapitre_haut').change(function(){ document.location = $(this).val(); });
    $('#liste_chapitre_bas').change(function(){ document.location = $(this).val(); });


    /*
    FUNCTIONS to expand content ___________________ */
    /*
    $('dt .expanding').click( function(){
        doToogleEffect($(this)); 
        return false;
    }) ;*/


    /*
    FUNCTIONS to epxand results above article ___________________ */
    $('#sujet .showmore a').click(function(){$('#sujet .more_sujet').show() ;$('#sujet .showmore').hide() ;return false;});
    $('#media .showmore a').click(function(){$('#media .more_media').toggle("slow") ;$('#media .showmore').hide() ;return false;});
    
    // Sujets
/*    $('#sujet .showmore a').click(function(){
        // Prepare display
        displayLoader('#sujet_content'); // display loading image ...
        $('#sujet .showmore').hide() ; // remove "see more" link

        var sRef = $(this).attr('rel') ;
        var aRef = sRef.split('_') ;

        // Call ajax
        //tx_eu_getExtraContent( '<xjxquery><q>&tx_eu[nref]='+$(this).attr('rel')+'&tx_eu[div_id]=sujet</q></xjxquery>' ) ;
        tx_eu_getExtraContent('n', aRef[0], 'd', 'sujet', 'napp', aRef[1] ) ;
        return false;
    });
*/
    

    // Medias
/*
    $('#media .showmore a').click(function(){
        // Prepare display
        displayLoader('#media_content'); // display loading image ...
        $('#media .showmore').hide() ; // remove "see more" link

        // Call ajax
        //tx_eu_getExtraContent( '<xjxquery><q>&tx_eu[nref]='+$(this).attr('rel')+'&tx_eu[div_id]=media</q></xjxquery>' ) ;
        tx_eu_getExtraContent('n', $(this).attr('rel'), 'd',  'media') ;

        return false;
    });
*/

    // Articles
    $('#articles .showmore a').click(function(){
        // Prepare display
        displayLoader('#article_content'); // display loading image ...
        $('#articles .showmore').hide() ; // remove "see more" link
        
        // Call ajax
        tx_eu_getExtraContent('n', $(this).attr('rel'), 'd',  'article') ;

        return false;
    });

    // Themes
    $('#themes .showmore a').click(function(){

        // Prepare display
        displayLoader('#themes_content'); // display loading image ...
        $(this).hide() ; // remove "see more" link

        // Call ajax
        //tx_eu_getExtraContent( '<xjxquery><q>&tx_eu[nref]='+$(this).attr('rel')+'&tx_eu[div_id]=themes</q></xjxquery>' ) ;
        tx_eu_getExtraContent('n', $(this).attr('rel'), 'd',  'themes') ;

        return false;
    });
});



function updateExtraContent(ps_divID) {
    $("#"+ps_divID+" p.showmore").after('<div id="'+ps_divID+'Extra"></div>');
}

function displayLoader(ps_idElement) {
    $(ps_idElement).html('<div class="center"><img src="/commun/images/facebox/loading.gif" alt="" /></div>') ;
}

function doAjaxToogleEffect() {
/*
    $("dt .expanding").unbind("click");
    $('dt .expanding').click( function(){
        doToogleEffect($(this)); 
        return false;
    }) ;
*/
}

function doToogleEffect(po_this) {
/*
    var oNext = $(po_this.parent('dt')).next() ;
    oNext.toggle();

    // change background image
    if ( po_this.css('background-position')=='0px 4px' ) {
        po_this.css('background-position', '-9px 4px') ;
    }
    else {
        po_this.css('background-position', '0px 4px') ;
    }

    return false ;
*/
}

