var m_nom,m_tx,m_div,m_vol,m_step,m_type,m_style,m_exercice,m_parite,m_spot,m_dat1,m_dat2,mystring;

m_step=100;

var loc22;

var awar = new Array();

function scenar() {
  var temp5;var tempdate;var f3;var f2;var f3;//m_step=100;
  v=testinput();
  if (v==true) {
    gh=calcprix(m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite);
    f3=parseFloat(document.mform.varact.value);
    f1=parseFloat(document.mform.varvol.value);
    f2=parseInt(document.mform.vartemps.value);
    tempdate=new Date();
    tempdate.setTime(m_dat1.getTime()+(f2*24*60*60*1000));
// ab
//temp5=calcprix(m_type,m_style,m_step,m_spot*(1+(f3/100)),tempdate,m_dat2,m_tx,m_div,m_vol+f1,m_exercice,m_parite);
    temp5=calcprix(m_type,m_style,m_step,f3,tempdate,m_dat2,m_tx,m_div,m_vol+f1,m_exercice,m_parite);
    document.mform.scenarwarr.value=round_up(temp5,4);
    document.mform.pourc.value=round_up(((temp5/gh)-1)*100.0,2);
//
//ab
    document.mform.pourcspread.value=round_up(100.*(temp5/(1.0*document.mform.varspread.value+gh)-1.0),2);
  }
}


function testvalue(x,borneinf,bornesup,nomvar)
{g="Erreur: "+nomvar+" n'est pas compris entre "+borneinf+" et "+bornesup;y="";if (x>=borneinf){if (x<=bornesup) return y;else return g;} else return g;}

function round_up(x, n) 
{
  var i;
  x = Math.round(x * Math.pow(10.0, n)) / Math.pow(10.0, n);  x = "" + x;  i = x.indexOf(".");
  if(i != -1) return x.substring(0, i + n + 1);  else return x;
}

function testinput()
{
var f;var h;

err1="";
m_tx=parseFloat(document.mform.ti.value);if (err1=="") err1=testvalue(m_tx,0,100,"Le taux d'intérêt");
m_div=parseFloat(document.mform.tdiv.value);if (err1=="") err1=testvalue(m_div,0,100,"Le taux de dividende");	
m_vol=parseFloat(document.mform.vol.value);
//if (err1=="") err1=testvalue(m_vol,0.001,200,"La volatilité");	
m_style=parseInt(document.mform.style[document.mform.style.selectedIndex].value);
m_type=parseInt(document.mform.type[document.mform.type.selectedIndex].value);
m_dat2=new Date(document.mform.datefina.value,document.mform.datefinm.value-1,document.mform.datefinj.value);
h=new Date();m_dat1=new Date(h.getFullYear(),h.getMonth(),h.getDate());
f=m_dat2.getTime()-m_dat1.getTime();if (f<=0) err1="Erreur : Date de valorisation supérieure ou égale à date d'échéance";	
m_spot=parseFloat(document.mform.pact.value);
if (err1=="") err1=testvalue(m_spot,0,1e10,"Le cours de l'action");	
m_exercice=parseFloat(document.mform.pexe.value);
if (err1=="") err1=testvalue(m_exercice,0,1e10,"Le prix d'exercice");	
m_parite=parseFloat(document.mform.parite.value);
if (err1=="") err1=testvalue(m_parite,0,1e10,"La parité du warrant");	
if (err1=="") return true;else {alert(err1);return false;}
}

function comment()
{
com0="Le warrant est ";com1="L'action devra varier de ";com2=" % pour ne pas perdre de l'argent à la maturité du warrant.";
if (m_type==0)
money=(m_spot/m_exercice)-1;else money=(m_exercice/m_spot)-1;
fg=document.mform.valo.value;
if (money<0.0) com10="en dehors de la monnaie.";else com10="dans la monnaie.";
if (m_type==0) perf=round_up((m_exercice+(fg*m_parite)-m_spot)/m_spot*100,2);else perf=round_up((m_exercice-(fg*m_parite)-m_spot)/m_spot*100,2);
document.mform.comment1.value=com0+com10+" "+com1+perf+com2;
}

