/***
* traitements de base
* version 2.0.a2  -  10/2010
***/


$(document).ready( function() { 

	$('table tbody tr:even').addClass('paire');		// markup pair/impaire des lignes de tableaux
	$('table tbody tr:odd').addClass('impaire');

	$.scrollTable (); // scrollTable

	$('div.Doc table').tableSorter({ // tableSorter
		sortClassAsc: 'headSortDown',
		sortClassDesc: 'headSortUp',
		headerClass: 'head',
		headerExclusion: 'noSort',
		stripingRowClass: ['paire','impaire']
	});

	$('div#Search label:first-child').labelIt('classLabelIt');	// labelIt

/*
$('.slideCyclePrev').each( function( index ){ $(this).attr('id','cycle_clicPrev'+index); })
$('.slideCycleNext').each( function( index ){ $(this).attr('id','cycle_clicNext'+index); })
$('.slideCycle').each( function( index ){ $(this).attr('id','cycle_slideCycle'+index); })
*/

$('.slideCycleContainer').each( function(index){

	$(this).append('<var></var>').children().show();
	$(this).children('button:eq(0)').attr('id','cycle_clicPrev'+index);
	$(this).children('button:eq(1)').attr('id','cycle_clicNext'+index);
	$(this).children('div:eq(0)').attr('id','cycle_slideCycle'+index);

	$(this).children('#cycle_slideCycle'+index).cycle({
		prev: '#cycle_clicPrev'+index,
		next: '#cycle_clicNext'+index,
		timeout: 0,
		before: cycleOnBefore
	});

	function cycleOnBefore() { 
//		var gauche=($('.cadre').width()-this.width)/2;
		var gauche=($(this).parent().width()-this.width)/2;
		var hauteur=this.height;
		$(this)	//img
			.css('left',gauche )
			.parent().height(hauteur)	// slideCycle
			.parent().height(hauteur+40)	// Container
			.children('var').html(this.alt);	//
	}; 

});


$('.info').append('<span class="ttip" style="display:none">Plus d\'informations :</div>')
	.hover(function(){
		$(this).children('span')
		.css('display','block')
		;
	},function(){
		$(this).children('span')
		.css('display','none')
		;
	}
	)
	;

$("a[rel^='prettyPhoto']").prettyPhoto({opacity: 0.7, theme:'light_rounded'});

function getBaseURL () {	// retourne url compléte d'une page
	var result = "";

	if ( document.baseURI === undefined ) {
		var baseTags = document.getElementsByTagName ("base");
		if ( baseTags.length > 0 ) {
			result = baseTags[0].href;	// ie
		} else {
			result = window.location.href;
		}
	} else {
		result = document.baseURI;
	}
	return result;

}

function getPage ( full ) {
	if ( full === undefined ) full=getBaseURL();
	var termes = full.split("\.php");
	var result = "";

	result = termes [ 0 ];
	termes = result.split("/");
	result = termes[ termes.length -1 ];
	return result;
}

/* appel ouverture prettyPhoto si necéssaire */


});	// end jQuery


