
function adatta()  {
	window.status = "";
	document.calc.ultimo.value = document.calc.primo.value;
	document.calc.meseu.value = document.calc.mesep.value;
}

function resetpr()  {
	window.status = "";
	document.calc.result.value = "";
	document.calc.dec.value = "";
	document.calc.spec.value = "";
}

function reset()  {
	
	window.status = "";	
	document.calc.primo.value = 1;
	document.calc.mesep.value = "dicembre";
	document.calc.ultimo.value = 1;
	document.calc.meseu.value = "dicembre";
	document.calc.eta.value = "adulti";
	document.calc.result.value = "";
	document.calc.spec.value = "";
	document.calc.tipo.value = "San Martino";
	
}



function rolle() {

	var primo = document.calc.primo.value;
	var mesep = document.calc.mesep.value;
	var ultimo = document.calc.ultimo.value;
	var meseu = document.calc.meseu.value;
	var eta = document.calc.eta.value;

//---------CONVERSIONE MESI e ETA'----------------
   if (mesep == 'dicembre') {
   	 var monthf = 0; }
   if (mesep == 'gennaio') {
    var monthf = 1; }
   if (mesep == 'febbraio') {
    var monthf = 2; }
   if (mesep == 'marzo') {
    var monthf = 3; }
   if (mesep == 'aprile') {
    var monthf = 4; }

   if (meseu == 'dicembre') {
   	 var monthl = 0; }
   if (meseu == 'gennaio') {
    var monthl = 1; }
   if (meseu == 'febbraio') {
    var monthl = 2; }
   if (meseu == 'marzo') {
    var monthl = 3; }
   if (meseu == 'aprile') {
    var monthl = 4; }


   if (eta == "adulti") {
	   var anni = 0   	}
   if (eta == "bambini")   {
	   var anni = 1  	}
   if (eta == "seniores")  { 
	   var anni = 2         }


//---------- DEFINIZIONE GIORNI DI PERMANENZA ------
    if (monthf == monthl) {	
	giorni = (ultimo - primo + 1);
	}

    if (((monthl == 1) && (monthf == 0)) || 
		 ((monthl == 2) && (monthf == 1)) || 
		 ((monthl == 4) && (monthf == 3))) {
	giorni = (ultimo - primo + 32);
	}

    if ((monthl == 3) && (monthf == 2)) {
	giorni = (ultimo - primo + 30);
	}


//------------- ETICHETTE ------------------------
	label1 = "Prezzo skipass giornaliero - Passo Rolle"


//------------- ALERT INPUT ----------------------

   if (giorni > 1)  {
	alert('La tariffa Passo Rolle è applicabile solo ai biglietti giornalieri.');
	document.calc.result.value = "";
	document.calc.dec.value = "";
	document.calc.spec.value = "";
   return;
	}

   if ((monthl != monthf) && ((monthl - monthf) != 1)) {
	alert('           Attenzione ! \nControllare i mesi selezionati');
   return;
	}

   if ((monthl == monthf) && ((ultimo * 10) < (primo * 10)))  {
	alert('           Attenzione ! \nControllare i giorni selezionati');
	return;
   }

	if (((monthf == 2) && (primo > 29)) ||
		((monthl == 2) && (ultimo > 29))) {
	alert('Attenzione ! \nI giorni di febbraio devono essere inferiori o uguali a 29!');
	return;
	}

	if (((monthf == 4) && (primo > 6)) ||
		((monthl == 4) && (ultimo > 6))) {
	alert('           Attenzione ! \nFine stagione 6 aprile 2008');
	return
	}

	if (giorni > 28)  {
   alert('Periodo troppo lungo per il plurigiornaliero.  Verificare i prezzi degli skipass stagionali');
	return;
	}


//---------- PREZZI GIORNALIERI -------------

     if ((giorni == 1) && (anni == 0) && 
	(monthf == 0) && (primo <= 22))  {
	document.calc.result.value = "25";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}

     if ((giorni == 1) && (anni == 1) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "18";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}

    if ((giorni == 1) && (anni == 2) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "23";
	document.calc.dec.value = "50";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 0)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "25";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 1)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "18";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 2)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "23";
	document.calc.dec.value = "50";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 0)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "27";
	document.calc.dec.value = "50";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 1)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "20";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}

    if (((giorni == 1) && (anni == 2)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "25";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1
	return;
	}
}


