function validate_pwd(){
        if (document.user_form.NewPassword.value == '' || document.user_form.NewPassword2.value == ''){
         alert ('Cambiamento password obbligatorio.');
         return false;
        }
        if (document.user_form.NewPassword.value == document.user_form.NewPassword2.value){
          document.user_form.submit();
        }else{
         alert ('I due campi password non coincidono. Riprovare.');
        }
}

function validate_multiform(){

var inday = new Date( document.multiform.a_inrq.options[document.multiform.a_inrq.selectedIndex].text, document.multiform.m_inrq.options[document.multiform.m_inrq.selectedIndex].text-1, document.multiform.d_inrq.options[document.multiform.d_inrq.selectedIndex].text);
var outday = new Date(document.multiform.a_outrq.options[document.multiform.a_outrq.selectedIndex].text, document.multiform.m_outrq.options[document.multiform.m_outrq.selectedIndex].text-1, document.multiform.d_outrq.options[document.multiform.d_outrq.selectedIndex].text);

                     if (outday <= inday){
                     //loadBar(1);
                     alert ("Attenzione! La data  di arrivo deve essere antecedente alla data di partenza.");
                     return false;
                     }

                     if (document.multiform.roomrq.options[document.multiform.roomrq.selectedIndex].text == "") {
                     alert("Inserire il tipo di camera.");
                     return false;
                     }
                     if (document.multiform.nomepaxrq.value == "") {
                     alert("Inserire il  nome.");
                     return false;
                     }
                     if (document.multiform.cognomepaxrq.value == "") {
                     alert("Inserire il cognome.");
                     return false;
                     }
        document.multiform.submit();
        return true;

}


function Nuwin(url,w,h){
        NewWin = window.open(url,'NewWin','toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=100,left=100,width='+w+',height='+h);
}
function validate(form)  {
document.reserv.d_inrq.options[document.reserv.d_inrq.selectedIndex].text
var inday = new Date( document.reserv.a_inrq.options[document.reserv.a_inrq.selectedIndex].text, document.reserv.m_inrq.options[document.reserv.m_inrq.selectedIndex].text-1, document.reserv.d_inrq.options[document.reserv.d_inrq.selectedIndex].text);
var outday = new Date(document.reserv.a_outrq.options[document.reserv.a_outrq.selectedIndex].text, document.reserv.m_outrq.options[document.reserv.m_outrq.selectedIndex].text-1, document.reserv.d_outrq.options[document.reserv.d_outrq.selectedIndex].text);
//var today = new Date();
 //                    if (today > inday){
 //                    alert ("Attenzione?"+today+" La data  di arrivo deve essere antecedente alla data di partenza.");
 //                    return false;
 //                    }

                     if (outday <= inday){
                     alert ("Attenzione! La data  di arrivo deve essere antecedente alla data di partenza.");
                     return false;
                     }
                     if (document.reserv.roomrq.options[document.reserv.roomrq.selectedIndex].text == "") {
                     alert("Inserire il tipo di camera.");
                     return false;
                     }


                     if (document.reserv.nomepaxrq.value == "") {
                     alert("Inserire il  nome.");
                     return false;
                     }
                     if (document.reserv.cognomepaxrq.value == "") {
                     alert("Inserire il cognome.");
                     return false;
                     }

//                       if (document.reserv.cartapaxrq.value == "") {
//                           alert("Inserire il numero di carta di credito.");
////                           return false;
////                        }
//                   if (document.reserv.d_inrq.value == "") {
 //                            alert("Inserire il giorno di arrivo");
//                             return false;
//                  }
//                 if (document.reserv.m_inrq.value == "") {
//                           alert("Inserire il mese di arrivo");
//                           return false;
//                }
//               if (document.reserv.a_inrq.value == "") {
//                         alert("Inserire l'anno di arrivo");
//                         return false;
//              }
//             if (document.reserv.d_outrq.value == "") {
//                       alert("Inserire il giorno di partenza");
//                       return false;
//            }
//           if (document.reserv.m_outrq.value == "") {
//                     alert("Inserire il mese di partenza");
//                     return false;
//          }
//         if (document.reserv.a_outrq.value == "") {
//                   alert("Inserire l'anno di partenza");
//                   return false;
//        }
//      if (document.reserv.roomrq.value == "") {
//                alert("Inserire il tipo di camera");
//                return false;
//     }
        form.submit();
        return true;
}


function Nuwin(url,w,h){
        NewWin = window.open(url,'NewWin','toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=100,left=100,width='+w+',height='+h);
}

function validate_date(){
var inday = new Date( document.reserv.a_inrq.value, document.reserv.m_inrq.value, document.reserv.d_inrq.value);
var outday = new Date(document.reserv.a_outrq.value, document.reserv.m_outrq.value, document.reserv.d_outrq.value);

if (outday <= inday) alert ("Attenzione alla data");
}

