// JavaScript Document


$(function(){
		   
	$(".suba").hover(function() {
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
		
		$(this).parent().hover(function() {  
		}, function(){  
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
		}); 
		
		//Following events are applied to the trigger (Hover events for the trigger)  
		}).hover(function() {  
			$(this).addClass("subhover"); //On hover over, add class "subhover"  
		}, function(){  //On Hover Out  
			$(this).removeClass("subhover"); //On hover out, remove class "subhover" 
			
	});
	
	
	$('#defaultCountdown').countdown({until: $.countdown.UTCDate(+2, 2011, 10 - 1, 28)}); 
	 
	$('#removeCountdown').toggle(function() { 
			$(this).text('Re-attach'); 
			$('#defaultCountdown').countdown('destroy'); 
		}, 
		function() { 
			$(this).text('Remove'); 
			$('#defaultCountdown').countdown({until: newYear}); 
		} 
	);
	
	$().piroBox_ext({
		piro_speed : 750,
		bg_alpha : 0.5,
		piro_scroll : true // pirobox always positioned at the center of the page
	});
	
	var windowSize = $(document).width();
	var initposConnect = windowSize/2 - 106;
	var initposRightHeader = (windowSize - 960 + 10)/2;
	$('#modalBoxConnect').css('right',initposConnect+'px');
	$('#rightHeader').css('right',initposRightHeader+'px');
	
	$('#connect').click(function(){
		$('#modalBoxCache').fadeIn();
		var windowSize = $(document).width();
		var posConnect = windowSize/2 - 106;
		$('#modalBoxConnect').fadeIn(200).animate({top:'100px', right:posConnect+'px'}, 750, 'easeOutBounce');
	});
	
	$(document).keydown(function(event){
		if (event.keyCode == '27') {
			$('#modalBoxCache').fadeOut();
			$('#modalBoxConnect').fadeOut().animate({top:'-180px'}, 150);
		}
	});
	
	$('#modalBoxCache').click(function(){
		$(this).fadeOut();
		$('#modalBoxConnect').fadeOut().animate({top:'-180px'}, 150);
	});
   
	$('.scrollPage').click(function() {
		var elementClicked = $(this).attr("href");
		var destination = $(elementClicked).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 750 );
		return false;
	});
	
	$('#autreVersions').change(function(){
		if ($('#autreVersions').is(':checked')) { $('#autreVersionsInput').fadeIn(); } else { $('#autreVersionsInput').fadeOut(); }
	});
	
	$(function() {		
		$( "#datePicker" ).datepicker({ 
			dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
			monthNames: ['Janvier','F&eacute;vrier','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','D&eacute;cembre'],
			monthNamesShort: ['Jan','F&eacute;v','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','D&eacute;c'],
			firstDay: 1,
			dateFormat: 'dd-mm-yy',
			maxDate: '-10y',
			minDate: '-100y',
			defaultDate: '-18y',
			changeMonth: true,
			changeYear: true
		});
	});
	
});
  
  
