
//~ Menu déroulant

$(document).ready(function(){
	$("#menu div").each(function(){
		$(this).mouseover(function(){
			$(this).children("ul").slideDown("fast");
			if($.browser.msie) {
				var hauteur = $(this).width();
				$(this).children("ul").css({marginLeft:"-"+hauteur+"px"});
			}
			$(this).prev().children("ul").fadeOut("fast");
			$(this).siblings().children("ul").fadeOut("fast");
		});
	});
	$("body").click(function(){
		$("#menu div ul").fadeOut("fast");
	});
	
	// Fermeture des fenetres info/erreurs
	if($("#close")){
		$("#close").click(function(){
			if($("#error")){
				$("#error").fadeOut("slow");
			}
			
			if($("#info")){
				$("#info").fadeOut("slow");
			}
		});
	}
	
	// Calendrier date de naissance
	if($("#birthday")){
		$("#birthday").datepicker({ dateFormat: 'yy-mm-dd 00:00:00' });
	}
	// Choix des mois pour la liste des articles
	if($("#month_min")){
		$("#month_min").datepicker({ dateFormat: 'yy-mm-dd' });
	}
	if($("#month_max")){
		$("#month_max").datepicker({ dateFormat: 'yy-mm-dd' });
	}
	
	if($("#mod_portrait")){
		$("#nav_more").click(function(){
			var mLeft = parseInt($("#contentMiniPortrait").css("margin-left"));
			var width = parseInt($("#contentMiniPortrait").css("width"));
			if(width+mLeft > 340){
				$("#contentMiniPortrait").animate({
					marginLeft: mLeft-340
				},1000);
			}
		});
		$("#nav_back").click(function(){
			var mLeft = parseInt($("#contentMiniPortrait").css("margin-left"));
			var width = parseInt($("#contentMiniPortrait").css("width"));
			if(mLeft < 0){
				$("#contentMiniPortrait").animate({
					marginLeft: mLeft+340
				},1000);
			}
		});
	}
	
	// Vote
	if($("#mod_sondage")){
		$("#formSondage").submit(function(){
			var vote = $(":checked").val();
			var sond = $("#idsond").val();
			request("inc/vote.inc.php?id="+sond+"&vote="+vote,"content_sondage");
			return false;
		});
	}
	
});


// Requete AJAX
function request(url,div){
	$("#"+div).load(url);
}

// Partage facebook
function fbs_click(u,t) {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	pageTracker._trackEvent("Actions", "Facebook", u);
	return false;
}

