// Messo in un file 12/7/2005
//<script Language="JavaScript">
//<!--

// Funzioni aggiunte da Petter in bnbritain per check email
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1){ return""; }
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){ return "";}
	else { return TRIM_VALUE;}
} //End Function

function RTrim(VALUE)
{
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
	if(v_length < 0){return"";}

var iTemp = v_length -1;

while(iTemp > -1)
	{ 
		if(VALUE.charAt(iTemp) == w_space){ }
		else { 
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
		iTemp = iTemp-1;
	} //End While
return strTemp;

} //End Function RTrim

function LTrim(VALUE)
{
var w_space = String.fromCharCode(32);
	if(v_length < 1){return"";}

var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length)
{
	if(VALUE.charAt(iTemp) == w_space) { }
	else {
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		 }
	iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function LTrim
  
function clearField(textField)
{
	var tv = textField.value.toString();
	var defValue = "    - Retype above email - ";
	if(tv.toLowerCase()==defValue.toLowerCase())   { textField.select();	}
}
 
function CalcDays() {
	if (document.MaoForm.fromyear.value==document.MaoForm.toyear.value) {
		if ((document.MaoForm.frommonth.value==document.MaoForm.tomonth.value)&&(parseInt(document.MaoForm.todate.value) >= parseInt(document.MaoForm.fromdate.value))) {
			Tot = (document.MaoForm.todate.value * 1) - (document.MaoForm.fromdate.value * 1);
			document.MaoForm.TotalDays.value= Tot;
			return (true);	  }
		if (parseInt(document.MaoForm.tomonth.value)==(parseInt(document.MaoForm.frommonth.value)+1))  {
		  if ((((document.MaoForm.fromyear.value * 1) % 4 == 0) && ((document.MaoForm.fromyear.value * 1) % 100 != 0)) || ((document.MaoForm.fromyear.value * 1) % 400 == 0)) { days[1] = 29; }
        else { days[1] =28; }
		Tot = days[(document.MaoForm.frommonth.value *1)] - (document.MaoForm.fromdate.value *1) + (document.MaoForm.todate.value * 1);
		document.MaoForm.TotalDays.value= Tot;
		return (true);	}	 }
	else
	 {  if ((parseInt(document.MaoForm.toyear.value)==((document.MaoForm.fromyear.value * 1)+1))&&(document.MaoForm.frommonth.value==11)&&(document.MaoForm.tomonth.value==0)) {
	     Tot = 31 - (document.MaoForm.fromdate.value *1) + (document.MaoForm.todate.value * 1);
        document.MaoForm.TotalDays.value = Tot; 
        return (true); }
	 }
	 document.MaoForm.TotalDays.value = " - - -";
}

function SettaFecha() {
  if (((ano%4==0)&&(ano%100!=0))||(ano%400==0)) { days[1] = 29; }
  else days[1] =28;

  if (Dia == days[mese]) {  DiaM=1; meseM=mese+1; meseMM=mese+1; meseMMM=mese+1; if (meseM==12) { meseM=0; meseMM=0; meseMMM=0; anoM=ano+1; anoMM=ano+1; anoMMM=ano+1; } }
  else DiaM= Dia+1;
    
  if (DiaM == days[meseM]) { DiaMM=1; meseMM=meseM+1; meseMMM=meseM+1; if (meseMM==12) { meseMM=0; meseMMM=0; anoMM=anoM+1; anoMMM=anoM+1; } }
  else  DiaMM=DiaM+1;
  
  if (DiaMM == days[meseMM]) { DiaMMM=1; meseMMM=meseMM+1; if (meseMMM==12) { meseMMM=0; anoMMM=anoMM+1; } }
  else
    DiaMMM=DiaMM+1; }

function RoomNumber()
 {	var Tot = 0;
	Tot += (document.MaoForm.single.value * 1);
	Tot += (document.MaoForm.doubleR.value * 1);
	Tot += (document.MaoForm.twin.value * 1);
	Tot += (document.MaoForm.treble1double.value * 1);
	Tot += (document.MaoForm.treble3single.value * 1);
	Tot += (document.MaoForm.family.value * 1);
	document.MaoForm.TotalRooms.value = Tot;
	Tot = 0;
	Tot += (document.MaoForm.single.value * 1);
	Tot += (document.MaoForm.doubleR.value * 2);
	Tot += (document.MaoForm.twin.value * 2);
	Tot += (document.MaoForm.treble1double.value * 3);
	Tot += (document.MaoForm.treble3single.value * 3);
	Tot += (document.MaoForm.family.value * 4);
	document.MaoForm.TotalPerson.value = Tot;  }
	

//-->
//</script>