function acceptOT(ID) {

var answer = confirm ("Se vuoi confermare la controproposta dell'albergo devi cambiare i dati nel modulo di prenotazione con quelli proposti dall'hotel:\nEs. nuova tipologia di camera, nuovo prezzo, nuove date.\nPer cambiarli premi Annulla, per proseguire premi OK?")
if (answer)
   document.reserv.submit();
}
function cancelYN(ID,ARGO) {

var answer = confirm ("Confermi:\nStai per cancellare questa prenotazione.\nUna email avvisara' l'hotel della cancellazione.\n Vuoi procedere?"+ID)
if (answer)
  location.href="home.php?Action=Cancella&ID="+ID;
//alert ("Woo Hoo! So am I.")
}
function rifiuta_OT(ID) {

var answer = confirm ("Confermi:\nVuoi rifiutare la controproposta fatta dall'hotel?")
if (answer)
  location.href="https://hotelbookings.it/home.php?Action=Rifiuta&ID="+ID;
//alert ("Woo Hoo! So am I.")
}
function delete_for_commission(ID) {

var answer = confirm ("Confermi:\nVuoi annullare la prenotazione da quelle commissionabili? ")
if (answer)
  location.href="https://hotelbookings.it/commissioni.php?Action=Delete&ID="+ID;
//alert ("Woo Hoo! So am I.")
}

function validate_voucher(){
 if (document.voucher.emailpaxrq.value == ""){
 alert ("Inserire un'indirizzo email valido");
 }else{
   document.voucher.submit();
 }
}
function validate_delete(){
 if (document.conf_elimina.Conf_Del.checked){
   document.conf_elimina.submit();
 }else{
 alert ("Devi confermare la cancellazione");
 }
}

function fill_mail(){
document.reserv.emailpaxrq.value = document.reserv.nomepaxrq.value+"."+document.reserv.cognomepaxrq.value+"@bain.it";
document.reserv.emailpaxrq.value = document.reserv.emailpaxrq.value.toLowerCase();
}
function show_all(){
document.cerca.Research.value = "%";
document.cerca.submit();
}
function check_mod(){
        if (document.reserv.d_inrq.options[0].text == document.reserv.d_inrq.options[document.reserv.d_inrq.selectedIndex].text 
	&& document.reserv.m_inrq.options[0].text == document.reserv.m_inrq.options[document.reserv.m_inrq.selectedIndex].text
	&& document.reserv.a_inrq.options[0].text == document.reserv.a_inrq.options[document.reserv.a_inrq.selectedIndex].text
	&& document.reserv.d_outrq.options[0].text == document.reserv.d_outrq.options[document.reserv.d_outrq.selectedIndex].text
	&& document.reserv.m_outrq.options[0].text == document.reserv.m_outrq.options[document.reserv.m_outrq.selectedIndex].text
	&& document.reserv.a_outrq.options[0].text == document.reserv.a_outrq.options[document.reserv.a_outrq.selectedIndex].text
	&& document.reserv.roomrq.options[0].text == document.reserv.roomrq.options[document.reserv.roomrq.selectedIndex].text
	&& document.reserv.roomraterq.value == document.reserv.roomraterq.defaultValue
	){
	alert('Non e\' stato effettuato alcun cambiamento');
	}else{
	document.reserv.submit();
	return true;
	}

}
function set_data_inout(){

}

function reloadForm(IDRQ, HTL, DAT){
 	 if (IDRQ != '0'){
	  document.reserv.action = "home.php?Action=Show&ID="+IDRQ+"&DAT="+DAT;
	}else{
	  document.reserv.action = "home.php?Action=Show&HTL="+HTL+"&DAT="+DAT;
	}
  document.reserv.submit();
}
function ShowAllHtl(){
document.cerca.action = "hotels.php?Action=ShowAll";
document.cerca.submit();
}
function ShowHtl(){
document.cerca.action = "hotels.php?Action=Show";
document.cerca.submit();
}
function set_catena(){
document.hotel_form.catena.value = document.hotel_form.gruppohtl.options[document.hotel_form.gruppohtl.selectedIndex].text;
}

function validate_pdw(){
	if (document.user_form.NewPassword.value == document.user_form.NewPassword2.value){
	  document.user_form.submit();
	}else{
	 alert ('I due campi password non coincidono. Riprovare.');
	}
}

function DelHtl(ID) {

var answer = confirm ("Stai per cancellare questo albergo e le relative tariffe da database.\n Vuoi procedere?"+ID)
if (answer)
  location.href="https://hotelbookings.it/hotels.php?Action=Cancella&ID="+ID;
//alert ("Woo Hoo! So am I.")
}
function loadBar(fl)
//fl is show/hide flag
{
  var x,y;
  if (self.innerHeight)
  {// all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
  }
  else
  if (document.documentElement && document.documentElement.clientHeight)
  {// Explorer 6 Strict Mode
   x = document.documentElement.clientWidth;
   y = document.documentElement.clientHeight;
  }
  else
  if (document.body)
  {// other Explorers
   x = document.body.clientWidth;
   y = document.body.clientHeight;
  }

    var el=document.getElementById('loader');
        if(null!=el)
        {
                var top = (y/2) - 50;
                var left = (x/2) - 50;
                if( left<=0 ) left = 10;
                el.style.visibility = (fl==1)?'visible':'hidden';
                el.style.display = (fl==1)?'block':'none';
                el.style.left = left + "px"
                el.style.top = top + "px";
                el.style.zIndex = 2;
        }
}
function chroom(){
                     if (document.reserv.roomrq.options[document.reserv.roomrq.selectedIndex].text == "") {
                     alert("Scegliere il tipo di camera.");
                     return false;
                     }

}
function SelectStato(str){

var Status = document.cerca.Stato.options[document.cerca.Stato.selectedIndex].text
location.href="home.php?Action=List&Statusrq="+Status;

}


