function confirmThis(inputString) {
var agree=confirm(inputString);
if (agree) {return true;}
else {return false;}
}

function confirmQuit(inputString) {
var agree=confirm(inputString);
if (agree) {window.close();}
//else {return false;}
}

function gotoURL (thePage){
var w = 800, h = 600;
if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}
var popW = 550, popH = 375;
var leftPos = (w-popW)/2, topPos = (h-popH)/2;

window.open(thePage,'help','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
}

function validatePayment(theForm) {

     if (theForm.amount_paid.value.length==0){
        alert('Please enter a payment amount');
        theForm.amount_paid.focus();
        return (false);
      }

     if (theForm.pay_method.selectedIndex==0){
        alert('Please enter a Pay Method');
        theForm.pay_method.focus();
        return (false);
      } else {theForm.submit();}
}

function validateMonthly(theForm) {
      if (theForm.pay_method.selectedIndex==0){
        alert('Please enter a Pay Method');
        theForm.pay_method.focus();
        return (false);
      } else {theForm.submit();}
}

function validateExtra(theForm) {

     if (theForm.extra.value.length==0){
        alert('Please enter an amount for the extra charge');
        theForm.extra.focus();
        return (false);
      } else {theForm.submit();}
}

function validateBooking(theForm) {

     if (theForm.arrive_date.value.length==0){
        alert('Please select an Arrive Date');
        return (false);
      }
	  
	  if(theForm.agent_test.value==0) {
	  if (theForm.date_test.value<0){
		var agree=confirm('OK Depart Date is earlier than today?  (Reservation will be saved in HISTORY)');
        if (agree) {return true;}
        else {return false;}
      }
	  } else {
	    if (theForm.date_test.value<0){
		alert('Depart Date is later than today');
        return false;
      }  
	  }

     if (theForm.depart_date.value.length==0){
        var agree=confirm('Depart date not known?');
        if (agree) {return true;}
        else {return false;}
      } 

else {theForm.submit();}
	  
}

function validate(theForm) {
	  if (theForm.date2.value < theForm.date1.value){
		alert('Depart Date is earlier than Arrive Date ');
        return (false);
      }

	  if (theForm.date2.value < theForm.date_st.value){
		var agree=confirm('Depart date is earlier than today?  (Reservation will be saved in HISTORY)');
        if (agree) {return true;}
        else {return false;}
      }

else {theForm.submit();}
	  
}

function popUp(thePage){
   w = screen.availWidth;
   h = screen.availHeight;
var leftPos = (w-640)/2, topPos = (h-480)/2;
window.open(thePage,'Photos','width=' + 640 + ',height=' + 480 + ',top=' + topPos + ',left=' + leftPos);
}


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function setText(thefield){
if (thefield.value== "")
thefield.value =thefield.defaultValue
}

function clearNote(thefield){
if (thefield.value=="note:")
thefield.value = ""
}

function checkClient(theForm){

if (theForm.first_name.value=='' && theForm.last_name.value=='')
	 {
        alert('Required: either a first last name');
        theForm.first_name.focus();
        return (false);
      }
	  
if (theForm.last_name.value=='')
	 {
        theForm.last_name.value = theForm.first_name.value
        theForm.first_name.value = ''
     }
	 
if (theForm.note.value=="note:") note.value = ""	 

}

function setNote(thefield){
if (thefield.value== "")
thefield.value = "note:"
}

function setComm(comField){
comField.value = ""
}

function defaultCheck(theField, theValue){
	var val = theValue
theField.value = val
}

function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 'year is wrong';
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 'month is wrong';
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 'day is wrong';
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = '29 days in this Feb this year';
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = '28 days in this Feb this year';
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 'only 31 days in this month';
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 'only 30 days in this month';
   }
   if (DateValue.length != 8) {
      err = 'needs to be like this: 22/06/2006 (dd/mm/yy)';}
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert(err);
      DateField.select();
	  DateField.focus();
	  DateField.value = "";
   }
}

function check_seasons(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   
   if (DateValue.length != 4) {
      err = "needs to be like this: 15/06 (dd/mm)";}

   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = "needs to be like this: 15/06 (dd/mm)";
   } 

   day = DateValue.substr(0,2);
   if (day < 1) {
     err = "needs to be like this: 15/06 (dd/mm)";
   } 

   /* Validation leap-year / february / day */
   if ((month == 2) && (day > 28)) {
      err = "use 28 for the end of Feb - forget leap year";
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = "only 31 days in this month";
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = "only 30 days in this month";
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month;
   }
   /* Error-message if err != 0 */
   else {
      alert(err);
      DateField.select();
	  DateField.focus();
	  DateField.value = "";
   }
}
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 'year is wrong';
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 'month is wrong';
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 'day is wrong';
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = '29 days in this Feb this year';
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = '28 days in this Feb this year';
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 'only 31 days in this month';
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 'only 30 days in this month';
   }
   if (DateValue.length != 8) {
      err = 'needs to be like this: 22/06/2006 (dd/mm/yy)';}
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert(err);
      DateField.select();
	  DateField.focus();
	  DateField.value = "";
   }
}

function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "-";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 'year is wrong';
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 'month is wrong';
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 'day is wrong';
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = '29 days in this Feb this year';
	  day = 29;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = '28 days in this Feb this year';
	  day = 28;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 'only 31 days in this month';
	  day = 31;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 'only 30 days in this month';
	  day = 30;
   }
   if (DateValue.length != 8) {
      err = "needs to be like this: 22-06-07 (dd-mm-yy) \n\nuse any seperator you like: / . - | \nor no seperator: 22062007 ";}
	  //day = '';
	  //month = '';
	  //year = '';
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
	  year = year.substr(2,2); 
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert(err);
      DateField.select();
	  DateField.focus();
	  year = year.substr(2,2); 
	  DateField.value = day + seperator + month + seperator + year;
   }
}



//JSP

function yesManage() {
manage.style.display = ''
}

function noManage() {
manage.style.display = 'none'
}

function yesBook() {
bookit.style.display = ''
}

function noBook() {
bookit.style.display = 'none'
}


