$(document).ready(function(){
    $("#no_region_de").change(function() {
        ajoute_item(document.recherche.no_region,document.recherche.no_region_de,document.recherche.no_region_a);
    }).change();
});

var jsparindex = 0;
var imopen = 0;
var imopenAide = 0;
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
var answer_selected = '';
var aide_selected = '';
var continuer=true;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}


function findDOM(objectID) {
	if (isID) { return (document.getElementById(objectID).style) ; }
	if (isAll) { return (document.all[objectID].style); }
	if (isLayers) { return (document.layers[objectID]); }
}


function doAnswer(name) {
	if(answer_selected != name) {
		if(answer_selected != '') {
			var lastDOM = findDOM(answer_selected,1);
			lastDOM.visibility = 'hidden';
			lastDOM.position = 'absolute';
		}
	}
	var recentDOM = findDOM(name,1);
	if (recentDOM.visibility == 'hidden') {
		recentDOM.visibility = 'visible';
		recentDOM.position = 'static';
		imopen=1;
		answer_selected = name;

	} else {
		recentDOM.visibility = 'hidden';
		recentDOM.position = 'absolute';
		imopen=0;
	}
}


function ajoute_item(champ,champ_de,champ_a) {
	for (var i = 1; i < champ_de.options.length; i++) {
		if (champ_de.options[i].selected) {
			if(champ_a.value == '') {
				champ_a.value = champ_de.options[i].text;
				champ.value = champ_de.options[i].value;
			} else {
                // ici on devrait comparer si la valeur est deja presente dans "champ.value"
				$tmpActVal = ","+champ.value+",";
                $tmpNewVal = ","+champ_de.options[i].value+",";

                if ($tmpActVal.indexOf($tmpNewVal) == -1) {
                    champ_a.value = champ_a.value + ',' + champ_de.options[i].text;
                    champ.value = champ.value + ',' + champ_de.options[i].value;
                }
			}
		}
	}

}


function enleve_item(champ,champ_a,champ_e) {
	champ_a.value = '';
	champ.value = '';
	if (champ_e != undefined) champ_e.options[0].selected = true;
}


function changeCritere(objCritere, val){
	var doc=document.recherche;

	doc.nbrpages.value='';
	doc.page.value='';
	doc.total.value='';


    objCritere.value = val;

	doc.submit();
}


function verifier(){
	continuer=true;
	var doc=document.recherche;

	if (continuer){
		return true;
	} else {
		return false;
	}
}


function valider() {
    var doc=document.recherche;
    doc.gr.value = doc.lstgr.value;
    doc.cp.value = '0';
    doc.submit();
}


