﻿
var dotatiFoto = new DotatiFoto();



function DotatiFoto() {

    this.logOff = logOff;
    this.checkForm = checkForm;
    this.showPicture = showPicture;
    this.hidePicture = hidePicture;
    this.getMouseXY = getMouseXY;
    var divShowPicture;
   
    function logOff() {

        document.URL = "default.aspx?IDCategoria=15";

    }
    function checkForm() {

        alert('');


        document.forms[2].submit();

    }   
   
    if(window.addEventListener)
    { 
        // Mozilla, Netscape, Firefox
	    window.addEventListener('mouseover', getMouseXY, false);
	}else
	{
        window.document.attachEvent("onmousemove", getMouseXY);
    }
    
    function getMouseXY(e) {
        if (document.body) {
        
            if(window.addEventListener)
            {   
                tempX = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft / 2 : document.documentElement.scrollLeft / 2) ;
                tempY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
            } 
            else if (e.clientX || e.clientY) 
            {   
                tempX = window.event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft / 2 : document.body.scrollLeft / 2) ;
                tempY = window.event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
            } 
        }
    }
    function showPicture(id, img) {
       
        divShowPicture = document.getElementById(id);
        if((tempX + 400) > 1000) tempX = tempX - 500;
        divShowPicture.style.display = '';
        divShowPicture.style.top = tempY - 400 +"px";
        divShowPicture.style.left = tempX +"px";
        
        var _imgTest = document.getElementById(id + "_IMG");
        if(_imgTest == null)
        {
            var _fkImg =new Image();
            img = img.replace("**", "\\");
            _fkImg.src= img.replace("**", "\\");
            _fkImg.id = id + "_IMG";
            divShowPicture.appendChild(_fkImg);
            
            window.status = 'Top=' + divShowPicture.style.top + ' Left=' + divShowPicture.style.left;
            _fkImg.onload = Loaded;    
        }
        
    }
    function hidePicture(id) {
        
        var divShowPicture = document.getElementById(id);

        divShowPicture.style.display = 'none';

    }
    function Loaded()
    {
        if(divShowPicture != null)
        {   
            divShowPicture.innerHTML = divShowPicture.innerHTML.replace("loading photo...", "" );
        }
    }
   
   }