// JavaScript Document

function async_art_det_old (id) {
	 
	
//	document.getElementById('div_tabella_catalogo').innerHTML = '<h2><img src="../img/pointer.jpg" alt="Fishing" />prodotti</h2><br /><p><img src="../img/loader_big.gif" alt="attendere" /></p>' ;

document.getElementById('popup_dettaglio_articolo').className = 'dettaglio_articolo_visibile';
document.getElementById('popup_dettaglio_articolo_frame').innerHTML = '<p><img src="../img/loader_big.gif" alt="attendere" /></p>' ;

var percorso = "async_dettaglio_articolo.asp?id=" + id 

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
 
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById('popup_dettaglio_articolo_frame').innerHTML=xmlhttp.responseText;
    }
  }
  
xmlhttp.open("GET",percorso,true);
xmlhttp.send();

	
	}

function async_art_det (id) {
	 
	
//	document.getElementById('div_tabella_catalogo').innerHTML = '<h2><img src="../img/pointer.jpg" alt="Fishing" />prodotti</h2><br /><p><img src="../img/loader_big.gif" alt="attendere" /></p>' ;

document.getElementById('popup_dettaglio_articolo').className = 'dettaglio_articolo_visibile';
document.getElementById('popup_dettaglio_articolo_frame').innerHTML = '<p><img src="../img/loader_big.gif" alt="attendere" /></p>' ;

var percorso = "dettaglio_articolo.asp?id=" + id 


    document.getElementById('popup_dettaglio_articolo_frame').src=percorso;

	
	}



function chiudi_popup_dettaglio_articolo() {
	document.getElementById('popup_dettaglio_articolo').className = 'dettaglio_articolo_hidden';
	
	}
	
	
	function async_ordina() {
var rest = -1; 
if (document.mod.qta.value == "") {
alert('Indicare una q.ta valida');
return false; }
else
	if (document.mod.qta.value == "") {
	alert('Indicare una q.ta valida');
	return false;	}
else
	if (document.mod.confezione.value == ""  || document.mod.confezione.value == 0 ) {
	document.mod.submit();
	return true;	}
else
	if (document.mod.confezione.value == document.mod.qta.value) {
	document.mod.submit();
	return true;}
else
	if (parseFloat(document.mod.confezione.value) > parseFloat(document.mod.qta.value)) {
	alert('Qta minima confezione : ' + document.mod.confezione.value );
	return false;}
	else
	rest = document.mod.qta.value % document.mod.confezione.value;
	if (rest == 0 ) {
	document.mod.submit();	}
	else
	alert('Qta minima confezione : ' + document.mod.confezione.value + ' o multipli ');
	return false;
	}

function async_articolo_carrello_add(articoloid) {
	//document.getElementById('popup_dettaglio_articolo').className = 'dettaglio_articolo_visibile';
//--document.getElementById('popup_dettaglio_articolo_frame').innerHTML = '<p><img src="../img/loader_big.gif" alt="attendere" /></p>' ;

var catalogo_tipologieid = document.getElementById('catalogo_tipologieid').value;
var confezione = document.getElementById('riga_articolo_confezione_' + articoloid).value;
var qta = document.getElementById('riga_articolo_' + articoloid).value;
var percorso = "async_carrelloins.asp?id=" + articoloid + "&qta=" +qta ; 
var vocicarrello = document.getElementById('lbl_voci_carrello').innerHTML;

if ((qta < confezione) && (catalogo_tipologieid ==1)) { alert('Questo articolo ha una confezione minima di ' + confezione + ' Pezzi');document.getElementById('riga_articolo_' + articoloid).value = confezione;return false;}


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
 
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {     document.getElementById('riga_immagine_articolo_' + articoloid).src='../img/icon_cart_ok.png';    
	incrementa_voci_carrello();}
  
  }
xmlhttp.open("GET",percorso,true);
xmlhttp.send();

	
	}
	
	function incrementa_voci_carrello() {
		var vocicarrello = document.getElementById('lbl_voci_carrello').innerHTML;
		if (vocicarrello=="") 
		{vocicarrello = 1;	
		}
		else
		if (isNaN(vocicarrello) )
		{vocicarrello =1;}
		else
		vocicarrello = eval(vocicarrello) +1;
		document.getElementById('lbl_voci_carrello').innerHTML = vocicarrello;
		
		}
