$(document).ready(function() {
	
	$("#main a[href^='http://'],#main a[href$='.pdf'],li.externe>a").click(function(){
		window.open(this.href);
	    return false;
	});
	
	
	$('#page').before('<img id="background" src="/images/refonte/dsc_0004.jpg" alt="" />');
	

	
	
	var mainHeight = $('#main').height()+40;
	var navHeight = $('#menuGauche ul.first_level>li.active').height();
	if(navHeight > mainHeight) {
		navHeight = navHeight;
		$('#main').css({'height':''+navHeight+'px'});
		navHeight = navHeight+40;
		$('#menuGauche ul.first_level>li.active').css({'height':''+navHeight+'px'});
	}else{
		$('#menuGauche ul.first_level>li.active').css({'height':''+mainHeight+'px'});
	}

	$('#menuGauche ul.first_level>li.formations ul.second_level').css({'width':'600px'});
	
	
	
	
	
	if($('li.par_diplome').attr('class')==='active par_diplome'){
		$('li.par_metier').after($('li.par_diplome'));
		// $('#menuGauche ul.first_level>li.formations li.par_diplome').css({'float':'left','margin-top':'50px','margin-left':'-340px','min-height':''+mainHeight-50+'px','background-image':'url(/images/refonte/bg-nav-diplome_02.png)'});
		$('#menuGauche ul.first_level>li.formations li.par_diplome').css({'float':'left','margin-top':'50px','margin-left':'-340px','min-height':''+mainHeight-50+'px','background':'transparent url(/images/refonte/bg-nav.png) no-repeat -10px 0'});
	 	$('#menuGauche ul.first_level>li.formations li.par_metier').css({'float':'left','min-height':''+mainHeight+'px','margin-left':'40px'});
		$('.par_metier ul.third_level li').css({'display':'none'});
	}else{
		$('#menuGauche ul.first_level>li.formations li.par_metier').css({'float':'left','margin-top':'50px','margin-left':'-260px','min-height':''+mainHeight-50+'px'});
	 	$('#menuGauche ul.first_level>li.formations li.par_diplome').css({'float':'left','min-height':''+mainHeight+'px'});
		$('.par_diplome ul.third_level li').css({'display':'none'});
	}

	$('#menuGauche ul.first_level>li.active.formations').css({'background':'none'});
	 
	 
	 
	 $('.formations .second_level>li>a').click(function(){
	 	if($(this).parent().attr('class')==='defaultmenu par_metier'||$(this).parent().attr('class')==='active par_metier'){
	 		$('li.par_diplome').after($('li.par_metier'));
	 		$('li.par_metier').css({'margin-left':'-260px','margin-top':'50px','min-height':''+mainHeight-50+'px'});
	 		// $('li.par_diplome').css({'margin-left':'0','margin-top':'0px','min-height':''+mainHeight+'px','background-image':'url(/images/refonte/bg-nav-diplome.png)'});		
	 		$('li.par_diplome').css({'margin-left':'0','margin-top':'0px','min-height':''+mainHeight+'px','background':'transparent url(/images/refonte/bg-nav.png) no-repeat -319px 0'});		
	 		$('.par_diplome ul.third_level li').css({'display':'none'});
	 		$('.par_metier ul.third_level li').css({'display':'block'});
	 
	 	}
	 	if($(this).parent().attr('class')==='defaultmenu par_diplome'||$(this).parent().attr('class')==='active par_diplome'){
	 		$('li.par_metier').after($('li.par_diplome'));
	 		$('li.par_metier').css({'margin-left':'40px','margin-top':'0px','min-height':''+mainHeight+'px'});
	 		// $('li.par_diplome').css({'margin-left':'-340px','margin-top':'50px','min-height':''+mainHeight-50+'px','background-image':'url(/images/refonte/bg-nav-diplome_02.png)'});	
	 		$('li.par_diplome').css({'margin-left':'-340px','margin-top':'50px','min-height':''+mainHeight-50+'px','background':'transparent url(/images/refonte/bg-nav.png) no-repeat -10px 0'});	
	 		$('.par_diplome ul.third_level li').css({'display':'block'});
	 		$('.par_metier ul.third_level li').css({'display':'none'});				
	 	}
	 
	 	return false;
	 });     

});

function resizeIframe(){
	var offsetIframe = $('iframe').offset();
	var windowHeight = $(window).height();
	$('iframe').height(windowHeight-Math.round(offsetIframe.top));
}
$(window).resize(function(){
	resizeIframe()
});
$(document).ready(function() {
	$('a.iframe').click(function(){
		$('#frame').html('<iframe name="iframe" src="http://www.google.fr"></iframe>');
		$('iframe').attr('src',$(this).attr('href'));
		$('.backhome').show();
		resizeIframe();
		return false;
	});
});