function sensibilite(parametre,callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,vol,exercice,parite) {
  t=calcprix(callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,vol,exercice,parite);
  tempdate=new Date();
// definition du theta : variation sur 1j
  tempdate.setTime(datedeb.getTime()+(1*24*60*60*1000));
  varact=0.0005;
  if (parametre=="delta") {
    t1=calcprix(callput,amereurop,nbreperiode,spot*(1.0-varact),datedeb,datefin,tx,div,vol,exercice,parite);
    t2=calcprix(callput,amereurop,nbreperiode,spot*(1.0+varact),datedeb,datefin,tx,div,vol,exercice,parite);
// ab simplification
//    return 100*((t1-t)/(-spot*varact/parite)+(t2-t)/(spot*varact/parite))/2;
    return 50.0*((t2-t1)/(spot*varact/parite));
  }
  if (parametre=="vol")
    return 100*(calcprix(callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,vol+1.0,exercice,parite)-t)/t;
  if (parametre=="temps")
    return 100*(calcprix(callput,amereurop,nbreperiode,spot,tempdate,datefin,tx,div,vol,exercice,parite)-t)/t;
  if (parametre=="levier")
// ab simplification
//  return((calcprix(callput,amereurop,nbreperiode,spot*(1+varact),datedeb,datefin,tx,div,vol,exercice,parite)-t)/(spot*varact/parite)*spot/t/parite);
  return((calcprix(callput,amereurop,nbreperiode,spot*(1.0+varact),datedeb,datefin,tx,div,vol,exercice,parite)-t)/(varact*t));
}


