

/*function GWindowInit(){

	if(document.body){
		var content=""
		 
		content+=	' <div id="gWindowDiv" style="visibility:hidden;position:absolute;height:650;width:700;z-index:20000000000000000001;filter:alpha(opacity=\'0\');opacity: 0.0;-moz-opacity: 0.0;top:10%;left:15%;">'+
					'<table width="100%" height="100%" cellspacing="0" bgcolor="white">'+
						'<tr>'+
							'<td height="25" bgcolor="#E3E3E3">'+
								'<div id="ScrollUp" onMouseOver="Gwindow_scrUp()" onmouseOut="gWindowStop()" style="width:100%;height:100%;cursor:pointer;">'+
									'<table width="100%" height="100%" cellspacing="0">'+
										'<tr>'+
											'<td align="center"><img id="GWinUpArrow" src="../../img/gWinUp.png"></td>'+
										'</tr>'+
									'</table>'+
								'</div>'+
							'</td>'+
						'</tr>'+
						'<tr>'+
							'<td id="gWindowMain">'+
								'<div id="gWindowContainer" style="position:relative;width:100%;height:100%;overflow:hidden;">'+
									'<div id="gWindowContent" style="position:absolute;width:100%;top:0px;">'+
									'</div>'+
								'</div>'+
							'</td>'+
						'</tr>'+
						'<tr>'+
							'<td height="25" bgcolor="#E3E3E3">'+
								'<div id="ScrollDown" onMouseOver="Gwindow_scrDwn()" onmouseOut="gWindowStop()" style="width:100%;height:100%;cursor:pointer;">'+
									'<table width="100%" height="100%" cellspacing="0">'+
										'<tr>'+
											'<td align="center"><img id="GWinDwnArrow" src="../../img/gWinDwn.png"></td>'+
										'</tr>'+
									'</table>'+
								'</div>'+
							'</td>'+
						'</tr>'+
						'<tr>'+
							'<td height="30">'+
								'<div id="Gfooter">'+
									'<table width="100%" height="100%" cellspacing="0">'+
										'<tr>'+
											'<td align="left" class="titolo" valign="bottom" style="color:#153565;">ARROW.IT</td>'+
											'<td align="right"><img style="cursor:pointer;" onClick="GWindowClose()" src="../../img/closelabel.gif"></td>'+
										'</tr>'+
									'</table>'+
								'</div>'+
							'</td>'+
						'</tr>'+
					'</table>'+
				'</div>'
		document.body.innerHTML=document.body.innerHTML+content
		alert(document.body.innerHTML)
	}else{
		window.setTimeout("GWindowInit()", 200)
	}
}

window.onload=GWindowInit()
*/
var GwindowGlobale = "first"
var globalFrame = ""
function GWindowOpen(opac, ajaxCall, WinHeight,  WinWidth, sezione){
	if(sezione){
		globalFrame = "gWin"+sezione
	}
	
	if (opac==0){	
		if (document.all){
			Pagewidth=document.body.clientWidth
			Pageheight=document.body.clientHeight
		}else{
			Pagewidth=window.innerWidth
			Pageheight=window.innerHeight
		}
		
		if (WinHeight){
				document.getElementById("gWindowDiv").style.height=WinHeight+"px"
		}else{
				document.getElementById("gWindowDiv").style.height="700px"
		}
		
		if (WinWidth){
				document.getElementById("gWindowDiv").style.width=WinWidth+"px"
		}else{
				document.getElementById("gWindowDiv").style.width="700px"
		}
		
		document.getElementById("gWindowDiv").style.top=(Pageheight/2)-(document.getElementById("gWindowDiv").offsetHeight/2)
		document.getElementById("gWindowDiv").style.left=(Pagewidth/2)-(document.getElementById("gWindowDiv").offsetWidth/2)
			
		document.getElementById("gWindowContent").style.left="0px"
		document.getElementById("gWindowContent").style.top="0px"
			
		if(!document.all){
			ajaxGetRand(ajaxCall, scrivi_gWindow, ajaxCall);
		}
		document.getElementById("gWindowContent").innerHTML=""
		document.getElementById("overlayLog").style.visibility="visible"
		document.getElementById("gWindowDiv").style.visibility="visible"
	}
	
	opac+=10
	
	if (opac<=100){
		if(document.all){
			opac=100
			document.getElementById('gWindowDiv').filters.alpha.opacity = opac;
		}

		if (document.getElementById('gWindowDiv').style.MozOpacity){
			document.getElementById('gWindowDiv').style.MozOpacity = opac/100;
		}
		
		if(document.getElementById('gWindowDiv').style.opacity){
			document.getElementById('gWindowDiv').style.opacity = opac/100;
		}
		window.setTimeout("GWindowOpen("+opac+", '"+ajaxCall+"')", 20)
	}
	if (opac>100){	
		if(document.all){
			ajaxGet(ajaxCall, scrivi_gWindow, ajaxCall);
		}
		GwindowGlobale="second"
	}
	
}

function scrivi_gWindow(content, ajaxCall){
	if (String(content)=="404"){
		alert("Impossibile trovare '"+ajaxCall+"'. Percorso o indirizzo non valido")
		document.getElementById("gWindowContent").innerHTML=""
	}else{	
		document.getElementById("gWindowContent").innerHTML=content
	}
		
	window.setTimeout("GWindow_Freccie()", 200)
}

