Drücken Sie ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'STRG') + ' + D um die Seite zu Ihren Favoriten hinzuzufügen.
')
}
}
var error_content;
function submitAjaxForm(f,callback,outputDiv,adminSend,params) {
form_id = $(f).attr("id");
$('#'+form_id+' .noInput').each(function(e){
$(this).val('');
});
$('#'+form_id+' input, #'+form_id+' select, #'+form_id+' textarea').each(function(e){
value = $(this).val();
basicValue = $(this).attr('data-basicValue');
if (value == basicValue && basicValue != '') {
$(this).val('');
}
});
if (adminSend == true) ajaxPath = "/modules/ajax.includes.php";
else ajaxPath = "/inc/modules/ajax.includes.php";
data_vars = $(f).serialize();
showAjaxLoading();
//Request abschicken
$.ajax({
url: ajaxPath,
type: "POST",
data: data_vars,
success: function (erfolgs_text) {
if (typeof(tinyMCE) != 'undefined') {
clearAllTinyMCE(params);
}
if(typeof(outputDiv) == 'undefined') {
alertErfolgMessage(erfolgs_text);
} else {
$(outputDiv).html(erfolgs_text);
makeBasicJQueryCalls(outputDiv);
}
if (callback && typeof(callback) === "function") {
window.setTimeout(callback, 300);
} else if (callback && typeof(callback) === "string") {
eval(callback+"('"+params+"')");
}
hideAjaxLoading();
},
error: function(fehler_text) {
console.log(fehler_text);
alertBasicErrorMessage(fehler_text);
}
});
}
function showAjaxLoading() {
centerElement('ajax_loader');
$('#ajax_loader').show();
}
function hideAjaxLoading() {
$('#ajax_loader').hide();
}
// Formularanpassungen / Fehlerkorrekturen (ohne Formularprüfung)
function focusFormular(f, act1, act2){
var myForm=document.getElementById(f);
try{
myForm.action = act1+act2;
}catch(e){
myForm.setAttribute('action', act1+act2);
}
}
function setFormAndSubmit(formular,feld,wert) {
form = document.getElementById(formular);
form.elements[feld].value = wert;
$(form).find('input[type="submit"]').click();
}
function enterFormElement(element) {
if(element.hasClass("noInput")) {
element.removeClass('noInput');
element.val("");
}
}
function setBasicValues(jqElement) {
if (jqElement.attr("data-jquery") != 0) {
basicValue = jqElement.attr("data-basicValue");
if (typeof(basicValue)!= 'undefined' && basicValue != '' && jqElement.val() == '' && !jqElement.hasClass('tinymce')) {
jqElement.removeClass('error_input');
jqElement.addClass("noInput");
jqElement.val(basicValue);
}
}
}
function handleFormCallback(data,f,title) {
if (title != '') {
formTitle = title;
} else {
formTitle = f.attr("title");
if (typeof(formTitle) == 'undefined') formTitle = "Formular:";
}
if (data != '') {
try {
jsonObj = JSON.parse(data);
if (typeof(jsonObj) == 'object') {
if (jsonObj.MESSAGE != '' && typeof(jsonObj.MESSAGE) != 'undefined') {
alertMessage(formTitle,jsonObj.MESSAGE,jsonObj.TYPE);
}
if (jsonObj.CODE != '') eval(jsonObj.CODE);
} else {
if (erfolgs_text.indexOf("alertMessage") == 0) eval(data);
else alertMessage(formTitle,data, true);
}
} catch(err) {
alert(data);
}
}
}
function setErrorClassAndReturnMessage(element,customMessage,debug){
$(element).parents().each(function(index,element){
if($(this).is('label') || $(this).is('tr') || $(this).hasClass('handleError')) {
$(this).addClass('error_input');
if (debug != true) {
return false;
}
}
});
if (typeof(customMessage) != 'undefined' && customMessage != '') {
return customMessage+", ";
}
if (element.attr("title") != '' && typeof(element.attr("title")) != 'undefined') {
return element.attr("title")+", ";
}
return "";
}
function removeErrorClass(element) {
$(element).parents().each(function(index,e){
if($(this).hasClass('error_input')) {
$(this).removeClass('error_input');
return;
}
});
}
function checkRadioCheckboxButton(name) {
var checked = 0;
var checkElement = document.getElementsByName(name);
for (var x = 0; x < checkElement.length; x++) {
if (checkElement[x].checked) {
checked++;
}
}
if (checked == 0) {
for (var x = 0; x < checkElement.length; x++) {
$(checkElement[x]).parents().each(function(index,element){
if($(this).is('label') || $(this).is('tr') || $(this).hasClass('handleError')) {
$(this).addClass('error_input');
return false;
}
});
}
return false;
} else {
return true;
}
}
function checkForm(f,sendViaAjax,callback,outputDiv,adminSend,params){
var alreadyChecked = new Array();
var error = 0;
var error_text = '';
f = document.forms[$(f).attr("id")];
if(typeof(f) == "undefined") return true;
$('#'+$(f).attr("id")+' .noInput').each(function(e){
$(this).val('');
});
$('#'+$(f).attr("id")+' input, #'+$(f).attr("id")+' select, #'+$(f).attr("id")+' textarea').each(function(e){
value = $(this).val();
basicValue = $(this).attr('data-basicValue');
if (value == basicValue && basicValue != '') {
$(this).val('');
}
});
var anzahlElements = f.elements.length;
if (sendViaAjax == '') sendViaAjax = false;
error_content = document.getElementById('message_content');
for(var i=0; i < anzahlElements; i++) {
name = f.elements[i].name;
type = f.elements[i].type;
if(type != 'hidden') {
if ($(f.elements[i]).hasClass('important')){
if ($(f.elements[i]).hasClass('noInput')) {
error_text +=setErrorClassAndReturnMessage($(f.elements[i]));
error++;
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
} else {
if (!$(f.elements[i]).hasClass('specialCheck') && (!in_array(f.elements[i].name, alreadyChecked) || $(f.elements[i]).hasClass('notUnique'))) {
if (type == 'text' || type == 'select-one' || type == 'textarea') {
if (f.elements[i].value == '') {
error_text += setErrorClassAndReturnMessage($(f.elements[i]));
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if (type == 'password') {
if (name == 'pw') {
var pw1 = f.elements[i].value;
if (pw1 == '') {
error_text += setErrorClassAndReturnMessage($(f.elements[i]));
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
if (typeof(f.elements['pw2']) != 'undefined') {
var pw2 = f.elements['pw2'].value;
if (pw2 == '') {
error_text += setErrorClassAndReturnMessage($(f.elements['pw2']));
error++;
}
if (pw1 != pw2 && pw1 != '') {
setErrorClassAndReturnMessage($(f.elements[i]),"");
setErrorClassAndReturnMessage($(f.elements["pw2"]),"");
error_text += "Beide Passwörter müssen übereinstimmen";
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements['pw2'].name;
}
}
}
if (type == 'radio' || type == 'checkbox') {
if (!checkRadioCheckboxButton(f.elements[i].name)) {
error_text += f.elements[i].title+", ";
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
} else {
if ($(f.elements[i]).hasClass('specialCheck')) {
/*
if ($(f.elements[i]).hasClass('typeEmail')) {
if (f.elements[i].value == '' || strpos(f.elements[i].value,'@') == false) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]),"gültige E-Mailadresse");
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
*/
if ($(f.elements[i]).hasClass('typeTel')) {
if (f.elements[i].value == '' || f.elements[i].value.length < 11) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]), 'Telefonnummer zu kurz (mindestens 11 Zeichen)', true);
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if ($(f.elements[i]).hasClass('typeEmail')) {
if (f.elements[i].value == '' || !isValidEmail(f.elements[i].value)) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]),"gültige E-Mailadresse");
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if ($(f.elements[i]).hasClass('typeTel')) {
if (f.elements[i].value == '' || !isValidPhoneNumber(f.elements[i].value)) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]), 'gültige Telefonnummer');
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if ($(f.elements[i]).hasClass('lextLen')) {
if (f.elements[i].value == '' || f.elements[i].value.length < 3) {
title_tmp = ($(f.elements[i]).attr('title') != '') ? $(f.elements[i]).attr('title') : $(f.elements[i]).attr('name');
error_text += setErrorClassAndReturnMessage($(f.elements[i]), title_tmp+' zu kurz (mindestens 3 Zeichen)', true);
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if ($(f.elements[i]).hasClass('decimalNumber')) {
value = valueString = f.elements[i].value;
value = value.replace(",",".");
value = parseFloat(value);
if (valueString == '' || isNaN(value)) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]), "Keine Dezimalnummer");
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
if ($(f.elements[i]).hasClass('intNumber')) {
value = valueString = f.elements[i].value;
value = parseInt(value);
if (isNaN(value) || (valueString.indexOf(",") >= 0 || valueString.indexOf(".") >= 0 || valueString == '')) {
error_text += setErrorClassAndReturnMessage($(f.elements[i]), "Keine Zahl");
error++;
}
alreadyChecked[alreadyChecked.length + 1] = f.elements[i].name;
}
}
}
}
}
}
}
if (error > 0) {
error_text = error_text.substr(0,error_text.length-2);
error_text = "
Fehler im Formular
Bitte geben Sie alle Pflichtfelder an: "+error_text+"
";
alertBasicErrorMessage(error_text);
$('#'+$(f).attr("id")+' .noInput').each(function(e){
setBasicValues($(this));
});
return false;
} else {
// Zweiter Paramter == true => Formular Mit AJAX abschicken
if (sendViaAjax == true) {
submitAjaxForm(f,callback,outputDiv,adminSend,params);
return false;
} else
return true;
}
}
function isValidEmail(mail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/g.test(mail))
{
return (true)
}
return (false)
}
function isValidPhoneNumber(mail)
{
if (/^(?:([+][0-9]{1,2})+[ .-]*)?([(]{1}[0-9]{1,6}[)])?([0-9 .\-\/]{3,30})((x|ext|extension)[ ]?[0-9]{1,4})?$/g.test(mail))
{
return (true)
}
return (false)
}
function countLettersAndOutput(elem,output,textlen) {
text = elem.value;
anzLetter = text.length;
$('#'+output).html('Anzahl Zeichen: '+anzLetter);
if (anzLetter > textlen) {
$(elem).addClass('error_input');
} else {
$(elem).removeClass('error_input');
}
}
function countLettersAndWordsAndOutput(elem,output,spacer,textlen,wordlen) {
text = elem.value;
words = text.split(spacer);
anzLetter = text.length;
anzWords = words.length;
$('#'+output).html('Anzahl Wörter: '+anzWords+' Anzahl Zeichen: '+anzLetter);
if (anzLetter > textlen || anzWords > wordlen) {
$(elem).addClass('error_input');
} else {
$(elem).removeClass('error_input');
}
}
function add2SelectBoxAndRemove(formular, from_select, to_select) {
var x = 0;
var newArray = new Array();
var removeArray = new Array();
element_from = formular.elements[from_select];
element_to = formular.elements[to_select];
for (var i=0; i < element_from.options.length; i++){
if (element_from.options[i].selected) {
var newOption = document.createElement("option");
newOption.text = element_from.options[i].text;
newOption.value = element_from.options[i].value;
element_to.options.add(newOption);
element_from.remove(i);
--i;
}
}
}
function clearSelectBox(element) {
elem = document.getElementById(element);
elem.length = 0;
}
function selectAll(formular,selectBox) {
f = formular.name;
for (var i=0; i < formular.elements[selectBox].options.length; i++){
formular.elements[selectBox].options[i].selected = true;
}
}
function resetSelectBox(formular,selectBox) {
for (var i=0; i < formular.elements[selectBox].options.length; i++){
formular.elements[selectBox].options[i] = null
}
}
function add2SelectBox(formular, from_select, to_select) {
var x = 0;
var newArray = new Array();
var removeArray = new Array();
element_from = formular.elements[from_select];
element_to = formular.elements[to_select];
for (var i=0; i < element_from.options.length; i++){
if (element_from.options[i].selected) {
var newOption = document.createElement("option");
newOption.text = element_from.options[i].text;
newOption.value = element_from.options[i].value;
element_to.options.add(newOption);
element_from.options[i].selected = false;
}
}
}
function removeFromSelectBox(formular, form_select) {
var x = 0;
element_form = formular.elements[form_select];
for (var i=0; i < element_form.options.length; i++){
if (element_form.options[i].selected) {
element_form.remove(i);
--i;
}
}
}
/*========================[ Alte Funktionen die irgendwann ersetzt / abgelösst werden können ]=======================*/
function alertBasicErrorMessage(error_text) {
if (error_text == '') {
error_text = '
Die wichtigsten Fakten und Informationen haben wir für Sie in einer Broschüre zusammengefasst. Durch einen Klick auf die Grafik können Sie sich die Datei herunterladen.