ejs_box2_message = new Array;  

ejs_box2_message[0] = 'Bienvenue sur JdidOuBali !';	
ejs_box2_message[1] = 'JdidOuBali est là pour vous simplifier la vie.';
ejs_box2_message[2] = 'Désormais, vous n\'aurez jamais à chercher loin !!';
ejs_box2_message[3] = 'Alors, n\'hésitez pas à le faire savoir !';
		
ejs_box2_actual = 0;
ejs_box2_html_flag = 0;
								 
function ejs_box2_go()
{
	if (document.getElementById)
	{
		ejs_box2_char = 1;
		ejs_box2_affich(ejs_box2_actual)
		ejs_box2_actual++;
		if (ejs_box2_actual >= ejs_box2_message.length)
		ejs_box2_actual = 0;
	}        
}
								 
function ejs_box2_affich(lactual)
{
	var pix = ejs_box2_message[lactual].charAt(ejs_box2_char);
	if (pix == "<")
	ejs_box2_html_flag = 1;
	if (pix == ">")
	ejs_box2_html_flag = 0;
	var texte = ejs_box2_message[lactual].substring(0,ejs_box2_char);
	document.getElementById("ejs_box2_box").innerHTML = texte;
	if (ejs_box2_char < ejs_box2_message[lactual].length)
	{
	ejs_box2_char++;
	if (ejs_box2_html_flag == 1)    
	ejs_box2_affich(lactual);
	else
	setTimeout("ejs_box2_affich("+lactual+")",100)
	}
	else
	setTimeout("ejs_box2_go()",1300)
}
window.onload = ejs_box2_go;
 


function ChoixPage(url, nbr_page, page_actuelle) {
	var page = prompt('Veuillez saisir un numéro de page entre 1 et ' + nbr_page + ' :', '');
	if (page >= 1 && page <= nbr_page) {
		document.location = url + page;
	}
	else {
		document.location = url + page_actuelle;
	}
}



function DateMaker()
{
	var jour = document.form.jour.selectedIndex;
	var mois = document.form.mois.selectedIndex;
	var annee = document.form.annee.selectedIndex;
	var jjTxt = document.form.jour.options[jour].value;
	var mmTxt = document.form.mois.options[mois].value;
	var aaTxt = document.form.annee.options[annee].value;
	document.form.validate.value = jjTxt + '/' + mmTxt + '/' + aaTxt;
}



function veriflogin(login)
{
	if (texte = file('http://www.jdidoubali.com/veriflogin.php?login='+escape(login)))
	{
		if (texte == 1)
			document.form.valog.value = login;
		else
			document.form.valog.value = '';
	}
}
function file(fichier)
{
	if (window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if (window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if (xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}



var selected_row = new Array;

function CocherDecocherElt(Form, tr_num) {
	var rows = Form.getElementsByTagName('tr');
	var checkbox = rows[tr_num].getElementsByTagName('input')[0];
	var unique_id;
	if (checkbox && checkbox.type == 'checkbox') {
		unique_id = checkbox.name + checkbox.value;
		if (checkbox.disabled == false) {
			if (typeof(selected_row[unique_id]) == 'undefined' || !selected_row[unique_id]) {
				rows[tr_num].className += '_selected';
				selected_row[unique_id] = true;
			}
			else {
				rows[tr_num].className = rows[tr_num].className.replace('_selected', '');
				selected_row[unique_id] = false;
			}
		}
	}
}

function CocherTout(Form) {
	var rows = Form.getElementsByTagName('tr');
	var unique_id;
	var checkbox;
	for (i=1; i <= Form.length; i++) {
		checkbox = rows[i].getElementsByTagName('input')[0];
		if (checkbox && checkbox.type == 'checkbox') {
			unique_id = checkbox.name + checkbox.value;
			if (checkbox.disabled == false) {
				checkbox.checked = true;
				if (typeof(selected_row[unique_id]) == 'undefined' || !selected_row[unique_id]) {
					rows[i].className += '_selected';
					selected_row[unique_id] = true;
				}
			}
		}
	}
}

function DecocherTout(Form) {
	var rows = Form.getElementsByTagName('tr');
	var unique_id;
	var checkbox;
	for (var i=1; i <= Form.length; i++) {
		checkbox = rows[i].getElementsByTagName('input')[0];
		if (checkbox && checkbox.type == 'checkbox') {
			unique_id = checkbox.name + checkbox.value;
			checkbox.checked = false;
			rows[i].className = rows[i].className.replace('_selected', '');
			selected_row[unique_id] = false;
		}
	}
}



function NbrCheckboxCoches(oForm) {
    var i, n = 0 ;
    var oElement ;
 
    for (i = 0 ; i < oForm.elements.length ; i++) {
        oElement = oForm.elements[i] ;
        if (oElement.tagName.toLowerCase() == "input") {
            if (oElement.type.toLowerCase() == "checkbox") {
                if (oElement.checked == true) {
                    n++ ;
                }
            }
        }
    }
	return n;
}
	

	
function Cocher(Form, tr_num) {
	var rows = Form.getElementsByTagName('tr');
	var checkbox = rows[tr_num].getElementsByTagName('input')[0];
	var unique_id;
	if (checkbox && checkbox.type == 'checkbox') {
		unique_id = checkbox.name + checkbox.value;
		if (typeof(selected_row[unique_id]) == 'undefined' || !selected_row[unique_id]) {
			rows[tr_num].className += '_selected';
			selected_row[unique_id] = true;
			checkbox.checked=true;
		}
	}
}


	
function DateText(strDate) {	  
	day = strDate.substring(0,2);
	month = strDate.substring(3,5);
	year = strDate.substring(6,10);
	d = new Date(0);
	d.setDate(day);
	d.setMonth(month-1);
	d.setFullYear(year); 
	return d;  
}
function compare(date_a_comparer) {
	d = new Date();
	diff = date_a_comparer.getTime()-d.getTime();
	return (diff==0?diff:diff/Math.abs(diff));
}


function url(param){
	var strParam = new String(param);
	var position = window.location.search.indexOf('&' + strParam + '=');
	if (position == -1)
		position = window.location.search.indexOf('?' + strParam + '=');
	if (position == -1)
		return '';
	return (window.location.search.indexOf('&', position + strParam.length + 2)==-1) ? window.location.search.substr(position + strParam.length + 2) : window.location.search.substr(position + strParam.length + 2, window.location.search.indexOf('&', position + strParam.length + 2) - (position + strParam.length + 2));
}

Array.prototype.findIndex = function(value) {
	var ctr = "";
	for (var i=0; i < this.length; i++) {
		if (this[i] == value) {
			return i;
		}
	}
	return ctr;
}

Array.prototype.inArray = function(value) {
	for(var i = 0; i < this.length; i++) {
		if (this[i] == value)
		return true;
	}
	return false;
}


function PopUp(contenu) {
	w = open('','popup','scrollbars=yes, resizable=yes, width=900, scrollbars=yes');
	w.document.write('<HTML><BODY onblur="window.close();"><div id="pop"></div></BODY></HTML>');
	w.document.getElementById('pop').innerHTML = contenu;
	w.document.close(); 
}



function SupprimerEnr(Form) {
	var n = NbrCheckboxCoches(Form);
	
	if (n == 0) {
		$('msg_confirm').hide();
		$('alerte').show();
		$('plus_select').hide();
		$('aucun_select').show();
		return false;
	}
	else {
		$('alerte').hide();
		$('msg_confirm').show();
		return false;
	}
}



