function select_prodotti_popup(campo) {
  window.open("elenco_prodotti_popup.php?strCampo="+campo,"Prodotti","width=710,height=540,scrollbars=yes,resizable=yes");
  return false;
}
function select_clienti_popup() {
  window.open("elenco_clienti_popup.php","Clienti","width=710,height=540,scrollbars=yes,resizable=yes");
  return false;
}

function seleziona(campo,idprodotto) {
  if (eval("window.opener.document.form_prodotti."+campo+".value")=="||") {
    eval("window.opener.document.form_prodotti."+campo+".value='|"+idprodotto+"|'");
  } else {
    eval("window.opener.document.form_prodotti."+campo+".value=window.opener.document.form_prodotti."+campo+".value+'"+idprodotto+"|'");
  }
  //alert(eval("window.opener.document.form_prodotti."+campo+".value"));
  self.close();
}

function mostra(id){
			if (document.getElementById) 
				  document.getElementById(id).style.display='inline';/* cambiare block con inline a seconda dell'elemento da mostrare */
			else if (document.all)
				  document.all[id].style.display='inline';
			else if (document.layers)
				  document.layers[id].display='inline';
			else
				alert("Browser incompatibile!");
}

function nascondi(id){
			if (document.getElementById) 
				  document.getElementById(id).style.display='none';/* cambiare block con inline a seconda dell'elemento da mostrare */
			else if (document.all)
				  document.all[id].style.display='none';
			else if (document.layers)
				  document.layers[id].display='none';
			else
				alert("Browser incompatibile!");
}

function seleziona_tipologia(id) {
   if (document.getElementById) 
				  tendina = document.getElementById(id);
			else if (document.all)
				  tendina = document.all[id];
			else if (document.layers)
				  tendina =  document.layers[id];
			else
				alert("Browser incompatibile!");
   nascondi_tutti_prodotti();
   mostra("idprodotto["+tendina.options[tendina.selectedIndex].value+"]");
}

/*
 * Funzione che crea un array con puntatori agli elementi della pagina con attributo class uguale al parametro strClassName passato.
*/
function getElementByClassName(strClassName){ 
	elem=new Array();
	var inc=0;
	var alltags=document.all? document.all : document.getElementsByTagName("*");
	for (i=0; i<alltags.length; i++){
		if (alltags[i].className==strClassName) 
			elem[inc++]=alltags[i];
	}
	return elem;
}

/*
 * Funzione che crea un array con puntatori agli elementi della pagina con attributo class uguale al parametro strClassName passato.
*/
function VerificaProdottiAggiunti(){ 
	elem=getElementByClassName('qnt');
	for (i=0; i<elem.length; i++){
		if (elem[i].value!='') 
			return confirm('Ci sono prodotti selezionati per essere aggiunti al carrello, vuoi cambiare pagina e perdere la selezione?');
	}
	return true;
}
