// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;
//if(document.getElementById('tabella'))
//	document.getElementById('tabella').onmousemove=getMouseXY;
//else alert('tabella');
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
var timerid= -1;
// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX<=0){tempX = 0}
  if (tempY<=0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.getElementById('divASContainer').style.left = tempX - 2   
  document.getElementById('divASContainer').style.top = tempY  - 2		
		
  
  return true
}

//-->

function verifyCompatibleBrowser(){ 
	this.ver=navigator.appVersion 
	this.dom=document.getElementById?1:0 
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	return this 
} 
bw=new verifyCompatibleBrowser() 
lstart=120
loop=false  
speed=50 
pr_step=3 
var objContainer
var objContent
var currentposition=0
var ferma=false

function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
	this.newsScroll=newsScroll; 
	this.moveIt=b_moveIt; 
	
	this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 

function b_moveIt(x,y){ 
	this.x=x;this.y=y 
	this.css.left=this.x 
	this.css.top=this.y 
	
} 
function findPosX()
  {
    var curleft = 0;
    var obj=document.getElementById('tabella');
	
	if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY()
  {
    var curtop = 0;
    var obj=document.getElementById('tabella');
	
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


//Makes the object scroll up 
function newsScroll(speed){ 
	if(this.y>-(this.scrollHeight-50)){ 
		this.moveIt(0,this.y-pr_step) 
		setTimeout(this.obj+".newsScroll("+speed+")",speed) 
	}else if(loop) { 
		this.moveIt(0,lstart) 
		eval(this.obj+".newsScroll("+speed+")") 
	  } 
} 
//Makes the object 
function stoppa()
{
timerid=-1;
//alert(timerid);
}
function impostatimeout(url,delay)
{
loadscroll()
setTimeout("document.location.reload()",3000)

}
function InitialiseAutoScrollArea(){ 
	TheForm=document.msgform;
	TheForm.submit();
} 

function loadscroll(testo,x,y){
	//if(ferma==false)
    
	if(true)
		{
		document.getElementById('divASContent').innerHTML = '<iframe src='+testo+
        ' class="bordato" style="padding:0px;border:1px solid #789DB3" scrolling=auto frameborder=no height=40% width=99%></iframe>'
		objContainer=new ConstructObject('divASContainer') 
		objContent=new ConstructObject('divASContent','divASContainer') 
		//objContent.moveIt(0,lstart) 
		//objContent.moveIt(0,-objContent.scrollHeight+200) 
		//alert(testo)
		var px=findPosX();
		var py=findPosY();
		var offx=x;
        var offy=y;
        //offx=100;
        //soffy=100;
        	  
	
		//document.getElementById('divASContainer').style.left = (px + offx ); 
 		//document.getElementById('divASContainer').style.top = (py - offy );		
		objContainer.css.visibility='visible' 
		//timerid=-2;
		}
} 



function chiudi()
{
//objContainer.css.visibility='hidden';
clearTimeout(timerid);
timerid=-1;

}

function hidescroll()
{
/*if(objContainer)
	{
    if(timerid==-2)
		{
		clearTimeout(timerid);
		timerid=setTimeout("chiudi()",500);
    	}
	else clearTimeout(timerid);
	}*/
}
function move_by(step)
{
objContent.moveIt(0,objContent.y-step) 
}