function putvalue() {
//m_step=100;

v1=testinput();
if (v1==true)
{	
// ab
//document.mform.valo.value=round_up(calcprix(m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),4);
document.mform.delta.value=round_up(sensibilite("delta",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
document.mform.levier.value=round_up(sensibilite("levier",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
document.mform.sensvol.value=round_up(sensibilite("vol",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
document.mform.senstemps.value=round_up(sensibilite("temps",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
comment();
//alert("Calculs terminés...")
}
}


function calcprix(callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,vol,exercice,parite) {
  prix = new Array(nbreperiode+1);
  OPT = new Array(nbreperiode+1);

  periode1=(datefin.getTime()-datedeb.getTime());
  periode=0.0+(periode1)/(1000.0*60*60*24*365.0*nbreperiode);
  temp1=0.0+(tx-div)/100.0*(periode);
  temp2=0.0+(tx)/100.0*(periode);
  temp3=0.0+(vol)/100.0*Math.sqrt(periode);
  rperdiv=Math.exp(temp1);
  rperinv=Math.exp(-temp2);
  up = Math.exp(temp3);
  upup = up *up;
  down = 1.0 / up;
  probup = (rperdiv - down) / (up - down);
  probdown = 1 - probup;

  prix[0] = 0.0+(spot) * (Math.pow(down, nbreperiode));
  test = prix[0] - (exercice);
  if (callput==1)test =0.0-test;
  OPT[0] = 0.0+Math.max(test, 0);

  for (i = 1;i<=nbreperiode;i++) {
    prix[i] = upup * prix[i - 1];
    test = prix[i] - (exercice);
    if (callput==1)test =0.0-test;
    OPT[i] = 0.0+Math.max(test, 0);
  }

  for(j = 1;j<=nbreperiode;j++) {
    n=nbreperiode-j;
    for(i = 0;i<=n;i++) {
      max1 = ((probup * OPT[i + 1]) + (probdown * OPT[i])) * rperinv;prix[i] = down * prix[i + 1];
      if (amereurop==0) {
        test = prix[i] - (exercice);
        if (callput ==1) test = 0.0-test;
        OPT[i] =0.0+Math.max(max1, test);
      } else OPT[i] = 0.0+max1;
    }
  }
  return (0.0+(OPT[0]/parite));
}

function calculvolat(valwar,callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,vol,exercice,parite) {
  min=0.0;max=110.0;temp=0;tempor=valwar;x=0;compt=0;mid=0;

  while ((Math.abs((tempor-temp)/temp)>=0.0001) && (compt<40)) {
    compt=compt+1;
//    if (compt==100) x=26;
//    if (Math.abs((tempor-temp)/temp)<=0.0001/100) x=27;
//    if(x<25) {
      mid=(min+max)*0.5;
      temp=calcprix(callput,amereurop,nbreperiode,spot,datedeb,datefin,tx,div,mid,exercice,parite);
//    }

//    if (temp==0) x=26;
    if (tempor>temp) min=mid;
    else max=mid;
  }
  if ((0.0==mid) || (mid==110.0)) return NaN;else return mid;
}

function calcvol() {
  document.mform.vol.value=1;
  v1=testinput();
  if (v1==true) {
    valwar=parseFloat(document.mform.valo.value);
    pipo=0.0+calculvolat(valwar,m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite);
//    if (pipo<0) alert("Volatilité impossible à calculer")
    //ab
    //else {document.mform.vol.value=round_up(pipo,2);alert("Calcul terminé");}
//    else {
//      document.mform.vol.value=round_up(pipo,2);
//    }
    document.mform.vol.value=round_up(pipo,2);
  }
}

//
// suite
var ctype,cmat,cprice,cdelt,cvolat,clevier,cstemps,csvol,cvolu,ccomment;
ctype=0;cmat=0;cprice=0;cdelt=0;cvolat=0;clevier=0;cstemps=0;csvol=0;cvolu=0;ccomment=0;

function cwarrant() {
  var newwind2=window.open('http://bourse.lesechos.fr/d_betd.asp?CodeSICO='+document.mform.sicovam.value,'warrant',"toolbar=yes,status=no,width=800,height=400,directories=no,scrollbars=yes,location=yes,resize=yes,menubar=yes");
}

function caction() {
  var newwind2=window.open('http://www.boursorama.com/cours33.phtml?code='+document.mform.sicojacent.value+'&choix_bourse=pays%3D33','action',"toolbar=yes,status=no,width=800,height=400,directories=no,scrollbars=yes,location=yes,resize=yes,menubar=yes");
}

function criteres(type,mat,price,delt,volat,levier,stemps,svol,volu,comment,em) {
}

function launch(a,b) {
  var newwind=window.open('http://www.boursorama.com/graphiques/graphique_histo.phtml?form=OUI&mo=0&code='+a+'&choix_bourse=pays%3D33&tc=1&duree=1&pe=0&is=0&mm1=50&mm2=&mm3=&comp=4&codeComp='+b+'&choix_bourseComp=pays%3D33&i1=1&i2=0&i3=0&st=7&grap.x=28&grap.y=11','Graphique',"toolbar=yes,status=no,width=800,height=400,directories=no,scrollbars=yes,location=yes,resize=yes,menubar=yes");
}

function extract(sep) {
  i=mystring.indexOf(sep);
  if (i != -1) {
	y=mystring;    	
	mystring=mystring.substring(i+1,mystring.length);
	return y.substring(0, i );
  }
  else
   	return mystring;
}

function graph() {
  launch(document.mform.sicovam.value,document.mform.sicojacent.value);
}


function detailwarr() {
  var loc1;var loc2;var ameur;
  var temp;var temp1;var typi;var f;var f1;
  var m_m;

  loc1=document.mform.select1.selectedIndex;
  loc2=document.mform.lwarr.selectedIndex;

  mystring=awar[loc2];
  m_m=extract(',');
  m_m=extract(',');

  mystring=a[loc1+1][m_m];
  document.mform.sicovam.value=extract(",");
  typi=extract(",");
  if (typi=="C") {
    document.mform.type.selectedIndex=0;
    document.mform.varvol.value=0.5;
  }
  else {
    document.mform.type.selectedIndex=1;
    document.mform.varvol.value=-0.5;
  }
  document.mform.varvol.value=0.0;
  f=extract(",");f1=mystring;mystring=f;
  document.mform.datefinj.value=extract("/");document.mform.datefinm.value=extract("/");
  f=parseInt(extract("/"));if (f<=70) f=f+2000; else f=f+1900;
  document.mform.datefina.value=f;mystring=f1;
  document.mform.pexe.value=extract(",");
//  document.mform.valo.value=extract(",");
//  document.mform.newwar.value=document.mform.valo.value;
//  document.mform.hasuivi.value=document.mform.valo.value;
//
//ab
//  document.mform.delta.value=extract(",");
//  document.mform.vol.value=extract(",");
//  document.mform.levier.value=extract(",");
//  document.mform.senstemps.value=extract(",");
//  document.mform.sensvol.value=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
//
//
//  document.mform.volume.value=extract(",");
  f=extract(",");
  document.mform.parite.value=extract(",");
  document.mform.quotite.value=extract(",");
  temp1=extract(",");
  if (temp1=="S") temp1="SG";
  if (temp1=="B") temp1="BN";
  if (temp=="CM") temp="CALC! MAT!";
  if (temp=="C") temp="CALC!";
  if (temp=="M") temp="MAT!";
  document.mform.comment.value=temp;
  document.mform.emett.value=temp1;
  document.mform.ti.value=extract(",");
  document.mform.tdiv.value=extract(",");
  ameur=extract(",");
  if (ameur=="A") document.mform.style.selectedIndex=0;else document.mform.style.selectedIndex=1;

  document.mform.varspread.value=extract(",");
//
// cours du support
//  prixg=mystring;
//  document.mform.pact.value=prixg;
//  document.mform.varact.value=document.mform.pact.value;
//  document.mform.varactp.value="0.00";
//
//ab
//  mydate=new Date();
//  document.mform.dmaj.value=mydate.getDate();
//  document.mform.mmaj.value=mydate.getMonth()+1;
//  document.mform.ymaj.value=mydate.getYear();

//  document.mform.hmaj.value=mydate.getHours();
//  document.mform.mnmaj.value=mydate.getMinutes();

  mystring=a[loc1+1][m_m];
//
// a virer
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
//
  document.mform.valo.value=extract(",");
  document.mform.newwar.value=document.mform.valo.value;
  document.mform.hasuivi.value=document.mform.valo.value;
//
  document.mform.delta.value=extract(",");
  document.mform.vol.value=extract(",");
  document.mform.levier.value=extract(",");
  document.mform.senstemps.value=extract(",");
  document.mform.sensvol.value=extract(",");
  document.mform.volume.value=extract(",");
//
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
  f=extract(",");
//
//  document.mform.varspread.value=extract(",");
}

function detailwarr2(loc22) {
  var loc1;var ameur;
  var temp;var temp1;var typi;var f;var f1;
//  var m_m;

  loc1=document.mform.select1.selectedIndex;
//  loc2=document.mform.lwarr.selectedIndex;

//  mystring=awar[loc22];
//  m_m=extract(',');
//  m_m=extract(',');

  mystring=a[loc1+1][loc22];
  document.mform.sicovam.value=extract(",");
  typi=extract(",");
  if (typi=="C") {
    document.mform.type.selectedIndex=0;
    document.mform.varvol.value=0.5;
  }
  else {
    document.mform.type.selectedIndex=1;
    document.mform.varvol.value=-0.5;
  }
  document.mform.varvol.value=0.0;
  f=extract(",");f1=mystring;mystring=f;
  document.mform.datefinj.value=extract("/");document.mform.datefinm.value=extract("/");
  f=parseInt(extract("/"));if (f<=70) f=f+2000; else f=f+1900;
  document.mform.datefina.value=f;mystring=f1;
  document.mform.pexe.value=extract(",");
  document.mform.valo.value=extract(",");
  document.mform.delta.value=extract(",");
  document.mform.vol.value=extract(",");
  document.mform.levier.value=extract(",");
  document.mform.senstemps.value=extract(",");
  document.mform.sensvol.value=extract(",");
  document.mform.volume.value=extract(",");
  document.mform.parite.value=extract(",");
  temp=extract(",");
  temp1=extract(",");
  if (temp1=="S") temp1="SG";if (temp1=="B") temp1="BN";
  if (temp=="CM") temp="CALC! MAT!";
  if (temp=="C") temp="CALC!";
  if (temp=="M") temp="MAT!";
  document.mform.comment.value=temp;
  document.mform.emett.value=temp1;
  document.mform.ti.value=extract(",");
  document.mform.tdiv.value=extract(",");
  ameur=extract(",");
  if (ameur=="A") document.mform.style.selectedIndex=0;else document.mform.style.selectedIndex=1;
}

function ctol(st,spot) {
  var sico;var type; var mat;var exer;var price;var delt;var volat;var levier;var stemps;
  var svol;var volu;var pari;var comment;var em;
  var fg;var money;var sep;var temp;var mid;var min;var max;
  sep=" | ";
  mystring=st;sico=extract(",");type=extract(",");mat=extract(",");exer=extract(",");price=extract(",");
  delt=extract(",");volat=extract(",");levier=extract(",");stemps=extract(",");svol=extract(",");
  volu=extract(",");pari=extract(",");comment=extract(",");em=extract(",");

//ab
  spot=extract(',');spot=extract(',');spot=extract(',');spread=extract(',');spot=extract(',');
  document.mform.pact.value=spot;
  document.mform.varact.value=document.mform.pact.value;
  document.mform.varspread.value=spread;
  document.mform.varactp.value="0.00";
  
  fg=sico+sep+type+sep+mat;
  mid="_°_";
  max="__°";
  min="°__";
//
// indicateurs de position du warrants Dans ou hors la monnaie
  if (type=="C") money=(spot/exer)-1;else money=(exer/spot)-1;
  if (money<0.0) temp="H";else temp="D";
  fg=fg+sep+temp
//
// indicateurs de position du delta du warrant
  delt=Math.abs(delt);
  if(delt>=60) temp="         60 < delta";
  if ((delt<60)&&(delt>40)) temp="40 < delta < 60";
  if(delt<=40) temp="delta < 40         ";
  fg=fg+sep+temp;
//
// Indicateur de position du levier du warrant
  levier=0+Math.abs(levier);
  if(levier>=6) temp="       6 < levier";
  if ((levier<6)&&(levier>3)) temp="3 < levier < 6";
  if(levier<=3) temp="levier < 3       ";
  fg=fg+sep+temp;
//
  if(stemps>=-0.6) temp="           -0.6 < theta";
  if ((stemps<-0.6)&&(stemps>-1.2)) temp="-1.2 < theta < -0.6";
  if(stemps<=-1.2) temp="theta < -1.2";
  fg=fg+sep+temp;
//if(svol>=4) temp=max;if ((svol<4)&&(svol>2)) temp=mid;if(svol<=2) temp=min;fg=fg+sep+"SVOL:"+temp;
if (comment=="CM") comment="CALC! MAT!";
if (comment=="C") comment="CALC!";
if (comment=="M") comment="MAT!";
//  fg=fg+sep+comment;
  return fg
}

function he(f) {
  return ("<td class=\"table\">"+"<font face='Arial' size='2'>"+f+"</font>"+"</td>");
}

function hec(f) {
  return ("<td align=\"center\" width=\"50\" class=\"table\">"+"<font face=\"Arial\" size=\"2\"><b>"+f+"</b></font>"+"</td>");
}

function hec3(f) {
  return ("<td align=\"center\" width=\"50\" class=\"table\" colspan=\"3\">"+"<font face=\"Arial\" size=\"2\"><b>"+f+"</b></font>"+"</td>");
}

function herg(f) {
  return ("<td align=\"right\"  bgcolor=\"#cccccc\" width=\"50\" class=\"table\">"+"<font face=\"Arial\" size=\"2\"><b>"+f+"</b></font>"+"</td>");
}

function her(f) {
  return ("<td align=\"right\" width=\"50\" class=\"table\">"+"<font face='Arial' size='2'><b>"+f+"</b></font>"+"</td>");
}

function het(f) {
  return ("<td align=\"right\" width=\"50\" class=\"table\" bgcolor=\"#121212\">"+"<font face='Arial' size='2'><b>"+f+"</b></font>"+"</td>");
}

function hex(f) {
  var charhex='0123456789abcdef';
  var c;
  c=f/16;
//  c=4;
  return (charhex.substring(c,c+1)+charhex.substring(c,c+1));
//  return (c);
}

function warrtohtml() {
  var sico;var type; var mat;var exer;var price;var delt;var volat;var levier;
  var cool;var stemps;var svol;var volu;var pari;var comment;var em;
  var tx;var txdiv;var typew;
  var r; var t;
  var fg;var money;var sep;var temp;var mid;var loc;var loc1;var j;var fg;var entete;var prixg;sep=" ";

  mystring=document.mform.select1[document.mform.select1.selectedIndex].value;
  r=extract(",");
  t=extract(",");
  prixg=extract(",");
  loc1=document.mform.select1.selectedIndex;
  var newwind2=window.open("liste.htm");
  cool="<font face='Arial' size='2'>"+r+"  "+t+"  Cours sous-jacent: "+prixg+"</font>";
  newwind2.document.write(cool);
  newwind2.document.write('<table width="100%" border="1" cellspacing="0" bgcolor="#CCCCCC">');
  cool="<tr>"+hec("Sico")+hec("C/P")+hec("Maturité")+hec("Prix exercice")+hec("Prix")
    +hec("Delta")+he("Volatilité")+hec("Levier")+hec("Sens Temps<br>20 jours")
    +hec("Sens volatilit&eacute;")+hec("Volume")+hec("Parité")+hec("Emetteur")+"</tr>";
    +"</tr></table>";
  newwind2.document.write(cool);
  newwind2.document.write('<table width="*" border="1" cellspacing="0" bgcolor="#CCCCCC">');

//  message=window.open("mes.html",,"width=640,height=480")
  message=window.open("mes.html")
  cool="Calcul les propriétés des warrants du support sélectioné. Cela peut prendre plusieurs minutes "
    +"suivant votre machine. <br>(ex. PIII 500, 2 secondes par warrant)";
  message.document.write(cool);
  setTimeout('message.close();',3000);

//  newwind2.focus();

  for(j = 1;j<=(a[loc1+1].length-1);j++) {
    mystring=a[loc1+1][j];
    sico=extract(",");
    type=extract(",");
    mat=extract(",");
    exer=extract(",");
    price=extract(",");
//
// ancienne methode, ne pas effacer ou modifier a cause de la fonction extract.
    delt=extract(",");volat=extract(",");levier=extract(",");stemps=extract(",");svol=extract(",");
    volu=extract(",");pari=extract(",");comment=extract(",");em=extract(",");
    tx=extract(",");txdiv=extract(",");typew=mystring;
    if (svol == "") {
// modifier pour calcul de stats
      loc22=j;
      detailwarr2(loc22);
      document.mform.vol.value=1;
      testinput();
      valwar=parseFloat(document.mform.valo.value);
      volat=round_up(calculvolat(valwar,m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
      document.mform.vol.value=volat;
//    calcvol();
//    volat=document.mform.vol.value;
//      m_step=100;
      testinput();
      //document.mform.valo.value=round_up(calcprix(m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),4);
      delt=round_up(sensibilite("delta",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
      levier=round_up(sensibilite("levier",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
      svol=round_up(sensibilite("vol",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
      stemps=round_up(sensibilite("temps",m_type,m_style,m_step,m_spot,m_dat1,m_dat2,m_tx,m_div,m_vol,m_exercice,m_parite),2);
      a[loc1+1][j]=sico+","+type+","+mat+","+exer+","+price+","+delt+","+volat+","+levier+","+stemps+","+svol+","
      +volu+","+pari+","+comment+","+em+","+tx+","+txdiv+","+typew;
    }
    if (comment=="CM") comment="CALC! MAT!";if (comment=="C") comment="CALC!";if (comment=="M") comment="MAT!";
    if (em=="S") em="SG";if (em=="B") em="BN";
    cool="<tr>"+her(sico)+hec(type)+hec(mat)+her(exer)+her(price)
      +her(delt)+her(volat)+her(levier)+her(stemps)
      +her(svol)+her(volu)+her(pari)+he(em)+"</tr>";
    newwind2.document.write(cool);
    +"</tr></table>";
    newwind2.document.write('<table width="*,*,*,*,*,*,*" border="1" cellspacing="0" bgcolor="#CCCCCC">');
    newwind2.document.write('<tr">');
  }
  newwind2.document.write('<br>Evaluation sans garantie, effectu&eacutee le ');
  newwind2.document.write('<script type="text/javascript">document.write(Date())</script>');
  newwind2.document.write('</table></body></html>');
}

function allwarrtohtml() {
  var sico;var type; var mat;var exer;var price;var delt;var volat;var levier;var cool;var stemps;var svol;var volu;var pari;var comment;var em;var r; var t;var k;
  var fg;var money;var sep;var temp;var mid;var loc;var loc1;var j;var fg;var entete;var prixg;sep=" ";
var newwind2=window.open("liste.htm");
for (k=1;k<=(a.length-1);k++)
{
mystring=document.mform.select1[k-1].value;
r=extract(",");
t=extract(",");
prixg=extract(",");
cool="<font face='Arial' size='2'>"+r+"  "+t+"  Cours sous-jacent: "+prixg+"</font>";
newwind2.document.write(cool);
newwind2.document.write('<table width="100%" border="1" cellspacing="0" bgcolor="#CCCCCC">');
cool="<tr>"+he("Sico")+he("C/P")+he("Maturité")+he("Prix exercice")+he("Prix")+he("Delta")+he("Volatilité implicite")+he("Levier")+he("S Temps")+he("S vol")+he("Volume")+he("Parité")+he("Emetteur")+he("Comment.")+"</tr>";
newwind2.document.write(cool);

for(j = 1;j<=(a[k].length-1);j++)
{
mystring=a[k][j];sico=extract(",");type=extract(",");mat=extract(",");exer=extract(",");price=extract(",");delt=extract(",");volat=extract(",");levier=extract(",");stemps=extract(",");svol=extract(",");volu=extract(",");pari=extract(",");comment=extract(",");em=extract(",");

if (comment=="CM") comment="CALC! MAT!";if (comment=="C") comment="CALC!";if (comment=="M") comment="MAT!";
if (em=="S") em="SG";if (em=="B") em="BN";
cool="<tr>"+he(sico)+he(type)+he(mat)+he(exer)+he(price)+he(delt)+he(volat)+he(levier)+he(stemps)+he(svol)+he(volu)+he(pari)+he(em)+he(comment)+"</tr>";
newwind2.document.write(cool);
}
newwind2.document.write('</table>');
}
}
function listewarr() {
  var loc;var loc1;var j;var fg;var entete;var prixg;
//  var sep;sep=" ";
  var m_j; var m_m; var tmp; var sico;
  var deltaj=0; var jmdj;
  var typewar; var strike;

  mystring=document.mform.select1[document.mform.select1.selectedIndex].value;
  document.mform.sicojacent.value=extract(",");
//  document.mform.ssjacent.value=extract(",");
//  prixg=extract(",");
//  document.mform.pact.value=prixg;
// ab
//  document.mform.varact.value=prixg;
//  document.mform.varactp.value="0.00";

  loc1=document.mform.select1.selectedIndex;
//
// suppression des ligne d'options en trop par rapport au nouveau support
  fg=document.mform.lwarr.length+1-(a[loc1+1].length);
  for(j=0;j<=(fg);j++) {
    document.mform.lwarr.options[0]=null;
  }
  if (a[loc1+1].length == 0) {
    df=new Option();
    document.mform.lwarr.options[0]=df;
    document.mform.lwarr.options[0].text="                                                      "
                       +"pas de warrant"+"                                                      ";
  }
  awar = new Array();
  deltaj=0;
  if (document.mform.trisort.selectedIndex == '0') {
//  if ('d' == 'd') {
// prepare le tri les warrants d'apres la date d'expiration
    awar[0]="99991231,9999";
    for(j = 1;j<=(a[loc1+1].length-1);j++) {
      mystring=a[loc1+1][j];
      sico=extract(",");
      typewar=extract(",");
      jmdj=j-deltaj;
      awar[jmdj]=extract(",");
      strike=extract(",");
      if ( ((typewar == document.mform.call.value) && (document.mform.call.checked)) ||
          ((typewar == document.mform.put.value) && (document.mform.put.checked)) ) {
//          &&
//          ((document.mform.strikeinf.value <= strike) && (document.mform.strikesup.value >= strike)) ) {
//
        mystring=awar[jmdj];
        m_j=extract("/");
        if (m_j.length == 1) {m_j='0'+m_j};
        m_m=extract("/");
        if (m_m.length == 1) {m_m='0'+m_m};
        if (mystring.length = 2) {
          if  (mystring == "99") {mystring='19'+mystring;} else {mystring='20'+mystring;}
        }
        awar[jmdj]=mystring+m_m+m_j+','+j+','+sico;
//    document.mform.sicog.value=typewar+' '+document.mform.call.value+' '+document.mform.put.value;
//      document.mform.lwarr.options[j-deltaj].text=ctol(a[loc1+1][m_m],prixg);
      } else {
        deltaj++
        document.mform.lwarr.options[0]=null;
      }
    }
  } else {
// prepare le tri les warrants d'apres le strike, puis la date
// la date (avant dans la base ...)
    awar[0]='99999999,999';
    for(j = 1;j<=(a[loc1+1].length-1);j++) {
      mystring=a[loc1+1][j];
      sico=extract(",");
      typewar=extract(",");
      if (((typewar == document.mform.call.value) && (document.mform.call.checked)) ||
          ((typewar == document.mform.put.value) && (document.mform.put.checked))) {
        awar[j]=extract(",");
        mystring=awar[j];
        m_j=extract("/");
        if (m_j.length == 1) {m_j='0'+m_j};
        m_m=extract("/");
        if (m_m.length == 1) {m_m='0'+m_m};
        if (mystring.length = 2) {
          if  (mystring == "99") {mystring='19'+mystring;} else {mystring='20'+mystring;}
        }
        tmp=mystring+m_m+m_j+','+j+','+sico;
// le strike
        mystring=a[loc1+1][j];
        awar[j]=extract(",");
        awar[j]=extract(",");
        awar[j]=extract(",");
        awar[j]=extract(",");
        mystring=awar[j];
        m_j=extract('.');
        awar[j]='';
        for (m_m=0;m_m<=4-m_j.length;m_m++) {awar[j]+='0';};
        awar[j]+=m_j+'.'+mystring+tmp;
//      awar[j]+=tmp
      } else {
        deltaj++
        document.mform.lwarr.options[0]=null;
      }
    }
  }
// trie
  awar.sort();
  
// affiche les warrants
  for(j = 0;j<=(a[loc1+1].length-2-deltaj);j++) {
    df=new Option();
    document.mform.lwarr.options[j]=df;
//    document.mform.lwarr.options[j].text=ctol(a[loc1+1][j],prixg);
    mystring=awar[j];
    m_m=extract(',');
    m_m=extract(',');
    document.mform.lwarr.options[j].text=ctol(a[loc1+1][m_m],prixg);
//
// test contenu awar    document.mform.lwarr.options[j].text=ctol(awar[j],prixg);
// ne marche pas ... pour modifier la couleur !!!
//    document.mform.lwarr.options[2].class="color: #055000;";
  }
}

function getsicov() {
  var sico;var sicot;var i;var j;
  var m_m;

  sico=document.mform.sicog.value;
  for(i = 1;i<=(a.length-1);i++){
    if (a[i].length>0 ) {
      for(j = 1;j<=(a[i].length - 1);j++) {
        mystring=a[i][j];
        sicot=extract(",");
        if (sico==sicot) {
          document.mform.select1.selectedIndex=i-1;
//          document.mform.lwarr.selectedIndex=j-1;
          listewarr();
          for (j=0;j<a[i].length-1;j++) {
            mystring=awar[j];
            sicot=extract(',');
            m_m=extract(',');
            if (sico == mystring) {
              document.mform.lwarr.selectedIndex=j;
              detailwarr();
              j=a[i].length;
            }
          }
        i=a.length-1;
        }
      }
    }
  }
}

// --- helpmaster.js
// --- by Josef Becker, Mediendidaktische Beratung
// --- http://www.helpmaster.com

// --- popupon and popupoff base on a script written by Andrew Castles bound to use with Dreamweaver 1.2
// --- http://www.arrakis.es/~andrewc/downloads/archives/tooltipdemo.htm

function popupon(text, eventObj) { 
  if (document.mform.disp.checked) { 

  ieLayer = 'document.all[\'popup\']';
  nnLayer = 'document.layers[\'popup\']';

  //-- Start Editable Area --
  borderColor = '#000000';
  bgColor = '#ffffcc';
  border = 1;
  padding = 3;
  xOffset = 3;
  yOffset = 3;
  Font = 'face="Verdana, Arial, Helvetica, sans-serif" size=2';
  //-- End Editable Area --

  if (!(document.all || document.layers)) return;
  if (null != document.all) document.popup = eval(ieLayer); else document.popup = eval(nnLayer);

  var table = "";
  var bigTable = ""; // Workaround for Netscape

  if (null != document.all) 
    { // If IE4+
    table += "<table bgcolor= "+ bgColor +" border= "+ border +" cellpadding= "+ padding +" cellspacing=0>";
    table += "<tr><td>";
    table += "<table cellspacing=0 cellpadding="+ padding +">";
    table += "<tr><td bgcolor= "+ bgColor +"><font "+ Font +">" + text + "</font></td></tr>";
    table += "</table></td></tr></table>"
    } 
  else 
    { // If NN4+
    table += "<table cellpadding="+ padding +" border="+ border +" cellspacing=0 bordercolor="+ borderColor +">";
    bigTable += "<table width="+(document.width - xOffset - eventObj.layerX - 30)+"cellpadding="+ padding +" border="+ border +" cellspacing=0 bordercolor="+ borderColor +">";
    table += "<tr><td bgcolor="+ bgColor +"><font "+ Font +">" + text + "</font></td></tr></table>";
    bigTable += "<tr><td bgcolor="+ bgColor +"><font "+ Font +">" + text + "</font></td></tr></table>";
    }

  if (null != document.all) 
    { // If IE4+
    document.popup.innerHTML = table;
    document.popup.style.left = Math.min(eventObj.x + xOffset,500);
    document.popup.style.top  = eventObj.y + yOffset;
    document.popup.style.visibility = "visible";
    } 
  else 
    { // If NN4+
    document.popup.document.open();
    document.popup.document.write(table);
    document.popup.document.close();
    if ((document.popup.document.width + xOffset + eventObj.layerX) > document.width)
    { // If the layer runs off the right hand side
      document.popup.document.open();
      document.popup.document.write(bigTable);
      document.popup.document.close();
    }
    document.popup.left = eventObj.layerX + xOffset;
    document.popup.top  = eventObj.layerY + yOffset;
    document.popup.visibility = "visible";
  }
}
}

function popupoff() { 
  if (!(document.all || document.layers)) return;
  if (null == document.popup) {
  } else if (null != document.all)
    document.popup.style.visibility = "hidden";
  else
    document.popup.visibility = "hidden";
    document.popup = null;
}

function bornestrike() {
  var strike;
  var loc1;
//
//  document.mform.strikeinf.value="";
//  document.mform.strikesup.value="";
  loc1=document.mform.select1.selectedIndex;
  mystring=a[loc1+1][1];
  strike=extract(",");
  strike=extract(",");
  strike=extract(",");
  strike=extract(",");
//  document.mform.strikeinf.value=strike;
//  document.mform.strikesup.value=strike;
  for(j=2;j<=a[loc1+1].length-1;j++) {
    mystring=a[loc1+1][j];
    strike=extract(",");
    strike=extract(",");
    strike=extract(",");
    strike=extract(",");
//    document.mform.strikeinf.value=Math.min(document.mform.strikeinf.value,strike);
//    document.mform.strikesup.value=Math.max(document.mform.strikesup.value,strike);
  }
}
