
var AccesEtudiant = function(){
	var login = $("form#AccesEtudiant input[name=login]").val();
	var mdp = $("form#AccesEtudiant input[name=mdp]").val();
	$.ajax({
		type: "POST",
		data: {
			act:'LOGIN',
			login: login,
			mdp: mdp
		},
		url: "login.php",
		success:function(retour){
			if(retour > 0){ window.location.replace('espace-etudiant/'); }else{ 
				alert('Accès refusé'); 
				if( mdp != $("form#AccesEtudiant input[name=mdp]").attr('default') ) $("form#AccesEtudiant input[name=mdp]").val('');
			}
		}
	});
}

var Submit = function(){
	
}

$(document).ready(function(){
						   
	$("a.zoom").fancybox();
	
	$("#menu a.slide:not('.home')").click(function(e){
		e.preventDefault();							  
	});
		
	$('#menu li, #menu dt').mouseenter(function(){		
		if( !$(this).hasClass('menu') ){
			var pos = $(this).parents('li').position();
			if( pos.left+400 > 900 ){ $(this).children('dl').css('left', -(200)+'px'); }
		}else{
			var pos = $(this).position();
			//if( pos.left+200 > 900 ){ $(this).children('dl').css('left', -(99)+'px'); }
			if( pos.left+200 > 900 ){ $(this).children('dl').css({'right':0+'px','left':'auto'}); }
		}
		$(this).children('dl').stop(true, true).slideDown();
	}).mouseleave(function(){
		$(this).children('dl').stop(true, true).hide();
	});
	
	$('div.p-left:not(".show") dl dt > dl').css('display','none');
	$('div.p-left:not(".show") a.select').next('dl').css('display','block');
	$('div.p-left:not(".show") a.select').parents('dl').css('display','block');
	
	/*
	$('div.p-left:not(".show") dt').mouseover(function(){
		$(this).children('dl').stop(true, true).slideDown();
	}).mouseleave(function(){
		if( $(this).find('a.select').length == 0 ) $(this).children('dl').stop(true, true).slideUp();
	});
	*/
	
	$('div.p-left:not(".show") a.slide').click(function(e){
		e.preventDefault();
		$(this).next('dl').stop(true, true).slideToggle();
	});
	
	/* Formulaire acces étudiant */
	$("form#AccesEtudiant input").focus(function(e) {
		$(this).val('');
	});
	$("form#AccesEtudiant input").blur(function(e) {
		if( $(this).val() == '' )$(this).val($(this).attr('default'));
	});
	$("form#AccesEtudiant input").keyup(function(e) {
		if(e.keyCode == 13) AccesEtudiant();
	});
	$("form#AccesEtudiant").submit(function(e) {
		AccesEtudiant();
		return false;
	});

});
