function popUp(url,w,h) {
	winname ='';
	if (w == '') w = '300';
	if (h == '') h = '300';
	opts = 'scrollbars=yes,resizable=yes,width='+w+',height='+h+'';
	window.open(url,winname,opts);

}
function notelegali(){
	return popUp('notelegali.htm', '400', '500');

}
function privacy(){
	return popUp('privacy.htm', '400', '500');
}
function finpop(id,idcat,idimg) {
	var pagina="finpop.php?id="+id+"&idcat="+idcat+"&idimg="+idimg;
	fin=window.open(pagina,"","scrollbars=yes,width=500,height=500");
	fin.document.close();
}
/*
function costoPagamento_null(d){
	d.getElementById('null').className='hidden';
	d.getElementById('div-1mese').className='hidden';
	d.getElementById('div-6mesi').className='hidden';
	d.getElementById('div-12mesi').className='hidden';
}

function costoPagamento(val,d){
	costoPagamento_null(d);
	if (val != ""){
	d.getElementById('div-'+val).className='visible';
	}
}
*/
function statoValoreAz(d){
	d.getElementById('tr-azienda').className='visible voce'; /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('tr-piva').className='visible voce'; /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('az').className='visible campo';  /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('tr-nome').className='hidden voce';  /*NASCONDE IL MENU PRIVATO*/
	d.getElementById('tr-cognome').className='hidden voce';  /*NASCONDE IL MENU PRIVATO*/
	d.getElementById('pr').className='hidden campo';  /*NASCONDE IL MENU PRIVATO*/
}
function statoValorePr(d){
	d.getElementById('tr-nome').className='visible voce'; /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('tr-cognome').className='visible voce'; /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('pr').className='visible campo';  /*VISUALIZZA IL MENU AZIENDA*/
	d.getElementById('tr-azienda').className='hidden voce';  /*NASCONDE IL MENU PRIVATO*/
	d.getElementById('tr-piva').className='hidden voce';  /*NASCONDE IL MENU PRIVATO*/
	d.getElementById('az').className='hidden campo';  /*NASCONDE IL MENU PRIVATO*/
}

/*function costoAbbonamento(periodo,cliente,combinazioni){
	if (cliente == 1)
		prezzo = 0.16;
	if (cliente == 2)
		prezzo = 1;
	var tot = (periodo*prezzo)*combinazioni;
	document.getElementById('totale').innerHTML = tot;
}
*/
function getPeriodo (p) {
	if ('mese'==p) var res = 1;
	else if ('semestre'==p) var res = 6;
	else if ('anno'==p) var res = 12;
	else return false;
	return res;
}

function selRadio(div){
	if (!div) return false;
	var p = document.getElementById(div).getElementsByTagName('input');
	for (i=0;i<p.length;i++){
		if ((p[i].type == 'radio') && (p[i].checked == true)) {
			var txt = p[i].value;
		}
	}
	return txt;
}
function totSpesa(comb){
	var periodo = selRadio()
	alert (periodo)
	var tot = comb*periodo;
	//document.getElementById('totale').innerHTML = tot;
}
function calcola() {
	var per = selRadio('calc-periodo');
	var cli = selRadio('calc-cliente');
	var estrazioni = parseInt(document.getElementById('estrazioni').value,10);
	costo = parseFloat(document.getElementById('prezzo-'+cli).value);
	if (cli==1 || cli==3) var comb = parseInt(document.getElementById('pr').value,10);
	else if (cli==2) var comb = parseInt(document.getElementById('az').value,10);
	var res = ((parseInt(getPeriodo(per),10)) * estrazioni * comb * costo);
//	alert ('periodo: '+per+'; tipo cliente: '+cli+'; estrazioni: '+estrazioni+'; combinazioni: '+comb+'; mesi: '+parseInt(getPeriodo(per),10)+'; risultato: '+res);
	returnTotal (res);
}
function returnTotal (tot) {
	if(isNaN(tot)) return false;
/*	var int = parseInt(tot,10);
	var float = parseInt((parseFloat(tot) - int) * 100,10);
	var price = int+','+float.toFixed(2)+' Euro';
*/
	var price = tot.toFixed(2)+' Euro IVA inclusa';
	var d = document.getElementById('calc-totale').firstChild;
	if (d)
		d.nodeValue = price;
	else
		document.getElementById('calc-totale').innerHTML = price;
}

