function savepic(){
   document.form.action="up_pic.php";
   document.form.target="hidden";
   document.form.submit();
}

function newDate(){
   $("#cluster").load('datesSelect.php?id='+document.form.Dates.value);
}


function delDate(id){
   alert('datesSelect.php?del=1&i='+id);
   $("#cluster").load('datesSelect.php?del=1&i='+id);
}

function newTel(){
   var input = document.form.vorwahl;
   var input2 = document.form.nummer;
	pattern=eval("/[^0-9 -]/i");
	tmp = input.value.match(pattern);
	tmp2 = input2.value.match(pattern);
   
   alert(tmp);
   
	if(tmp != null || tmp2 != null)
   {
         alert("Erlaubt sind nur Zahlen,- und Leerzeichen");
         return false;
   }
   
   if(input.value == "" || input2.value == "")
   {
      alert("Bitte geben Sie die Rufnummer ein");
      return false;
   }
   
   if(document.form.telType.value == "")
   {
      alert("Bitte Telefontyp auswählen");
      return false;
   }
   
   $("#telNr").load('phoneNumbers.php?vorwahl='+document.form.vorwahl.value+'&nummer='+document.form.nummer.value+'&telType='+document.form.telType.value);
}

function delTel(id){
   $("#telNr").load('phoneNumbers.php?del=1&i='+id);
}

function checkForm(){
   name = document.form.name.value;
   street = document.form.street.value;
   hsnr = document.form.hsnr.value;
   vorwahl = document.form.vorwahl.value;
   nummer = document.form.nummer.value;
   telType = document.form.telType.value;
   email = document.form.email.value;
   homepage = document.form.homepage.value;
   
   if(name == "" || street == "" || hsnr ==""){
      alert("Mindestangaben:\nName, Straße, Hausnummer");
      return false;
      }
      
   if(vorwahl != "" || nummer != "")
   {
      var input = document.form.vorwahl;
      var input2 = document.form.nummer;
   	pattern=eval("/[^0-9 -]/i");
   	tmp1 = input.value.match(pattern);
   	tmp2 = input2.value.match(pattern);
            
   	if(tmp1 != null || tmp2 != null)
      {
         alert("Erlaubt sind nur Zahlen,- und Leerzeichen");
         return false;
      }
      
      if(input.value == "" || input2.value == "")
      {
         alert("Bitte geben Sie die Rufnummer ein");
         return false;
      }
      
      if(document.form.telType.value == "")
      {
         alert("Bitte Telefontyp auswählen");
         return false;
      }
   }
   
   if(document.form.categ.value == "3") //hotel
   {
      categ = document.form.categ.value;
      hDz = document.form.hDz.value;
      hEz = document.form.hEz.value;
      hFz = document.form.hFz.value;
      hBett = document.form.hBett.value;
      hGarage = document.form.hGarage.value;
      hSmoke = document.form.hSmoke.value;
   }
   
   document.form.target='';
   document.form.action='address_insert.php';
   document.form.submit();
}

function checkFormDate(){

/* dayFrom
   dayTo
   hrFrom
   hrTo */

   if(document.form.title.value == "")
   {
      alert("Bitte Titel eintragen");
      return false;
   }
   if(document.form.descr.value == "")
   {
      alert("Bitte Beschreibung eintragen");
      return false;
   }
   if(document.form.dayFrom.value == "")
   {
      alert("Bitte Start-Datum eintragen");
      return false;
   }

   
/*   var dayF = document.form.dayFrom.value;
   var hrF = document.form.hrFrom.value;
   var dayT = document.form.dayTo.value;
   var hrT = document.form.hrTo.value;
   
   if (hrT != "" && dayT == ""){
      alert("Bitte Enddatum eintragen");
   }
   
   if((hrT != "" && hrF == "") || (hrF != "" && dayT == "")){
      alert("Bei Start- und Enddatum bitte BEIDE Uhrzeiten eintragen,\noder keine");
   }
   
   var dateFSplit = dayF.split(".");
   if(dateFSplit.length != 3){
      alert("Startdatum bitte im Format DD.MM.YYYY eintragen");
      document.form.dayFrom.focus();
      return false;
   }

   if(hrF != ""){
      var hrFSplit = hrF.split(":");
      if(hrFSplit.length != 2){
         alert("Uhrzeit bitte im Format hh:mm eintragen");
         document.form.hrFrom.focus();
         return false;
      }
   }
   
   
   if(dayT != ""){
      var dayTSplit = dayT.split(".");
      if(dayTSplit.length != 3){
         alert("Enddatum bitte im Format DD.MM.YYYY eintragen");
         document.form.dayTo.focus();
         return false;
      }
   }
   
   if(hrT != ""){
      var hrTSplit = hrT.split(":");
      if(hrTSplit.length != 2){
         alert("Datum bitte im Format DD.MM.YYYY eintragen");
         document.form.dayTo.focus();
         return false;
      }
   } */
   
   document.form.target='';
   document.form.action='date_insert.php';
   document.form.submit();
}

function checkFormCluster(){
   document.form.target='';
   document.form.action="cluster_insert.php";
   document.form.submit();
}

function getMonth(month,year)
{
   $('#kalender1').load('module/calendar.php?date=&month='+month+'&year='+year).val();
}

function setDates(from,to){
   document.search_form.datefrom.value = from;
   document.search_form.dateto.value = to;
   document.search_form.submit();
}
