function send_forms() {

  new Ajax.Request('includes/ajax/functions.php',   {     
    method:'post',
    parameters: $('contact_form').serialize(),   
    onLoading: function() {
      $('contact_submits').style.height = "20px";
      $('contact_submits').style.color  = "#023A8A";
      $('contact_submits').innerHTML    = "Wird versendet ...";
      Effect.Pulsate('contact_submits', { pulses: 20, duration: 10 });
    },
    onSuccess: function(transport) {
    	new Effect.SlideUp('contact_div',{ duration: 1.0, queue: { position: 'front', scope: 'scroller' }, afterFinish: function () {
    		$('contact_div').innerHTML = transport.responseText;                           
    		$('contact_div').setStyle( { height: $('contact_div').getHeight() } );
    		new Effect.SlideDown('contact_div',{ duration: 1.0, queue: { position: 'end', scope: 'scroller' }});
    	}});
    	
    },     
    onFailure: function(e){ 
      alert('Irgendwas ist schiefgelaufen ...'+e.status);
      return false;
    }   
  });

}

function send_eventplaner_form() {
var send = true;
  
  if (!check_field('name','Name')) {
    send = false;
  } else if (!check_field('street','Straße')) {
    send = false;
  } else if (!check_field('street_nr','Straßen Nr')) {
    send = false;
  } else if (!check_field('plz','PLZ')) {
    send = false;
  } else if (!check_field('ort','Ort')) {
    send = false;
  } else if (!check_field('email','E-Mail')) {
    send = false;
  } else if (!check_field('phone','Telefon')) {
    send = false;
  }
  
  if ($('sec_code')) {
    if (!check_field('sec_code','Security-Code')) {
      send = false;
    } 
  }
  
  if ($('showData').checked == true) {
  	txt = "Ihre Daten werden nun öffentlich in der Reservierung jedem Besucher angezeigt.\n\nMöchten Sie dies nicht, klicken Sie Abbrechen und entfernen Sie den Haken.";
  } else {
  	txt = "Ihre Daten werden nun keinem Besucher angezeigt.\n\nMöchten Sie dies nicht, klicken Sie Abbrechen und setzen Sie den Haken.";
  }
  
  if (send == true) {
	  var check = confirm(txt);
	  if (check == false) {
	  	send = false;
	  }
  }
  
  if (send == true) {
    send_forms()
  }
}

function send_events_form() {
  var send = true;
  
  if (!check_field('title','Veranstaltung')) {
    send = false;
  } else if (!check_field('veranstalter','Veranstalter')) {
    send = false;
  } else if (!check_field('ort','Ort der Veranstaltung')) {
    send = false;
  } else if (!check_field('f-calendar-field-1','Datum')) {
    send = false;
  } else if (!check_field('name','Ihr Name')) {
    send = false;
  } else if (!check_field('email','Ihre E-Mail-Adresse')) {
    send = false;
  }
    
  if ($('sec_code')) {
    if (!check_field('sec_code','Security-Code')) {
      send = false;
    } 
  }
    
  if (send == true) {
    send_forms()
  }
}

function send_link_form() {
  var send = true;
  
  if (!check_field('title','Link-Titel')) {
    send = false;
  } else if (!check_field('url','Link-URL','http://')) {
    send = false;
  } else if (!check_field('content','Link-Beschreibung')) {
    send = false;
  } else if (!check_field('name','Ihr Name')) {
    send = false;
  } else if (!check_field('email','Ihre E-Mail-Adresse')) {
    send = false;
  }
  
  if ($('sec_code')) {
    if (!check_field('sec_code','Security-Code')) {
      send = false;
    } 
  }
  
  if (send == true) {
    send_forms()
  }
}

function send_contact_form() {
  var send = true;
  
  if (!check_field('from_vorname','Vorname')) {
    send = false;
  } else if (!check_field('from_nachname','Nachname')) {
    send = false;
  } else if (!check_field('from_email','E-Mail')) {
    send = false;
  } else if (!check_field('betreff','Betreff')) {
    send = false;
  } else if (!check_field('content','Nachricht')) {
    send = false;
  }
  
  if (send == true) {
    send_forms()
  }
}

function send_contacts_list_form() {
	var send = true;
	
	if ($('action').value == "company") {
		if (!check_field('company','Firma')) {
			send = false;
		/*} else if (!check_field('url','URL')) {
      send = false;*/
		} else if (!check_field('firstname','Vorname')) {
      send = false;
    } else if (!check_field('lastname','Nachname')) {
      send = false;
    } else if (!check_field('street','Straße')) {
      send = false;
    } else if (!check_field('street_nr','Straßen Nr')) {
      send = false;
    } else if (!check_field('email','E-Mail')) {
      send = false;
    } else if (!check_field('phone','Telefon')) {
      send = false;
    } 
    
    if ($('sec_code')) {
      if (!check_field('sec_code','Security-Code')) {
        send = false;
      } 
    }
	} else if ($('action').value == "email") {
    if (!check_field('firstname','Vorname')) {
      send = false;
    } else if (!check_field('lastname','Nachname')) {
      send = false;
    } else if (!check_field('email','E-Mail')) {
      send = false;
    } 
    
    if ($('sec_code')) {
	    if (!check_field('sec_code','Security-Code')) {
	      send = false;
	    } 
    }
	}
	
	if (send == true) {
		send_forms()
	}
}

function check_field(f,n,dv) {
  if (dv) {
  	va = dv
  } else {
  	va = "";
  }
  
  if (trim($(f).value) == va) {
    alert("Bitte füllen Sie das Feld \""+n+"\" korrekt aus.");
    $(f).value = va;
    $(f).focus();
    return false;
  } else {
  	return true;
  }
}

function update_status(transport) {
  var sta = $('status_div');     
  var response = transport.responseText;       
  sta.update(response); 
  Effect.Pulsate('status_div', { pulses: 3, duration: 2 });
}

function updateHtmlContent(transport,f) {
	var sta = $(f);     
  var response = transport.responseText;       
  sta.update(response); 
  Effect.Pulsate(f, { pulses: 3, duration: 2 });
}