// JavaScript Document
function $(x) { return typeof(x) == "string" ? document.getElementById(x) : x; }
function zou(url){window.top.location.href=url;}
function resrc(id,avant,apres){$(id).src=$(id).src.replace(avant,apres);}
function reclass(id,classes){$(id).className=classes;}
function magicprotect(qui,ou){if(!ou) ou="bibuloba-evenements.fr";location.href="mailto:"+qui+"@"+ou;}
function affiche(quoi){ with($(quoi).style) {display=(display=="none") ? "block":"none";}}
function efface(quoi){ $(quoi).innerHTML='';}
var IE6 = ((navigator.userAgent.match(/MSIE 6/i)) && (navigator.userAgent.search(/MSIE 7/i)<0) && (navigator.userAgent.search(/MSIE 8/i)<0)) ? true:false;
var extension = (IE6) ? 'gif':'png';
var IE = (navigator.userAgent.match(/MSIE/i)) ? true:false;
var bloc_aouvrir_id = '';
var bloc_base_id = '';
var mv_hauteur = 0;
var mv_nb = 0;
var mv_motif = '';
var mv_action = false;
var mv_checking = false;
var timer = 0;
var mv_frequence = 42; //42 = 24fps
var mv_pas = 2;
function valeur_numerique(chaine){ numerique_temp = chaine.split("px"); numerique = parseInt(numerique_temp[0]); return numerique;}
function mv_check(){timercheck = new Date();delai = timercheck-timer;if(delai>5000) mv_restore();}
function mv_start(clef,motif,nb,hauteur){
	if(!mv_checking) mv_checking = window.setInterval("mv_check()",3000);
	timer = new Date();mv_hauteur = hauteur;mv_nb = nb;	mv_motif = motif;bloc_aouvrir_id = motif+clef;
	for(i=0;i<mv_nb;i++) if($(mv_motif+i).style.display=='block'){bloc_base_id = motif+i;mv_pas = Math.ceil(mv_hauteur/mv_frequence);}
	mv_action = window.setInterval("mv_move()",mv_frequence);
}
function mv_move(){
	hauteur_bloc_aouvrir = valeur_numerique($(bloc_aouvrir_id).style.height);
	if((mv_hauteur-hauteur_bloc_aouvrir) <= mv_pas) {window.clearInterval(mv_action);$(bloc_aouvrir_id).style.height=mv_hauteur+'px';for(i=0;i<mv_nb;i++) if((mv_motif+i) != bloc_aouvrir_id) $(mv_motif+i).style.height = '0px';
	}else{$(bloc_aouvrir_id).style.height = (hauteur_bloc_aouvrir + mv_pas) + 'px';for(i=0;i<mv_nb;i++) if( ((mv_motif+i) != bloc_aouvrir_id) && ($(mv_motif+i).style.height != '0px') ) $(mv_motif+i).style.height = (valeur_numerique($(mv_motif+i).style.height) - mv_pas) + 'px';}
}
function mv_restore(){
	if(mv_action) window.clearInterval(mv_action);
	if( (bloc_base_id != '') && ($(bloc_base_id).style.height != (mv_hauteur+'px')) ){bloc_aouvrir_id = bloc_base_id;bloc_base_id = '';mv_action = window.setInterval("mv_move()",mv_frequence);}
}
var object_moving_id = '';
var object_moving_typecoord = '';
var object_moving_action = false;
var object_moving_val_deb = 0;
var object_moving_val_fin = 0;
var object_moving_step = 2;
function object_move_start(id,typecoord,depart,arrivee,step){
	object_moving_id = id;object_moving_typecoord = typecoord;object_moving_val_deb = depart;object_moving_val_fin = arrivee;object_moving_step = step;object_moving_action = window.setInterval("object_move()",42);
}
function object_move(){
	var val_now = valeur_numerique(eval("$('"+object_moving_id+"').style."+object_moving_typecoord));if(isNaN(val_now)) val_now = object_moving_val_deb;
	if(Math.abs(object_moving_val_fin-val_now) <= object_moving_step ){window.clearInterval(object_moving_action);eval("$('"+object_moving_id+"').style."+object_moving_typecoord+" = "+object_moving_val_fin+"+'px'");
	}else{val_new = ((object_moving_val_fin-object_moving_val_deb) > 0) ? (val_now + object_moving_step):(val_now - object_moving_step);eval("$('"+object_moving_id+"').style."+object_moving_typecoord+" = "+val_new+" + 'px'");}
}
var xhr = null; 
function Xhr_get(){
	if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); // Firefox et autres
	else if(window.ActiveXObject){ // Internet Explorer 
	   try { xhr = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){	xhr = new ActiveXObject("Microsoft.XMLHTTP");}
	}else { alert("Votre navigateur est obsolète ou restreint dans ses fonctionnalités\n\n- mettez à jour la version de votre navigateur\n- activez le support des activeX"); xhr = false;} 
}
function Xhr_give(){
	idDest = (arguments[0] != null) ? arguments[0]:"nulle_part";
	urlcible = (arguments[1] != null) ? arguments[1]:"nulle_part.html";
	parametres = (arguments[2]) ? arguments[2]:null;
	methode = (arguments[3]) ? arguments[3]:"GET";
	async = (arguments[4]) ? arguments[4]:true;
	Xhr_get();
	xhr.onreadystatechange = function(){if(xhr.readyState == 4 && xhr.status == 200) {if(xhr.responseText.substr(0,4)=='js::') {eval(xhr.responseText.substr(4));}else {$(idDest).innerHTML = xhr.responseText;}if(Xhr_fonction) {eval(Xhr_fonction);Xhr_fonction=false;}}}
	xhr.open(methode,urlcible,async);
	if(methode=='POST') { xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');	parametres=encodeURI(parametres);}
	xhr.send(parametres);
}
var path_lib_img_ajax = 'http://www.bibuloba-evenements.fr/__lib/img/ajax/';
var suite = new Array('HG','H','HD','G','C','D','BG','B','BD');
function charge_design_ajax(){var image = new Array();for(var i=0;i<suite.length;i++){image[i]=new Image();image[i].src=path_lib_img_ajax+suite[i]+'.'+extension;} return true;}
function try_focus(){var liste='INPUT,TEXTAREA';if(document.forms.length>0) for(var i=0;i<document.forms[0].length;i++)if(liste.indexOf(document.forms[0].elements[i].nodeName.toUpperCase())>-1){document.forms[0].elements[i].focus();break;}}
var Xhr_fonction = false;
function injecte(quoi){
	affiche('plan1');affiche('plan2');
	tout_charge = charge_design_ajax();
	Xhr_fonction = 'inj_open();';
	Xhr_give('plan2',quoi);
	if(IE6){$('plan2').style.height=document.body.clientHeight+'px';$('plan2').style.top=document.documentElement.scrollTop+'px';}
}
function efface_ajax(){$('plan2').style.display='none';$('plan1').style.display='none';if(inj_action_O) {window.clearInterval(inj_action_O);inj_action_O=false;};if(IE) $('plan1').filters[0].opacity=0;else $('plan1').style.opacity=0;$('plan2').innerHTML=$('plan2_cache').innerHTML;}
var inj_largeur_cible = 0;
var inj_hauteur_cible = 0;
var inj_frequence = 33;
var inj_pas = 20;
var inj_action_H = false;
var inj_action_V = false;
var inj_action_O = false;
function inj_open(){
	inj_largeur_cible = valeur_numerique($('inj_params').style.width);
	inj_hauteur_cible = valeur_numerique($('inj_params').style.height);
	//inj_pas = Math.ceil(inj_largeur_cible/inj_frequence);
	inj_action_H = window.setInterval("inj_move_H()",inj_frequence);
}
function inj_move_H(){
	if( (inj_largeur_cible-valeur_numerique($('injection').style.width)) <= inj_pas) {
		window.clearInterval(inj_action_H);
		$('injection').style.width = inj_largeur_cible+'px';
		$('inj_H').style.width = (inj_largeur_cible-36)+'px';
		$('inj_B').style.width = (inj_largeur_cible-36)+'px';
		$('inj_C').style.width = (inj_largeur_cible-36)+'px';
		if(!IE6) $('inj_o_B').style.width = (inj_largeur_cible-14)+'px';
		//inj_pas = Math.ceil(inj_hauteur_cible/inj_frequence);
		inj_action_V = window.setInterval("inj_move_V()",inj_frequence);
	}else{
		$('injection').style.width = (valeur_numerique($('injection').style.width) + inj_pas) + 'px';
		$('inj_H').style.width = ((valeur_numerique($('inj_H').style.width)) + inj_pas) + 'px';
		$('inj_B').style.width = $('inj_H').style.width;
		$('inj_C').style.width = $('inj_H').style.width;
		if(!IE6) $('inj_o_B').style.width = ((valeur_numerique($('inj_o_B').style.width)) + inj_pas) + 'px';
	}
}
function inj_move_V(){
	if( (inj_hauteur_cible-valeur_numerique($('injection').style.height)) <= inj_pas) {
		window.clearInterval(inj_action_V);
		$('injection').style.height = inj_hauteur_cible+'px';
		$('inj_G').style.height = (inj_hauteur_cible-36)+'px';
		$('inj_D').style.height = (inj_hauteur_cible-36)+'px';
		$('inj_C').style.height = (inj_hauteur_cible-36)+'px';
		if(!IE6) $('inj_o_D').style.height = (inj_hauteur_cible-14)+'px';
		affiche('inj_contenu');affiche('inj_closer');try_focus();
		inj_action_O = window.setInterval("inj_opacite_plan1()",inj_frequence);
	}else{
		$('injection').style.height = (valeur_numerique($('injection').style.height) + inj_pas) + 'px';
		$('inj_G').style.height = ((valeur_numerique($('inj_G').style.height)) + inj_pas) + 'px';
		$('inj_D').style.height = $('inj_G').style.height;
		$('inj_C').style.height = $('inj_G').style.height;
		if(!IE6) $('inj_o_D').style.height = ((valeur_numerique($('inj_o_D').style.height)) + inj_pas) + 'px';
	}
}
function inj_opacite_plan1(){
	var max_opacite = 50;var step_opacite = 1;
	if(IE) with($('plan1').filters[0]){valeur = parseInt(opacity);if(valeur<max_opacite) opacity = valeur + step_opacite; else {window.clearInterval(inj_action_O);inj_action_O=false;opacity=max_opacite;}}
	else with($('plan1').style) {valeur = parseFloat(opacity);if(valeur<(max_opacite/100)) opacity = valeur + (step_opacite/100);else {window.clearInterval(inj_action_O);inj_action_O=false;opacity=(max_opacite/100);}}
}
var test_complete_action = false;
var test_complete_tab = false;
var test_complete_suite = false;
function test_complete(){
	var nb = test_complete_tab.length;
	var completes = 0;
	for(var i=0;i<nb;i++) completes+= ($(test_complete_tab[i]).complete) ? 1:0;
	if(completes==nb) {window.clearInterval(test_complete_action);test_complete_action=false;eval(test_complete_suite+"();");}
}
var flip_flop_opacite_first = new Array();
var flip_flop_opacite_second = new Array();
var flip_flop_opacite_action = false;
var flip_flop_opacite_step = 4;
var flip_flop_opacite_suite = false;
function flip_flop_opacite(){
	for(var i=0;i<flip_flop_opacite_first.length;i++){
		if(IE){
			with($(flip_flop_opacite_first[i]).filters[0]){valeur = parseInt(opacity);if(valeur>0) opacity = valeur - flip_flop_opacite_step; else {flip_flop_opacite_stop();break;}}
			with($(flip_flop_opacite_second[i]).filters[0]){valeur = parseInt(opacity);if(valeur<100) opacity = valeur + flip_flop_opacite_step;else {flip_flop_opacite_stop();break;}}
		}else{
			with($(flip_flop_opacite_first[i]).style) {valeur = parseFloat(opacity);if(valeur>0) opacity = valeur - (flip_flop_opacite_step/100);else {flip_flop_opacite_stop();break;}}
			with($(flip_flop_opacite_second[i]).style) {valeur = parseFloat(opacity);if(valeur<1) opacity = valeur + (flip_flop_opacite_step/100);else {flip_flop_opacite_stop();break;}}
		}
	}
}
function flip_flop_opacite_stop(){
	window.clearInterval(flip_flop_opacite_action);
	for(var i=0;i<flip_flop_opacite_first.length;i++){
		if(IE){$(flip_flop_opacite_first[i]).filters[0].opacity=0;$(flip_flop_opacite_second[i]).filters[0].opacity=100; 
		}else{$(flip_flop_opacite_first[i]).style.opacity=0;$(flip_flop_opacite_second[i]).style.opacity=1;}
	}
	if(flip_flop_opacite_suite) eval(flip_flop_opacite_suite+"();");
}
var eve_photos_tab = new Array();
function eve_diapo_start(){
	var photos_divs = $('eve_diapo').childNodes;
	var photos_divs_nb = photos_divs.length;
	for(var i=0;i<photos_divs_nb;i++) if(photos_divs[i].childNodes[0].nodeName=='IMG') eve_photos_tab[i] = photos_divs[i].childNodes[0].id;
	if(eve_photos_tab.length) {test_complete_tab=eve_photos_tab;test_complete_suite='eve_diapo_go';test_complete_action = window.setInterval("test_complete()",1000);}
}
function eve_diapo_go(){eve_diapo_go_action = window.setInterval("eve_diapo_run()",4000);}
function eve_diapo_run(){
	var nb = eve_photos_tab.length;
	if(IE){for(var i=0;i<nb;i++) if(parseInt($(eve_photos_tab[i]).filters[0].opacity)>0) photo_on_indice = i; 
	}else{for(var i=0;i<nb;i++) if(parseFloat($(eve_photos_tab[i]).style.opacity)>0) photo_on_indice = i; }
	photo_suivante_indice = ((photo_on_indice+1)==nb) ? 0:photo_on_indice+1;
	flip_flop_opacite_first[0] = eve_photos_tab[photo_on_indice];
	flip_flop_opacite_second[0] = eve_photos_tab[photo_suivante_indice];
	flip_flop_opacite_action = window.setInterval("flip_flop_opacite()",42);
}
var idees_photos_tab = new Array();
var idees_teasers_tab = new Array();
function idees_diapo_start(){
	var idees_photos_divs = $('diato_photos').childNodes;
	var idees_photos_divs_nb = idees_photos_divs.length;
	var idees_teasers_divs = $('diato_teasers');
	for(var i=0;i<idees_photos_divs_nb;i++) if(idees_photos_divs[i].childNodes[0].nodeName=='IMG') {idees_photos_tab[i] = idees_photos_divs[i].childNodes[0].id;idees_teasers_tab[i] = idees_teasers_divs.childNodes[i].id;}
	if(idees_photos_tab.length) {test_complete_tab=idees_photos_tab;test_complete_suite='idees_diapo_go';test_complete_action = window.setInterval("test_complete()",1000);}
}
function idees_diapo_go(){idees_diapo_go_action = window.setInterval("idees_diapo_run()",4000);flip_flop_opacite_suite='idees_diapo_ajust';}
function idees_diapo_run(){
	var nb = idees_photos_tab.length;
	if(IE){for(var i=0;i<nb;i++) if(parseInt($(idees_photos_tab[i]).filters[0].opacity)>0) photo_on_indice = i; 
	}else{for(var i=0;i<nb;i++) if(parseFloat($(idees_photos_tab[i]).style.opacity)>0) photo_on_indice = i; }
	photo_suivante_indice = ((photo_on_indice+1)==nb) ? 0:photo_on_indice+1;
	flip_flop_opacite_first[0] = idees_photos_tab[photo_on_indice];
	flip_flop_opacite_second[0] = idees_photos_tab[photo_suivante_indice];
	flip_flop_opacite_first[1] = idees_teasers_tab[photo_on_indice];
	flip_flop_opacite_second[1] = idees_teasers_tab[photo_suivante_indice];
	flip_flop_opacite_action = window.setInterval("flip_flop_opacite()",42);
}
function idees_diapo_ajust(){
	var nb = idees_photos_tab.length;
	if(IE){for(var i=0;i<nb;i++) if(parseInt($(idees_photos_tab[i]).filters[0].opacity)>0) photo_on_indice = i; 
	}else{for(var i=0;i<nb;i++) if(parseFloat($(idees_photos_tab[i]).style.opacity)>0) photo_on_indice = i;}
	for(var i=0;i<nb;i++) {
		$('diato_zoneclic').childNodes[i].style.visibility = (i==photo_on_indice) ? 'visible':'hidden';
		if(IE) $('diato_boutons').childNodes[i].filters[0].opacity = (i==photo_on_indice) ? '100':'50';
		else $('diato_boutons').childNodes[i].style.opacity = (i==photo_on_indice) ? '1':'0.5';
	}
}
function idees_diapo_focus(diato_photoobject_id){
	if(flip_flop_opacite_action) window.clearInterval(flip_flop_opacite_action);
	if(idees_diapo_go_action) window.clearInterval(idees_diapo_go_action);
	var nb = idees_photos_tab.length;
	var photo_on_indice = -1;
	for(var i=0;i<nb;i++){
		if(IE){
			$(idees_photos_tab[i]).filters[0].opacity = (idees_photos_tab[i]==diato_photoobject_id) ? 100:0;
			$(idees_teasers_tab[i]).filters[0].opacity = (idees_photos_tab[i]==diato_photoobject_id) ? 100:0;
			$('diato_boutons').childNodes[i].filters[0].opacity = (idees_photos_tab[i]==diato_photoobject_id) ? '100':'50';
		}else{
			$(idees_photos_tab[i]).style.opacity = (idees_photos_tab[i]==diato_photoobject_id) ? 1:0;
			$(idees_teasers_tab[i]).style.opacity = (idees_photos_tab[i]==diato_photoobject_id) ? 1:0;
			$('diato_boutons').childNodes[i].style.opacity = (idees_photos_tab[i]==diato_photoobject_id) ? '1':'0.5';
		}
		$('diato_zoneclic').childNodes[i].style.visibility = (idees_photos_tab[i]==diato_photoobject_id) ? 'visible':'hidden';
	}
}
function champs_de_formulaire(quoi){
	switch(quoi.nodeName){
		case 'INPUT' 	: 
		case 'TEXTAREA'	: 
		case 'SELECT'	: retour = true;break;
		default		: retour = false;
	}
	return retour;
}
function check_it(f){var erreur = false;var x=f.elements;var params = '';for(var i=0;i<x.length;i++){if(champs_de_formulaire(x[i]) && (x[i].className.substr(0,11)=='obligatoire')){nom = x[i].parentNode.parentNode.childNodes[0].innerHTML;if(x[i].value=='') {erreur = 'Le champs [ '+nom+' ] est obligatoire !';break;}else if((x[i].name=='EMAIL') && !is_email(x[i].value)){erreur = 'Veuillez vérifier l\'adresse email saisie !';break;}}}if(erreur) {$('formulaire_erreur').style.display='block';$('formulaire_erreur').innerHTML = '<p class="erreur">'+erreur+'</p>';x[i].parentNode.parentNode.childNodes[0].innerHTML='<span class="erreur">'+nom+'</span>';x[i].className='obligatoirerreur';x[i].focus();return false;} else return true;}
function post_it(receptacle,f,script){var erreur = false;var x=f.elements;var params = '';for(var i=0;i<x.length;i++)if(champs_de_formulaire(x[i])) {separator = (params=='') ? '':'&';if(x[i].type=='checkbox'){if(x[i].checked==true) {params+= separator+f[i].name+'='+escape(f[i].value);}}else params+= separator+f[i].name+'='+escape(f[i].value);}Xhr_give(receptacle,script,params,'POST');}
function is_email(adresse){var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');if(reg.test(adresse)) return true; else return false;}
function courriel(prefixe,id_societe){domaine = false;switch(id_societe){case 1 : domaine = "bibuloba-evenements.fr";break;case 2 : domaine = "trans-sphere.com";break;}if(domaine && prefixe) location.href = "mailto:"+prefixe+"@"+domaine;}
