/////////////////////////////////////////////
///                                       ///
///     creato da standard  ©  2002       ///
///                                       ///
///   con la collaborazione di kronik     ///
///                                       ///
/////////////////////////////////////////////


function initleft(valleft,valwidth) {
if(typeof(valleft)== "string") {
    switch(valleft) {
        case "left":    retleft = 0;                                   break;
        case "center":  retleft = (screen.width - valwidth)/2;         break;
        case "right":   retleft = screen.width - valwidth;             break;
        default: alert("STRINGA ERRATA\n(avviso per il debugging)");break;
        }
 }
 else retleft = valleft
return(retleft)
}


function inittop(valtop,valheight) {
if(typeof(valtop)== "string") {
    switch(valtop) {
        case "top":     rettop = 0;                                   break;
        case "center":  rettop = (screen.height - valheight)/2;       break;
        case "bottom":  rettop = screen.height - valheight;           break;
        default: alert("STRINGA ERRATA\n(avviso per il debugging)");break;
        }
 }
 else rettop = valtop
return(rettop)
}


function initpassitot() {
this.passitot = Math.round(Math.max(Math.abs((this.fw-this.iw))/Math.abs(this.passow),Math.abs((this.fh-this.ih))/Math.abs(this.passoh))) 

 if(!this.passitot || this.passitot==0) 
 this.passitot = Math.round(Math.max(Math.abs((this.fl-this.il))/Math.abs(this.passow),Math.abs((this.ft-this.it))/Math.abs(this.passoh))) 
}


function popplay() {

if(!this.pp.closed){
  
  this.pp.focus()  
  
  if(this.ciclo < this.passitot) {
     opw = (this.passow > 0) ? "<" : ">" ;
     oph = (this.passoh > 0) ? "<" : ">" ;

     if(eval("this.iw "+opw+" this.fw")) this.iw += this.passow
     if(eval("this.ih "+oph+" this.fh")) this.ih += this.passoh

     this.il += this.passol 
     this.it += this.passot 
     this.pp.resizeTo(this.iw,this.ih)
     this.pp.moveTo(this.il,this.it)
     this.ciclo++
     eval("setTimeout(this.obj+'.play()',"+this.ms+")")
     }
  else {
     this.ciclo = 0
     eval(this.af)
     }
 }
}


function popslide(fw,fh,fileft,fitop,passow,passoh,ms,af,noslide){
 
 this.fw = (fw == "max") ? screen.width : (fw || this.iw);  
 this.fh = (fh == "max") ? screen.height : (fh || this.ih); 
 this.fl = (fileft) ? initleft(fileft,this.fw) : initleft(this.inleft,this.fw); 
 this.ft = (fitop) ? inittop(fitop,this.fh) : inittop(this.intop,this.fh); 
 this.inleft = fileft || this.inleft;
 this.intop = fitop || this.intop;
 this.passow = (this.fw - this.iw >=0) ? (passow || 10) : eval("-"+(passow || 10));
 this.passoh = (this.fh - this.ih >=0) ? (passoh || 10) : eval("-"+(passoh || 10)); 
 this.passi() 
 this.passol = (this.fl - this.il)/this.passitot 
 this.passot = (this.ft - this.it)/this.passitot
 this.ms = ms || 1; 
 this.af = af || ''
 if(!noslide) this.play()
}


function pop(nome,url,tools,iw,ih,fw,fh,inleft,intop,fileft,fitop,passow,passoh,ms,af,noslide) {          
 this.obj = nome 
 this.iw = (iw == "max") ? screen.width : iw;           
 this.ih = (ih == "max") ? screen.height : ih;   

 this.il = initleft(inleft,this.iw) 
 this.it = inittop(intop,this.ih)  
 
 tools = tools || '';
 if(document.layers)
   tools = (tools.toLowerCase().indexOf("resizable")==-1) ? 'resizable=yes,'+tools : tools;
 
 this.pp = window.open(url,nome,tools+" width=100,height=100,left="+this.il+",top="+this.it) 
 this.pp.resizeTo(this.iw,this.ih)
 this.ciclo = 0    
 
 this.inleft = inleft
 this.intop = intop
 this.slide(fw,fh,fileft,fitop,passow,passoh,ms,af,noslide) 

}



function popclose() {
 this.pp.close()
}


function poplocation(url) {
 this.pp.location = url
 this.pp.focus()
}


function addpop(nome,url,tools,iw,ih,fw,fh,inleft,intop,fileft,fitop,passow,passoh,ms,af,noslide) {
eval(nome+" = new pop(nome,url,tools,iw,ih,fw,fh,inleft,intop,fileft,fitop,passow,passoh,ms,af,noslide);")
}


pop.prototype.passi = initpassitot
pop.prototype.slide = popslide
pop.prototype.play = popplay
pop.prototype.close = popclose
pop.prototype.location = poplocation


var stile = "center, center, width=743, height=500, fullscreen=no,locationbar=no,toolbar=no,menubar=no,resizable=yes,status=no, scrollbar=no";
     function Popup(apri) {
        window.open(apri, "", stile);
     }
