// JavaScript Document

$(document).ready(function() {
  	$('.btnGray').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('#lang_sel_list li').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('.popupCalendar').click(function() {							
		wichLink = $(this).children('h2').children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('#nav li').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('#featureZone h2').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('#comingShow h2').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});	
  	$('.savoirPlus').click(function() {							
		wichLink = $(this).children('a');
		window.location.href=(wichLink.attr("href"));
	});		
	$('.galerie').lightBox();
    $('#cStyle').calendarLite({
        showYear: true,
        prevArrow: '&nbsp;',
        nextArrow: '&nbsp;',
        months: ['Janvier', 'F&eacute;vrier', 'Mars', 'Avril', 'Mai', 'Juin',
                 'Juillet', 'Ao&ucirc;t', 'Septembre', 'Octobre', 'Novembre', 'D&eacute;cembre'],
        days: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
    });
    $('#cStyleEn').calendarLite({
        showYear: true,
        prevArrow: '&nbsp;',
        nextArrow: '&nbsp;',
        months: ['January', 'February', 'March', 'April', 'May', 'June',
                 'July', 'August', 'September', 'October', 'Noevember', 'December'],
        days: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
    });
	initMonth();
});


function initMonth(){	

	for (i=0;i<$('.popupCalendar').length;i++){
		var myPopup2 = ($('.popupCalendar')[i]);
		var myTd2 = ($(myPopup2).attr('id'));
		
	}	

	$('#calendarTable td').mouseover(function(e) {
		var mySelectedDate = ($(this).attr('id'));
		var offset = $(this).offset();
		$('#popup-' + mySelectedDate).css('left', (offset.left)-(($('#popup-' + mySelectedDate).width())/2)-5);
		$('#popup-' + mySelectedDate).css('top', (offset.top)-(($('#popup-' + mySelectedDate).height())+40));
		$('#popup-' + mySelectedDate).show();
											  
	});
	$('#calendarTable .active').click(function(e) {
		var mySelectedDate = ($(this).attr('id'));
		wichLink = $('#popup-' + mySelectedDate).children('h2').children('a');
		window.location.href=(wichLink.attr("href"));								  
	});
	$('#calendarTable td').mouseout(function() {
		var mySelectedDate = ($(this).attr('id'));
		$('#popup-' + mySelectedDate).hide();
											  
	});
	$('.popupCalendar').mouseover(function() {
		$(this).show();							  
	});
	$('.popupCalendar').mouseout(function() {
		$(this).hide();							  
	});


	for (i=0;i<$('.popupCalendar').length;i++){
		var myPopup = ($('.popupCalendar')[i]);
		var myTd = ($(myPopup).attr('name'));
		$('#'+myTd).attr("class", "active");
	}	
}
