﻿<!--


var distanzadalmouse
distanzadalmouse = 20

function GestisciDIV(a,b,c,d,e,num) {
    document.getElementById(a).style.display = num == "1" ? 'block' : 'none';
    document.getElementById(b).style.display = num == "2" ? 'block' : 'none';
    document.getElementById(c).style.display = num == "3" ? 'block' : 'none';
    document.getElementById(d).style.display = num == "4" ? 'block' : 'none';
    document.getElementById(e).style.display = num == "5" ? 'block' : 'none';
}

function anteprimaimmagine(comando, nomediv, percorsoimmagine) {
    if (comando == 'apri') {
        document.getElementById("visualizzaimmagineanteprima").innerHTML = '<img id="anteprimaimg" src="' + percorsoimmagine + '" height="260" />';
        document.getElementById("visualizzaimmagineanteprima").style.display = 'block';
    }
    else {
        document.getElementById("visualizzaimmagineanteprima").style.marginTop = -250
        document.getElementById("visualizzaimmagineanteprima").style.display = 'none';
    }
}

var IE = document.all ? true : false
if (!IE) { document.captureEvents(Event.MOUSEMOVE) }
document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0

var coordinatefinestraw
var coordinatefinestrah

function getMouseXY(e) {

    var unita_misura = "";
    var ScrollLeft = 0;
    var ScrollTop = 0;
    if (IE) {
        // grab the x-y pos.s if browser is IE
        tempX = event.clientX   //event.x//event.clientX// + document.body.scrollLeft
        tempY = event.clientY   //event.y//event.clientY// + document.body.scrollTop
        coordinatefinestraw = document.body.parentNode.clientWidth
        coordinatefinestrah = document.body.parentNode.clientHeight
        unita_misura = "";
        ScrollLeft = document.body.parentNode.scrollLeft
        ScrollTop = document.body.parentNode.scrollTop
    }
    else {

        // grab the x-y pos.s if browser is NS
        tempX = e.clientX//e.pageX //- document.body.scrollLeft
        tempY = e.clientY //- document.body.scrollTop
        coordinatefinestraw = window.innerWidth
        coordinatefinestrah = window.innerHeight
        unita_misura = "px";
        ScrollLeft = window.pageXOffset //document.body.scrollLeft
        ScrollTop = window.pageYOffset    //document.body.scrollTop
    }

    if (tempX < 0) { tempX = 0 }
    if (tempY < 0) { tempY = 0 }

    try
    {
        calcoloposizionedicontrollo = tempX + document.images.anteprimaimg.width;

        x_img = document.images.anteprimaimg.width
        y_img = document.images.anteprimaimg.height

        az_MaLeft = tempX + ScrollLeft
        az_MaTop = tempY + ScrollTop + 250

        if (tempX + distanzadalmouse + x_img > coordinatefinestraw)
            az_MaLeft = tempX + ScrollLeft - distanzadalmouse * 2 - document.images.anteprimaimg.width
        if (tempY + y_img > coordinatefinestrah)
            az_MaTop = tempY + ScrollTop + 250 - document.images.anteprimaimg.height


        var pippa = tempX + distanzadalmouse + x_img
        var pippa2 = tempY + y_img

        //document.getElementById("pippo").value = x_img + "--" + y_img + "||||" + tempX + "--" + tempY

        document.getElementById("visualizzaimmagineanteprima").style.marginLeft = az_MaLeft + unita_misura
        document.getElementById("visualizzaimmagineanteprima").style.marginTop = az_MaTop + unita_misura
    }
    catch(err)
    {
    }
}

