function checkDate(theDay, theMonth)
{
        if(theDay == 31 &&
	   (theMonth == 4 || theMonth == 6 || theMonth == 9 || theMonth == 11  ))
	{
		alert("There are only 30 days in this month.");
		return false;
	}

	if( theMonth == 2 && theDay >28 )
	{
		alert("There are only 28 days in February.");
		return false;
	}
}

function LoadReserve(id, startDate, endDate, ref)
{
//   var fenster = window.open("../bookings/reserve.php?hid="+id+"&startDate="+startDate+"&endDate="+endDate+"&ref="+ref, "new", "status=yes, scrollbars=yes, height=700,width=480");
   var fenster = window.open("https://ssl.kundenserver.de/www.allhotels-inn.com/bookings/reserve.php?hid="+id+"&startDate="+startDate+"&endDate="+endDate, "new", "status=yes, scrollbars=yes, height=500,width=500");
   //self.name = "Origin";
   //if( fenster.opener == null ) fenster.opener = self;
}
function LoadRequest(id, startDate, endDate, ref)
{
//   var fenster = window.open("../bookings/sendreq.php?hid="+id+"&startDate="+startDate+"&endDate="+endDate+"&ref="+ref, "new", "status=yes, scrollbars=yes, height=700,width=480");
   var fenster = window.open("https://ssl.kundenserver.de/www.allhotels-inn.com/bookings/sendreq.php?hid="+id+"&startDate="+startDate+"&endDate="+endDate, "new", "status=yes, scrollbars=yes, height=500,width=500");
   //self.name = "Origin";
   //if( fenster.opener == null ) fenster.opener = self;
}

function LoadReserve_a(aid, id, startDate, endDate, ref)
{
   var fenster = window.open("https://ssl.kundenserver.de/www.allhotels-inn.com/a_bookings/reserve_a.php?aid="+aid+"&hid="+id+"&startDate="+startDate+"&endDate="+endDate, "new", "status=yes, scrollbars=yes, height=500,width=500");
}

function LoadRequest_a(aid, id, startDate, endDate, ref)
{
   var fenster = window.open("https://ssl.kundenserver.de/www.allhotels-inn.com/a_bookings/sendreq_a.php?aid="+aid+"&hid="+id+"&startDate="+startDate+"&endDate="+endDate, "new", "status=yes, scrollbars=yes, height=500,width=500");
}

function bill_info_a(id)
{
   var fenster = window.open("https://ssl.kundenserver.de/www.allhotels-inn.com/agencies/bill_info_a.php?id="+id, "new", "status=yes, scrollbars=yes, height=500,width=500");
}

function isAPhoneNumber(n){
   var s = "" + n //Umwandlung in eine Zeichenkette
   var zeichen = "0123456789+-()[]/ " //Gultige Zeichen
   for (var i=0; i<s.length; i++)
      if (zeichen.indexOf(s.charAt(i))==-1)
         //kein gultiges Zeichen
         return false
   return true
}

// check if a valid decimalnumber
function isAFract(n){
   var s = "" + n //Umwandlung in String
   while (s.indexOf(",")>-1){//Kommata durch Punkte ersetzen
      s=s.substring(0,s.indexOf(",")) + "."
+ s.substring(s.indexOf(",")+1 ,s.length)
   }
   var anzahl_punkt=0//Variable zum Zahlen der Dezimalpunkte
   for (var i=0; i<s.length; i++)
      if (s.charAt(i)==".")
         anzahl_punkt++
   if (anzahl_punkt>1) //Mehr als ein Dezimalpunkt?
      return false
   // *** Eigentliche Uberprufung nach obigem Muster
   // *** Neu: Der Dezimalpunkt ist ein erlaubtes Zeichen
   var ziffern = ".0123456789" //Gultige Zeichen
   if (s.charAt(0)=="0" && s.charAt(1)!=".")
      //Bei 0 am Anfang ohne folgenden Punkt
      return false
   for (var i=0; i<s.length; i++) {
      if (ziffern.indexOf(s.charAt(i))==-1) //Keine Ziffer
         return false
      if( (s.length > 4 && s.indexOf(".") == -1) || s.indexOf(".")>4)  //1234.56 - is allowed
         return false
   }
   return true
}


function zoom(picture, pic_width, pic_height)
{
 if( (pic_width == 0) || (pic_height == 0) ) {
    window.open("../pict_zoom.php?picture="+picture, "new", "resizable=yes, statusbar=yes, scrollbars=yes, height=60,width=600");
 } else {
    pic_height=pic_height+60;
    pic_width=pic_width+15;
    window.open("../pict_zoom.php?picture="+picture, "new", "resizable=no, status=yes, height="+pic_height+",width="+pic_width);
 }
}

function update_days(f)

{
        dFrom=f.dayFrom.selectedIndex;
        mFrom=f.monthFrom.selectedIndex;
        yFrom=f.yearFrom.selectedIndex;
        dFrom=dFrom+1;
        mFrom=mFrom+1;
        yFrom=yFrom+1;
        mTo = mFrom;
        yTo = yFrom;
        if( dFrom<28 ) {
            dTo = dFrom+1;
        } else if( mFrom == 2 ) {
            dTo = 1;
            mTo = mTo+1;
        } else if( ((mFrom==4) || (mFrom==6) || (mFrom==9) || (mFrom==11)) && (dFrom<30) ) {
            dTo = dFrom+1;
        } else if( ((mFrom==4) || (mFrom==6) || (mFrom==9) || (mFrom==11)) && (dFrom>=30) ) {
            dTo = 1;
            mTo = mTo+1;
        } else if( dFrom<31 ) {
            dTo = dFrom+1;
        } else {
            dTo = 1;
            mTo = mTo+1;
        }

        if( mTo > 12 ) {
            mTo = 1;
            yTo = yTo+1;
        }
        
        f.dayTo.selectedIndex = dTo-1;
        f.monthTo.selectedIndex = mTo-1;
        f.yearTo.selectedIndex = yTo-1;
}

function checkPeriod() {
  var f =document.Period;
  if (checkDate (f.dayFrom.selectedIndex+1, f.monthFrom.selectedIndex+1) == false) return false;
  if (checkDate (f.dayTo.selectedIndex+1, f.monthTo.selectedIndex+1) == false) return false;
  return true;
}

function newWin(url, h, scroll)
{
  window.open(''+url+'','jav','width=500,height='+h+',resizable=yes, scrollbars='+scroll+'');
}

function newWinSmall(url, h, scroll)
{
  window.open(''+url+'','jav','width=260,height='+h+', scrollbars='+scroll+'');
}