/*
*
*  Script creati da Pasquale Tufano per Lottologia.com
*  Copyright 2004 - Tutti i diritti sono riservati all'autore.
*
*/
 function image_over( obj, name) { obj.src = 'images/'+name+'_on.jpg'; }
 function image_out( obj, name ) { obj.src = 'images/'+name+'.jpg'; }


 function grafico(title, data, name, note, width, height, with_border)
 {
   var html = "";
   var hfont_title = 10;
   var hfont_text = height/25;
   if (hfont_text<7) hfont_text = 7;
   if (height==0)
     height=parseInt(width/4*2);

   html += '<table style="width:'+width+'px; height:'+height+'px; border: 1px inset" cellspacing="0" cellpadding="0">';

   with_border = false;

   if (with_border)
   {
     html += '<tr style="background: #3399ff">';
     html += '<td colspan="3" style="text-align:center;width:99%;height:15px;">'+title+'</td>';
     html += '</tr>';
   }
   else
   {
     html += '<tr height="15"><td colspan="3" style="text-align:center;width:99%;height:15px; font-family: verdana, sans-serif,arial,times;font-size:'+(hfont_title+3)+'px; font-weight: bold; color: black;">'+title+'</td></tr>';
   }

   html += '<tr>';
   html += '<td colspan="3" valign="top" style="background-color: #ffffff">';

   leftprec = 0;
   
   var left=0;
   var top=0,  topprec=0;
   var maxval = 0;
   var x=0, y=0;
   var hpx;

   for(var pos=0;pos<data.length; pos++)
    if (maxval<data[pos])
      maxval = data[pos];
  
   maxval=parseInt(maxval*1.1);
   maxval+=10+(40-maxval%40);

   // linee verticali
   for(var pos=1;pos<data.length-1; pos++)
   {
     if (document.all)
     {
       x = left = parseInt((pos*(width-2))/(data.length-1));
       y = 18;
     }
     else
     {
       x = left = parseInt((pos*(width-2))/(data.length-1));
       y = 18;
     }
     hpx = height-38;
     if (parseInt(name[pos])%5==0 || (parseInt(name[pos])==0 && pos%5==0))
       html += '<img src="images/gray2point.jpg" style="left: '+x+'px; width: 1px; top: '+y+'px; height: '+(hpx)+'px; position: absolute; border:0; margin:0" />';
     else
       html += '<img src="images/graypoint.jpg" style="left: '+x+'px; width: 1px; top: '+y+'px; height: '+(hpx)+'px; position: absolute; border:0; margin:0" />';
   }

   // linee orizzontali
   var incy;
   if (maxval<200) incy = 10;
   else if (maxval<1000) incy = 50;
   else if (maxval<2000) incy = 100;
   else if (maxval<4000) incy = 200;
   else if (maxval<6000) incy = 300;
   else if (maxval<8000) incy = 400;
   else inc = 500;
   for(var pos=0; pos<maxval-incy; pos+=incy)
   {
     if (document.all)
     {
       x = 0;
       y = top  = height-(20+parseInt((pos*(height-28))/maxval));
     }
     else
     {
       x = 0;
       y = top  = height-(20+parseInt((pos*(height-28))/maxval));
     }
     
     html += '<img src="images/graypoint.jpg" style="width: '+(width)+'px; height: 1px; position: absolute; left: '+x+'px;top: '+(y)+'px; border:0; margin:0" />';
     html += '<span style="font-size: 10px; position: absolute; left: '+x+'px;top: '+parseInt(y-10)+'px; border:0; margin:0">'+(pos)+'</span>';
   }

   // linee verticali
   for(var pos=1;pos<data.length-1; pos++)
   {
     if (document.all)
     {
       x = left = parseInt((pos*(width-2))/(data.length-1))-10;
       y = parseInt(height-32);
     }
     else
     {
       x = left = parseInt((pos*(width-2))/(data.length-1));
       x = ((pos<data.length-2)?(x-10):(x));
       y = parseInt(height-32);
     }

     if (parseInt(name[pos])%5==0 && y>20)
       html += '<span style="font-size: 10px; position: absolute; left: '+x+'px;top: '+y+'px; border:0; margin:0">'+name[pos]+'</span>';
   }

   for(var pos=0;pos<data.length; pos++)
   {
     if (document.all)
     {
       y = top  = parseInt(height-20-parseInt((data[pos]*(height-20))/maxval) );
       y = parseInt(y-20);
       x = left = parseInt((pos*(width-2))/(data.length-1));
     }
     else
     {
       y = top  = parseInt(height-20-parseInt((data[pos]*(height-20))/maxval) );
       y = parseInt(y-20);
       x = left = parseInt((pos*(width-2))/(data.length-1));
     }
     if (pos>0)
     {
       if (pos==data.length-1)
         html += '<span style="font-size: 10px; position: absolute; left: '+(x-20)+'px;top: '+y+'px; border:0; margin:0">'+data[pos]+'</span>';
       else
         html += '<span style="font-size: 10px; position: absolute; left: '+((x>3)?(x-3):(x))+'px;top: '+y+'px; border:0; margin:0">'+data[pos]+'</span>';
       y=topprec;
     }
     for(var x=leftprec;x<left; x++)
     {
       var delta = (top-topprec)/(left-leftprec);
       if (delta<0.0) delta = -delta;
       hpx = parseInt(delta)+2;
       if (delta<2.0) hpx = 2;
       if (document.all)
       {
         html += '<img src="images/graypoint.jpg" style="width: 1px; height: '+hpx+'px; position: absolute; left: '+(x+2)+'px;top: '+parseInt(y+2)+'px; border:0; margin:0" />';
         html += '<img src="images/blackpoint.jpg" style="width: 1px; height: '+hpx+'px; position: absolute; left: '+(x)+'px;top: '+parseInt(y-parseInt(hpx/2))+'px; border:0; margin:0" />';
       }
       else
       {
         html += '<img src="images/graypoint.jpg" style="width: 1px; height: '+hpx+'px; position: absolute; left: '+(x+2)+'px;top: '+parseInt(y+2)+'px; border:0; margin:0" />';
         html += '<img src="images/blackpoint.jpg" style="width: 1px; height: '+hpx+'px; position: absolute; left: '+(x)+'px;top: '+parseInt(y-parseInt(hpx/2))+'px; border:0; margin:0" />';
       }
       y    += (top-topprec)/(left-leftprec);
     }
     leftprec = left;
     topprec = top;
   }
   html += '</div>';

   html += '&nbsp;</td>';
   html += '</tr>';

   html += '<tr><td colspan="3" align="center" width="99%" height="1" style="font-family: verdana, sans-serif,arial,times;font-size:'+(hfont_title+3)+'px; font-weight: bold; color: red; background-image: url(\'./images/bground_bottom.gif\')">'+note+'</td></tr>';
 
   html +='</table>';

   return(html);
 }

 // Funzione creata da Pasquale Tufano
 // Tutti i diritti sono riservati