function ChiudiMappa(a) {
    document.getElementById(a).style.display = 'none';
}

    //  VECCHIO CODICE
    /*var distanzadalmouse;
    distanzadalmouse = 20;
    function anteprimaimmagine(comando, nomediv, percorsoimmagine)
    {
        if (comando == 'apri')
        {
            document.getElementById("visualizzaimmagineanteprima").innerHTML = '<img id="anteprimaimg" src="' + percorsoimmagine + '" height="260">';
            document.getElementById("visualizzaimmagineanteprima").style.display = 'block';
        }
        else
        {
            document.getElementById("visualizzaimmagineanteprima").style.marginTop = -250;
            document.getElementById("visualizzaimmagineanteprima").style.display = 'none';
        }
    }

    var tempX = 0;
    var tempY = 0;

    var coordinatefinestraw = 0;
    var coordinatefinestrah = 0;

    var ScrollLeft = 0;
    var ScrollTop = 0;
    
    var unita_misura = "";

    var IE = document.all ? true : false
    if (IE)
    {
        unita_misura = "";
        coordinatefinestraw = document.body.parentNode.clientWidth;
        coordinatefinestrah = document.body.parentNode.clientHeight;
        ScrollLeft = document.body.parentNode.scrollLeft;
        ScrollTop = document.body.parentNode.scrollTop;
    }
    else
    {
        document.captureEvents(Event.MOUSEMOVE);
        unita_misura = "px";
        /*coordinatefinestraw = window.innerWidth;
        coordinatefinestrah = window.innerHeight;
        ScrollLeft = window.pageXOffset; //document.body.scrollLeft
        ScrollTop = window.pageYOffset;    //document.body.scrollTop
    }
    
    document.onmousemove = getMouseXY;
        
    function getMouseXY(e)
    {
        if (IE)
        {
            // grab the x-y pos.s if browser is IE
            tempX = event.x;//event.x//event.clientX// + document.body.scrollLeft
            tempY = event.y;//event.y//event.clientY// + document.body.scrollTop
            //coordinatefinestraw = document.body.parentNode.clientWidth;
            //coordinatefinestrah = document.body.parentNode.clientHeight;
            //unita_misura = "";
            //ScrollLeft = document.body.parentNode.scrollLeft;
            //ScrollTop = document.body.parentNode.scrollTop;
        }
        else
        {
            // grab the x-y pos.s if browser is NS
            tempX = e.clientX;//e.pageX //- document.body.scrollLeft
            tempY = e.clientY; //- document.body.scrollTop
            coordinatefinestraw = window.innerWidth;
            coordinatefinestrah = window.innerHeight;
            //unita_misura = "px";
            ScrollLeft = window.pageXOffset; //document.body.scrollLeft
            ScrollTop = window.pageYOffset;    //document.body.scrollTop
        }
        
        if (tempX < 0) { tempX = 0; }
        if (tempY < 0) { tempY = 0; }

        calcoloposizionedicontrollo = tempX + document.images.anteprimaimg.width;

        x_img = document.images.anteprimaimg.width;
        y_img = document.images.anteprimaimg.height;

        az_MaLeft = tempX + ScrollLeft;
        az_MaTop = tempY + ScrollTop + 250;

        if (tempX + distanzadalmouse + x_img > coordinatefinestraw)
            az_MaLeft = tempX + ScrollLeft - distanzadalmouse * 2 - document.images.anteprimaimg.width;
        if (tempY + y_img > coordinatefinestrah)
            az_MaTop = tempY + ScrollTop + 250 - document.images.anteprimaimg.height;


        var pippa = tempX + distanzadalmouse + x_img;
        var pippa2 = tempY + y_img;

        //document.getElementById("pippo").value = x_img + "--" + y_img + "||||" + tempX + "--" + tempY;

        if (IE)
        {
            document.getElementById("visualizzaimmagineanteprima").style.marginLeft = az_MaLeft;
            document.getElementById("visualizzaimmagineanteprima").style.marginTop = az_MaTop;
        }
        else
        {
            document.getElementById("visualizzaimmagineanteprima").style.marginLeft = az_MaLeft + unita_misura;
            document.getElementById("visualizzaimmagineanteprima").style.marginTop = az_MaTop + unita_misura;
        }
    }*/

-->
