// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
    {
      try
      {
         // try to create XMLHttpRequest object
         xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      }
      catch (e) {}
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}
// read a file from the server
function process(url,id,redirectPage)
{
  // only continue if xmlHttp isn't void
  if (xmlHttp)
  {
    // try to connect to the server
    try
    {
      // iate reading a file from the server
      xmlHttp.open("GET", url, true);
      xmlHttp.onreadystatechange = handleRequestStateChange(redirectPage);
      xmlHttp.send(null);
    }
    // display the error in case of failure
    catch (e)
    {
      alert("Can't connect to server:\n" + e.toString());
    }
  }
}
// function called when the state of the HTTP request changes
function handleRequestStateChange(redirectPage)
{
  // when readyState is 4, we are ready to read the server response
  if (xmlHttp.readyState == 4)
  {
    // continue only if HTTP status is "OK"
    if (xmlHttp.status == 200)
    {
      try
      {
         // do something with the response from the server
        var results=xmlHttp.responseText;
	if(redirectPage=="" || results!="1") {
						
		var temp=id.split("~"); // To display on multiple div 
		//alert(temp.length);
		var r=results.split("~"); // To display multiple data into the div 
		//alert(temp.length);
		if(temp.length>1) {
			for(i=0;i<temp.length;i++) {	
			//alert(temp[i]);
				document.getElementById(temp[i]).innerHTML=r[i];
				}
			} else {
				document.getElementById(id).innerHTML = results;
				}	
			} else {
				//alert(results);
				window.location.href=redirectPage;
      }
      }
      catch(e)
      {
         // display error message
         alert("Error reading the response: " + e.toString());
      }
    }
    else
    {
      // display status message
      alert("There was a problem retrieving the data:\n" +
             xmlHttp.statusText);
    }
  }
}

function display($message)
{
  // obtain a reference to the <div> element on the page
  myDiv = document.getElementById("myDivElement");
  // display message
  myDiv.innerHTML = $message + "<br/>";
}


function submitform (theform, serverPage, objID, valfunc){
  var file = serverPage;
  var str = getformvalues(theform,valfunc);
  //If the validation is ok.
  if (aok == true){
    obj = document.getElementById(objID);
    processajax (serverPage, obj, "post", str);
  }
}

//Functions to submit a form.
function getformvalues (fobj, valfunc){
  var str = "";
  aok = true;
  var val;
  //Run through a list of all objects contained within the form.
  for(var i = 0; i < fobj.elements.length; i++){
    if(valfunc) {
      if (aok == true){
        val = valfunc (fobj.elements[i].value,fobj.elements[i].name);
        if (val == false){
           aok = false;
        }
      }
    }
    str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&";
  }
  //Then return the string values.
  return str;
}
//Function to process an XMLHttpRequest.
function processajax (serverPage, obj, getOrPost, str){
  //Get an XMLHttpRequest object for use.
  xmlhttp = getxmlhttp ();
  if (getOrPost == "get"){
    xmlhttp.open("GET", serverPage);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        var results=xmlhttp.responseText;
        var temp=obj.split("~");
        var r=results.split("~");

	if(temp.length>1) {
		for(i=0;i<temp.length;i++) {	
			document.getElementById(temp[i]).innerHTML=r[i];
		}
	} else {
		document.getElementById(obj).innerHTML = results;
	}	

        //document.getElementById(obj).innerHTML = xmlhttp.responseText;
      }
    }
      xmlhttp.send(null);
    } else {
      xmlhttp.open("POST", serverPage, true);
      xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
          obj.innerHTML = xmlhttp.responseText;
        }
      }
      xmlhttp.send(str);
    }
  }
