var http_request = false;

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;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var mouseX = 0;
var mouseY = 0;
// 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
  mouseX = tempX;
  mouseY = tempY;
  return true
}





function waitingbanner()
{
	with (document.getElementById("loading")) 
	{
		//alert("sono nel metodo waitingbanner");
	    style.visibility = "visible";
	    if (navigator.appName == "Microsoft Internet Explorer") 
	    {
	      //style.posLeft = document.body.clientWidth - 575;
	      //style.posTop = 400;
	      // 50 px sopra la posizione del mouse e 50 px a destra della posizione del mouse
	      style.posRight = mouseX  + 50;
	      style.posTop = mouseY - 50 ;
	    } 
	    else 
	    {
	      //style.left = (window.innerWidth - 575) + "px";
	      //style.top = "400px";
	      style.right = (mouseX + 50) + "px";
	      style.top = (mouseY - 50) + "px";
	    }
  	}

}




function makeRequest(url, parameters) 
{
	  
      http_request = false;
      if (window.XMLHttpRequest) 
      { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) 
         {
            http_request.overrideMimeType('text/html');
         }
      } 
      else
      { 
      		if (window.ActiveXObject) 
      		{ // IE
		        try 
		        {
	            	http_request = new ActiveXObject("Msxml2.XMLHTTP");
	            } 
	            catch (e) 
	            {
	            	try 
	            	{
	               		http_request = new ActiveXObject("Microsoft.XMLHTTP");
		            }
		            catch (e) 
		            {}
	         	}
      		}
      }
      if (!http_request) 
      {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
      waitingbanner();
}


function utf8encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c < 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	}




