var MouseMosso=0; 

function MM_IconaMouse() { //v2.0
  var i, visStr /*visible?*/,	args, theObj;

  args = MM_IconaMouse.arguments;
  for (i=0; i<(args.length-1); i+=2)
   { //with arg triples (objNS,objIE,visStr)
    visStr   = args[i+1]; // hide or show
    if (navigator.appName == 'Netscape' && document.layers != null)
     {
      theObj = eval(document.layers[args[i]]);
      if (theObj) theObj.left = captureMouseX(eval(document.all))+5;
      if (theObj) theObj.top = captureMouseY(eval(document.all))-10;
      if (theObj) theObj.visibility = visStr;
     } 
    else if (document.all != null)
     { //IE
	  //document.writeln('tratta DIV:' + args[i] + 'S/H' + args[i+1] )
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      theObj = eval(document.all[args[i]]);
      if (theObj) theObj.style.left = captureMouseX(eval(document.all))+5;
      if (theObj) theObj.style.top = captureMouseY(eval(document.all))-10;
      if (theObj) theObj.style.visibility = visStr;
     }
   }
}
//-------browser sniff--------------
var nome=(navigator.appName=="Microsoft Internet Explorer")?true:false;
var wt=nome?(navigator.appVersion.split(';').toString().split(" ").toString().split(',')[4] ):null;
var isie5=((wt)>=5 && nome)?true:false;
var isie4=((wt <5 && wt >=4) && nome)?true:false;
var isNS4=(document.layers)?true:false;
var isNS6=document.getElementById && (navigator.appName=="Netscape")?true:false;

var sty=(isie4 || isie5 || isNS6)?'hidden':(isNS4)?'hide':'hidden'
var stv=(isie4 || isie5 || isNS6)?'visible':(isNS4)?'show':'visible'

var ax=0;
var ay=0;
var x_pos1=0;
var y_pos1=0;

if(isNS4 || isNS6){
   window.captureEvents(Event.MOUSEMOVE);
   window.onmousemove=move;
}
else if (isie4 || isie5)document.onmousemove=move;
   
function move(e){
	//document.visite.nv.value=<%=application("NumVisits")%>;
    if (isie4 || isie5)ax=window.event.clientX, ay=window.event.clientY;
	else if (isNS4 || isNS6)ax=e.pageX, ay=e.pageY;
	return ax;ay;
}
   //-----------------------sposta-------------------------------
   function sposta(qq){
    qw=qq;
    liv_p=(isie5 || isNS6)?document.getElementById(qq).style:(isNS4)?document.layers[qq]:document.all[qq].style;
    liv_p.left=(ax-10)
    liv_p.top=(ay-20)
    qt=setTimeout('sposta(qw)',1)
    }
    
   //--------------------rilascia-------------------------------
   function rel(qq){
    clearTimeout(qt)
   }
//-------------------------------------------------------------

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page
oldEvent_x = 0;
oldEvent_y = 0;

function captureMouseY(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        yMousePos = e.pageY;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        yMousePos = window.event.y+document.body.scrollTop;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        yMousePos = e.pageY;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
	return(yMousePos)
}

function captureMouseX(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        xMousePosMax = window.innerWidth+window.pageXOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        xMousePosMax = window.innerWidth+window.pageXOffset;
    }
	return(xMousePos) 
}

// funzione per la visializzazione / occultamento degli ogetti
function gopag( pagina, TipoWin )
{
 	if ( TipoWin == 'VT' ) finopen(pagina,'Fin4','toolbar,titlebar=0,hotkeys=4,menubar=1,scrollbars=yes,resizable=yes,top=0,screenY=0,left=0,screenX=0,height=450,width=800');

	if ( TipoWin == 'VB' ) finopen(pagina,'Fin3','toolbar,titlebar=0,hotkeys=4,menubar=1,scrollbars=yes,resizable=yes,top=150,screenY=150,left=0,screenX=0,height=450,width=800');

	if ( TipoWin == 'OD' ) finopen(pagina,'Fin2','toolbar,titlebar=0,hotkeys=4,menubar=1,scrollbars=yes,resizable=yes,top=0,screenY=0,left=165,screenX=165,height=450,width=630')

	if ( TipoWin == 'OS' ) finopen(pagina,'Fin5','toolbar,titlebar=0,hotkeys=4,menubar=1,scrollbars=yes,resizable=yes,top=0,screenY=0,left=0,screenX=0,height=450,width=630');

	if ( TipoWin == 'PS' ) finopen(pagina,'Fin6','toolbar,titlebar=0,hotkeys=4,menubar=1,scrollbars=yes,resizable=yes,top=0,screenY=0,left=0,screenX=0,height=600,width=800');

	if ( TipoWin == 'CS' ) finopen(pagina,'Fin7','scrollbars=yes,resizable=yes,top=150,screenY=150,left=220,screenX=220,height=300,width=470');

	if ( TipoWin == 'CC' ) finopen(pagina,'Fin8','scrollbars=yes,resizable=yes,top=150,screenY=150,left=180,screenX=180,height=300,width=600');
	
	if ( TipoWin == 'PP' ) finopen(pagina,'POPUPMENU','scrollbars=yes,resizable=yes,top=220,screenY=220,left=198,screenX=205,height=340,width=575');
//	if ( TipoWin == 'PP' ) finopen1(pagina,'POPUPMENU','scrollbars=yes,resizable=yes,top=204,screenY=220,left=198,screenX=205,height=340,width=575');

	return (true)
}
var win=null;

