var t;
function subMenuShowHide(){
	$("div.mainMenu>ul li ul").css("display", "none");
	$('div.mainMenu>ul li.active').find('ul').css("display", "block");
}
$(document).ready(function() {

//BACKGROUNDS :

$("body.eleves div.background img").attr("src", "/img/bg/bg_002.jpg");	
$("body.parents div.background img").attr("src", "/img/bg/bg_005.jpg");	
$("body.anciens div.background img").attr("src", "/img/bg/bg_004.jpg");	
var l =Math.floor(Math.random()*6);
//$("body.home div.background img").attr("src", "/img/bg/bg_00"+l+".jpg");

	

//MENU DE NAVIGATION GLOBAL :

	/*$("#condors").hover(function(){
		$(this).attr("src", "img/nosCondorsHov.jpg");
	}, function(){
		$(this).attr("src", "img/nosCondors.jpg");	
	});*/
	
	
	var sum = $('div.mainMenu>ul').width();
	$("div.mainMenu>ul li ul").css("left", 500-sum+"px");
	
	$("div.mainMenu>ul>li").hover(function(){
		
		$("div.mainMenu>ul li ul").css("display", "none");
		if($(this).find('ul').is(':hidden')){
			$(this).find('ul').css("display", "block");
		}
	}, function(){});
	
	$("div.menu").hover(function(){
		clearTimeout(t);
	}, function(){
		t = setTimeout("subMenuShowHide()", 300);
	});
	
	
	$('a.open_calculate_box').click(function(){
		$('div.calculate_box').slideToggle();
		return false;
	});
		
	$('div.calculate_box select').change(function(){
		var maxYear = 2011;
		var val = parseInt($(this).find('option:selected').val())+5;
		if(val > maxYear){
			val = maxYear;
		}
		$('#GraduatePromotionYear').val(val);
		$('div.calculate_box').slideUp();
	});
	
	
	// Tiroirs :
	
	$('.tiroires .tiroire_head').click(function() {
		$(this).next().slideToggle('100');
		return false;
	}).next().hide();

	$('.tiroires .tiroire_head').click(function(){
			if($(this).hasClass("x")){
				$(this).removeClass("x");
			}else{
				$(this).addClass("x");
			}
	});
	
	
	//BACKGROUND 
	
	
	function imgPos() {
		if($(window).width() < 1200) {
			$('.background img').attr('style', '');
			$('.background img').css('bottom', '0px');
		} else {
			$('.background img').attr('style', '');
			$('.background img').css('top', '0px');
		}
	};
	
	imgPos();
	
	$(window).resize(function() {
		imgPos();
	});
	
	
	//Accordion page nous-joindres
	/*$('.staffs p.staff_category_name').click(function() {
		$(this).next().toggle();
		$(this).toggleClass('staff_category_name_minus');
		return false;
	}).next().hide();*/

});

