/*
<?
$rep = "";
while(!file_exists($rep."include/configuration.inc")) { $rep = $rep."../"; }
include($rep."include/configuration.inc");
?>
*/
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
/*** ***** Utiliser ***** ***/

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
	}
		  
		  function loadOne() {
        window.location.reload();
        }

function openwindow(url,name,width,height,ptop,pleft) {
	window.open(url,name,'toolbar=0,menubar=0,scrollbars=yes,resizable=0,width=' + width + ',height=' + height + ',top=' + ptop + ',left=' + pleft);
	}

/************************** ajouter
 *
 */

function ajouter(id,url) {
	pleft = (window.screen.availWidth - 640) / 2;
	ptop = (window.screen.availHeight - 480) / 2;
	openwindow(url+'_modifier.php?id='+id,'modifier',640,480,ptop,pleft);
	}

/************************** repondre
 *
 */

function repondre(id,table) {
	pleft = (window.screen.availWidth - 640) / 2;
	ptop = (window.screen.availHeight - 480) / 2;
	openwindow('repondre.php?id='+id+'&table='+table,'repondre',640,480,ptop,pleft);
	}

/************************** supprimer
 *
 * Version : 1.2 2003-09-04
 * Auteur : Sebastien Poubelle
 *
 * Appelle la page supprimer.php qui permet de supprimer
 * l'enregistrement 'id' de la table 'table' de la base
 * de donnée courante.
 * 'url' est l'adresse de retour et 'arg' est la chaine
 * de caractères correspondant aux argument à retourner.
 *
 */

function supprimer(id,table,url,arg) {
	if(confirm("Confirmez-vous la suppression définitive ?\n")) {
		location = "supprimer.php?id="+ id +"&table="+table +"&url="+ url +"&arg=&"+ arg;
		}
	}

function traiteur_supprimer(id,type,url,arg) {
	if(confirm("Confirmez-vous la suppression définitive ?\n")) {
		if(type == 0) {
			if(confirm("Il est possible que le traiteur soit associé à des lieux de réception.\nConfirmez-vous leurs suppressions définitives ?\n")) {
				location = "traiteur_supprimer.php?sup_id="+ id +"&url="+ url +"&arg=&"+ arg;
				}
			}
		else location = "traiteur_supprimer.php?sup_id="+ id +"&url="+ url +"&arg=&"+ arg;
		}
	}

function pub_supprimer(id,arg) {
	if(confirm("Confirmez-vous la suppression définitive ?\n")) {
		location = "pub_supprimer.php?id="+ id;
		}
	}

function fiche(id,table)
{
        pleft = (window.screen.availWidth - 640) / 2;
        ptop = (window.screen.availHeight - 480) / 2;
        openwindow('fiche.php?id='+id+'&table='+table,'fiche',640,480,ptop,pleft);
}

function traiter(id,table) {
        pleft = (window.screen.availWidth - 640) / 2;
        ptop = (window.screen.availHeight - 480) / 2;
        openwindow('traiter.php?id='+id+'&table='+table,'traiter',640,480,ptop,pleft);
        }

function valider_traitement(color,id,table) { // version 1.1
        if(confirm("Confirmez-vous le traitement ?")) {
                document.getElementById("nowLoading").innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
                document.location.href = "traiter_valid.php?id="+ id +"&table="+ table;
               }
        }

function loaded(color) { // version 1.2
        document.getElementById("nowLoading").innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
        }

function reloaded(color,id) { // version 1.2
        document.getElementById(id).innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
        }

function verif(color) { // version 3.1 (dernière modification éffectuée par Sébastien Poubelle)
        if(eval('document.form.objet')) {
                if( document.form.objet.value == "" ) {
                        alert("Vous n'avez pas saisi d'objet");
                        document.form.objet.focus();
                        return;
                        }
                }
        if(eval('document.form.corps')) {
                if(document.form.corps.value == "") {
                        alert("Vous n'avez pas saisi de message");
                        document.form.corps.focus();
                        return;
                        }
                }
        if(eval('document.form.email')) {
                var email = document.form.email.value;
                if(email.indexOf("@") == "-1" || email.indexOf(".") == "-1" || email == "") {
                        alert("Vous n'avez pas saisi d'email");
                        document.form.email.focus();
                        return;
                        }
                }
        document.getElementById("nowLoading").innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
        document.form.submit();
        }

function IsNumeric(strString)
// check for valid numeric strings
{
        var strValidChars = "0123456789.- ";
        var strChar;
        var blnResult = true;

        if (strString.length == 0) return false;

        // test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
                strChar = strString.charAt(i);
                if (strValidChars.indexOf(strChar) == -1) blnResult = false;
        }
        return blnResult;
}

function popup(pop_url,pop_width,pop_height) {
        pop_name = pop_url.substring(0,pop_url.indexOf("."));
        pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
        pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
        window.open(pop_url,pop_name,"left=" + pop_left + ",top=" + pop_top + ",width=" + pop_width + ",height=" + pop_height + ",scrollbars=no,noresize");
        }

/******************** FONCTION PHPMYADMIN ********************/

/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */

function setSelectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

//    return true;
} // end of the 'setSelectOptions()' function

function ejs_img_fx(img) {
     if(img && img.filters && img.filters[0]) {
          img.filters[0].apply();
          img.filters[0].play();
          }
     }

/************************** mailto 1.1 2007-06-22
 *
 * Auteur : Sébastien Poubelle
 *
 */


function mailto(user,domaine,style) {
	var at = "@"
	document.write("<a href=\"mailto:"+ user + at + domaine +"\" style=\""+ style +"\">");
	document.write(user + at + domaine +"</a>");
	}

