﻿
//Apre il l'oggetto gradualmente
function LayerPopUp(id, larghezza, altezza)
{
    //
    var y = f_scrollTop();
    
    //
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }

    //Mozzilla
    if (document.layers){
        //document.layers[id].style.visibility = "visible";
        document.layers[id].width = larghezza;
        document.layers[id].pageX = (myWidth/2)-(larghezza/2);
        document.layers[id].height = altezza;
        document.layers[id].pageY = (myHeight/2)-(altezza/2);
    }
    
    //Passiamo al codice per IE4:
    else if (document.all){
        document.all[id].style.background = "#FFFFFF";
        document.all[id].style.width=larghezza; 
        document.all[id].style.posLeft =(myWidth/2)-(larghezza/2); 
        //document.all[id].style.height=altezza; 
        document.all[id].style.posTop =(((myHeight)/2)+y)-(altezza/2); 
    }
    
    //Passiamo al codice per IE5+ e NN6:
    else if(document.getElementById){

        document.getElementById(id).style.width = larghezza+"px";
        document.getElementById(id).style.left = (myWidth/2)-(larghezza/2)+"px";
        document.getElementById(id).style.height = altezza+"px";
        document.getElementById(id).style.top = (((myHeight)/2)+y)-(altezza/2)+"px";
        
    }
    
    
    
    LayerPopUpAperturaWidth = 0;
    LayerPopUpAperturaHeigth = 0;
    
    fadeIn(id, 0);
    
    //LayerPopUpApertura(id, larghezza, altezza);
} 



var LayerPopUpAperturaWidth = 0;
var LayerPopUpAperturaHeigth = 0;
//Ricorsione
function LayerPopUpApertura(id, larghezza, altezza)
{
    //
    var rectW = (larghezza-LayerPopUpAperturaWidth);
    if(LayerPopUpAperturaWidth > larghezza ) rectW = 0;
    var rectH = (altezza-LayerPopUpAperturaHeigth);
    if(LayerPopUpAperturaHeigth > altezza) rectH = 0;
    //
    
    //larghezza
   if(LayerPopUpAperturaWidth <= larghezza){
        if (document.layers){
            document.layers[id].style.width = LayerPopUpAperturaWidth+"px";
            document.layers[id].style.clip = "rect("+rectH+"px auto auto "+rectW+"px)";
        }
        else if (document.all)
        {
            document.all[id].style.width = LayerPopUpAperturaWidth+"px";
            document.all[id].style.clip = "rect(0px "+rectW+"px "+rectH+"px 0px)";
        }
        else if(document.getElementById)
        {
            document.getElementById(id).style.width = LayerPopUpAperturaWidth+"px";
            //document.getElementById(id).style.clip = "rect("+altezza+"px "+rectW+"px "+rectH+"px "+larghezza+"px)";
            //document.getElementById(id).style.clip = "rect("+(LayerPopUpAperturaHeigth)+"px "+(rectW)+"px "+(rectH)+"px "+(LayerPopUpAperturaWidth)+"px)";
        }
        
        LayerPopUpAperturaWidth += (((larghezza/altezza))*10);
   }
   
   
   //altezza
    if(LayerPopUpAperturaHeigth <= altezza)
    {
        if (document.layers){
            document.layers[id].style.height = LayerPopUpAperturaHeigth+"px";
            document.layers[id].style.clip = "rect("+rectH+"px auto auto "+rectW+")";
        }
        else if (document.all)
        {
            document.all[id].style.height = LayerPopUpAperturaHeigth+"px";
            document.all[id].style.clip = "rect(0px "+rectW+"px "+rectH+"px 0px)";
        }
        else if(document.getElementById)
        {
            document.getElementById(id).style.height = LayerPopUpAperturaHeigth+"px";
            //document.getElementById(id).style.clip = "rect("+0+"px "+rectW+"px "+rectH+"px "+(LayerPopUpAperturaWidth)+"px)";
            document.getElementById(id).style.clip = "rect("+(LayerPopUpAperturaHeigth-rectH)+"px "+(rectW*2)+"px "+(rectH*2)+"px "+(LayerPopUpAperturaWidth-rectW)+"px)";
        }
        LayerPopUpAperturaHeigth += 10; 
    }
    
    //
    var mousex = _PosizioneMouseX;
    var posX = (window.innerWidth/2)-(larghezza/2);
    
    if(LayerPopUpAperturaWidth <= larghezza || LayerPopUpAperturaHeigth <= altezza) setTimeout("LayerPopUpApertura('"+id+"', "+larghezza+", "+altezza+")",1);
}

