function fill_prix(NomChamp)
{
  document.FORM_SOUS[NomChamp].onkeypress=function(){ return compleat_combo(NomCombo,document.FORM_SOUS[NomChamp].value)}
  document.FORM_SOUS[NomChamp].onkeyup=function(){ return calcul_total()}
}

function calcul_notaire()
{
  PrixAchat = Math.round(document.FORM_SOUS.P1_PRIX_BIEN.value.replace(',','.')) ;

  if ( PrixAchat > 16770 )     FraisNotaire = 429.16 + 0.00825 * ( PrixAchat - 16770 ) ;
  else if ( PrixAchat > 6100 ) FraisNotaire = 253.12 + 0.0165  * ( PrixAchat - 6100  ) ;
  else if ( PrixAchat > 3050 ) FraisNotaire = 152.5 + 0.033  * ( PrixAchat - 3050  ) ;
  else FraisNotaire = 0.05  * PrixAchat ;

  FraisNotaire = 300 + Math.round(FraisNotaire * 1.196) ;

  if ( document.FORM_SOUS.P1_TYPE_BIEN.selectedIndex == 1  || document.FORM_SOUS.P1_TYPE_BIEN.selectedIndex == 3)
  {
    DroitMut = Math.round ( 0.0509 * PrixAchat ) ;
  }
  else
  {
    DroitMut = Math.round ( (0.00715 * PrixAchat ) / 1.196 ) ;
  }

  Debours = 250 + Math.round ( 0.001 * PrixAchat ) ;
  document.FORM_SOUS.P1_PRIX_NOTAIRE.value = (FraisNotaire + Debours + DroitMut ) ;
}

function calcul_total()
{
  PrixTotal  = Math.round(document.FORM_SOUS.P1_PRIX_BIEN.value.replace(',','.')) ;
  PrixTotal += Math.round(document.FORM_SOUS.P1_PRIX_TRAVAUX.value.replace(',','.')) ;
  PrixTotal += Math.round(document.FORM_SOUS.P1_PRIX_NOTAIRE.value) ;
  PrixTotal += Math.round(document.FORM_SOUS.P1_PRIX_FRAIS.value.replace(',','.')) ;

  document.FORM_SOUS.P1_PRIX_TOTAL.value = PrixTotal ;
}

/* --------------------------------------------------------------
Verification que l'on a rentre les bon champs dans la Form
-----------------------------------------------------------------*/
function CheckForm()
{
  FormError = '' ;

  if ( document.FORM_SOUS.P1_PRIX_BIEN.value == 0 ) FormError += "Veuillez donner un Prix à votre bien\n" ;
  if ( document.FORM_SOUS.P1_PRIX_TOTAL.value.length == 0  || document.FORM_SOUS.P1_PRIX_TOTAL.value < 10) calcul_total();

  if ( FormError.length > 5 )
  {
    alert ( FormError ) ;
    return false ;
  }
  else return true;
}


function info_bulle(Id_Info,visible)
{
  //alert (BulleStyle ) ;
  var oInfoBulle = document.getElementById(Id_Info);

  var browser=new getBrowser();
  if (  visible == 1 )
  {
    fade(oInfoBulle);
    if (browser.gotSelectBug) {
        document.FORM_SOUS.P1_USAG_BIEN.style.display = 'none' ;
        document.FORM_SOUS.P1_TYPE_BIEN.style.display = 'none' ;
        document.FORM_SOUS.P1_VILLE.style.display = 'none' ;
    }
  }
  else
  {
    fade(null) ;
    if (browser.gotSelectBug) {
        document.FORM_SOUS.P1_USAG_BIEN.style.display = '' ;
        document.FORM_SOUS.P1_TYPE_BIEN.style.display = '' ;
        document.FORM_SOUS.P1_VILLE.style.display = '' ;
    }
  }
}

 /*-------------------------------*
  *     Code postal - ville       *
  *-------------------------------*/

function onchange_cp(el) {
  cpv.setCP(el.value);
  cpv.calculateVilles();
}
function onchange_cpv() {
  ville=getObject("P1_VILLE");
  myVilles=cpv.getVilles();
  if (myVilles.length==1) {
    ville.blur();
    ville.value=myVilles[0];
    getObject("P1_PRIX_BIEN").focus();
  }
}