$(document).ready(function(){
	
/*tabs de la homepage + Page recrutement_carriere/carrieres_envisageables*/
	$("#bloc1 ul").idTabs("!mouseover"); 
	$("#bloc2 ul").idTabs("!mouseover"); 
	$("#bloc3 ul").idTabs("!mouseover"); 

/*Remove inputValue onfocus and recall default inputValue onblur*/
	$('input, textarea', '#research').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
	});
	$('input, textarea', '#research').blur(function() {
		if($(this).val()=="") {
			$(this).val(value);
		}
	});
	
// Lightbox
	$(function() {
        $('.lightbox').lightBox();
    });
    
//jCarousel
	$('#carousel').jcarousel({
		scroll: 5
	});
	$('#carousel a').click(function(){
		$('#imagecarousel img').attr('src', this.href);
		return false;	
	});
	
//Accordion
    $("#acc1").accordion({
    	active: true,
    	alwaysOpen: false,
		autoheight: false,
		collapsible: true
	});	
	$("#rightlinksAcc").accordion({
		active: true,
		autoheight: false,
		navigation: true,
		header: '.acc2'
	});
	$("#rightlinksAccVideo").accordion({
		active: true,
		autoheight: false,
		navigation: true,
		header: '.acc3'
	});
	
	// formulaire d'inscription online
	$('input[name=selection]').click(function(){
		  var selection_value = $(this).filter(':checked').val();
		  if(selection_value == "Oui"){
			  $('.selectioninfo').slideDown();
		  } else if(selection_value == "Non") {
			  $('.selectioninfo').slideUp();
		  }
	  }).trigger('click');


	  
	(function($){
	$.fn.jMenu = function(){		
		$this=$(this);
		widthOpen=398;
		selected='selected';
		e = this.find('>div>a');

		$.fn.close = function(){	
			this.animate({width:99}).removeClass(selected);
		}
		$.fn.open = function(){
			this.animate({width:widthOpen}).addClass(selected);
		}

		return e.each(function(){
			$(this).bind('click', function(){
				thisSel = $(this).parent().css('width')=='398px';
				oSel = $this.find('.selected div');
				if(oSel.length)	oSel.parent().close();
				if(!thisSel) $(this).parent().open();
				return false;
			});
		});
	}

// Datepicker
        var frenchLocale = { closeText: 'Fermer',
                             prevText: '&#x3c;Préc',
                             nextText: 'Suiv&#x3e;',
                             currentText: 'Courant',
                             monthNames: 
['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
                             monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun','Jul','Aoû','Sep','Oct','Nov','Déc'],
                             dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
                             dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
                             dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
                             weekHeader: 'Sm',
                             dateFormat: 'dd-mm-yy',
                             firstDay: 1,
                             isRTL: false,
                             showMonthAfterYear: false,
                             yearSuffix: ''};
        $( '#date_deb' ).datepicker( frenchLocale );
        $( '#date_end' ).datepicker( frenchLocale );
		
	//Auto-run 
  	$(function(){ $('#grade').jMenu(); });	
	})(jQuery);
	
	
	
});

$(window).bind('load', function() {
	$('#scroll1, #scroll2, #scroll3, #scroll4').jScrollPane({showArrows:true});
});



//Search
var initSearch = '';

function onFocusSearch( id ){
	if ( document.getElementById('search').value == initSearch ) document.getElementById('search').value = '';
}

function onBlurSearch( id ){
	if ( document.getElementById('search').value == '' ) document.getElementById('search').value = initSearch;
}


