$(document).ready(function(){
	$(".lienecole").fancybox_ms();
	$(".link_invit").fancybox_ms();
	$(".share_offre").fancybox_ms();	
	$(".lienoffre_publy").fancybox_ms();
		
		$(".postul").fancybox_ms();
		
	$(".img_matching").hover(function(){
		$(".statut_match",$(this).parent()).stop(false,true).fadeIn();
	},function(){
		$(".statut_match",$(this).parent()).stop(false,true).fadeOut();
	});
	
	$(".link_update_clic").click(function(){
		update_clic();
	});
		
});

function publy_only(id){
	$(".btn_confirm_publy").fadeOut("fast");
	var tab=$(id).attr("id").split("offre_");
	id=tab[1];
	var alertes=1;
	if($("#chk_alertes").is(":checked")) alertes=0;
	else if($("#nothing_alertes").is(":checked")) alertes=2;
	$.post(LIEN_ROOT+"includes/customer/ajaxed/offre_publy.php?lang="+LANG,{liste:id, alertes:alertes},function(data){
		window.location.reload();		
	})
}

function add_candidature(){
	var cv=$("#cv_choix").val();
	var lettre=$("#lettre_choix").val();
	var id=$("#id").val();
	$.post(LIEN_ROOT+"includes/customer/ajaxed/candidature_ajout.php?lang="+LANG,{id:id,cv:cv,lettre:lettre,posted:1},function(data){
		data=data.split('|||');
		$("#contenu_postule").html(data[0]);
		$("#span_btn_postul").html(data[1]);
	})
}

function publy_stage(id){
	$(".btn_confirm_publy").fadeOut("fast");
	var alertes=1;
	if($("#chk_alertes").is(":checked")) alertes=0;
	$.post(LIEN_ROOT+"includes/customer/ajaxed/offre_stage_publy.php?lang="+LANG,{id:id, alertes:alertes},function(data){
		window.location.reload();		
	});
}

function send_offre(){
	var adresse=$("#mail_offre_propose").val();
	var id=$("#id").val();
	$.post(LIEN_ROOT+"includes/front/ajaxed/offre_proposer.php?lang="+LANG,{adresse:adresse, id:id, posted:1}, function(data){
		$.fancybox_ms.close();
	})
}

function vide_champ(){
	$("#mail_offre_propose").focus(function(){
		$(this).val("");
	});	
}

function update_clic(){
	var id_offre=$("#hart_id_offre").html();
	$.post(LIEN_ROOT+"includes/front/ajaxed/offre_update_clics.php?lang="+LANG,{id:id_offre,posted:1});
}
function ini_share(){
	$("#share_offre").mouseenter(function(){
		$(".sharing_user").fadeIn("normal");
		statut_sha="display";
	});
	$(".share_offre").mouseenter(function(){
		//if(statut_sha=="hide"){
		$(".sharing_user").fadeIn("normal");
		$(".sharing_user").addClass('enable');
		
	});
	
	$(".sharing_user").mouseenter(function(){
		if($('.sharing_user').hasClass('enable')==false){
		$(".sharing_user").addClass('enable');
		}
	});
	
	$(".share_offre").mouseleave(function(){
		$(".sharing_user").removeClass('enable');
		setTimeout(function(){
		if($(".sharing_user").hasClass('enable')==false){
			$(".sharing_user").hide()
			$(".sharing_user").removeClass('enable');}
												},500);
	 });
	 $(".sharing_user").mouseleave(function(){
		 $(".sharing_user").removeClass('enable');
		setTimeout(function(){
		if($(".sharing_user").hasClass('enable')==false){
			$(".sharing_user").hide()
			$(".sharing_user").removeClass('enable');}
												},500);
	 });
}
function share_offre(a){
	var id=a;
	var type=20;
	var comment=$('#comment_sharing').val();
	$.post(LIEN_ROOT+"includes/customer/ajaxed/share_actu.php?lang="+LANG,{id:id, comment:comment, type:type},function(data){
		setTimeout("$.fancybox_ms.close()",1500);
		$(".alertbox").html(data);
	});
	return false;
}