function finopen(pagina,nome,feat)
{
	if (win && win.open && !win.closed){
		win.focus();
		win.close()
//		win.location.href=pagina;
	}
//	else
	win = window.open(pagina,nome,feat);
	return (true)
}

function finopen1(pagina,nome,feat) {
  var popupObj = window.createPopup();
  var popupBodyObj = popupObj.document.body;
  popupBodyObj.style.border = "1px purple solid";
  popupBodyObj.innerHTML = pagina;
  for (var i = 0; i < popupBodyObj.all.length; i++) {
    if (popupBodyObj.all[i].tagName == "A")
      popupBodyObj.all[i].onclick = doClick;
  }
  popupObj.show(0, linkObj.offsetHeight, menuID.offsetWidth, menuID.offsetHeight, linkObj);
}

function MM_showHideLayers() { //v2.0
var i, visStr /*visible?*/, args, theObj, x_pos, y_pos;
  
  args = MM_showHideLayers.arguments;
  for (i=0; i<(args.length-1); i+=2)
   { //with arg triples (objNS,objIE,visStr)
    visStr   = args[i+1]; // hide or show
    if (navigator.appName == 'Netscape' && document.layers != null)
     {
      theObj = eval(document.layers[args[i]]);
      if (theObj && captureMouseX(eval(document.all)) <= 0) theObj.left = 210;
      if (theObj && captureMouseX(eval(document.all)) <= 300) theObj.left = captureMouseX(eval(document.all))+10;
      if (theObj && captureMouseX(eval(document.all))  > 300) theObj.left = captureMouseX(eval(document.all))-250;
      if (theObj) theObj.top = captureMouseY(eval(document.all))-30;
      if (theObj) theObj.visibility = visStr;
     } 
    else if (document.all != null)
     { //IE
	  //document.writeln('tratta DIV:' + args[i] + 'S/H' + args[i+1] )
      if (visStr == 'show') visStr = 'visible'; //convert vals
      if (visStr == 'hide') visStr = 'hidden';
      theObj = eval(document.all[args[i]]);
      if (theObj && captureMouseX(eval(document.all)) <= 0) {theObj.style.left = 210;}
	  else { if (theObj && captureMouseX(eval(document.all)) <= 300) theObj.style.left = captureMouseX(eval(document.all))+10;}
      if (theObj && captureMouseX(eval(document.all))  > 300) theObj.style.left = captureMouseX(eval(document.all))-250;
      if (theObj) theObj.style.top = captureMouseY(eval(document.all))-30;
      if (theObj) theObj.style.visibility = visStr;
     }
   }
}


function MM_Move() { //v2.0
var i, args, theObj;

	args = MM_Move.arguments;
	if (navigator.appName == 'Netscape' && document.layers != null)
	{	theObj = eval(document.layers[args[0]]);
        if (theObj && captureMouseX(eval(document.all)) < 0) 
		   		theObj.left = 210;
		else {	if (theObj) 
			 	  theObj.left = captureMouseX(eval(document.all))+10; 
				if (theObj) theObj.top  = captureMouseY(eval(document.all))-30;
        		if (theObj && captureMouseX(eval(document.all))  > 500) theObj.left = captureMouseX(eval(document.all))-350;
        		if (theObj && captureMouseX(eval(document.all)) <= 500) theObj.left = captureMouseX(eval(document.all))+10;
			 }
	} 
	else if (document.all != null)
	{ 	theObj = eval(document.all[args[0]]);
        if (theObj && captureMouseX(eval(document.all)) < 200) 
				theObj.style.left = 210;
		else {	if (theObj) 
			 	   theObj.style.left = captureMouseX(eval(document.all))+10; 
				if (theObj) theObj.style.top  = captureMouseY(eval(document.all))-30;
				if (theObj && captureMouseX(eval(document.all))  > 500) theObj.style.left = captureMouseX(eval(document.all))-350;
				if (theObj && captureMouseX(eval(document.all)) <= 500) theObj.style.left = captureMouseX(eval(document.all))+10;
			 }
	}
}

