﻿function loadSearch(bn)
{
    AJS.fx.fadeIn(document.body,{duration:80,to:0.7});
    if (document.getElementById("container") != null)
    {
        AJS.fx.fadeIn(document.getElementById("left"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("center"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("right"),{duration:80,to:0.4});
    }
    if (document.getElementById("container2") != null)
    {
        AJS.fx.fadeIn(document.getElementById("left2"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("center2"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("right2"),{duration:80,to:0.4});
    }
    
    var t = nw_findPosY(bn);
    var l = nw_findPosX(bn);
    
    var c = document.createElement("div");
    c.className = "loadingDiv";
    var i = document.createElement("img");
    i.setAttribute("src","/img/busy.gif");
    i.setAttribute("width","20");
    i.setAttribute("height","20");
    c.appendChild(i);
    var s = document.createElement("span");
    s.innerHTML = "Sto cercando, attendi"
    c.appendChild(s);
    c.style.top = t + "px";
    c.style.left = l + "px";
    document.body.appendChild(c);
}

function loadWaitReport(bn)
{
    AJS.fx.fadeIn(document.body,{duration:80,to:0.7});
    if (document.getElementById("container") != null)
    {
        AJS.fx.fadeIn(document.getElementById("left"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("center"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("right"),{duration:80,to:0.4});
    }
    if (document.getElementById("container2") != null)
    {
        AJS.fx.fadeIn(document.getElementById("left2"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("center2"),{duration:80,to:0.4});
        AJS.fx.fadeIn(document.getElementById("right2"),{duration:80,to:0.4});
    }
    
    var t = nw_findPosY(bn);
    var l = nw_findPosX(bn);
    
    var c = document.createElement("div");
    c.className = "loadingDiv";
    var i = document.createElement("img");
    i.setAttribute("src","/img/busy.gif");
    i.setAttribute("width","20");
    i.setAttribute("height","20");
    c.appendChild(i);
    var s = document.createElement("span");
    s.innerHTML = "Sto generando il report, attendi"
    c.appendChild(s);
    c.style.top = t + "px";
    c.style.left = l + "px";
    document.body.appendChild(c);
}

function nw_findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curleft -= obj.scrollLeft;
			obj = obj.offsetParent;				
		}
	} else if (obj.x) {
		curleft += obj.x;
		curleft -= obj.scrollLeft;
	}
	return curleft;
}

function nw_findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			curtop -= obj.scrollTop;
			obj = obj.offsetParent;				
		}
	} else if (obj.y) {
		curtop += obj.y;
		curtop -= obj.scrollTop;
	}
	return curtop;
}