function GWindow_Freccie(){
	/*if (document.getElementById("gWindowContent").offsetHeight>document.getElementById("gWindowContainer").offsetHeight){
		//alert("content maggiore di contenitore")
		document.getElementById("GWinUpArrow").style.visibility="visible"
		document.getElementById("GWinDwnArrow").style.visibility="visible"
	}else{
		//alert("contenitore maggiore di content")
		document.getElementById("GWinUpArrow").style.visibility="hidden"
		document.getElementById("GWinDwnArrow").style.visibility="hidden"
	}*/
	document.getElementById("GWinUpArrow").style.visibility="visible"
	document.getElementById("GWinDwnArrow").style.visibility="visible"
}

function GWindowClose(){
	globalScrSearch = "false";
	
	GwindowGlobale="first"
	document.getElementById("overlayLog").style.visibility="hidden"
	if(document.all){
		document.getElementById('gWindowDiv').filters.alpha.opacity = 0;
	}

	if (document.getElementById('gWindowDiv').style.MozOpacity){
		document.getElementById('gWindowDiv').style.MozOpacity = 0.0;
	}
	
	if(document.getElementById('gWindowDiv').style.opacity){
		document.getElementById('gWindowDiv').style.opacity = 0.0;
	}
	document.getElementById("gWindowDiv").style.visibility="hidden"
	document.getElementById("gWindowContent").innerHTML=""
	globalFrame = ""
}

var IntUp 
if (document.all){
	var gWindowSpeed = 30
}else{
	var gWindowSpeed = 10
}


var aspetta = 0
var gSpeed = 20
function Gwindow_scrUp(){
	/*if(parseInt(document.getElementById("gWindowContent").style.top)<0){
		document.getElementById("gWindowContent").style.top=parseInt(document.getElementById("gWindowContent").style.top)+gWindowSpeed+"px"
		IntUp = setTimeout("Gwindow_scrUp()", 30)
	}*/
	if (document.getElementById(globalFrame)){
		eval(globalFrame).scrollBy(0, -gSpeed);aspetta=setTimeout("Gwindow_scrUp()", 10)
	}
}

function Gwindow_scrDwn(){
	/*if((document.getElementById("gWindowContent").offsetHeight - (-parseInt(document.getElementById("gWindowContent").style.top)))>document.getElementById("gWindowContainer").offsetHeight){
		document.getElementById("gWindowContent").style.top=parseInt(document.getElementById("gWindowContent").style.top)-gWindowSpeed+"px"
		IntUp = setTimeout("Gwindow_scrDwn()", 40)
	}
	*/	
	if (document.getElementById(globalFrame)){
		eval(globalFrame).scrollBy(0, gSpeed);aspetta=setTimeout("Gwindow_scrDwn()", 10);
	}
}

function gWindowStop(){
	 //clearTimeout(IntUp);
	 clearTimeout(aspetta);
}


function handle(delta, event) {
	var myTop=parseInt(document.getElementById("gWindowDiv").style.top)+document.getElementById("ScrollUp").offsetHeight
	var myLeft=parseInt(document.getElementById("gWindowDiv").style.left)
	
	
	var Contain = document.getElementById("gWindowContainer")
        if(mouseX(event) > myLeft && mouseX(event)<(myLeft+Contain.offsetWidth) && mouseY(event)>  myTop && mouseY(event)<( myTop+Contain.offsetHeight)){
		var flag = "true"
	}else{
		var flag = "false"
	}
	//alert(flag)
	//alert(event.pageX+" "+parseInt(Contain.offsetLeft)+" "+Contain.offsetWidth)
	
	//var style = document.defaultView.getComputedStyle(Contain, "offsetTop");
	//alert(style.Top)
	
	if (flag=="true"){
		
		if (delta < 0){
			if((document.getElementById("gWindowContent").offsetHeight - (-parseInt(document.getElementById("gWindowContent").style.top)))>document.getElementById("gWindowContainer").offsetHeight){
				document.getElementById("gWindowContent").style.top=parseInt(document.getElementById("gWindowContent").style.top)-30+"px"
			}
		}else{
			if(parseInt(document.getElementById("gWindowContent").style.top)<0){
				document.getElementById("gWindowContent").style.top=parseInt(document.getElementById("gWindowContent").style.top)+30+"px"
			}
		}
	}
}

/** Event handler for mouse wheel event.
 */
function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta, event);
	
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

/** Initialization code. 
 * If you use your own event management code, change it as required.
 */
if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;

	

/*if (window.addEventListener){
        window.addEventListener('click', cc, false);
}*/


//document.onclick=cc;	
	
function cc(event){
	var coords=getIDCoords("gWindowDiv")
	if(document.getElementById("gWindowDiv").style.visibility=="visible" && GwindowGlobale=="second"){
	
		if (!(mouseX(event)>=coords.x1 && mouseX(event)<=coords.x2 && mouseY(event)>=coords.y1 && mouseY(event)<=coords.y2)){
			//alert("è fuori")
			GWindowClose()
		}else{
			//alert("è dentro")
		}
	
	}
}



/*funzioni che ritornano le coordinate del mouse*/
function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

/*fine delle funzioni che ritornano le coordinate del mouse*/



function GetIDX(sender) {
  var x = sender.offsetTop
  if (sender.parentNode != null)
    x += GetIDX(sender.offsetParent);
  return x;
}

function GetIDY(sender) {
  var y = sender.offsetLeft
  if (sender.offsetParent != null)
    y += GetIDY(sender.offsetParent);
  return y;
}

function getIDCoords(id){
	var El = document.getElementById(id)
	var myArr=new Array()
	myArr.x1=parseInt(El.style.left)
	myArr.y1=parseInt(El.style.top)
	myArr.x2=myArr.x1+El.offsetWidth
	myArr.y2=myArr.y1+El.offsetHeight
	
	return myArr
}








