$(document).ready(function(){
	
	// HOVER du bouton submit de recherche des concours
	$('input.submitVF').hover(function() {
		$(this).addClass('survolsubmitVF');
    },
	function() {
    	$(this).removeClass('survolsubmitVF');
	});
	
	// Défilement du texte des forums
	// basic version is: $('marquee').marquee() - but we're doing some sexy extras
    //$('marquee').marquee();
	
	$('marquee').marquee('pointer').mouseover(function () {
		$(this).trigger('stop');
	}).mouseout(function () {
		$(this).trigger('start');
	}).mousemove(function (event) {
		if ($(this).data('drag') == true) {
			this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
		}
	}).mousedown(function (event) {
		$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
	}).mouseup(function () {
		$(this).data('drag', false);
	});
	
	
	// sliding tab menu fiches-concours / en direct / en bref
	//Get the height of the first item
	//$('#mask').css({'height':$('#panel-1').height()});	
	$('#mask').css({'height':$('#panel-2').height()});	
	
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div').width($('#mask').width());
	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();
		
		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');
		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});
	
	
	
	// sliding tab menu du sommaire : edito / à la une / pratique / forum
	//Get the height of the first item
	var numLow = 1;
	var numHigh = $("#panel-sommaire div.panoJQ").length;
	var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;
	var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow);
	
	$('#mask-sommaire').css({'height':$('#panel-'+numRand+'-sommaire').height()});
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel-sommaire').width(parseInt($('#mask-sommaire').width() * $('#panel-sommaire div').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel-sommaire div').width($('#mask-sommaire').width());
	
	$('#mask-sommaire').scrollTo($("#panel-"+numRand+"-sommaire"), 0);
	$('a[rel=panel-sommaire]').removeClass('selected');
	$('#pan'+numRand+'sommaire').addClass('selected');	
	
	//Get all the links with rel as panel
	$('a[rel=panel-sommaire]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();
		
		//Set class for the selected item
		$('a[rel=panel-sommaire]').removeClass('selected');
		var idCherche = $(this).attr('href').substring(7,8);
		$('#pan'+idCherche+'sommaire').addClass('selected');
		
		//Resize the height
		$('#mask-sommaire').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask-sommaire').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});
	


});
