
function find(item) {
  if( window.mmIsOpera ) return(document.getElementById(item));
  if (document.all) return(document.all[item]);
  if (document.getElementById) return(document.getElementById(item));
  return(false);
}

/***************************************************************************/
/*Declaration de la fonction handler*/
/***************************************************************************/
function    press_handler() {
  if (typeof(fetcher) == 'undefined') {
    return (true);
  }

  var div = find("content");		// Recherche en cours

  switch (fetcher.get_state()) {              // A chaque changement d'etat
  case    4:{
    div.innerHTML = fetcher.result();	// Fin de la recherche
    break;
  }
  default:
    break;
  }
}

function	go_form(){
  var		url = go_form.arguments[0];


  fetcher = new	js_fetch('POST');
  if(!fetcher.init()){
    alert(fetcher.error);
    return(true);
  }
  var div = find('test');
  if ((url == 'ecrans.phtml?ecran=depose_mandat')||(url == 'ecrans.phtml?ecran=contact')){
    div.style.background = "url('images/partie_droite.jpg')";     
  } else {div.style.background = "url('images/partie_droite.jpg')";     }
  for ( i = 1; i < go_form.arguments.length; i++){
    var theform = find(go_form.arguments[i]);
    if(!theform){return;}
    for (j = 0; j < theform.elements.length; j++) {
      name = theform.elements[j].name;
      if(theform.elements[j].type == "checkbox") {
	if(theform.elements[j].checked) {
	  value = theform.elements[j].value;
	  fetcher.add_param(theform.elements[j].name, value);
	}
      } else if (theform.elements[j].type == "select-one") {
	     value = theform.elements[j].options[theform.elements[j].selectedIndex].value;
	     fetcher.add_param(theform.elements[j].name, value);
	} else {
	value = theform.elements[j].value;
	fetcher.add_param(theform.elements[j].name, value);
      }
    }
  }
  fetcher.set_handler(press_handler);
  fetcher.go(url);
}

function	alert_mail()
{
  alert("Veuillez saisir une adresse E_Mail valide");
  return;
}




function var_dump(obj) {
  var s = new Array ();
  var i;
  var j = 0;

  for (i in obj) {
    s[j] = i + ": " + obj[i];
    j = j + 1;
  }
  s.sort ();
  document.open ("text/html");
  for (i=0; i<j; i++) {
    document.writeln (s[i], "<br />");
  }
}


function	verif_ch_sup() {
  var		theform = find("form_souhaits");

  inf = theform.ch_inf[theform.ch_inf.selectedIndex].value;
  sup = theform.ch_sup[theform.ch_sup.selectedIndex].value;

  if ( sup < inf ) {
    for (i = 1; i < theform.ch_sup.length; i++) {
      if (theform.ch_sup[i].value >= inf) {
	theform.ch_sup.selectedIndex = i;
	return ;
      }
    }
  }
}

function	verify_s_sup() {
  var		theform = find("form_souhaits");

  inf = theform.s_inf[theform.s_inf.selectedIndex].value;
  sup = theform.s_sup[theform.s_sup.selectedIndex].value;

  if(sup < inf) {
    for (i = 1; i < theform.s_sup.length; i++) {
      if(theform.s_sup[i].value >= inf) {
	theform.s_sup.selectedIndex = i;
	return;
      }
    }
  }
}

