function open_close_div(id){
	var curdiv = document.getElementById(id);
	if (curdiv.style.display == "none")	{
		curdiv.style.display = "block";
	} else {
		curdiv.style.display = "none";
	}
}

/********************************** LES FONCTIONS STANDARDS ******************************************/
function on_focus(){
	if (document.formSearch.txt.value=='Rechercher'){
		document.formSearch.txt.value=''
	}
}
function on_blur(){
	if (document.formSearch.txt.value==''){
		document.formSearch.txt.value='Rechercher'
	}
}

function sendData(param, page, contenu)	{
	if(document.all) {
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	} else {
		//Mozilla
		var XhrObj = new XMLHttpRequest();
	}
	//définition de l'endroit d'affichage:
	var content = document.getElementById(contenu);
 	var elt = document.getElementById('loading');
	var navigation = document.getElementById('navigation');
	if (navigation){
		navigation.innerHTML="";
	}

	XhrObj.open("POST", page);
	//Ok pour la page cible
	XhrObj.onreadystatechange = function() {

					switch (XhrObj.readyState) {
						case 1:
							// 1 (loading)	début du transfert des données : loading visible
							elt.style.display="block";
							break;
						case 2:
							// 2 (loaded)	données transférées : loading visible
							elt.style.display="block";
							break;
						case 3:
							// 3 (interactive)	les données reçues sont accssibles en partie : loading visible
							elt.style.display="block";
							break;
						case 4:
							//si la page cible est OK (code HTTP 200) et 4 (complete :les données sont complètement accessibles), loading caché
							// NB : Firefox declanche avec "status" tant que le code de chargement n'est pas à  4
							if (XhrObj.status == 200) 
								{
									//définition de l'endroit d'affichage:
									var content = document.getElementById(contenu);
									//on affecte à  l'endroit d'affichage la valeur du fichier distant recupéré avec  la propriété .responseText
									content.innerHTML = XhrObj.responseText ;
									// s'il y avait un Javascript à  interpreter dans le fichier distant, on ecrirait : eval(XhrObj.responseText);
								}
							elt.style.display="none";
							
							break;
						default:
							// 0 (uninitialized)	non initialisé
							alert('Le serveur est bloqué. Veuillez recommencer.');
							break;
					}

	}
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(param);
}



function GetData(param, page, contenu)	{
	if(document.all) {
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	} else {
		//Mozilla
		var XhrObj = new XMLHttpRequest();
	}
	//définition de l'endroit d'affichage:
	var content = document.getElementById(contenu);
	XhrObj.open("POST", page);
	//Ok pour la page cible
	XhrObj.onreadystatechange = function() {
		if (XhrObj.readyState == 4 && XhrObj.status == 200)
				content.innerHTML = XhrObj.responseText ;
	}
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(param);
}


function submitform(pressbutton){
	document.adminForm.action.value=pressbutton;
	if (pressbutton=="apply"){
		document.adminForm.mode.value="appliquer";
	}
	try {
		validateForm();
		}
	catch(e){}
}

var confirmMsg  = 'Voulez-vous vraiment effectuer ';
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'img' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' marked';
            } else {
                this.className = this.className.replace(' marked', '');
            }

        }
    }
}
window.onload=PMA_markRowsInit;



