function pathUrl(){
	chemin=window.location.pathname;
	tableau=chemin.split('/');
	tableau.pop();
	return tableau.join('/');
}

function pathStyle(){
	lien=document.getElementsByTagName('link')[0];
	elts=(lien.href).split('/');
	elts.pop();
	css=elts.pop();
	return css;
}

function getParamValue(param,url){
    var u = url == undefined ? document.location.href : url;
    var reg = new RegExp('(\\?|&|^)'+param+'=(.*?)(&|$)');
    matches = u.match(reg);
	if (!matches) return false;
	else return matches[2] != undefined ? decodeURIComponent(matches[2]).replace(/\+/g,' ') : false;
}

function verifMail(mail){
	var re=/^\w+([\.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/;
	return re.test(mail);
}
function ancreDynamique (id){
	if (elt=$(id)) {
		Element.scrollTo(elt);
		Effect.Pulsate(elt,{ pulses: 3, from:0.3, duration: 2 });
	}
}

function initialisation (){
	$$('table#calendrier caption a').each(function(a) {
		Event.observe(a,'click',rafraichitCalendrier);
	});
	$$('p.debriefing').each(function(p) {
		new Effect.BlindUp(p,{duration:0.5,delay:2});
	});
	$$('#zone_1 a.edit').each(function(a) {
		a.title="Modifier cet élément";
	});
	redirectionTimer();
	afficheTwits();

}


function afficheTwits(){
		$('zone_2').insert({bottom:'<div><h2>Boîte à tweets</h2><ul id="AjaxTwits"><li id="AjaxTwitsLoader"><em>Chargement des tweets</em></li></ul><script type="text/javascript">getAjaxTwits("'+pathUrl()+'/include/ajaxtwits/AjaxTwitsRequest.php",5);</script></div>\n'});

}

function secoueLogin(){
	new Effect.Shake('formLogin');
}

function redirectionTimer(){
	if (redirect=$('redirect')) {
		compteur=redirect.down('span');
		lien=redirect.down('a').href;
		setTimeout('location.href=lien;',(compteur.innerHTML)*1000+1);
		setInterval('if (compteur.innerHTML!=0) compteur.innerHTML--;',1000);
	}
}

function rafraichitCalendrier(evnt){
	Event.stop(evnt);
	elt=$('calendrier').up('div');
	new Ajax.Request (pathUrl()+'/ajax/rafraichitCal.php',{
			method: 'post',
			encoding: 'ISO-8859-15',
			parameters: {lien:this.href},
			onComplete: function(xhr) {
						elt.update(xhr.responseText);
						$$('table#calendrier caption a').each(function(a) {
							Event.observe(a,'click',rafraichitCalendrier);
						});
						}
		});

}


Event.observe(window, 'load', initialisation, false);