function MM_Move1() { //v2.0
var i, args, theObj, dato_x, dato_y;

	while (window.event.mousedown) {
	args = MM_Move1.arguments;
	if (navigator.appName == 'Netscape' && document.layers != null)
	{	theObj = eval(document.layers[args[0]]);
		if (theObj) theObj.left = theObj.left+(theObj.left-captureMouseX(eval(document.all)));
		if (theObj) theObj.top = theObj.top+(theObj.top-captureMouseY(eval(document.all)));
	} 
	else if (document.all != null)
	{ 	theObj = eval(document.all[args[0]]);
		//if (theObj) theObj.style.left = theObj.style.left+(theObj.style.left-captureMouseX(eval(document.all)));
		//if (theObj) theObj.style.top = theObj.style.top+(theObj.style.top-captureMouseY(eval(document.all)));
		if (theObj) 
		{	theObj.style.left = parseInt(theObj.style.left)+(window.event.x-oldEvent_x);
			theObj.style.top = parseInt(theObj.style.top)+(window.event.y-oldEvent_y);
			oldEvent_x = window.event.x
			oldEvent_y = window.event.y
		}
	}
	}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//function MM_showHideLayers0() { //v2.0
//var i, visStr /*visible?*/, args, theObj, x_pos, y_pos;
//  
//  args = MM_showHideLayers0.arguments;
//  for (i=0; i<(args.length-1); i+=2)
//   { //with arg triples (objNS,objIE,visStr)
//    visStr   = args[i+1]; // hide or show
//    if (navigator.appName == 'Netscape' && document.layers != null)
//     {
//      theObj = eval(document.layers[args[i]]);
//      if (theObj) theObj.left = captureMouseX(eval(document.all))+50;
//      if (theObj && captureMouseX(eval(document.all))  > 500) theObj.left = captureMouseX(eval(document.all))-300;
//      if (theObj && captureMouseX(eval(document.all)) <= 500) theObj.left = captureMouseX(eval(document.all))-10;
//      if (theObj) theObj.top = captureMouseY(eval(document.all))-50;
//      if (theObj) theObj.visibility = visStr;
//     } 
//    else if (document.all != null)
//     { //IE
//	  //document.writeln('tratta DIV:' + args[i] + 'S/H' + args[i+1] )
//      if (visStr == 'show') visStr = 'visible'; //convert vals
//      if (visStr == 'hide') visStr = 'hidden';
//      theObj = eval(document.all[args[i]]);
//      if (theObj) theObj.style.left = captureMouseX(eval(document.all))+50;
//      if (theObj && captureMouseX(eval(document.all)) > 500) theObj.style.left = captureMouseX(eval(document.all))-300;
//      if (theObj && captureMouseX(eval(document.all)) <= 500) theObj.style.left = captureMouseX(eval(document.all))-10;
//      if (theObj) theObj.style.top = captureMouseY(eval(document.all))-50;
//      if (theObj) theObj.style.visibility = visStr;
//     }
//   }
//}

//function MM_showHideLayers1() { //v2.0
//var i, visStr /*visible?*/, args, theObj;
//
//	Rallenta(100);	
//	//if (MouseMosso == 0) {
//		args = MM_showHideLayers1.arguments;
//		for (i=0; i<(args.length-1); i+=2)
//		{ //with arg triples (objNS,objIE,visStr)
//			visStr   = args[i+1]; // hide or show
//			if (navigator.appName == 'Netscape' && document.layers != null)
//			{	theObj = eval(document.layers[args[i]]);
//				if (theObj) theObj.visibility = visStr;
//			}
//			else if (document.all != null)
//			{ //IE
//			  //document.writeln('tratta DIV:' + args[i] + 'S/H' + args[i+1] )
//				if (visStr == 'show') visStr = 'visible'; //convert vals
//				if (visStr == 'hide') visStr = 'hidden';
//				theObj = eval(document.all[args[i]]);
//				if (theObj) theObj.style.visibility = visStr;
//			  }
//			}
//	//	}
//}

//function Rallenta(Millisecondi) {
//var datacomodo, adesso;
//	datacomodo = new Date();
//	adesso = new Date();
//	while (adesso.getTime() - datacomodo.getTime() < Millisecondi) 	   
//		adesso = new Date();
//}  

//function SiSposta() { //v2.0
//	MouseMosso=1;
//window.status="DEBUG:SiSposta" + MouseMosso;
//}


