// Vérifie qu'un fichier a bien été rentré
function validFileForm(form,langue) {
    with (form) {
		if (fichier.value=="") {
            if (langue=="Fr") alert("Veuillez rentrer un fichier, SVP.");
			else if (langue=="En") alert("Please, select a file.");
			else if (langue=="All") alert("");
            return false;
        }
		submit();
    }
}

// Lance une page dans l'iframe nom avec l'id de l'élément sélectionné dans la liste obj
function changeListe(obj,nom,langue) {
	indice = obj.options.selectedIndex;
	if (indice>0) {
		document.getElementById(nom).src = nom+".php?langue="+langue+"&id="+obj.options[indice].value;
	}
}
/*
// Ouvre le popup de la liste des résultats
function openListe(obj,langue,nomFich,id1) {
	indice = obj.options.selectedIndex;
	if (indice>0) {
		window.open(nomFich+".php?langue="+langue+"&id1="+id1+"&id2="+obj.options[indice].value,"Liste","width=600, height=500, scrollbars=1");
	}
}
*/
// Ouvre le popup de la liste des résultats
function openListe(nom,obj,langue,nomFich,id0,id1) {
	if (id0!="" && id0!="0") {
		indice = obj.options.selectedIndex;
		if (indice>0) {
			window.open(nomFich+".php?langue="+langue+"&id0="+id0+"&id1="+id1+"&id2="+obj.options[indice].value,"Liste","width=420, height=500, scrollbars=1");
		} else {
			if (nomFich=='listeVehicules') {
				if (langue=="Fr") alert("Veuillez sélectionner un outil, SVP.");
				else if (langue=="En") alert("Select a tool, please");
				else if (langue=="All") alert("Wählen Sie bitte ein Werkzeug aus.");
				
			}
		}
	} else {
		if (langue=="Fr") alert("Veuillez sélectionner "+nom+", SVP.");
		else if (langue=="En") alert("Select a "+nom+", please.");
		else if (langue=="All") alert("Wählen Sie bitte "+nom+" aus.");
	}
}

// Met à jour l'id du modèle choisi dans la page parent
function setIdModele(obj) {
	indice = obj.options.selectedIndex;
	parent.formMarque.idModeleType.value = obj.options[indice].value;
}


/**
 * The global array below will be used inside the "setPointer()" function
 */
var markedRow = new Array();
/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 * @param   object   the background color
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // end of the 'setPointer()' function
