(function ($) { $.fn.selectIndex = function (index) { return this.each(function () { var $this = $(this); var sel = $this.is("select") ? $this : $this.find("select"); sel.val(sel.find("option").eq(index).val()); }); }; $.fn.showHideIn = function (prefix, showIndex, hideIndex, setValidator) { $(this).attr('data-' + prefix + 'ShowIn', showIndex); $(this).attr('data-' + prefix + 'HideIn', hideIndex); if (setValidator) { $(this).attr('data-' + prefix + 'Validator', true); } return $(this); }; function showOrHide(prefix, index, animated) { animated = animated !== false; $('[data-' + prefix + 'ShowIn]').each(function () { if ($.inArray(index.toString(), $(this).attr('data-' + prefix + 'ShowIn').split(',')) != -1) { $(this).slideDown(animated ? "fast" : 0); if ($(this).attr('data-' + prefix + 'Validator')) { $(this).enableValidator(true); } } }); $('[data-' + prefix + 'HideIn]').each(function () { if ($.inArray(index.toString(), $(this).attr('data-' + prefix + 'HideIn').split(',')) != -1) { $(this).slideUp(animated ? "fast" : 0); if ($(this).attr('data-' + prefix + 'Validator')) { $(this).disableValidator(true); } } }); } $(function () { $(document).ready(function (animated) { // Blende Bereiche mit deaktivierten Auswahlelementen aus var parentSection = $('*[disabled=disabled]').not('.ddlCountry, .dontHide').parent('p').hide().parent('section'); // Blende Sektionen ohne Sichtbaren Inhalt (p-tags) aus if (parentSection.children('p:visible').length == 0) { parentSection.hide(); } var ref = document.referrer; $('.referrer_div input[type=hidden]').val(ref); $('.postal_div input[type=hidden]').val("Aus datenschutzrechtlichen Gründen bekommen Sie gegebenenfalls eine postalische Antwort."); var d = new Date(); var month = d.getMonth() + 1; var day = d.getDate(); var output = 'Ihre Nachricht an ERGO vom ' + (day < 10 ? '0' : '') + day + '.' + (month < 10 ? '0' : '') + month + '.' + d.getFullYear(); $('.date_div input[type=hidden]').val(output); var refList = $('.nameValueList_div input[type=hidden]').val(); if (typeof refList == 'undefined') refList = ''; var splittedList = refList.split('&'); var dictionaryList = new Object(); for (var i = 0; i < splittedList.length; i++) { dictionaryList[i] = splittedList[i].split('='); } var referrer = $('.referrer_div input[type=hidden]').val(); if (typeof referrer == 'undefined') referrer = ''; var key; for (key in dictionaryList) { var keyValuePair = dictionaryList[key]; var paths = decodeURIComponent(keyValuePair[1]).split(';'); var index, value, result; for (index = 0; index < paths.length; ++index) { value = paths[index]; if (referrer.search(value) != -1) { result = value; } } if (result != undefined && result.length > 0) { /* var nachricht = "Ich habe mir gerade folgende Seite angesehen:\r" + referrer + "\r\rBitte erstellen Sie mir ein Angebot dazu!"; $('.tbxxNachricht').val(nachricht); $(".betreff").val(1); */ $(".lZip").text("PLZ* / Ort"); $(".hide-innumber").slideUp(animated ? "fast" : 0); $(".bdaydiv").slideDown(animated ? "fast" : 0); $(".hide-customer").slideDown(animated ? "fast" : 0); $(".hidethema1").slideDown(animated ? "fast" : 0); $(".hide-weitergabe").slideDown(animated ? "fast" : 0); $(".rfvThema1").enableValidator(); $(".rblCustomer").enableValidator(); $(".rfvZip").enableValidator(); if (($(".ddlCountry").val()) != "D") { $(".revZip").disableValidator(); } $(".thema").val(keyValuePair[0]); break; } } if (($(".ddlCountry").val()) == "D") { $(".revZip").enableValidator(); $(".revCity").enableValidator(); } else { $(".revZip").disableValidator(); $(".revCity").disableValidator(); } hideOrShowThema4(); }); $(".rblCustomer").radioChecked(0, function (animated) { $(".hide-innumber").slideDown(animated ? "fast" : 0); if ($(".betreff").val() == 5) { $(".hide-erklaerung").slideDown(animated ? "fast" : 0); } }); $(".rblCustomer").radioChecked(1, function (animated) { $(".hide-innumber").slideUp(animated ? "fast" : 0); $(".hide-erklaerung").slideUp(animated ? "fast" : 0); }); $("div.addresscontainer").each(function () { var salutation = $(this), title, firstname, $title = salutation.find(".title"), $firstname = salutation.find(".firstname"); salutation.find(".salutation").radioChecked(2, function () { // Firma ist ausgewählt var tbBday = $(".tbBday"); tbBday.prop("disabled", true); tbBday.val(""); tbBday.disableValidator(); $title.attr("disabled", true).addClass("disabled"); title = $title.val(); $title.val(""); $firstname.attr("disabled", true).addClass("disabled").disableValidator(); firstname = $firstname.val(); $firstname.val(""); }, function () { // Herr oder Frau ist ausgewählt var tbBday = $(".tbBday"); tbBday.prop("disabled", false); tbBday.enableValidator(); $title.attr("disabled", false).removeClass("disabled"); if (!$title.val() && title) $title.val(title), title = null; $firstname.attr("disabled", false).removeClass("disabled"); if (!$firstname.val() && firstname) $firstname.val(firstname), firstname = null; }, function () { // Nichts ist ausgewählt $firstname.enableValidator(); }); }); $(".ddlCountry").change(function () { if (($(".ddlCountry").val()) == "D") { $(".revZip").enableValidator(); $(".revCity").enableValidator(); } else { $(".revZip").disableValidator(); $(".revCity").disableValidator(); } }); $('.hideaddress, .hidephone').showHideIn('betreff', [1, 2, 3, 4, 6, 7], [5]); $('.hide-innumber').showHideIn('betreff', [2, 3, 4, 5], [1, 6, 7]); $('.hide-customer').showHideIn('betreff', [1, 6, 7], [0, 2, 3, 4, 5]); $('.bdaydiv, .hide-weitergabe').showHideIn('betreff', [1, 7], [0, 2, 3, 4, 5, 6], true); $('.hidethema1').showHideIn('betreff', [1], [0, 2, 3, 4, 5, 6, 7], true); $('.hidethema2').showHideIn('betreff', [2, 3], [0, 1, 4, 5, 6, 7], true); $('.hidethema3').showHideIn('betreff', [7], [0, 1, 2, 3, 4, 5, 6], true); $('.hide-erklaerung').showHideIn('betreff', [2], [0, 1, 3, 4, 5, 6, 7]); $('.meineversicherungen-infotext').showHideIn('betreff', [4], [0, 1, 2, 3, 5, 6, 7]); $('.fragen-infotext').showHideIn('betreff', [2], [0, 1, 3, 4, 5, 6, 7]); $('.schadennrp').showHideIn('betreff', [3], [0, 1, 2, 4, 5, 6, 7]); showOrHide('betreff', $('.betreff').find('option:selected').index(), false); $('.betreff').change(function () { var selectedIndex = $(this).find('option:selected').index(); showOrHide('betreff', selectedIndex); }); $(".betreff").optionSelected([1, 7], function (animated) { $(".lZip").text("PLZ* / Ort"); $(".rblCustomer").enableValidator(); $("#hidebdaysum").show(); if ($(".salutation").val() != 2) { $(".tbBday").enableValidator(); } else { $(".tbBday").disableValidator(); } // Lasse nur Deutschland zu }, function (animated) { $(".lZip").text("PLZ / Ort"); $("#hidebdaysum").hide(); $(".rblCustomer").disableValidator(); $(".rblCustomer").removeAttr("checked"); var options = $(".rblCustomer").find('input:radio'); options.removeAttr('checked'); }); $(".betreff").optionSelected([1, 2, 3, 4, 7], function (animated) { $(".rfvZip").enableValidator(); if (($(".ddlCountry").val()) != "D") { $(".revZip").disableValidator(); } $('.postal_div input[type=hidden]').val("Aus datenschutzrechtlichen Gründen bekommen Sie gegebenenfalls eine postalische Antwort."); }, function (animated) { $(".rfvZip").disableValidator(); $(".lZip").text("PLZ / Ort"); }); $(".betreff").optionSelected([2, 3, 4], function (animated) { $(".rfvStreet").enableValidator(); $(".rfvCity").enableValidator(); if (($(".ddlCountry").val()) != "D") { $(".revCity").disableValidator(); } $(".lZip").text("PLZ* / Ort*"); $(".lStreet").html("Straße* / Nr.*"); $(".lCountry").text("Land*"); if ($(".salutation").find("input:radio").eq(2).is(":checked")) { firstnameRequ(false); } else { firstnameRequ(true); } }, function (animated) { $(".rfvStreet").disableValidator(); $(".rfvCity").disableValidator(); if (($(".ddlCountry").val()) == "D") { $(".revCity").enableValidator(); } $(".lStreet").text("Straße / Nr."); $(".lCountry").text("Land"); firstnameRequ(false); }); $(".betreff").optionSelected([3], function (animated) { }, function (animated) { $(".tbSnummer").val(""); }); $(".betreff").optionSelected([4, 5, 6], function (animated) { $('.postal_div input[type=hidden]').val(""); $(".tbVnummer").val(""); }); $(".betreff").optionSelected([1, 5], function (animated) { $(".rblCustomer :checked").prop('checked', false); }); $('.hidethema1').change(function () { hideOrShowThema4(); }); $('.betreff').change(function () { hideOrShowThema4(); }); function hideOrShowThema4() { if ($(".betreff :selected").val() == 1 && $('.hidethema1 :selected').val() == 5) { $('.hidethema4').slideDown("fast"); $(".rfvThema4").enableValidator(); } else { $('.hidethema4').slideUp(0); $(".rfvThema4").disableValidator(); } }; function disableTelValidator() { $('.tbhiddenPhone').disableValidator(); } $('.tbPhone').blur(disableTelValidator); $('.tbMobile').blur(disableTelValidator); function firstnameRequ(arg) { if (arg) { $(".firstname").enableValidator(); $(".lbaddrfirstname").text("Vorname*"); } else { $(".firstname").disableValidator(); $(".lbaddrfirstname").text("Vorname"); } } $(".salutation").radioChecked(2, function () { firstnameRequ(false); }, function () { if ($(".betreff").val() == "2" || $(".betreff").val() == "3" || $(".betreff").val() == "6") { firstnameRequ(true); } else { firstnameRequ(false); } }); }); })(jQuery);