function getPageScroll(){

    var yScroll;
    
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    }
    else 
        if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
        }
        else 
            if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
            }
    
    arrayPageScroll = new Array('', yScroll)
    return arrayPageScroll;
}

function getPageSize(){

    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    }
    else 
        if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        }
        else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    }
    else 
        if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        }
        else 
            if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
    
    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    }
    else {
        pageHeight = yScroll;
    }
    
    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    }
    else {
        pageWidth = xScroll;
    }
    
    
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}



var giafatto = false;
var oldx
var oldy;
var xx = 280;
var yy = 160;
var myImage;



function mostra(ogg){
    ob = document.getElementById('fo')
    os = $(ob);
    
    // 	xx=280;
    // 	yy=160;
    //var foto=String(ogg.getAttribute('rel'));
    var foto = String(ogg.getAttribute('href'));
    //foto=urlsito+'galleria/'+foto
    
    myImage = new Image();
    myImage.src = foto;
    
    cancImage = new Image();
    cancImage.src = urlo + 'img/cancel.png';
    
    var alt = String(ogg.getAttribute('title'));//titolo
    var tit = String(ogg.getAttribute('rel'));//testo
    var pulsante = document.createElement('img');
    pulsante.setAttribute('id', 'cancel');
    pulsante.setAttribute('onclick', 'chiudi()');
    pulsante.setAttribute('src', cancImage.src);
    pulsante.setAttribute('alt', 'Chiudi');
    pulsante.setAttribute('title', 'Chiudi');
    pulsante.setAttribute('style', 'float:right;cursor:pointer;margin-bottom:2px;z-index:20;');
    pulsante.style.cssText = 'float:right;cursor:pointer;marging-bottom:2px;z-index:20;';
    ob.appendChild(pulsante);
    
    
    
    var objOverlay = document.createElement('img');
    objOverlay.setAttribute('id', 'foimg');
    objOverlay.setAttribute('src', myImage.src);
    objOverlay.setAttribute('alt', alt);
    objOverlay.setAttribute('title', alt);
    ob.appendChild(objOverlay);
    
    if (giafatto) {
        chiudi();
        return;
    }
    arrayPageScroll = getPageScroll();
    page = getPageSize();
    pageX = page[0];
    pageY = page[1];//altezza pagina
    pageH = page[3];//alteza finestra browser
    myImage.onload = function(){
        //if(myImage.complete){//non funzia su ie6
        xx = myImage.width / 2;
        yy = myImage.height / 2;
        
        a = 2 * xx;
        b = 2 * yy + 60;
        oldy = pageY / 2;
        oldx = pageX / 2;
        
        ob.style.display = 'none';
        Nxx = oldx - xx
        
        
        var apertura = arrayPageScroll[1] + (pageH / 13);
        ob.style.top = apertura + 'px';
        ob.style.left = Math.round(Nxx) + 'px';
        ob.style.width = Math.round(a) + 'px';
        ob.style.height = Math.round(b) + 'px';
        
        ob.innerHTML += '<p class="par2">' + tit + '</p>';
        ob.innerHTML += '<p id="par" onclick="chiudi();"><strong>Chiudi</strong></p>';
        
        new Effect.Grow('fo', {
            duration: 0.5
        });
        //cancel = document.getElementById('cancel');
        //cancel.onclick = function(){chiudi();}
        
        giafatto = true;
        delete xx;
        delete yy;
        //}
    } //fine oload
}//fine mostra
function chiudi(){
    giafatto = false;
    new Effect.Fade('fo')
    ob = document.getElementById('fo');
    ob.innerHTML = "";
}

///////////////////////////		