function sm() {

	var primo = document.calc.primo.value;
	var mesep = document.calc.mesep.value;
	var ultimo = document.calc.ultimo.value;
	var meseu = document.calc.meseu.value;
	var eta = document.calc.eta.value;

//------------- COEFFICIENTI DI CALCOLO F/O ---------
	c_pre_a = (186 / 7) * 0.8;
	c_bas_a = (186 / 7) * 0.88;
	c_alt_a = (186 / 7);

	c = 0.0001

//------------- SCONTI ETA'--------------------------
	et_a = 1
	et_j = 0.7
	et_s = 0.9

//------------- PERCENTUALI PER GIORNI DI PERMANENZA  F/O ---------
	var perc = [0,1.24,1.23,1.2,1.15,1.1,1,0.98,0.96,0.94,0.92,0.9,0.88,0.86,0.84,0.82,0.8,0.79,0.78,0.77,0.76,0.75,0.74,0.73,0.72,0.71,0.70,0.69];



//---------CONVERSIONE MESI e ETA'----------------
   if (mesep == 'dicembre') {
   	 var monthf = 0; }
   if (mesep == 'gennaio') {
    var monthf = 1; }
   if (mesep == 'febbraio') {
    var monthf = 2; }
   if (mesep == 'marzo') {
    var monthf = 3; }
   if (mesep == 'aprile') {
    var monthf = 4; }

   if (meseu == 'dicembre') {
   	 var monthl = 0; }
   if (meseu == 'gennaio') {
    var monthl = 1; }
   if (meseu == 'febbraio') {
    var monthl = 2; }
   if (meseu == 'marzo') {
    var monthl = 3; }
   if (meseu == 'aprile') {
    var monthl = 4; }


   if (eta == "adulti") {
	   var anni = 0   	}
   if (eta == "bambini")   {
	   var anni = 1  	}
   if (eta == "seniores")  { 
	   var anni = 2         }


//---------- DEFINIZIONE GIORNI DI PERMANENZA ------
    if (monthf == monthl) {	
	giorni = (ultimo - primo + 1);
	}

    if (((monthl == 1) && (monthf == 0)) || 
		 ((monthl == 2) && (monthf == 1)) || 
		 ((monthl == 4) && (monthf == 3))) {
	giorni = (ultimo - primo + 32);
	}

    if ((monthl == 3) && (monthf == 2)) {
	giorni = (ultimo - primo + 30);
	}

//------------- ETICHETTE ------------------------
	label1 = "Prezzo skipass giornaliero San Martino / Passo Rolle"
	label2 = "Prezzo skipass San Martino / Passo Rolle - validità " + giorni + " giorni"



//------------- ALERT INPUT ----------------------
   if ((monthl != monthf) && ((monthl - monthf) != 1)) {
	alert('           Attenzione ! \nControllare i mesi selezionati');
   return;
	}

   if ((monthl == monthf) && ((ultimo * 10) < (primo * 10)))  {
	alert('           Attenzione ! \nControllare i giorni selezionati');
	return;
   }

	if (((monthf == 2) && (primo > 29)) ||
		((monthl == 2) && (ultimo > 29))) {
	alert('Attenzione ! \nI giorni di febbraio devono essere inferiori o uguali a 29!');
	return;
	}

	if (((monthf == 4) && (primo > 6)) ||
		((monthl == 4) && (ultimo > 6))) {
	alert('           Attenzione ! \nFine stagione 6 aprile 2008');
	return
	}

	if (giorni > 28)  {
   alert('Periodo troppo lungo per il plurigiornaliero.  Verificare i prezzi degli skipass stagionali');
	return;
	}


//---------- PREZZI GIORNALIERI -------------

     if ((giorni == 1) && (anni == 0) && 
	(monthf == 0) && (primo <= 22))  {
	document.calc.result.value = "29";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}


     if ((giorni == 1) && (anni == 1) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "21";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if ((giorni == 1) && (anni == 2) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "26";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 0)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "30";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 1)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "22";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 2)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "28";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 0)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "33";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 1)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "24";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 2)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "30";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}


