
function mostraNascondi(){
   	var bottone = document.getElementById('mostra');
	var dettaglio = document.getElementById('dettaglio');
	
	if (bottone.value == "<<"){
		bottone.value = ">>";
		dettaglio.style.display = "none";
	}
	else{
		bottone.value = "<<";
		dettaglio.style.display="";
	}	
}

function IsNumeric(sText){
	var regexpression=new RegExp('^([1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|\.[0-9]{1,2})$');
	return sText.match(regexpression);
   }



function aggiornaCarrello(num){
	
	if (!num)
		return;
	
	arr = document.getElementsByTagName('input');
	
	for (i=0; i<arr.length; i++){
		if(arr[i].id[0] == 'q' && arr[i].id[1] == 't' && arr[i].id[2] == 'y' ){
			if (!IsNumeric(arr[i].value)){
				alert("La quantita' inserita non e' corretta!");
				arr[i].focus();	
				return;
			}
		}
	}
			
	document.getElementById('crtAggiornaJava').value = "1";
	document.getElementById('f1').submit();
}

function changeQty(e){
	
	var keynum;
	var keychar;
	var numcheck;
	
	keynum = (e.which) ? e.which : e.keyCode;
	
	
	if (keynum == 13){
		aggiornaCarrello(1);
	}
}

function procediOrdine(num){
	if (num==0){
		alert("Il carrello non contiene prodotti");
		return false;
	}
	
	return true;
}

function salvaOrdine(numProd){
	
	if (numProd==0){
		alert("Il carrello non contiene prodotti");
		return false;
	}
		
	
	var datSped = new Array();
	var datSpedNonValidi = new Array();
	
	datSped[0]=document.getElementById('spsDati0');
	datSped[1]=document.getElementById('spsDati1');
	datSped[2]=document.getElementById('spsDati2');
	datSped[3]=document.getElementById('spsDati3');
	datSped[4]=document.getElementById('spsDati4');
	datSped[5]=document.getElementById('spsDati5');
	
	count = 0
	for (i=0; i<datSped.length; i++)
		if (datSped[i].value == "")
			datSpedNonValidi[count++] = datSped[i] ;
		
	if (datSpedNonValidi.length != datSped.length && datSpedNonValidi.length != 0){
		datSpedNonValidi[0].focus();
		alert("Valore non valido");
		return false;
	}
	
	
	if (document.getElementById('spsTipoPagamento').value ==0 )	{
		alert("Tipo di pagamento non valido");
		document.getElementById('spsTipoPagamento').focus();
		return false;
	}
	
	
	
	if (document.getElementById('frmtrattDati1').checked == false){
		if (confirm("Acconsenti trattamento dati?")){
			document.getElementById('frmtrattDati1').checked=true;
			return true;
		}
		else
			return false;
	}
			

	return true;
}

function mostraCarrello(){}

function aggiungiCarrello(id){
	document.getElementById('id').value = id;
	return true;
}


function mostraFullOrdini(){
	var extra = document.getElementById('extra');
	var cont = document.getElementById('content');
	var briciola = document.getElementById('briciola');
	
	extra.style.display = "none";
	cont.style.marginRight = "0px";
	briciola.style.display = "none";	
}

function mostraFattura(url,id){
        window.open(url + id, "_blank", "",true);
}

function svuotaCarrello(){
	return confirm('Si sta per svuotare il carrello.\ncontinuare?')
}