function search(){

	if (document.ricerca.idmarca.value=="") {
	
		alert("Selezionare la marca di una stampante");
		return false;
	}
	
	if (document.ricerca.idmodello.value=="") {
	
		alert("Selezionare il modello della stampante");
		return false;
	}

	document.ricerca.submit()
}


function apri(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "";
}

function chiudi(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "none";
}


function toolsLinksSnapSection(section,numerotag) 
{
	
	toolsLinksUnselectText();	
	if (toolsLinksIsAlreadyOpen(section)) 
	{
		toolsLinksClose(section);
	}	
	else
	{
		
		for (i=0; i<numerotag; i++) { 
			toolsLinksClose("marca"+i);
		}
		
		toolsLinksOpen(section);

	}
}

function toolsLinksOpen(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "";
}

function toolsLinksClose(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "none";
}

function toolsLinksIsAlreadyOpen(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return 0;
	return (tbody.style.display == "");
}

function toolsLinksUnselectText()
{
	try { document.getSelection().empty() } catch(e) {};
	try { document.selection.empty() } catch(e) {};
	try { window.getSelection().empty() } catch(e) {};
}




/* parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/

function inscarrello(pagina,responsediv){

 
	 url  = pagina +"&rand="+escape(Math.random())
	 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.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage1(self.xmlHttpReq.responseText,responsediv);
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage1('<img src="images/preload4.gif">',responsediv);

		}
    }
     self.xmlHttpReq.open('GET', url, true);
    self.xmlHttpReq.send(null);
}




/* parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/

function Richiesta(pagina,responsediv){

 
	 url  = pagina +"&rand="+escape(Math.random())
	 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.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage1(self.xmlHttpReq.responseText,responsediv);
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage1('<img src="images/preload4.gif">',responsediv);

		}
    }
     self.xmlHttpReq.open('GET', url, true);
    self.xmlHttpReq.send(null);
}


/* parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/

function Richiesta1(pagina,responsediv1){

 
	 url  = pagina +"&rand="+escape(Math.random())
	 var xmlHttpReq1 = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq1 = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq1.onreadystatechange = function() {
        if (self.xmlHttpReq1.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage(self.xmlHttpReq1.responseText,responsediv1);
            
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage('<img src="images/preload4.gif">',responsediv1);

		}
    }
     self.xmlHttpReq1.open('GET', url, true);
    self.xmlHttpReq1.send(null);
}

/* FINE parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/





function updatepage(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}







function updatepage1(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}