function istogramma(title, data, name, note, width, height)
 {
   var hfont_title = height/25;
   var hfont_text = height/21;
   if (hfont_title>name.lenght+3) hfont_title = name.lenght+3;
   if (hfont_title<9) hfont_title = 9;

   document.write('<table summary="istogramma" style="position: relative; width:'+width+'; height:'+height+'; border: 0px" cellspacing="0" cellpadding="0">');

   document.write('<tr>');
   document.write('<td><img src="./images/round_top_sx.gif" border="0" /></td>');
   document.write('<td align="center" width="99%" height="1" style="font-family: sans-serif,arial,times;font-size: '+hfont_title+'pt;font-weight: bold; color: white; background-image: url(\'images/bground_top.gif\')">'+title+'</td>');
   document.write('<td><img src="./images/round_top_dx.gif" border="0" /></td>');
   document.write('</tr>');

   document.write('<tr>');
   document.write('<td colspan="3" valign="top" style="background-color: #f0f0f0">');

   var maxdata=0;
   for(var r=0; r<data.length; r++)
     if (maxdata<data[r]) maxdata=data[r];

   for(var r=0; r<data.length; r++)
   {
     document.write('<table cellpadding="0" cellspacing="0" style="background-image: url(\'./images/goldpoint.jpg\'); height:10px; margin:2px; border:1px solid #999999" width="'+parseInt((data[r]*90.0)/maxdata)+'%" /><tr>');
     document.write('<td valign="middle" style="font-size:'+hfont_text+'pt; font-family: sans-serif,arial,times; font-weight:bold">&nbsp;'+name[r]+'</td>');
     document.write('<td></td>');
     document.write('<td style="font-size:'+hfont_text+'pt; font-family: sans-serif,arial,times" width="2%">'+data[r]+'</td>');
     document.write('</tr></table>');
   }
   document.write('</td>');
   document.write('</tr>');

   document.write('<tr>');
   document.write('<td><img src="./images/round_bottom_sx.gif" border="0" /></td>');
   document.write('<td align="center" width="99%" height="1" style="font-family: sans-serif,arial,times;font-size:'+hfont_title+'pt; font-weight: bold; color: red; background-image: url(\'./images/bground_bottom.gif\')">&nbsp;'+note+'</td>');
   document.write('<td><img src="./images/round_bottom_dx.gif" border="0" /></td>');
   document.write('</tr>');

  document.write('</table>');
 }


 function m(obj)
 {
   var z = 'a.c';
   var m = 'mai';
   var c = '@';
   var g = 'lto';
       m = m+g+':posta';
       m+= c;
       m+= 'lottologi'+z;
       m+= 'om';

    obj.href = m;
 }
