function show_message(title_msg, msg) {
	jQuery("#GE_message").html(msg);
	jQuery( "#GE_message" ).dialog({title: title_msg,modal: true,resizable: false,buttons: {Ok: function() {jQuery( this ).dialog( "close" );}}});
}

function send_inscription(hndl,lang){
	if(validForm(hndl)){
		jQuery.post('/script/ajax.php?what=inscription&lang='+lang, jQuery("#mailing_form").serialize(), function(html){
			document.getElementById('mailing').innerHTML = '<p style="font-size:10px; padding:10px; padding-top:0px; padding-left:0px; color:#ffffff;">'+html+'</p>';
		}, "html");
	}
}

function addcomment(lang, post){
	if(validForm(post)){
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('comment_form').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=comment&lang='+lang,ret,null,post);
	}
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function swchOnglet(id){
	jQuery("#onglets").find("a").removeClass("selected") ;
	jQuery("#nContent").fadeOut(400,function(){
		document.getElementById("nContent").innerHTML = eval(id);
		jQuery("#nContent").fadeIn(400);
	});
	document.getElementById(id).className = "selected";
}

function togglebtnsac(){
	if(jQuery("#sacscontainer li").length > 0 && jQuery("#btnSac:hidden").length>0){
		if($("#btnSac").length>0){
			jQuery("#btnSac").css("display","");
		}
	}
	else if(jQuery("#sacscontainer li").length <= 0 && jQuery("#btnSac:visible").length>0){
		if($("#btnSac").length>0){
			jQuery("#btnSac").css("display","none");
		}
	}
}

function addtofiche(id,pro,lan){
	jQuery.ajax({
		url: "/script/ajax.php?what=addtofiche",
		type: "POST",
		data: "id="+id+"&lan="+lan+"&pro="+pro,
		success: function(html){
			eval(html);
		}
	});
}

function delfromfiche(id,pro,lan){
	jQuery.ajax({
		url: "/script/ajax.php?what=delfromfiche",
		type: "POST",
		data: "id="+id+"&lan="+lan+"&pro="+pro,
		success: function(html){
			eval(html);
		}
	});
}

function addalltofiche(){
	jQuery.ajax({
		url: "/script/ajax.php?what=addalltofiche",
		type: "POST",
		success: function(html){
			var brokenstring = html.split(",");
			for(i=0;i<brokenstring.length;i++){
				jQuery.cookie(brokenstring[i],null, { path: '/' });
			}
			$("#sacscontainer").html("");
			togglebtnsac();
		}
	});
}

function sacstriping(){
	$("#sacscontainer li.alt").removeClass("alt");
	$("#sacscontainer li:nth-child(even)").addClass("alt");
}

function getsac(lan){
	jQuery.ajax({
		url: "/script/ajax.php?what=getsac",
		type: "POST",
		data: "lan="+lan,
		success: function(html){
			jQuery("#sacscontainer").html(html);
			sacstriping();
			togglebtnsac();
		}
	});
}

function sendpartage(nom,courriel,url,lan){
	jQuery.ajax({
		url: "/script/ajax.php?what=partage",
		type: "POST",
		data: "nom="+nom+"&courriel="+courriel+"&url="+url+"&lan="+lan,
		success: function(html){
			jQuery("#partager").html(html);
		}
	});
}

function delsac(id,typ){
	if(jQuery.cookie('sacs_'+id+typ)){
		jQuery.cookie('sacs_'+id+typ,null, { path: '/' });
		jQuery("#sac_"+id+typ).slideUp(200,function(){
			jQuery(this).remove();
			sacstriping();
			togglebtnsac();
		});
	}
}

function addsac(id,typ,lan){
	if(!jQuery.cookie('sacs_'+id+typ)){
	jQuery.ajax({
		url: "/script/ajax.php?what=addsac",
		type: "POST",
		data: "id="+id+"&type="+typ+"&lan="+lan,
		success: function(html){
			jQuery.cookie('sacs_'+id+typ,id+';'+typ, { expires: 31, path: '/' });
			jQuery("#sacscontainer").append(html);
			jQuery("#sacscontainer li:last").slideDown(300);
			sacstriping();
			togglebtnsac();
		}
	});
	}
}

function checkEnter(e){
	var characterCode;
	if(e && e.which){
		e = e;
		characterCode = e.which;
	}else{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13){
		return true;
	}else{
		return false; 
	}
}

function isNumberKey(evt,fraction){
	var pass = true;
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(fraction){
		pass = (charCode == 46) ? false:true;
	}
	if (charCode > 31 && (charCode < 48 || charCode > 57) && pass)
		return false;
	
	return true;
}

function menuSelect(id){
	$(id).find("a:first").css("background-color","#8dc5e7");
}
function menuDeselect(id){
	if(!$(id).find("a:first").hasClass('selected')){
		$(id).find("a:first").css("background-color","#5babdc");
	}
}

function menuSelect2(id){
	$(id).find("a:first").css({'background-image' : 'url(/images/bgSousMenu.jpg)', 'font-weight' : 'bold' , 'color' : '#fff'});
}
function menuDeselect2(id){
	$(id).find("a:first").css({'background-image' : 'url(/images/sousmenuSep.jpg)', 'font-weight' : 'normal' ,  'color' : '#306b8e'});
}

function menuSelect2L(id){
	$(id).find("a:first").css({'background-image' : 'url(/images/bgSousMenuLong.jpg)', 'font-weight' : 'bold' , 'color' : '#fff'});
}
function menuDeselect2L(id){
	$(id).find("a:first").css({'background-image' : 'url(/images/sousmenuSep.jpg)', 'font-weight' : 'normal' ,  'color' : '#306b8e'});
}

changemois = function(dir,mois,annee){
	jQuery.post('/script/ajax.php?what=calendrier&dir='+dir+'&mois='+mois+'&annee='+annee+'&lan='+langue,function(data){jQuery("#calendar").html(data);});
};




