/*
* pop_immagine 
* 
* @version 1.0.0.0
* mostra una immagine in pop-up  
* delle stesse dimensioni dell'immagini
*/
function pop_immagine(imm,larga,alta) {
//imm.src = imm;

fright = "<scri"+"pt>  </scri"+"pt>"
js = '';
html = '<HTML><HEAD>' +fright+' <TITLE>Image</TITLE></HEAD><BODY '+ js +'LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><IMG SRC="'+imm+'" BORDER=0"></BODY></HTML>';

aa=window.open(imm,'','left=200,top=0,width='+larga+',height='+alta+',scrollbars=yes, status=no,menubar=no,resizable=yes');
aa.document.write(html);
}

/*
* riempe un div con un fato 
*
* * @version 1.0.0.0
*/
function riempi_div(namediv,pathfotobig,dimx,dimy)
{ 
 
 var lnk = document.getElementById(namediv).getElementsByTagName("a")[0];
 lnk.href="javascript:pop_immagine('"+pathfotobig+"',"+dimx+","+dimy+")";
 
 lnk.firstChild.src = pathfotobig;  
 
 /*
 var livello = document.getElementById(namediv);
 var callPop = "javascript:pop_immagine('"+escape(pathfotobig)+"',"+dimx+","+dimy+")";
 livello.innerHTML = "<a href='"+callPop+"'> premi </a>";
 alert(livello.innerHTML);
 */
}

function sleepByMseconds(numberMillis)
{
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }

}

function preloadAnim()
{
     sDiv = 'O';
     var sez = document.getElementById("prelaodImg");
     sez.innerHTML = sez.innerHTML + sDiv;
     
     if (sez.innerHTML.length >=(6*sDiv.length) ) sez.innerHTML = ''; 
     setTimeout("preloadAnim()",1000); 
     window.scrollBy(1,1);

}

function preloadForm(p_nome,p_lista)
{   
    try
    {
     
     //alert(window);
     
     var sez = document.getElementById(p_nome);
     sez.style.display = 'none';
     
     var info = document.getElementById("preload");
     info.style.display = 'block';
     
     var oprelaodImg = document.getElementById("prelaodImg");

     oDate = new Date();
     curSecond1 = oDate.getTime();
     nTime = 5; 
     stopSecond = (1000*nTime);
     //screen.updateInterval=10000;
     //alert(stopSecond);
     //alert(screen.updateInterval);
     //preloadAnim();
     //sleepByMseconds(stopSecond);
     /*
     for (;;)
     {
      
       oDate = new Date();
       curSecond2 = oDate.getTime();
       tot = curSecond2 - curSecond2; 
       
       
       //alert(tot);
       window.scrollBy(1,1);
       info.style.display = 'block';
       
       
       if (  (curSecond2 - curSecond1) > stopSecond)
       {
        alert('stop');
        break;
       }
       //delete oDate;
     }
     */ 

     return true;
    }
    catch(e)
    {
        alert('Si verificato un errore sconosciuto:'+e);
        return false;
    }
}


/*
* blocca in un textarea 
* il limite di caratteri
*
*/
function countAreaChars(areaName,counter,limit)
{
if (areaName.value.length>limit)
areaName.value=areaName.value.substring(0,limit);
else
counter.value = limit - areaName.value.length;
}


