//fichier js here


function bookmarksite()
{
         if (document.all)
        {
             // For IE
             window.external.AddFavorite(location.href, document.title);
         }
        else if (window.sidebar)
       {
             // For Firefox
             window.sidebar.addPanel(document.title, location.href, "");
        }
}


function changemois(direction,mois,annee){
	killAjax()
	ret = function() {
		if(ajaxOk()){
			document.getElementById('calendrier').innerHTML=objAjax.responseText;
			cleanCal();
		}
	}
	callAjax('/script/ajax.php?what=calendrier&dir='+direction+'&mois='+mois+'&annee='+annee,ret,null);
}

function cleanCal(){
	var a = document.getElementById('calendrier').getElementsByTagName('td');
	for(i=0;i<a.length;i++){
		if(a[i].innerHTML=='' || a[i].innerHTML=='&nbsp;'){a[i].className='vide';}
	}
}

sfHover = function() {
	var sfEls = document.getElementById("menu").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 downMenu(id){
	callAjax('/script/menus.php?action=down&id='+id,null,document.getElementById('tableMenus'));
}

function upMenu(id){
	callAjax('/script/menus.php?action=up&id='+id,null,document.getElementById('tableMenus'));
}

function partage(hndl){
	if(validForm(hndl)){
		callAjax('/ajax/partager.php',null,document.getElementById('cformres'),hndl);
	}
}

function promesseform(){
	if(validForm(document.getElementById('fcontact'))){
		if(document.getElementById('fcontact').montantPre.value=='other' && document.getElementById('fcontact').montant.value==''){
			alert('Veuillez entrer le montant de votre don.');
			return false;
		}
		callAjax('/ajax/promesse.php',null,document.getElementById('cform'),document.getElementById('fcontact'));
	}
}

function contactform(hndl){
	if(validForm(hndl)){
		callAjax('/ajax/addDemande.php',null,document.getElementById('cform'),hndl);
	}
}

function changeSizeTxt(plus){
	if(document.getElementById("contentLeftPadding") && document.getElementById("msize") && document.getElementById("psize")){
		var cH = (document.getElementById("contentLeftPadding"));
		var mA = document.getElementById("msize");
		var pA = document.getElementById("psize");
		
		if(!cH.style.fontSize) cH.style.fontSize = "12px";
		var fSize = parseInt(cH.style.fontSize.replace("px",""));
		
		mA.className = "small";
		pA.className = "large";
		
		if(plus){
			if(fSize<17){
				fSize++;
				cH.style.fontSize = fSize+"px";
			}
		}else{
			if(fSize>10){
				fSize--;
				cH.style.fontSize = fSize+"px";
			}
		}
		if(fSize>=17) pA.className = "hidden";
		if(fSize<=10) mA.className = "hidden";
	}
	return false;
}


function printPage(){
	window.print();
	return false;
}
function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}
function getcookie(cookiename) {
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration){
	if (arguments.length == 3) cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
	else if (arguments.length == 2) cookiestring=name+"="+escape(value);
	else if (arguments.length == 1) cookiestring=name+"=;EXPIRES="+getexpirydate(-1);
	else return;
	document.cookie=cookiestring;
	if(!getcookie(name)) return false;
	else return true;
}

jQuery(document).ready(function(){
	jQuery(".print").click(function(e){e.preventDefault();printPage();});
	jQuery("a.small").bind("click", function(){
		changeSizeTxt(0);
		return false;
	});
	jQuery("a.large").bind("click", function(){
		changeSizeTxt(1);
		return false;
	});
	if(getcookie("fSize")) changeSizeTxt(-1);
});