//---------- DEFINIZIONE DOPPIE STAGIONI -------------
    if ((monthf == 0) && (primo < 23) && (monthl == 1) && (ultimo >= 6))  {
	var alta = 14;
	var pre = 23 - primo;
	var bassa = giorni - (alta + pre);
	return salti();    }
	
    if (((monthf == 0) && (primo < 23) && (monthl == 0) && (ultimo >= 23)) ||
	((monthf == 0) && (primo < 23) && (monthl == 1) && (ultimo <= 5)))  {
	var pre = 23 - primo;
	var alta = giorni - pre;
	var bassa = 0;
	return salti();    }

    if (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo >= 6)) || 
	((monthf == 1) && (primo < 6) && (monthl == 1) && (ultimo >= 6)))  {
	var bassa = ultimo - 5;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

    if ((monthf == 1) && (primo <= 5) && (monthl == 2) && (ultimo <= 2))  {
	var alta = 6 - primo;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }

    if (((monthf == 1) && (primo <= 5) && (monthl == 2) && (ultimo >= 3)))    {
	var bassa = 28;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

   if (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo >= 3)) ||
       ((monthf == 2) && (primo <= 2) && (monthl == 2) && (ultimo >= 3)))  {
	var alta = ultimo - 2;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }

   if (((monthf == 3) && (primo <= 24) && (monthl == 3) && (ultimo >= 25)) || 
	((monthf == 2) && (monthl == 3) && (ultimo >= 25)))  {
	var bassa = ultimo - 24;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

   if ((monthf == 3) && (primo <= 24) && (monthl == 4))  {
	var alta = 25 - primo;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }



//---------- CALCOLO PREZZI IN STAGIONE -----------
	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 0))) {
 var res = Math.round(c_pre_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 1))) {
 var res = Math.round(c_pre_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 2))) {
 var res = Math.round(c_pre_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 0)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 0)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 0)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 0)))  {
 var res = Math.round(c_alt_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 1)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 1)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 1)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 1)))  {
 var res = Math.round(c_alt_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 2)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 2)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 2)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 2)))  {
 var res = Math.round(c_alt_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 0)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 0)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 0)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 0)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 0)))  {
 var res = Math.round(c_bas_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 1)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 1)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 1)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 1)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 1)))  {
 var res = Math.round(c_bas_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 2)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 2)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 2)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 2)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 2)))  {
 var res = Math.round(c_bas_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

function salti()  {


//----------- CALCOLO PREZZO SALTI STAGIONI --------
   
   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 0))  {
	var res = Math.round((Math.round((c_pre_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}
   	
   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 1))  {
	var res = Math.round((Math.round((c_pre_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}

   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 2))  {
	var res = Math.round((Math.round((c_pre_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}
}
//-------FINE CALCOLO PREZZO DOPPIE STAGIONI -------

	return conv();
}



function superski() {

	var primo = document.calc.primo.value;
	var mesep = document.calc.mesep.value;
	var ultimo = document.calc.ultimo.value;
	var meseu = document.calc.meseu.value;
	var eta = document.calc.eta.value;

//------------- COEFFICIENTI DI CALCOLO ---------
	c_pre_a = (222 / 7) * 0.8;
	c_bas_a = (222 / 7) * 0.88;
	c_alt_a = (222 / 7);

	c = 0.0001


//------------- SCONTI ETA'--------------------------
	et_a = 1
	et_j = 0.7
	et_s = 0.9

//------------- PERCENTUALI PER GIORNI DI PERMANENZA ---------
	var perc = [0,1.24,1.23,1.2,1.15,1.1,1,0.98,0.96,0.94,0.92,0.9,0.88,0.86,0.84,0.82,0.8,0.79,0.78,0.77,0.76,0.75,0.74,0.73,0.72,0.71,0.70,0.69];



//---------CONVERSIONE MESI e ETA'----------------
   if (mesep == 'dicembre') {
   	 var monthf = 0; }
   if (mesep == 'gennaio') {
    var monthf = 1; }
   if (mesep == 'febbraio') {
    var monthf = 2; }
   if (mesep == 'marzo') {
    var monthf = 3; }
   if (mesep == 'aprile') {
    var monthf = 4; }

   if (meseu == 'dicembre') {
   	 var monthl = 0; }
   if (meseu == 'gennaio') {
    var monthl = 1; }
   if (meseu == 'febbraio') {
    var monthl = 2; }
   if (meseu == 'marzo') {
    var monthl = 3; }
   if (meseu == 'aprile') {
    var monthl = 4; }


   if (eta == "adulti") {
	   var anni = 0   	}
   if (eta == "bambini")   {
	   var anni = 1  	}
   if (eta == "seniores")  { 
	   var anni = 2         }


//---------- DEFINIZIONE GIORNI DI PERMANENZA ------
    if (monthf == monthl) {	
	giorni = (ultimo - primo + 1);
	}

    if (((monthl == 1) && (monthf == 0)) || 
		 ((monthl == 2) && (monthf == 1)) || 
		 ((monthl == 4) && (monthf == 3))) {
	giorni = (ultimo - primo + 32);
	}

    if ((monthl == 3) && (monthf == 2)) {
	giorni = (ultimo - primo + 30);
	}


//------------- ETICHETTE ------------------------
	label1 = "Prezzo skipass giornaliero - Dolomiti Superski"
	label2 = "Prezzo skipass Dolomiti Superski - validità " + giorni + " giorni"



//------------- ALERT INPUT ----------------------
   if ((monthl != monthf) && ((monthl - monthf) != 1)) {
	alert('           Attenzione ! \nControllare i mesi selezionati');
   return;
	}

   if ((monthl == monthf) && ((ultimo * 10) < (primo * 10)))  {
	alert('           Attenzione ! \nControllare i giorni selezionati');
	return;
   }

	if (((monthf == 2) && (primo > 29)) ||
		((monthl == 2) && (ultimo > 29))) {
	alert('Attenzione ! \nI giorni di febbraio devono essere inferiori o uguali a 29!');
	return;
	}

	if (((monthf == 4) && (primo > 6)) ||
		((monthl == 4) && (ultimo > 6))) {
	alert('           Attenzione ! \nFine stagione 6 aprile 2008');
	return
	}

	if (giorni > 28)  {
   alert('Periodo troppo lungo per il plurigiornaliero.  Verificare i prezzi degli skipass stagionali');
	return;
	}


//---------- PREZZI GIORNALIERI -------------

     if ((giorni == 1) && (anni == 0) && 
	(monthf == 0) && (primo <= 22))  {
	document.calc.result.value = "34";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

     if ((giorni == 1) && (anni == 1) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "24";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if ((giorni == 1) && (anni == 2) && 
	(monthf == 0) && (primo <= 22)) {
	document.calc.result.value = "31";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 0)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "37";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 1)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "26";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 2)) &&
	(((monthf == 1) && (primo >= 6)) || ((monthf == 2) && (primo <= 2)) || ((monthf == 3) && (primo >= 25)) || (monthf == 4)))  {
	document.calc.result.value = "33";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 0)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "42";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 1)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "29";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}

    if (((giorni == 1) && (anni == 2)) && 
	(((monthf == 0) && (primo >= 23)) || ((monthf == 1) && (primo <= 5)) || 
	 ((monthf == 2) && (primo >= 3)) || ((monthf == 3) && (primo <= 24))))  {
	document.calc.result.value = "38";
	document.calc.dec.value = "00";
	document.calc.spec.value = label1;
	return;
	}


//---------- DEFINIZIONE DOPPIE STAGIONI -------------
    if ((monthf == 0) && (primo < 23) && (monthl == 1) && (ultimo >= 6))  {
	var alta = 14;
	var pre = 23 - primo;
	var bassa = giorni - (alta + pre);
	return salti();    }
	
    if (((monthf == 0) && (primo < 23) && (monthl == 0) && (ultimo >= 23)) ||
	((monthf == 0) && (primo < 23) && (monthl == 1) && (ultimo <= 5)))  {
	var pre = 23 - primo;
	var alta = giorni - pre;
	var bassa = 0;
	return salti();    }

    if (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo >= 6)) || 
	((monthf == 1) && (primo < 6) && (monthl == 1) && (ultimo >= 6)))  {
	var bassa = ultimo - 5;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

    if ((monthf == 1) && (primo <= 5) && (monthl == 2) && (ultimo <= 2))  {
	var alta = 6 - primo;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }

    if (((monthf == 1) && (primo <= 5) && (monthl == 2) && (ultimo >= 3)))    {
	var bassa = 28;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

   if (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo >= 3)) ||
       ((monthf == 2) && (primo <= 2) && (monthl == 2) && (ultimo >= 3)))  {
	var alta = ultimo - 2;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }

   if (((monthf == 3) && (primo <= 24) && (monthl == 3) && (ultimo >= 25)) || 
	((monthf == 2) && (monthl == 3) && (ultimo >= 25)))  {
	var bassa = ultimo - 24;
	var alta = giorni - bassa;
	var pre = 0;
	return salti();    }

   if ((monthf == 3) && (primo <= 24) && (monthl == 4))  {
	var alta = 25 - primo;
	var bassa = giorni - alta;
	var pre = 0;
	return salti();    }



//---------- CALCOLO PREZZI IN STAGIONE -----------
	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 0))) {
 var res = Math.round(c_pre_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 1))) {
 var res = Math.round(c_pre_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (monthl == 0) && (ultimo < 23)) && (anni == 2))) {
 var res = Math.round(c_pre_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 0)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 0)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 0)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 0)))  {
 var res = Math.round(c_alt_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 1)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 1)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 1)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 1)))  {
 var res = Math.round(c_alt_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 0) && (primo >= 23) && (monthl == 0)) && (anni == 2)) ||
	    (((monthf == 0) && (primo >= 23) && (monthl == 1) && (ultimo <= 5)) && (anni == 2)) ||
	    (((monthf == 1) && (monthl == 1) && (ultimo <= 5)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo >= 3)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 3) && (ultimo <= 24)) && (anni == 2)) ||
	    (((monthf == 3) && (monthl == 3) && (ultimo <= 24)) && (anni == 2)))  {
 var res = Math.round(c_alt_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 0)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 0)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 0)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 0)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 0)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 0)))  {
 var res = Math.round(c_bas_a * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 1)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 1)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 1)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 1)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 1)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 1)))  {
 var res = Math.round(c_bas_a * et_j * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}

	if ((((monthf == 1) && (primo >= 6) && (monthl == 1)) && (anni == 2)) ||
	    (((monthf == 1) && (primo >= 6) && (monthl == 2) && (ultimo <= 2)) && (anni == 2)) ||
	    (((monthf == 2) && (monthl == 2) && (ultimo <= 2)) && (anni == 2)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 4)) && (anni == 2)) ||
	    (((monthf == 3) && (primo >= 25) && (monthl == 3)) && (anni == 2)) ||
	    (((monthf == 4) && (primo >= 1)) && (anni == 2)))  {
 var res = Math.round(c_bas_a * et_s * (perc.slice(giorni - 1,giorni)) * giorni);
 document.calc.result.value = res;
 document.calc.spec.value = label2;
 return conv();
	}


function salti()  {


//----------- CALCOLO PREZZO SALTI STAGIONI --------
   
   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 0))  {
	var res = Math.round((Math.round((c_pre_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_a * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}
   	
   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 1))  {
	var res = Math.round((Math.round((c_pre_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_j * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}

   if ((((alta > 0) && (bassa > 0) && (pre > 0)) ||
	((alta == 0) && (bassa > 0) && (pre > 0)) ||
	((alta > 0) && (bassa == 0) && (pre > 0)) ||
	((alta > 0) && (bassa > 0) && (pre == 0))) && (anni == 2))  {
	var res = Math.round((Math.round((c_pre_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * pre) + (Math.round((c_bas_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * bassa) + (Math.round((c_alt_a * et_s * perc.slice(giorni - 1, giorni) * giorni)) / giorni * alta) + c);
	document.calc.result.value = res;
	document.calc.spec.value = label2;
	return conv();
   	}
}
//-------FINE CALCOLO PREZZO DOPPIE STAGIONI -------

	return conv();
}

//------- CONVERSIONE IN LIRE ----------

 function conv()  {

 document.calc.dec.value = "00";

}

