
function myvoid() {}

function popup(url,wname,opzioni) {
	if (opzioni.length==0) {
		opzioni='resizable=no,width=500,height=500,scrollbars=no,status=no';
	}
	if (wname.length==0) wname='zoom';
	wpopup=window.open(url,wname,opzioni);
	wpopup.opener=self;
	wpopup.focus();
}

function confirmOrder(){
	if(document.getElementById("carrello").innerHTML != ""){
		if (confirm("Si desidera stampare l' ordine prima di procedere  ?")) window.print();  
		if (confirm("Conferma ordine ?")) {
			document.getElementById('loading').style.display='block';
			var basket = new Basket();
			var noteOrdine = escape(document.getElementById('noteordine').value);
			var url="/ecommerce.php?command=Ecommerce-confermaOrdine&tpl=raw&noteordine="+noteOrdine;
			var contentRetriever = new ContentRetriever(url);
			contentRetriever.attach(basket);
			contentRetriever.getContent();
		}
	}else{
		alert("Nessun prodotto presente nel carrello!");
	}
}

function anteprimaNote(){
    contenuto_testo=document.getElementById("noteordine").value;
    contenuto_testo=contenuto_testo.replace(/\n/g,"<br/>");
    document.getElementById("totNoteOrdine").innerHTML=contenuto_testo;
}

function destDivOrder(conto){

   var noteOrdine = escape(document.getElementById('noteordine').value);
   var url="/ecommerce.php?command=Ecommerce-ricercaDestDiv&tpl=ecommerceDestDiv&label=CARRELLO&conto="+conto+"&noteordine="+noteOrdine;
   popup(url,'wclientedd','')
}

function delDestDivOrder(conto){

   var noteOrdine = escape(document.getElementById('noteordine').value);
  window.location="/ecommerce.php?command=Ecommerce-gestioneCarrello&destdiv=CANCEL&label=CARRELLO&noteordine="+noteOrdine;
} 

function goToPage(page){
	window.location = page;
}

function ricercaColori(){
	if(document.formRicercatc.codicetc.value != ""){
		document.formRicercatc.codicetc.value = document.formRicercatc.codicetc.value.toUpperCase();
//		alert("ricercaColori: |"+document.getElementById('coloriDisponibili').innerHTML+"|");
		if(document.formRicercatc.hiddencodicetc.value == document.formRicercatc.codicetc.value && document.getElementById('coloriDisponibili').innerHTML != ""){
			var ar_codvar1_selected = false;
			for (var i=1; i < 100; i++){	
				if(document.formRicercatc["ar_codvar1_"+i] != undefined){			
					if(document.formRicercatc["ar_codvar1_"+i].checked){
						ar_codvar1_selected = true;					
					}
				}
			}
			if(ar_codvar1_selected == true || document.getElementById('coloriDisponibili').innerHTML == "Caricamento in corso..."){		
				document.formRicercatc.submit();		
			}else{
				alert("Selezionare almeno un colore valido!");						
			}
		}else{
			/*
			Codice da decommentare nel caso ci siano + marche
			for (var i=0; i < document.formRicercatc.marcatc.length; i++){
				if (document.formRicercatc.marcatc[i].checked){
					var marca = document.formRicercatc.marcatc[i].value;
				}
			}
			*/
			var marca = 0;
			document.formRicercatc.hiddencodicetc.value = document.formRicercatc.codicetc.value;			
			codice = document.formRicercatc.codicetc.value;
			showTC(marca,document.formRicercatc.codicetc.value);
		}
	}else{
		alert("Inserire un codice root valido!");		
	}
}

function azzeracampiTC(){
	document.formRicercatc.hiddencodicetc.value="";
	document.formRicercatc.codicetc.value="";	
	document.formRicercatc.codicetc.readOnly = false;
	document.getElementById('coloriDisponibili').innerHTML="";
}
function selezionatutti(){
	for (var i=1; i < 100; i++){	
		if(document.formRicercatc["ar_codvar1_"+i] != undefined){			
			document.formRicercatc["ar_codvar1_"+i].checked = true
		}
	}
}
function deselezionatutti(){
	for (var i=1; i < 100; i++){	
		if(document.formRicercatc["ar_codvar1_"+i] != undefined){			
			document.formRicercatc["ar_codvar1_"+i].checked = false
		}
	}
}
