var $div = $('
').appendTo($('body')); $div.html(''); var ieTest = $div.find('a').length; $div.remove(); return ieTest; } function alertMessage(headline,text,type) { container = $('#alertMessage'); if (typeof(headline) == 'undefined') headline = 'Fehler'; msgClass = (type) ? 'success' : 'error'; container.removeAttr('class'); container.addClass(msgClass); container.width($(window).width() * 0.8); $('#messageHeadline').html(headline); $('#messageText').html(text); centerMe(container,true); container.show(); } function centerMe(element,windowMode) { var top = 0; var left = 0; if (typeof(windowMode) == 'undefined') windowMode = false; thisWidth = element.width(); thisHeight = element.height(); if (windowMode) { var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ? window.document.documentElement : window.document.body || null; windowHeight = $(window).height() / 2; windowWidth = $(window).width() / 2; top = windowHeight - (thisHeight / 2) + parseInt(window.pageYOffset || body.scrollTop) ; left = windowWidth - (thisWidth / 2) + parseInt(window.pageXOffset || body.scrollLeft); if (top < 50) { top = 50; } } else { parentWidth = element.parent().css('width').replace('px',''); parentHeight = element.parent().css('height').replace('px',''); parentWidth = parseInt(parentWidth); parentHeight = parseInt(parentHeight); top = (parentHeight / 2) - (thisHeight / 2); left = (parentWidth / 2) - (thisWidth / 2); } element.css('top',top+'px'); element.css('left',left+'px'); } function overflowMe(element) { thisWidth = element.width(); thisHeight = element.height(); if (thisWidth > 0 && thisHeight > 0) { calculateOverflow(element); } else { $(element).load(function(esponse, status, xhr) { calculateOverflow($(this)); }); } } function calculateOverflow(element) { thisWidth = element.width(); thisHeight = element.height(); parentWidth = element.parent().actual('width'); parentHeight = element.parent().actual('height'); if (thisWidth > thisHeight) { factor = parentWidth / thisWidth; finalWidth = parentWidth; finalHeight = thisHeight * factor; if (finalHeight < parentHeight) { factorScale = (parentHeight / thisHeight); finalHeight = parentHeight; finalWidth = thisWidth * factorScale; } } else { factor = parentHeight / thisHeight; finalHeight = parentHeight; finalWidth = thisWidth * factor; if (finalWidth < parentWidth) { factorScale = (parentWidth / thisWidth); finalWidth = parentWidth; finalHeight = thisHeight * factorScale; } } marginLeft = Math.floor((parentWidth - finalWidth) / 2); marginTop = Math.floor((parentHeight - finalHeight) / 2); cssObj = { 'width' : finalWidth+'px', 'height' : finalHeight+'px', 'marginLeft' : marginLeft+'px', 'marginTop' : marginTop+'px' }; $(element).css(cssObj); } function scaleMe (element) { thisWidth = element.width(); thisHeight = element.height(); if (thisWidth > 0 && thisHeight > 0) { calculateScale(element); } else { $(element).load(function(esponse, status, xhr) { calculateScale($(this)); }); } } function calculateScale(element) { thisWidth = element.width(); thisHeight = element.height(); parentWidth = element.parent().actual('width'); parentHeight = element.parent().actual('height'); if (thisWidth > thisHeight) { factor = parentWidth / thisWidth; finalWidth = parentWidth; finalHeight = thisHeight * factor; if (finalHeight > parentHeight) { factor = parentHeight / thisHeight; finalHeight = parentHeight; finalWidth = thisWidth * factor; } } else { factor = parentHeight / thisHeight; finalHeight = parentHeight; finalWidth = thisWidth * factor; if (finalWidth > parentWidth) { factor = parentWidth / thisWidth; finalWidth = parentWidth; finalHeight = thisHeight * factor; } } marginLeft = Math.floor((parentWidth - finalWidth) / 2); marginTop = Math.floor((parentHeight - finalHeight) / 2); cssObj = { 'width' : finalWidth+'px', 'height' : finalHeight+'px', 'marginLeft' : marginLeft+'px', 'marginTop' : marginTop+'px' }; $(element).css(cssObj); } function fullWidthMe(element) { thisWidth = element.width(); thisHeight = element.height(); if (thisWidth > 0 && thisHeight > 0) { calculateFullWidth(element); } else { $(element).load(function(esponse, status, xhr) { calculateFullWidth($(this)); }); } } function calculateFullWidth(element) { thisWidth = element.width(); thisHeight = element.height(); parentWidth = element.parent().actual('width'); factor = parentWidth / thisWidth; finalWidth = parentWidth; finalHeight = thisHeight * factor; cssObj = { 'width' : finalWidth+'px', 'height' : finalHeight+'px', }; $(element).css(cssObj); } /*****************************************************/ /* Update a jqTransform Selectbox */ function updateJqSelect(selector,callback) { selectedVal = $(selector).children(':selected').val(); $(selector).children('option').removeAttr('selected'); $(selector).children('option[value="'+selectedVal+'"]').attr('selected','selected'); $(selector).removeClass('jqTransformHidden'); $(selector).css('display','block'); $(selector).prev('ul').remove(); /*$(selector).prev('div.selectWrapper').remove();*/ $(selector).prev('div.jqTransformElement').remove(); var selectElm = $(selector).closest('.jqTransformSelectWrapper').html(); $(selector).closest('.jqTransformSelectWrapper').after(selectElm); $(selector).closest('.jqTransformSelectWrapper').remove(); $(selector).closest('form').removeClass('jqtransformdone'); $(selector).closest('form').jqTransform(); $(selector).removeAttr('style'); if (typeof(callback) != 'undefined') { eval(callback+'("'+selector+'")'); } } /**fix_select('select#my_updated_select_box');*/ function addToFavorites() { if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark window.sidebar.addPanel(document.title,window.location.href,''); } else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite window.external.AddFavorite(location.href,document.title); } else if(window.opera && window.print) { // Opera Hotlist this.title=document.title; return true; } else { // webkit - safari/chrome //alert('Drücken Sie ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'STRG') + ' + D um die Seite zu Ihren Favoriten hinzuzufügen.'); alertBasicErrorMessage('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 = "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+'Bitte füllen Sie alle Pflichtfelder aus!
'; } error_text = '