function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 element.style.display='';
 if (!element) {
  alert("Bad id " + id + "passed to clientSideInclude." + "You need a div or span element " + "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}
function controlloLogin(val, campo, newVal) {
	if (val=='') {
		document.forms['Form1'][campo].value=newVal;
	} 
	if (val=='Username') {
		document.forms['Form1'][campo].value=newVal;
	}
	if (val=='Password') {
		document.forms['Form1'][campo].value=newVal;
	}
}
function changeColor(target, val) {
    tg = target.name;
	splitTarget = tg.split("_");
	nTarget = splitTarget[1];
	riga = document.getElementById("riga_"+nTarget);
	if (val) {	
		riga.style.backgroundColor='#f0fcff';
	} else {
		riga.style.backgroundColor='';
	}
}
// COLORA ON ROLLOVER OGNI TR, COMPATIBILE CON IE
var righe = document.getElementsByTagName('tr');
for (var i = 0; i < righe.length; i++) {
righe[i].onmouseover = function() {
this.className += ' secondocolore';
}
righe[i].onmouseout = function() {
this.className = this.className.replace('secondocolore', '');
}
}
//-------------------------------------------------
//----------------- AJAX FUNCTIONS -----------------------------------
function xmlhttpPost(strURL) {
	obj_loading = document.getElementById("loading");
	obj_result = document.getElementById("result");
	obj_loading.innerHTML = '<img src="images/ajax-loader.gif" name="loader1" width="16" height="16" id="loader1">';
	obj_result.innerHTML = 'Caricamento in corso...'
    var xmlHttpReq = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

/*function getquerystring() {
    var result = document.forms['Form'];
	alert(result);
	var menu1 = form.menu1.value;
	var menu2 = form.menu2.value;
	var menu3 = form.menu3.value;
	
    qstr = 'menu1=' + escape(menu1)+'&menu2=' + escape(menu2)+'&menu3=' + escape(menu3);  // NOTARE bene che non viene messo '?' prima della querystring
    return qstr;
}*/

function updatepage(str){
    document.getElementById("result").innerHTML = str;
	document.getElementById("loading").innerHTML = '';
}
//--------------------------------------------------------------------
function actionForm(azione,richiesta){
	if (azione=='Elimina') {
		chiediConferma = confirm('Sei sicuro di volerlo eliminare definitivamente?'); 
		if (chiediConferma == true){
		checkFound = false;
		var theForm = document.forms['FormEdit'];
		for(z=0; z<theForm.length;z++){
    		if(theForm[z].type == 'checkbox'){
	  			if (theForm[z].checked) {
					checkFound = true;
					break;
				}
			}
	  	}
		if (checkFound) {
			document.forms['FormEdit'].azione.value = 'Elimina';
			document.forms['FormEdit'].action = "eliminaVeicolo.asp?type=" + richiesta;
			document.forms['FormEdit'].submit();
		} else {
			alert('Seleziona almeno un elemento da eliminare!');
		}
		}
	}
}
//----------------------------
function checkUncheckAll(theElement, action) {
	var theForm = document.forms['FormEdit'];
	for(z=0; z<theForm.length;z++){
    	if(theForm[z].type == 'checkbox' && action=='checkAll'){
	  		theForm[z].checked = 'checked';
	  	}
		
    	if(theForm[z].type == 'checkbox' && action=='uncheckAll'){
	  		theForm[z].checked = '';
	  	}
    }
}
//----------------------------