//Function to create an XMLHttp Object.
function getxmlhttp (){
  //Create a boolean variable to check for a valid Microsoft active x instance.
  var xmlhttp = false;
  //Check if we are using internet explorer.
  try {
    //If the javascript version is greater than 5.
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    //If not, then use the older active x object.
    try {
      //If we are using internet explorer.
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      //Else we must be using a non-internet explorer browser.
      xmlhttp = false;
    }
  }
  // If not using IE, create a
  // JavaScript instance of the object.
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function init_tablep(id) {
  processajax('cprodotti.php?Id='+id,'tablep','get');
}

function init_tckt(id){
  processajax('listatckt.php?Id='+id,'showtckt','get');
}

function delxsp(){
  processajax('delxsp.php','delfilexsp','get');
}


function init_guida() {
  processajax('guida.php','showtable','get');
}

function init_gestione() {
  processajax('utenti.php','showtable','get');
}

function azioni(Id) {
	processajax('azioni.php?Id='+Id,'azioni','get');
}

function save_telea(id, prodotto, id_admin) {
  var showtable = "showtable"+prodotto;
  var testo=escape(document.getElementById(prodotto).value);
  processajax('ins_teleassistenza.php?Id='+id+'&Prodotto='+prodotto+'&Testo='+testo+'&Id_Admin='+id_admin, showtable,'get');
}

function load_telea(id, prodotto, old) {
  document.getElementById(prodotto).value = old;
}

function xsploadstorico(id, testo, idc) {
  document.getElementById(id+'TESTO').value = testo;
}

function lock_telea(id, admin, lock) {
  processajax('lock_telea.php?Id='+id+'&Id_Admin='+admin+'&Lock='+lock,'showlock','get');
}

function save_serie(day, month, year, max, esame) {
        parent.document.getElementById("nuovo").innerHTML = "";
	processajax('show_table.php?month='+month+'&year='+year,'showtable','get');
}

function save_password(operatore) {
  var oldpass=document.getElementById("oldpass").value;	
  var pass1=document.getElementById("pass1").value;
  var pass2=document.getElementById("pass2").value;
  parent.document.getElementById("nuovo").innerHTML = "";
  processajax('set_password.php?mode=insert&oldpass='+oldpass+'&pass1='+pass1+'&pass2='+pass2+'&operatore='+operatore,'showPassword','get');
}

function del_serie(day, id, month, year, tab, operatore) {

var mode = 'delete_serie';
tab_esame='Esami';

  xmlhttpa = new XMLHttpRequest();
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "visible";
  var objID = "nuovo";
  var serverPage = "cprenotazione.php?mode="+mode+"&day="+day+"&month="+month+"&year="+year+"&Id="+id+"&tab_esame="+tab+"&operatore"+operatore;
  var obj = document.getElementById(objID);
  xmlhttpa.open("GET", serverPage);
  xmlhttpa.onreadystatechange = function() {
    if (xmlhttpa.readyState == 4 && xmlhttpa.status == 200) {
      obj.innerHTML = xmlhttpa.responseText;
    }
  }
  xmlhttpa.send(null);

  xmlhttp = new XMLHttpRequest();
  theObjecta = parent.document.getElementById("showtable");
  theObjecta.style.visibility = "visible";
  var objaID = "showtable";
  var serveraPage = "show_table.php?mode="+mode+"&month="+month+"&year="+year+"&ids="+id+"&datas="+day+"&tab_esame="+tab;
  var obja = document.getElementById(objaID);
  xmlhttp.open("GET", serveraPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obja.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function del_prenotazione(day, id, month, year, operatore, tab_esame) {

var mode = 'delete_prenotazione';

  xmlhttpa = new XMLHttpRequest();
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "visible";
  var objID = "nuovo";
  var serverPage = "cprenotazione.php?mode="+mode+"&day="+day+"&month="+month+"&year="+year+"&Id="+id+"&tab_esame="+tab_esame+"&operatore="+operatore;
  var obj = document.getElementById(objID);
  xmlhttpa.open("GET", serverPage);
  xmlhttpa.onreadystatechange = function() {
    if (xmlhttpa.readyState == 4 && xmlhttpa.status == 200) {
      obj.innerHTML = xmlhttpa.responseText;
    }
  }
  xmlhttpa.send(null);

  xmlhttp = new XMLHttpRequest();
  theObjecta = parent.document.getElementById("showtable");
  theObjecta.style.visibility = "visible";
  var objaID = "showtable";
  var serveraPage = "show_table.php?mode="+mode+"&month="+month+"&year="+year+"&ids="+id+"&datas="+day+"&tab_esame="+tab_esame+"&operatore="+operatore;
  var obja = document.getElementById(objaID);
  xmlhttp.open("GET", serveraPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obja.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function prenotazione(month, year, day, max, tab_esame) {
	document.getElementById("nuovo").innerHTML = "";
parent.parent.processajax('nuovo.php?day='+data+"&month="+month+"&year="+year+"&max="+max+"&tab_esame="+tab_esame,'nuovo','get');
//        processajax('prenotazione.php?day='+day+'&month='+month+'&year='+year+'&Id='+id+'&tab_esame='+esame,'nuovo','get');
}

function upload (theform){
  theform.submit();
}

function doneloading(frame, numdoc) {

//	frame.processajax('temp.php?num_doc='+numdoc, 'ris_up','get');
	frame.processajax('show_table.php?mode=save_new&numdoc='+numdoc,'showtable','get');

}
//////////////////////////ULTIMA MODIFICA//////////////////////////////
function DelDay(day,id) {

	processajax('prenotazione.php?mode=del&day='+day+'&Id_p='+id,'del_data','get');
}

function AzioniDate(Id) {

	processajax('date_prenotazione.php?Id='+Id,'dateazioni','get');
}
//////////////////////////////////////////////////////////////////////////////////
var showOrHide = true;
function showDateSerie(max, Id, shift, dayp, month, year) {
		
		//The location we are loading the page into.
	var objID = "small_date";
		
		//Change the current image of the minus or plus.
	if (showOrHide == true){
		//Show the calendar.
		//document.getElementById("opencloseimg").src = "web_gestione_home/mins.gif";
		//The page we are loading.
		var serverPage = "data_con.php";
		//Set the open close tracker variable.
//		showOrHide = false;
		var obj = document.getElementById(objID);
		processajax('data_con.php?max='+max+'&Id_esami='+Id+'&shift='+shift+'&dayp='+dayp+'&month='+month+'&year='+year, 'small_date','get');
	} else {
		//Hide the calendar.
		//document.getElementById("opencloseimg").src = "web_gestione_home/plus.gif";
		showOrHide = true;
		//Reset the content.
		document.getElementById(objID).innerHTML = "";
	}
}

function addprodotto(id, prodotto) {
  if (document.getElementById(prodotto).checked == true){
    var telea = 'S';
  }
  else var telea = 'N';
  var mode = "Add";
  parent.processajax('cprodotti.php?Id='+id+'&Prodotto='+prodotto+'&Mode='+mode+'&Telea='+telea, 'tablep', 'get');
}

var showOrHidec = true;
function showHideContatti(Id) {
		
		//The location we are loading the page into.
	var objID = "testo_con";
		
		//Change the current image of the minus or plus.
	if (showOrHidec == true){
		//Show the calendar.
		document.getElementById(Id).src = "web_gestione_home/mins.gif";
		//The page we are loading.
		var serverPage = "testo_con.php?Id="+Id;
		//Set the open close tracker variable.
		showOrHidec = false;
		//var obj = document.getElementById(objID);
		processajax('testo_con.php?Id='+Id, 'div'+Id,'get');
	} else {
		//Hide the calendar.
		document.getElementById(Id).src = "web_gestione_home/plus.gif";
		showOrHidec = true;
		//Reset the content.
		document.getElementById('div'+Id).innerHTML = "";
	}
}

var showOrHides = true;
function showHideSerie(Id) {
//	var objID = "Id"+Id;
	//Change the current image of the minus or plus.
	if (showOrHides == true){
		//Show the calendar.
		document.getElementById("img").src = "images/mins.gif";
		//The page we are loading.
		var serverPage = "dateserie.php?Id="+Id;
		//Set the open close tracker variable.
		showOrHides = false;
		//var obj = document.getElementById(objID);
		processajax('dateserie.php?Id='+Id, 'Id'+Id,'get');
	} else {
		//Hide the calendar.
		document.getElementById("img").src = "images/plus.gif";
		showOrHides = true;
		//Reset the content.
		document.getElementById("Id"+Id).innerHTML = "";
	}
}

function DateSerie(date_serie, max, operatore) {
	var objID = "show_data";
//	var serverPage = "testo_con.php?data="+data;
	//Set the open close tracker variable.
	//var obj = document.getElementById(objID);
	processajax('testo_con.php?data_serie='+date_serie+'&max='+max+'&operatore='+operatore, 'datas','get');
}

function updatedayserie(date_serie, id, day, month, year, tab, operatore) {

var mode = 'add_serie';

  xmlhttpc = new XMLHttpRequest();
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "visible";
  var objID = "nuovo";
  var serverPage = "cprenotazione.php?mode="+mode+"&Id="+id+"&day="+day+"&month="+month+"&year="+year+"&tab_esame="+tab+"&operatore="+operatore;
  var obj = document.getElementById(objID);
  xmlhttpc.open("GET", serverPage);
  xmlhttpc.onreadystatechange = function() {
    if (xmlhttpc.readyState == 4 && xmlhttpc.status == 200) {
      obj.innerHTML = xmlhttpc.responseText;
    }
  }
  xmlhttpc.send(null);

  xmlhttpd = new XMLHttpRequest();
  theObjecta = parent.document.getElementById("showtable");
  theObjecta.style.visibility = "visible";
  var objaID = "showtable";
  var serveraPage = "show_table.php?mode="+mode+"&ids="+id+"&datas="+day+"&month="+month+"&year="+year+"&tab_esame="+tab;
  var obja = document.getElementById(objaID);
  xmlhttpd.open("GET", serveraPage);
  xmlhttpd.onreadystatechange = function() {
    if (xmlhttpd.readyState == 4 && xmlhttpd.status == 200) {
     obja.innerHTML = xmlhttpd.responseText;
   }
 }
 xmlhttpd.send(null);

}

function ChiudiContatti(Id) {	
	processajax('chiudi_con.php?Id='+Id, 'div_az'+Id,'get');
}

function createform (e, month, year, data_p, tab, operatore){
  theObject = document.getElementById("createtask");
  theObject.style.visibility = "visible";
  theObject.style.height = "370px";
  theObject.style.width = "200px";
  var posx = 0;
  var posy = 0;
  if (e.clientY < 250) posy = e.clientY
  else posy = e.clientY - 150
  posx = e.clientX + document.body.scrollLeft;
  //posy = e.clientY + document.body.scrollTop - pos;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "createtask";
  var serverPage = "theform.php?month="+month+"&year="+year+"&data_p="+data_p+"&tab_esame="+tab+"&operatore="+operatore;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);

}

function formPassword (e, operatore){
  xmlhttp = createXmlHttpRequestObject();
  winPassw = document.getElementById("winpwd");
  winPassw.style.visibility = "visible";
  winPassw.style.height = "185px";
  winPassw.style.width = "400px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY + 50;
  posx = e.clientX - 400;
  //posy = e.clientY + document.body.scrollTop - pos;
  winPassw.style.left = posx + "px";
  winPassw.style.top = posy + "px";
  //The location we are loading the page into.
     //var objID = "winpwd";
  var serverPage = "password.php?operatore="+operatore;
     //var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      winPassw.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function save_password(operatore) {
  var oldpass=document.getElementById("oldpass").value;	
  var pass1=document.getElementById("pass1").value;
  var pass2=document.getElementById("pass2").value;
  parent.document.getElementById("nuovo").innerHTML = "";
  processajax('set_password.php?mode=insert&oldpass='+oldpass+'&pass1='+pass1+'&pass2='+pass2+'&operatore='+operatore,'showPassword','get');
}

function createcprenotazioni (mode, month, year, day, id, tab_esame){
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "visible";
  theObject.style.height = "10px";
  theObject.style.width = "10px";
  var posx = 0;
  var posy = 0;
  //if (e.clientY < 250) posy = e.clientY
  //else posy = e.clientY - 150
  //posx = e.clientX + document.body.scrollLeft;
  //posy = e.clientY + document.body.scrollTop - pos;
  //theObject.style.left = 420 + "px";
  //theObject.style.top = -60 + "px";
  //The location we are loading the page into.
  var objID = "nuovo";
  var serverPage = "cprenotazione.php?mode="+mode+"&day="+day+"&month="+month+"&year="+year+"&Id="+id+"&tab_esame="+tab_esame;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
  closetask();
}

function formDay (e, Id){

  var scrolledX, scrolledY;
  if( self.pageYOffset ) {
    scrolledX = self.pageXOffset;
    scrolledY = self.pageYOffset;
  }
  else if( document.documentElement && document.documentElement.scrollTop ) {
    scrolledX = document.documentElement.scrollLeft;
    scrolledY = document.documentElement.scrollTop;
  }
  else if( document.body ) {
    scrolledX = document.body.scrollLeft;
    scrolledY = document.body.scrollTop;
  }

  var centerX, centerY;
  if( self.innerHeight ) {
    centerX = self.innerWidth;
    centerY = self.innerHeight;
  }
  else if( document.documentElement && document.documentElement.clientHeight ) {
    centerX = document.documentElement.clientWidth;
    centerY = document.documentElement.clientHeight;
  }
  else if( document.body ) {
    centerX = document.body.clientWidth;
    centerY = document.body.clientHeight;
  }

  var leftOffset = scrolledX + (centerX - 250) / 2;
  var topOffset = scrolledY + (centerY - 200) / 2;

  theObject = document.getElementById("createtask");
  theObject.style.visibility = "visible";
  theObject.style.height = "200px";
  theObject.style.width = "300px";
  theObject.style.left = (centerX/2 - 150) + "px";
  theObject.style.top = (centerY/2 - 100) + "px";

  processajax('day.php?Id='+Id+'&x='+centerX,'createtask','get');
}

function formProdotto (e, id){
  xmlhttp = createXmlHttpRequestObject();
//  xmlhttp = new XMLHttpRequest();
  theObject = document.getElementById("createtask");
  theObject.style.visibility = "visible";
  theObject.style.height = "210px";
  theObject.style.width = "760px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY + 50;
  posx = e.clientX + 0;  
//  posx = 75 + document.body.scrollLeft;
  //posy = e.clientY + document.body.scrollTop - pos;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "createtask";
  var serverPage = "nuovoprodottoc.php?Id="+id;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function formNota (e, max, esame, data){
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
  var ddn = document.getElementById("ddn").value;
  theObject = document.getElementById("createtask");
  theObject.style.visibility = "visible";
  theObject.style.height = "90px";
  theObject.style.width = "186px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY - 45;
  posx = e.clientX - 45;
  //posy = e.clientY + document.body.scrollTop - pos;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "createtask";
  var serverPage = "nota.php?esame="+esame+"&nome="+nome+"&cognome="+cognome+"&ddn="+ddn+"&data="+data;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function formNotas (e, ids){
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
  var ddn = document.getElementById("ddn").value;
  theObject = document.getElementById("createtask");
  theObject.style.visibility = "visible";
  theObject.style.height = "90px";
  theObject.style.width = "186px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY - 45;
  posx = e.clientX - 45;
  //posy = e.clientY + document.body.scrollTop - pos;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "createtask";
  var serverPage = "notas.php?Ids="+ids;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function closetask (){
  theObject = document.getElementById("createtask");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function closetaskpassword(){
  theObject = document.getElementById("winpwd");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function closetasknota (){
  theObject = document.getElementById("notatelea");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function pclosetask (){
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function closeNota (){
  theObject = document.getElementById("shownota");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function closeFile (){
  theObject = document.getElementById("showfile");
  theObject.style.visibility = "hidden";
  theObject.style.height = "0px";
  theObject.style.width = "0px";
}

function closeformcliente (id){
  document.getElementById(id).innerHTML = "";
}

function closeNuovoRef (){
  document.getElementById('nuovoref').innerHTML = "";
}

function closeNuovoPro(){
  document.getElementById('nuovostorico').innerHTML = "";
}

function closeNuovoStorico (){
  document.getElementById('nuovostorico').innerHTML = "";
}

function noSto(id, idc, testo){
  document.getElementById(id).innerHTML = "<a href=\"javascript:void(null);\" onclick=\"xspdatastor(this, '"+id+"', '"+idc+"');\">"+testo+"</a>"
}

function noTestoSto(link, id, idc, testo){
  var div = id+'TESTO'; alert(testo);
  testo = testo.replace("\n", "<br>");
  document.getElementById(div).innerHTML = "<a href=\"javascript:void(null);\" onclick=\"xsptestostor(this, '"+id+"', '"+idc+"');\">"+testovecchio+"</a>"
}

function siSto(id, idc){
 var aa = document.getElementById('prova').value; alert(aa);
 processajax('storico.php?Id='+idc+'&Idr='+id+'&Data='+aa+'&Mode=Updatedata','storico','get');
}

function siTestoSto(id, idc){
  aa = document.getElementById('testosto').value;alert(aa);
//  var aa = escape(document.getElementById('testosto').value); alert(aa);
  aa = aa.replace("\n/g", "<br>"); aa = escape(aa); alert(aa);

 processajax('storico.php?Id='+idc+'&Idr='+id+'&Testo='+aa+'&Mode=Updatestorico','storico','get');
}

function noformRef (id, campo){
  var val = id+campo;
  document.getElementById(val).innerHTML = "";
}

//document.getElementById("nuovo").innerHTML = "";

function showNuovo(month, year, data, max, tab_esame) {
  processajax('nuovo.php?day='+data+"&month="+month+"&year="+year+"&max="+max+"&tab_esame="+tab_esame,'nuovo','get');
  closetask ()
}

function showCerca(tab_esame) {
  processajax('cerca.php?tab_esame='+tab_esame,'nuovo','get');
  closetask ()
}

function showRapportino(id) {
  processajax('rapportino.php?Id='+id,'showrapportino','get');
}

function showCPrenotazione(month, year, day, id, tab_esame) {
closetask ();
processajax('cprenotazione.php?day='+day+"&month="+month+"&year="+year+"&Id="+id+"&tab_esame="+tab_esame,'nuovo','get');
 //processajax('cprenotazione.php?tab_esame='+tab_esame,'nuovo','get');
  closetask ()

}

function showAvvisi(day, month, year, tab, operatore) {
  parent.parent.processajax('avvisi.php?day='+day+'&month='+month+'&year='+year+'&tab_esame='+tab+'&operatore='+operatore,'nuovo','get');
}

function del_avviso(month, year, day, id, del, tab, operatore) {
  xmlhttpc = new XMLHttpRequest();
  theObject = document.getElementById("nuovo");
  theObject.style.visibility = "visible";
  var objID = "nuovo";
  var serverPage = "avvisi.php?day="+day+"&Id="+id+"&mode="+del+"&tab_esame="+tab+"&operatore="+operatore;
  var obj = document.getElementById(objID);
  xmlhttpc.open("GET", serverPage);
  xmlhttpc.onreadystatechange = function() {
    if (xmlhttpc.readyState == 4 && xmlhttpc.status == 200) {
      obj.innerHTML = xmlhttpc.responseText;
    }
  }
  xmlhttpc.send(null);

  xmlhttpd = new XMLHttpRequest();
  theObjecta = parent.document.getElementById("showtable");
  theObjecta.style.visibility = "visible";
  var objaID = "showtable";
  var serveraPage = "show_table.php?month="+month+"&year="+year+"&tab_esame="+tab;
  var obja = document.getElementById(objaID);
  xmlhttpd.open("GET", serveraPage);
  xmlhttpd.onreadystatechange = function() {
    if (xmlhttpd.readyState == 4 && xmlhttpd.status == 200) {
     obja.innerHTML = xmlhttpd.responseText;
   }
 }
 xmlhttpd.send(null);


}

function showEsclusi(month, year, day, esame, operatore) {
  parent.processajax('show_table.php?mode=escludi&day='+day+'&month='+month+'&year='+year+'&tab_esame='+esame,'showtable','get');
  closetask ()
}

function enableEsclusi(month, year, day, esame, operatore) {
  parent.processajax('show_table.php?mode=enable&day='+day+'&month='+month+'&year='+year+'&tab_esame='+esame+'&operatore='+operatore,'showtable','get');
  closetask ()
}

function creaAvviso(month, year, day, esame, operatore) {
  var avviso=document.getElementById("avviso").value;
  if (avviso=='') processajax('errori.php?Id=avviso','nuovo','get');
  else {
  processajax('show_table.php?mode=ins_avviso&day='+day+'&month='+month+'&year='+year+'&testo='+avviso+'&tab_esame='+esame+'&operatore='+operatore,'showtable','get');
  }
  closetask ()
}

function creaNota(id) {
  var nota=document.getElementById("nota").value;	
  processajax('creanota.php?Id='+id+'&Nota='+nota,'nota','get');
}

function creaNotap(id) {
  var B = 'B';
  var nota=document.getElementById("nota").value;	
  processajax('creanota.php?Id='+id+'&nota='+nota+'&mode='+B,'nota','get');
}

function creaNotas(id) {
  var C = 'C';
  var nota=document.getElementById("nota").value;	
  processajax('creanota.php?Ids='+id+'&nota='+nota+'&mode='+C,'nota','get');
}

function modPre(mode, row, Id) {
  parent.processajax('azioni.php?mode='+mode+'&row='+row+'&Id='+Id,'azioni','get');
}

function salva(Id) {
  var data=document.getElementById("data").value;
  processajax('azioni.php?mode=cambia&Id='+Id+'&data='+data,'azioni','get');
}

function tab_cerca(month, year, tab) {
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
  var ddn = document.getElementById("1").value + '/' + document.getElementById("2").value + '/' + document.getElementById("3").value;
//  var ddn = document.getElementById("ddn").value;
  processajax('tab_cerca.php?nome='+nome+'&cognome='+cognome+'&tab_esame='+tab+'&ddn='+ddn,'tab_cerca','get');
}

function tab_modifica(month, year, tab) {
  var sex;
  if (document.getElementById("sessom").checked == true){
    sex = 'M';
  }
  else if (document.getElementById("sessof").checked == true){
   sex = 'F';
  }
  else {
   sex = 'X';
  }
  var ddn = document.getElementById("1").value + '/' + document.getElementById("2").value + '/' + document.getElementById("3").value;
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
//  var ddn = document.getElementById("ddn").value;
  var indirizzo = document.getElementById("indirizzo").value;
  var citta = document.getElementById("citta").value;
  var telefono = document.getElementById("telefono").value;
  var note = document.getElementById("note").value;
  var id = document.getElementById("id").value;
  processajax('tab_modifica.php?nome='+nome+'&cognome='+cognome+'&tab_esame='+tab+'&ddn='+ddn+'&sesso='+sex+'&id='+id+'&indirizzo='+indirizzo+'&citta='+citta+'&telefono='+telefono+'&note='+note,'tab_cerca','get');
}

function autocomplete (thevalue, e){
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
  theObject = document.getElementById("autocompletediv");
  theObject.style.visibility = "visible";
  theObject.style.width = "152px";
//  var posx = 0;
//  var posy = 0;
//  posx = (findPosX (document.getElementById("ddn")) + 1);
//  posy = (findPosY (document.getElementById("ddn")) + 23);
//  theObject.style.left = posx + "px";
//  theObject.style.top = posy + "px";
  var theextrachar = e.which;
  if ((theextrachar == undefined)||(theextrachar < 13 && theextrachar != 8)||(theextrachar >=14 && theextrachar < 32)){
    theextrachar = e.keyCode;
  }
  //The location we are loading the page into.
  var objID = "autocompletediv";
    //Take into account the backspace.
    if (theextrachar == 8){
//      if (thevalue.length == 1){
//        var serverPage = "autocomp.php";
//      } else {
//        var serverPage = "autocomp.php" + "?sstring=" + thevalue.substr (0, (thevalue.length -1))+'&nome='+nome+'&cognome='+cognome+'&aa='+theextrachar;
//      }
    } else {
      var serverPage = "autocomp.php" + "?sstring=" + thevalue + String.fromCharCode (theextrachar) +'&nome='+nome+'&cognome='+cognome;
    }
    var obj = document.getElementById(objID);
    xmlhttp.open("GET", serverPage);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        obj.innerHTML = xmlhttp.responseText;
      }
    }
    xmlhttp.send(null);
  }

function findPosX(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
    }
  } else if (obj.x){
    curleft += obj.x;
  }
  return curleft;
}

function findPosY(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  } else if (obj.y){
    curtop += obj.y;
  }
  return curtop;
}

function setvalue (nome, cognome, thevalue, idv, indirizzo, citta, telefono, operatore, data_op, operatore_mod, data_op_mod, note,sesso, d1, d2, d3){

  if (sesso == 'M'){
    document.getElementById("sessom").checked = true;
  }
  else if (sesso == 'F'){
    document.getElementById("sessof").checked = true;
  }
//  acObject = document.getElementById("autocompletediv");
//  acObject.style.visibility = "hidden";
//  acObject.style.height = "0px";
//  acObject.style.width = "0px";
  document.getElementById("nome").value = nome;
  document.getElementById("cognome").value = cognome;  
  document.getElementById("1").value = d1;
  document.getElementById("2").value = d2;
  document.getElementById("3").value = d3;
  document.getElementById("id").value = idv+' '+'['+operatore+' '+data_op+']';
  document.getElementById("indirizzo").value = indirizzo;
  document.getElementById("citta").value = citta;
  document.getElementById("telefono").value = telefono;
  document.getElementById("note").value = note;   
  document.getElementById("operatore_mod").value = idv+' '+'['+operatore_mod+' '+data_op_mod+']';
}

function showNota (e, idr, id){
  xmlhttp = createXmlHttpRequestObject();
  theObject = document.getElementById("shownota");
  theObject.style.visibility = "visible";
  theObject.style.height = "90px";
  theObject.style.width = "186px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY - 45;
  posx = e.clientX - 45;
  //posy = e.clientY + document.body.scrollTop - pos;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "shownota";
  var serverPage = "shownota.php?Id="+idr;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function showFile (e, id){
  xmlhttp = createXmlHttpRequestObject();
  theObject = document.getElementById("showfile");
  theObject.style.visibility = "visible";
  theObject.style.height = "270px";
  theObject.style.width = "400px";
  var posx = 0;
  var posy = 0;
//  posy = e.clientY;
  posx = e.clientX + 10;
  posy = e.clientY + document.body.scrollTop;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "showfile";
  var serverPage = "showfile.php?Id="+id;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}


function note_telea (e, id, prodotto){
  xmlhttp = createXmlHttpRequestObject();
//  xmlhttp = new XMLHttpRequest();

  winNote = document.getElementById("notatelea");
  winNote.style.visibility = "visible";
  winNote.style.height = "90px";
  winNote.style.width = "500px";
  var posx = 0;
  var posy = 0;
//  if (e.clientY < 250) posy = e.clientY
  posy = e.clientY;
  posx = e.clientX;
   posy = e.clientY + document.body.scrollTop;
  winNote.style.left = posx + "px";
  winNote.style.top = posy + "px";
  //The location we are loading the page into.
  var objID = "notatelea";
  var serverPage = "shownotatelea.php?Id="+id+"&Prodotto="+prodotto;
  var obj = document.getElementById(objID);
  xmlhttp.open("GET", serverPage);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      obj.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
}

function showMesi(mese, anno, esame) {
  processajax('mesi.php?mese='+mese+'&anno='+anno+'&esame='+esame,'nuovo','get');
  closetask ()
}

function List() {
  msg = '';
  for (var i = 0; i < List.arguments.length/2; i++)                     
    if (List.arguments[i] == '')                    
      msg = msg + 'MANCA '+List.arguments[i+List.arguments.length/2]+'\n';
  return msg;
}

function salvaRapportino(id) {
  var mode = 'ins';
  var int = document.getElementById("int").value;
  var note = document.getElementById("note").value;
  var mat = document.getElementById("mat").value;
  var orai = document.getElementById("orai").value;
  var oraf = document.getElementById("oraf").value;
  var pausai = document.getElementById("pausai").value;
  var pausaf = document.getElementById("pausaf").value;

  re = /^\d{2}:\d{2}?$/;
  if(!orai.match(re)) alert("ERRATO FORMATO ORA");

  var msg = List(int, orai, oraf, pausai, pausaf, 'Intervento', 'Ora inizio', 'Ora Fine', 'Inizio Pausa', 'Fine Pausa');
  if (msg != '')
    alert(List(int, orai, oraf, pausai, pausaf, 'Intervento', 'Ora inizio', 'Ora Fine', 'Inizio Pausa', 'Fine Pausa'));

  else{
  processajax('loadrapportino.php?Id='+id+'&int='+int+'&note='+note+'&mat='+mat+'&orai='+orai+'&oraf='+oraf+'&pausai='+pausai+'&pausaf='+pausaf+'&mode='+mode,'rapportino','get');
  }
}

function print_telea(id, anagrafica) {
  var winURL = "http://svr-intranet/ei/stampe/stampatelea.php?Id="+id+"&anagrafica="+anagrafica;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=700,height=400,left=150,top=100,scrollbars=yes,resizable=yes');
}

function print_rapportino(id) {
  var winURL = "http://svr-intranet/ei/stampe/stamparapportino.php?Id="+id;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=700,height=400,left=150,top=100,scrollbars=yes');
}

function PrintStampam(mese, anno, esame) {
  var winURL = "http://10.0.0.2/lab@genda/stampe/stampam.php?month="+mese+"&year="+anno+"&esame="+esame;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=700,height=400,left=150,top=100,scrollbars=yes');
}

//###########FUNZIONI GESTONE
function gestione_nuovocliente() {
  var winURL = "http://svr-intranet/ei/gestione/nuovocliente.php";
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=800,height=450,left=150,top=100,scrollbars=yes');
}
//###########FINE FUNZIONI GESTIONE

//###########FUNZIONI POPUP
function popup_telea(Id) {
  var winURL = "http://svr-intranet/ei/popup/popup_telea.php?Id="+Id;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=760,height=400,left=150,top=100,scrollbars=yes');
}

function popup_teleall(Id, Numt) {
  var winURL = "http://svr-intranet/ei/popup/popup_teleall.php?Id="+Id+"&Numt="+Numt;
  popWindow = window.open(winURL, 'popWindow', 'dependent,resizable=1,width=790,height=400,left=150,top=100,scrollbars=yes');
}

function popup_storico(Id, Anno) {
  var winURL = "http://svr-intranet/ei/popup/popup_storico.php?Id="+Id+"&Anno="+Anno;
  popWindow = window.open(winURL, 'popWindow', 'dependent,resizable=1,width=790,height=400,left=150,top=100,scrollbars=yes');
}

function popup_procedura(Id) {
  var pagina = Id + ".php";
  var winURL = "http://svr-intranet/ei/procedure/"+pagina+"?Id="+Id;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=790,height=600,left=150,top=100,scrollbars=yes');
}

function popup_mailt(id, anagrafica) {;
  var winURL = "http://svr-intranet/ei/stampe/mailt.php?Id="+id+"&anagrafica="+anagrafica;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=790,height=600,left=150,top=100,scrollbars=yes');
}

function popup_mailxsp(id) {;
  var winURL = "http://svr-intranet/ei/stampe/mailxsp.php?Id="+id;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=790,height=600,left=150,top=100,scrollbars=yes');
}

function popup_nuovoi(day, id) {
  var winURL = "http://svr-intranet/ei/popup/popup_nuovoi.php?Day="+day+"&Id="+id;
  popWindow = window.open(winURL, 'popWindow', 'dependent,width=700,height=400,left=150,top=100,scrollbars=yes');
}

function loadrapportino(id, data1, data2) {
  processajax('loadrapportino.php?Id='+id+"&data1="+data1+"&data2="+data2,'rapportino','get');
}
//###########FINE FUNZIONI POPUP

function formCliente(id) {
  processajax('formcliente.php?Id='+id,id,'get');
}

function Guida(arg) {
  if (arg == 'reset') {
    processajax('guida_reset.php','guida','get');
  }
  else if (arg == 'mesi') {
    processajax('guida_mese.php','guida','get');
  }
  else if (arg == 'cerca') {
    processajax('guida_cerca.php','guida','get');
  }
  else if (arg == 'anagrafica') {
    processajax('guida_anagrafica.php','guida','get');
  }
  else
  processajax('guida_show.php?Arg='+arg,'guida','get');
}

function Gestione(arg) {
  processajax('applicazioni.php?Arg='+arg,'gestione','get');
}

function GestioneNuovoU() {
  processajax('nuovou.php','gestione','get');
}

function checkLen(x,y){
  if (y.length==x.maxLength){
    var next=x.tabIndex;
    if (next<3){
      document.getElementById(next+1).focus();
    }
  }
}

function xspref(id, campo, idc) {
  var div = id+campo;
  processajax('referente.php?Id='+id+'&Field='+campo+'&Idc='+idc,div,'get');
}

function xspdatastor(link, id, idc) {
  if(link.innerText)
    {testovecchio=link.innerText}
  else
    {testovecchio=link.text}
  document.getElementById(id).innerHTML = "<input id='prova' type='text' value='"+testovecchio+"'><a href=\"javascript://\" onClick=\"siSto('"+id+"','"+idc+"')\"><img src=icone/si.png border=0 width=10 height=10></a><a href=\"javascript://\" onClick=\"noSto('"+id+"','"+idc+"','"+testovecchio+"')\"><img src=icone/no.png border=0 width=10 height=10></a>";
}

function xsptestostor(link, id, idc) {
  var div = id+'TESTO';
//  if(link.innerText)
//    {testovecchio=link.innerText}
//  else
//    {testovecchio=link.text} alert(testovecchio);
  testovecchio = link.innerHTML;
  testovecchioes =escape(link.innerHTML);
//  testovecchio = testovecchio.replace("\n", "%0A");alert('TESTOVECCHIO='+testovecchio);
  testovecchioa = testovecchio.replace("/<br>/g", "\n");
  testovecchioa = testovecchio.replace("%0A", "\n");alert('TESTOVECCHIOA='+testovecchioa);
  document.getElementById(div).innerHTML = "<TEXTAREA id='testosto'>"+testovecchio+"</TEXTAREA><a href=\"javascript://\" onClick=\"siTestoSto('"+id+"','"+idc+"')\"><img src=icone/si.png border=0 width=10 height=10></a><a href=\"javascript:void(null);\" onClick=\"noTestoSto(this,'"+id+"','"+idc+"','"+testovecchioes+"')\"><img src=icone/no.png border=0 width=10 height=10></a>";
}

function nuovotckt(id) {
  processajax('nuovotckt.php?Id='+id,'nuovotckt','get');
}

function xspnuovoprodotto(id) {
  processajax('nuovoprodotto.php?Id='+id,'nuovostorico','get');
}

function xspnuovostorico(id) {
  processajax('nuovostorico.php?Id='+id,'nuovostorico','get');
}

function xspdelref(id, idc) {
  processajax('referenti.php?Id='+idc+'&Idr='+id+'&Mode=del','showref','get');
}

function xspdelstorico(id, idc) {
  processajax('storico.php?Id='+idc+'&Idr='+id+'&Mode=del','storico','get');
}

function formRef(id, campo, idc){
  var val = document.getElementById("valore").value;
  processajax('referenti.php?Id='+idc+'&Field='+campo+'&Val='+val+'&Idr='+id,'showref','get');
}

function formNuovoRef(id){
  var nome = document.getElementById("nome").value;
  var cognome = document.getElementById("cognome").value;
  var email = document.getElementById("email").value;
  var telefono = document.getElementById("telefono").value;
  var cellulare = document.getElementById("cellulare").value;
  processajax('referenti.php?Id='+id+'&Nome='+nome+'&Cognome='+cognome+'&Email='+email+'&Telefono='+telefono+'&Cellulare='+cellulare+'&Mode=nuovo','showref','get');
}

function formNuovoPro(id){
  var sp = document.getElementById("sp").value;
  var patch = document.getElementById("patch").value;
  var login = document.getElementById("login").value;
  var idpro = document.getElementById("idpro");
  var aa = idpro.selectedIndex;
  var aaa = idpro.options[aa].value;alert(aa+' '+aaa);

//  var aa = idpro.options[indice].value;
  processajax('prodottixsp.php?Id='+id+'&Sp='+sp+'&Patch='+patch+'&Login='+login+'&Idpro='+aaa+'&Mode=nuovo','storico','get');
}

function formNuovoTckt(id){
  var desc = document.getElementById("desc").value;
  processajax('listatckt.php?Id='+id+'&Desc='+desc+'&Mode=nuovotckt','showtckt','get');
  document.getElementById('nuovotckt').innerHTML = "";
}

function showStorico(id) {
  processajax('storico.php?Id='+id,'storico','get');
}

function showProdotti(id) {
  processajax('prodottixsp.php?Id='+id,'storico','get');
}

function init_registra(){
  processajax('ofajax.php?mode=noins','registra','get');
}

function ofregistra(){
  var stringa = '';
  var date = '';
  var azienda = document.getElementById("azienda").value;
  var rif = document.getElementById("rif").value;
  var mail = document.getElementById("mail").value;
 
  var idgiorno = document.getElementById("giorno");
  var aa = idgiorno.selectedIndex;
  var aaa = idgiorno.options[aa].value;
  var idmese = document.getElementById("mese");
  var bb = idmese.selectedIndex;
  var bbb = idmese.options[bb].value;
  var idanno = document.getElementById("anno");
  var cc = idanno.selectedIndex;
  var ccc = idanno.options[cc].value;
  var data = ccc+'-'+bbb+'-'+aaa;
  for (var j=1; j<9; j++){
    if (document.getElementById("check-"+j).checked == true)
      stringa=stringa+j;
  }
//  if (stringa == '') alert("Selezionare almeno un prodotto");
//  else{
    processajax('ofajax.php?znd='+azienda+'&rf='+rif+'&ml='+mail+'&stringa='+stringa+'&date='+data+'&mode=ins','registra','get');
//  }
}

