PageSourceSearch

https://www.stadtwerke-karlsruhe.de/wLayout/wGlobal/layout/scripts…orm-tarifeBestellstreckeAll.js?260904160011

js stadtwerke-karlsruhe.de collected 2026-09-24 20:57:29 UTC 88,419 bytes, 1,821 lines download raw bytes

1console.log('form-tarifeBestellstreckeAll.js');
2
3wMaskAutofillIfConditionalHidden        = false; //Falls bedingt ausgeblendete Eingabefelder für die Autofill-Funktion deaktiviert werden sollen
4
5tarifeAutocompleteItems = {}; 
6tarifeVersorger         = {};   
7tarifeProduktAlt        = {};
8
9tarifeDateIsShift       = false;  
10tarifeDateSeperator     = ".";
11
12if(typeof wEditor == 'undefined') {       
13  //Zurücksetzen
14  document.addEventListener('DOMContentLoaded', function waitUntilContentLoaded(){
15    if(!window.jQuery){
16      return setTimeout(waitUntilContentLoaded, 100);
17    }
18    jQuery(document).ready(function(){
19      //console.log('zurücksetzen bestimmter design.js-Werte');
20      wResetConditionalFormdataOnHide = false; //Falls beim Ausblenden bedingter Formularfelder die Werte zurückgesetzt werden sollen
21      wScrollSmoothToElementEasing    = 'swing'; //Easing Funktion beim automatischen Scrollen zu einem Element
22    });
23  }, false);
24}
25
26jQuery(document).ready(function() {
27  if(typeof wEditor == 'undefined') {
28
29    //console.log('form-tarifeBestellstreckeAll.js: '+jQuery('form.frmTarifCockpitAdministration .autocompleteContainer span.opener').length);
30
31		//jQuery('form.frmTarifCockpitAdministration .autocompleteContainer span.opener').on('touchstart click', function(e){ //, form.frmTarifeBestellstrecke .autocompleteContainer span.opener
32    jQuery('body').delegate('form.frmTarifCockpitAdministration .autocompleteContainer span.opener, form.frmTarifeBestellstrecke .autocompleteContainer span.opener', 'click', function(e){
33      var span   = jQuery(this);
34      //var id    = span.attr('id');
35      var form  = span.parents('form');
36      var inp   = span.prev();
37      var cont  = span.parents().parents();
38      //console.log('autocompleteContainer: ');
39
40      if(inp.length > 0) {
41        var name  = inp.attr('name');
42        //console.log('autocompleteContainer: '+name);
43        //alert(name);
44        if(cont.hasClass('formElementInputReadonly') || cont.hasClass('formElementInputReadonlyTmp')) {
45          e.preventDefault();
46          e.stopPropagation();
47        } else {
48          //console.log('autocompleteContainer: '+name+' == search');
49          if(span.parents().hasClass('autocompleteOpened')) {
50            inp.autocomplete('close');
51          } else {
52            inp.autocomplete('search', 'SHOWALL');
53          }
54        }
55      } else {
56        //console.log('autocompleteContainer: no INP');
57      }
58    });
59
60		//Zählernummern und Marktlokations-Nummern von Leerzeichen bereinigen
61		jQuery('form.frmTarifeBestellstrecke input[name^="lieferstelle-zaehlernummer"], form.frmTarifeBestellstrecke input[name^="lieferstelle-marktlokationsnummer"], form.frmTarifeBestellstrecke input[name^="zaehlernummer"], form.frmTarifeBestellstrecke input[name^="marktlokationsID"]').on('keyup', function(e){
62      var inp 	= jQuery(this);
63      var val 	= inp.val();
64      var val2 	= val.replace(/\s/g, '');
65
66      inp.val(val2);
67			//console.log('removeSpaces: '+inp.attr('name')+' => '+val+' || '+val2);
68    });
69  }
70});
71
72function tarifeObjectLength(obj) {
73	return jQuery.map(obj, function(n, i) { return i; }).length;
74}
75
76function tarifeUnEntity(str) {
77  sendBack = '';
78  if(str != undefined && str != null && str != '') {
79    sendBack = str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
80  }
81  //console.log(str+' => '+sendBack);
82  return sendBack;
83}
84
85function tarifeCheckLabel4Empty(inp, valLength) {
86	if(inp !== undefined && inp !== null) {
87	  //tarifeShowDebugInfo('plz-blur', inp, 'blur', false, 'input[name="plz"] blur');
88	  var hasEmpty = (inp.parent().parent().hasClass('empty')) ? true : false
89	  var val = inp.val().trim();
90	  if(val !== undefined && val !== null && val !== '') {
91		  //console.log('tarifeCheckLabel4Empty:'+inp.attr('name')+' :: '+val+'('+val.length+') :: => '+hasEmpty);
92		  if(hasEmpty == true) {
93		  	if(valLength == null || val.length == valLength) {
94		  		inp.parent().parent().removeClass('empty');
95		  		//alert('remove empty');
96		  		//console.log('remove empty');
97		  	}
98		  }
99	  }
100	}
101}
102
103function tarifeCreateAutocomplete(form, name) {
104  if(name == 'plz' || name == 'rechnungsanschrift_plz' || name == 'kontoinhaber_plz') { 
105    var selector = form.find('input[name="'+name+'"]');   
106    //alert('name: '+name+' : '+selector.length);
107    if(selector.length > 0) {
108      selector.attr('autocomplete', 'nope');  //off not working
109      selector.parent().addClass('autocompleteContainer'); 
110      selector.parent().addClass('autocompleteContainerPLZ');
111      form.find('input[name="'+name+'"]').autocomplete({
112        source: function(request, response) {   
113          var element       = jQuery(this.element);                     
114          var elementName   = element.attr('name');
115          var elementForm   = element.parents('form'); 
116          var plz           = '';                                                     
117          var verwendung    = elementForm.find('select[name="verwendung"]').val();
118          var bestandskunde = elementForm.find('select[name="bestandskunde"]').val();
119          var produktsparte = elementForm.find('select[name="produktsparte"]').val();    
120          var viewmode      = 'tarifBestellstreckePLZ';
121
122          if(elementName == 'plz') {
123            plz       = elementForm.find('input[name="plz"]').val(); 
124          } else if(elementName == 'rechnungsanschrift_plz') {
125            plz       = elementForm.find('input[name="rechnungsanschrift_plz"]').val();
126            viewmode  = 'tarifBestellstreckePLZ2';
127          } else if(elementName == 'kontoinhaber_plz') {
128            plz       = elementForm.find('input[name="kontoinhaber_plz"]').val(); 
129            viewmode  = 'tarifBestellstreckePLZ2';
130          }    
131
132          //console.log('name: '+elementName);  
133          //console.log('plz: '+plz);
134          //console.log('produktsparte: '+produktsparte);
135
136          jQuery.ajax({
137            url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
138            dataType: 'json',
139            data: {
140              viewmode: viewmode,
141              val: request.term,                                                  
142              plz: plz,                       
143              verwendung: verwendung,
144              bestandskunde: bestandskunde,
145              produktsparte: produktsparte  
146            },
147            success: function(json) {
148              //response(json.data);
149              if(json.success == true) {         
150                var c=0;
151                response(jQuery.map(json.dataPrep, function(item) {
152                  //alert(item.strong+"\n"+item.standard+"\n"+((item.standard != '') ? item.standard+'' : '')+"\n"+((item.standard !== '') ? item.standard+'' : ''));
153                  if(c == 0) {
154                    tarifeAutocompleteItems[elementName] = item;
155                  }
156                  c++;
157
158                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : ''),
159                  //var label = ((item.strong != undefined && item.strong != null && item.strong != '' && item.strong != 'false') ? tarifeUnEntity(item.strong) : '')+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : '')+((item.ort != undefined && item.ort != null && item.ort != '' && item.ort != 'false') ? ' '+tarifeUnEntity(item.ort) : ''),
160                  //var label = (((item.plz != undefined && item.plz != null && item.plz != '' && item.plz != 'false') ? tarifeUnEntity(item.plz) : '')+((item.ort != undefined && item.ort != null && item.ort != '' && item.ort != 'false') ? ' '+tarifeUnEntity(item.ort) : '')).trim();
161                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : (((item.plz != undefined && item.plz != null && item.plz != '' && item.plz != 'false') ? tarifeUnEntity(item.plz) : '')+((item.ort != undefined && item.ort != null && item.ort != '' && item.ort != 'false') ? ' '+tarifeUnEntity(item.ort) : ''))).trim();
162                  var value = tarifeUnEntity(item.plz);
163                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
164                		var replace = '(.*)('+item.regexp+')(.*)';
165                  	//console.log('label: '+label);
166                  	//console.log('replace: '+replace);
167                		var re = new RegExp(replace, "gi");
168                  	label = label.replace(re, '$1<strong>$2</strong>$3');
169                  	//console.log('label: '+label);
170                  }
171                     
172                  //console.log('item: '+JSON.stringify(item));
173                  return {
174                    //label: '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : ''),
175                    label: label,
176                    value: value,
177                    itemData: item
178                  } 
179                }));
180                //response(json.data);
181              }
182            }
183          });
184        },
185        minLength: 1,
186        autoFocus: true,
187        //appendTo: '#plzContainer',         
188        appendTo: selector.parent(), 
189        select: function(event, ui) {     
190          //console.log('autocomplete: select: '+this.value);
191          //jQuery("input#plzAreaInput").trigger('change');
192         
193          //*
194          var element     = jQuery(this);                  
195          var elementName = element.attr('name');
196          var elementForm = element.parents('form');  
197          //console.log('name: '+elementName);  
198          
199          //if(jQuery('html').hasClass('isAdmSC')) {
200          //  console.log('autocomplete: select');
201          //}    
202          //console.log(ui.item ?
203          //"Selected: " + ui.item.label :
204          //"Nothing selected, input was " + this.value);
205
206          //console.log(ui.item);     
207          //console.log(ui.item.itemData);   
208             
209          if(ui.item.itemData.plz != undefined && ui.item.itemData.plz != null && ui.item.itemData.plz != '') { 
210            element.val(ui.item.itemData.plz);    
211            //console.log('autocomplete: select: '+ui.item.itemData.plz);
212            tarifeAutocompleteItems[elementName] = null;
213          }
214          
215          tarifeAddOrRemoveEmpty(element, element.val(), 'remove');
216          
217          //wglValidateElementInline(element, {'clientside' : elementForm.attr('action').indexOf('/weblication/grid5/tmpHTTP/wF
217orm-') == -1});
218          
219          var fieldNames  = tarifeGetPLZ4StreetFieldNames(elementName);   
220          var fieldInputs = tarifeGetPLZ4StreetFieldInputs(elementForm, fieldNames); 
221          //var fieldValues = getPLZ4StreetFieldValues(fieldInputs);
222          //console.log('tarifeCheckPLZ4Street - select: '+elementName+': '+JSON.stringify(fieldNames)); 
223          //console.log('tarifeCheckPLZ4Street: '+name+': '+JSON.stringify(fieldValues));
224
225          if(fieldInputs['ort'] != null && fieldInputs['ort'].length > 0 && ui.item.itemData.ort != undefined && ui.item.itemData.ort != null && ui.item.itemData.ort != '') {
226            fieldInputs['ort'].val(ui.item.itemData.ort);     
227            
228            if(elementName == 'plz' && elementForm.find('input[name="plz_ort_dummy"]').length > 0) {
229              elementForm.find('input[name="plz_ort_dummy"]').val(ui.item.itemData.ort);
230            }
231            
232            tarifeAddOrRemoveEmpty(fieldInputs['ort'], ui.item.itemData.ort, 'remove');
233            //tarifeTriggerValidationEvent(elementForm, fieldInputs['ort'], 'change', false, 'autocomplete-select-'+elementName); 
234                  
235            if(fieldInputs['strasse'] != null && fieldInputs['strasse'].length > 0) {
236              fieldInputs['strasse'].val('');       
237              tarifeAddOrRemoveEmpty(fieldInputs['strasse'], '', 'add');
238              //tarifeTriggerValidationEvent(elementForm, fieldInputs['strasse'], 'change', false, 'autocomplete-select-'+elementName);  
239            } 
240            if(fieldInputs['hausnummer'] != null && fieldInputs['hausnummer'].length > 0) {
241              fieldInputs['hausnummer'].val('');      
242              tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], '', 'add');
243              //tarifeTriggerValidationEvent(elementForm, fieldInputs['hausnummer'], 'change', false, 'autocomplete-select-'+elementName); 
244            }
245          } 
246          tarifeTriggerValidationEvent(elementForm, element, 'blur', false, 'autocomplete-select-'+elementName);
247           
248          tarifeCheckPLZ4Street(elementForm, elementName, 'autocomplete-select: '+elementName);
249   
250          if(elementName == 'plz') {
251            plz2Dummy(element);
252          }
253          //wAdaptConditionalFormData();
254          //*/ 
255        },
256        create: function(event, ui) {                                         
257          //console.log('autocomplete CREATE');
258          jQuery(this).attr('autocomplete', 'nope').parent().addClass('autocompleteCreated'); 
259        },
260        open: function(event, ui) {                   
261          //console.log('autocomplete OPEN');                    
262          //console.log('autocomplete OPEN autocompleteFirstItem: '+autocompleteFirstItem);
263          jQuery(this).parent().addClass('autocompleteOpened'); 
264          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').addClass('autocompleteOpened');
265        },
266        close: function(event, ui) {      
267          //console.log('autocomplete CLOSE');         
268          //console.log('autocomplete CLOSE autocompleteFirstItem: '+autocompleteFirstItem);
269          jQuery(this).parent().removeClass('autocompleteOpened');        
270          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').removeClass('autocompleteOpened');
271        },
272        change: function (event, ui) {  
273          //console.log('autocomplete: change: '+this.value);         
274          var element     = jQuery(this);                  
275          var elementName = element.attr('name');           
276          var elementVal  = element.val();     
277          var elementForm = element.parents('form');
278          //console.log('name: '+elementName+' == '+elementVal);
279          
280          var usedItem =null; 
281          //usedItem = ui.item;
282          if(ui.item === null) {
283            if(tarifeAutocompleteItems[elementName] !== undefined && tarifeAutocompleteItems[elementName] !== null && tarifeAutocompleteItems[elementName] !== '') {
284              usedItem = tarifeAutocompleteItems[elementName];
285            }
286          }       
287          //console.log('usedItem - change: '+elementName+': '+JSON.stringify(ui.item));
288          //console.log('tarifeAutocompleteItems[elementName] - change: '+elementName+': '+JSON.stringify(tarifeAutocompleteItems[elementName])); 
289
290          //*
291          //console.log('autocomplete ('+elementName+'): change');
292          if(ui.item === null && usedItem !== null) {     
293            if(elementVal != undefined && elementVal != null && elementVal != '' && elementVal.length == 5) {          
294              tarifeAddOrRemoveEmpty(element, elementVal, 'remove');
295              if(usedItem !== undefined && usedItem !== null && usedItem !== '') {
296                //console.log('autocomplete ('+elementName+'): '+JSON.stringify(usedItem));
297                var fieldNames  = tarifeGetPLZ4StreetFieldNames(elementName);   
298                var fieldInputs = tarifeGetPLZ4StreetFieldInputs(elementForm, fieldNames); 
299                //var fieldValues = getPLZ4StreetFieldValues(fieldInputs);
300                //console.log('tarifeCheckPLZ4Street - select: '+elementName+': '+JSON.stringify(fieldNames)); 
301                //console.log('tarifeCheckPLZ4Street: '+name+': '+JSON.stringify(fieldValues));
302                if(fieldInputs['ort'] != null && fieldInputs['ort'].length > 0 && usedItem['ort'] != undefined && usedItem['ort'] != null && usedItem['ort'] != '') {
303                  fieldInputs['ort'].val(tarifeAutocompleteItems[elementName]['ort']);              
304                  tarifeAddOrRemoveEmpty(fieldInputs['ort'], tarifeAutocompleteItems[elementName]['ort'], 'remove');
305                  tarifeTriggerValidationEvent(elementForm, fieldInputs['ort'], 'change', true, 'autocomplete-change-'+elementName); 
306                  if(fieldInputs['strasse'] != null && fieldInputs['strasse'].length > 0) {
307                    fieldInputs['strasse'].val('');              
308                    tarifeAddOrRemoveEmpty(fieldInputs['strasse'], '', 'add');
309                    tarifeTriggerValidationEvent(elementForm, fieldInputs['strasse'], 'change', true, 'autocomplete-change-'+elementName); 
310                  } 
311                  if(fieldInputs['hausnummer'] != null && fieldInputs['hausnummer'].length > 0) {
312                    fieldInputs['hausnummer'].val('');  
313                    tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], '', 'add');  
314                    tarifeTriggerValidationEvent(elementForm, fieldInputs['hausnummer'], 'change', true, 'autocomplete-change-'+elementName);
315                  }
316                }
317              }       
318            } else if(elementVal.length > 0) {
319              element.val(''); 
320              tarifeAddOrRemoveEmpty(element, '', 'add'); 
321              tarifeTriggerValidationEvent(elementForm, element, 'change', false); 
322
323              var fieldNames  = tarifeGetPLZ4StreetFieldNames(elementName);   
324              var fieldInputs = tarifeGetPLZ4StreetFieldInputs(elementForm, fieldNames); 
325              //var fieldValues = getPLZ4StreetFieldValues(fieldInputs);
326              //console.log('tarifeCheckPLZ4Street - select: '+elementName+': '+JSON.stringify(fieldNames)); 
327              //console.log('tarifeCheckPLZ4Street: '+name+': '+JSON.stringify(fieldValues));
328              if(fieldInputs['ort'] != null && fieldInputs['ort'].length > 0) {
329                fieldInputs['ort'].val('');                          
330                tarifeAddOrRemoveEmpty(fieldInputs['ort'], '', 'add'); 
331                tarifeTriggerValidationEvent(elementForm, fieldInputs['ort'], 'change', true, 'autocomplete-change-'+elementName); 
332                if(fieldInputs['strasse'] != null && fieldInputs['strasse'].length > 0) {
333                  fieldInputs['strasse'].val('');                          
334                  tarifeAddOrRemoveEmpty(fieldInputs['strasse'], '', 'add');   
335                  tarifeTriggerValidationEvent(elementForm, fieldInputs['strasse'], 'change', true, 'autocomplete-change-'+elementName); 
336                } 
337                if(fieldInputs['hausnummer'] != null && fieldInputs['hausnummer'].length > 0) {
338                  fieldInputs['hausnummer'].val('');   
339                  tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], '', 'add');   
340                  tarifeTriggerValidationEvent(elementForm, fieldInputs['hausnummer'], 'change', true, 'autocomplete-change-'+elementName);  
341                }
342              }
343            }
344          }
345          //*/
346          
347          if(elementName == 'plz') {
348            plz2Dummy(element);
349          }
350
351          //tarifeCheckPLZ4Street(elementForm, elementName, 'autocomplete-change: '+elementName);
352        }
353      }).data("ui-autocomplete")._renderItem = function(ul, item) {
354         return jQuery("<li></li>")
355											             .data("item.autocomplete", item)
356											             .append("<span>" + item.label + "</span>")
357											             .appendTo(ul);
358    	};
359    }
360  } else if(name == 'strasse' || name == 'rechnungsanschrift_strasse' || name == 'kontoinhaber_strasse') {
361    var selector = form.find('input[name="'+name+'"]');   
362    //alert('name: '+name+' : '+selector.length);
363    if(selector.length > 0) {            
364      selector.attr('autocomplete', 'nope');  //off not working 
365      selector.parent().addClass('autocompleteContainer'); 
366      //selector.parent().addClass('autocompleteContainerStrasse');
367      //jQuery('<span class="opener">&#160;</span>').insertAfter(selector);  
368      form.find('input[name="'+name+'"]').autocomplete({
369        source: function(request, response) {   
370          var element       = jQuery(this.element);                     
371          var elementName   = element.attr('name'); 
372          var elementForm   = element.parents('form'); 
373          var plz           = ''; 
374          var ort           = '';  
375          var stadtteil     = ''; 
376          var produktsparte = elementForm.find('select[name="produktsparte"]').val();    
377
378          if(elementName == 'strasse') {
379            plz       = elementForm.find('input[name="plz"]').val(); 
380            ort       = elementForm.find('input[name="ort"]').val();  
381            stadtteil = elementForm.find('input[name="stadtteil"]').val();
382          } else if(elementName == 'rechnungsanschrift_strasse') {
383            plz       = elementForm.find('input[name="rechnungsanschrift_plz"]').val(); 
384            ort       = elementForm.find('input[name="rechnungsanschrift_ort"]').val();  
385            stadtteil = elementForm.find('input[name="rechnungsanschrift_stadtteil"]').val();
386          } else if(elementName == 'kontoinhaber_strasse') {
387            plz       = elementForm.find('input[name="kontoinhaber_plz"]').val(); 
388            ort       = elementForm.find('input[name="kontoinhaber_ort"]').val();  
389            stadtteil = elementForm.find('input[name="kontoinhaber_stadtteil"]').val();
390          }    
391
392          //console.log('name: '+elementName);  
393          //console.log('plz: '+plz);
394          //console.log('ort: '+ort);                     
395          //console.log('stadtteil: '+stadtteil);
396          //console.log('produktsparte: '+produktsparte);
397
398          jQuery.ajax({
399            url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
400            dataType: 'json',
401            data: {
402              viewmode: 'tarifBestellstreckeStrasse',
403              val: request.term,                                                  
404              plz: plz,
405              ort: ort,    
406              stadtteil: stadtteil,
407              produktsparte: produktsparte,  
408            },
409            success: function(json) {
410              //response(json.data);
411              if(json.success == true) {         
412                var c=0;
413                response(jQuery.map(json.dataPrep, function(item) {
414                  //alert(item.strong+"\n"+item.standard+"\n"+((item.standard != '') ? item.standard+'' : '')+"\n"+((item.standard !== '') ? item.standard+'' : ''));
415                  if(c == 0) {
416                    tarifeAutocompleteItems[elementName] = item;
417                  }
418                  c++;
419
420                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
421                  //var label = (((item.strasse != undefined && item.strasse != null && item.strasse != '' && item.strasse != 'false') ? tarifeUnEntity(item.strasse) : '')).trim();
422                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : (((item.strasse != undefined && item.strasse != null && item.strasse != '' && item.strasse != 'false') ? tarifeUnEntity(item.strasse) : ''))).trim();
423                  var value = tarifeUnEntity(item.strasse);
424                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
425                		var replace = '(.*)('+item.regexp+')(.*)';
426                  	//console.log('label: '+label);
427                  	//console.log('replace: '+replace);
428                		var re = new RegExp(replace, "gi");
429                  	label = label.replace(re, '$1<strong>$2</strong>$3');
430                  	//console.log('label: '+label);
431                  }
432
433                  return {
434                    label: label,
435                    value: value,
436                    itemData: item
437                  }
438                }));
439                //response(json.data);
440              }
441            }
442          });
443        },
444        minLength: 0,
445        autoFocus: true,
446        //appendTo: '#plzContainer',               
447        appendTo: selector.parent(), 
448        select: function(event, ui) {    
449          var element       = jQuery(this);                  
450          var elementName   = element.attr('name');  
451          var elementForm   = element.parents('form');      
452          //console.log('name: '+elementName);        
453          
454          //if(jQuery('html').hasClass('isAdmSC')) {
455          //  console.log('autocomplete: select');
456          //}    
457          /*
458          console.log(ui.item ?
459          "Selected: " + ui.item.label :
460          "Nothing selected, input was " + this.value);
461          */
462          //console.log(ui.item); 
463          //console.log(ui.item.itemData);   
464                   
465          if(ui.item.itemData.strasse != undefined && ui.item.itemData.strasse != null && ui.item.itemData.strasse != '') { 
466            element.val(ui.item.itemData.strasse);  
467            element.parent().parent().removeClass('empty');
468            tarifeAddOrRemoveEmpty(element, ui.item.itemData.strasse, 'remove', 'autocomplete-select-str');    
469            //console.log('autocomplete: select: '+ui.item.itemData.strasse);
470            tarifeAutocompleteItems[elementName] = null;
471          }
472
473          var hausnummer = tarifeGetInpHausnummerName(elementName);      
474          //console.log('hausnummer: '+hausnummer);
475          if(elementForm.find('input[name="'+hausnummer+'"]').length > 0) {
476            elementForm.find('input[name="'+hausnummer+'"]').val('');     
477            tarifeAddOrRemoveEmpty(elementForm.find('input[name="'+hausnummer+'"]'), '', 'add', 'autocomplete-select-hnr');
478            tarifeTriggerValidationEvent(elementForm, elementForm.find('input[name="'+hausnummer+'"]'), 'change', false, 'autocomplete-select-'+elementName);
479          }           
480          tarifeTriggerValidationEvent(elementForm, element, 'blur', false, 'autocomplete-select-'+elementName);
481
482          wAdaptConditionalFormData();        
483        },
484        create: function(event, ui) {                                         
485          //console.log('autocomplete CREATE');
486          jQuery(this).attr('autocomplete', 'nope').parent().addClass('autocompleteCreated');
487        },
488        open: function(event, ui) {                   
489          //console.log('autocomplete OPEN');                    
490          //console.log('autocomplete OPEN autocompleteFirstItem: '+autocompleteFirstItem);
491          jQuery(this).parent().addClass('autocompleteOpened'); 
492          jQuery(this).parents('form.formCheck4AutocompleteButton').find('bu
492tton').addClass('autocompleteOpened');
493        },
494        close: function(event, ui) {      
495          //console.log('autocomplete CLOSE');         
496          //console.log('autocomplete CLOSE autocompleteFirstItem: '+autocompleteFirstItem);
497          jQuery(this).parent().removeClass('autocompleteOpened');        
498          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').removeClass('autocompleteOpened');
499        },
500        change: function (event, ui) {            
501          //console.log('autocomplete: change');
502          var element     = jQuery(this);                  
503          var elementName = element.attr('name');           
504          var elementVal  = element.val();     
505          var elementForm = element.parents('form');
506          //console.log('autocomplete: change | name: '+elementName+' | '+elementVal);
507
508          if(ui.item === null) {     
509            if(elementVal != undefined && elementVal != null && elementVal != '') {
510             if(tarifeAutocompleteItems[elementName] !== undefined && tarifeAutocompleteItems[elementName] !== null && tarifeAutocompleteItems[elementName] !== '') {  
511                //console.log('autocomplete ('+elementName+'): '+JSON.stringify(tarifeAutocompleteItems[elementName]));
512                if(tarifeAutocompleteItems[elementName]['strasse'] != undefined && tarifeAutocompleteItems[elementName]['strasse'] != null && tarifeAutocompleteItems[elementName]['strasse'] != '') {
513                  element.val(tarifeAutocompleteItems[elementName]['strasse']);      
514                  tarifeAddOrRemoveEmpty(element, tarifeAutocompleteItems[elementName]['strasse'], 'remove', 'autocomplete-change-str');
515                  tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);
516                  //element.trigger('blur');
517                }
518                var hausnummer = tarifeGetInpHausnummerName(elementName);      
519                //console.log('hausnummer: '+hausnummer);
520                if(elementForm.find('input[name="'+hausnummer+'"]') != null && elementForm.find('input[name="'+hausnummer+'"]').length > 0) { // && tarifeAutocompleteItems[elementName]['ort'] != undefined && tarifeAutocompleteItems[elementName]['ort'] != null && tarifeAutocompleteItems[elementName]['ort'] != ''
521                  elementForm.find('input[name="'+hausnummer+'"]').val('');     
522                  tarifeAddOrRemoveEmpty(elementForm.find('input[name="'+hausnummer+'"]'), '', 'add', 'autocomplete-change-hnr');
523                  tarifeTriggerValidationEvent(elementForm, elementForm.find('input[name="'+hausnummer+'"]'), 'change', false, 'autocomplete-change-'+elementName);   
524                }
525              } else {
526                //console.log(elementName+': tarifeAutocompleteItems[elementName] undefined');
527                //element.val('');  
528                //tarifeAddOrRemoveEmpty(element, '', 'add', 'autocomplete-change-strleer');
529                //tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);  
530              }
531            } else {
532              element.val('');       
533              tarifeAddOrRemoveEmpty(element, '', 'add', 'autocomplete-change-strvalleer');
534              tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);
535            }
536          }
537        }
538      }).data("ui-autocomplete")._renderItem = function(ul, item) {
539         return jQuery("<li></li>")
540											             .data("item.autocomplete", item)
541											             .append("<span>" + item.label + "</span>")
542											             .appendTo(ul);
543    	};
544    }
545  } else if(name == 'email') {         
546    var selector = form.find('input[name="'+name+'"]');   
547    //alert('name: '+name+' : '+selector.length);
548    if(selector.length > 0) {
549      selector.parent().addClass('autocompleteContainer'); 
550      selector.parent().addClass('autocompleteContainerMail');                                    
551      form.find('input[name="'+name+'"]').autocomplete({
552        source: function(request, response) {   
553          var element       = jQuery(this.element);                     
554          var elementName   = element.attr('name');  
555          var elementForm   = element.parents('form');                    
556          var elementVal    = element.val();     
557
558          //console.log('name: '+elementName);  
559          //console.log('elementVal: '+elementVal);
560
561          if(elementVal.indexOf('@') >= 1) {
562            jQuery.ajax({
563              url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
564              dataType: 'json',
565              data: {
566                viewmode: 'tarifBestellstreckeEmailDomains',
567                val: request.term                                                    
568              },
569              success: function(json) {
570                //response(json.data);
571                if(json.success == true) {         
572                  var c=0;
573                  response(jQuery.map(json.dataPrep, function(item) {
574                    //alert(item.strong+"\n"+item.standard+"\n"+((item.standard != '') ? item.standard+'' : '')+"\n"+((item.standard !== '') ? item.standard+'' : ''));
575                    c++;
576
577	                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : ''),
578                    var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.mail != undefined && item.mail != null && item.mail != '' && item.mail != 'false') ? tarifeUnEntity(item.mail) 
578: '')).trim();
579	                  var value = tarifeUnEntity(item.mail);
580	                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
581	                		var replace = '(.*)('+item.regexp+')(.*)';
582	                  	//console.log('label: '+label);
583	                  	//console.log('replace: '+replace);
584	                		var re = new RegExp(replace, "gi");
585	                  	label = label.replace(re, '$1<strong>$2</strong>$3');
586	                  	//console.log('label: '+label);
587	                  }
588	                     
589	                  return {
590	                    label: label,
591	                    value: value,
592	                    itemData: item
593	                  }
594                  }));
595                  //response(json.data);
596                }
597              }
598            });
599          }
600        },
601        minLength: 1,
602        autoFocus: true,
603        //appendTo: '#plzContainer',                     
604        appendTo: selector.parent(), 
605        select: function(event, ui) {    
606          var element       = jQuery(this);                  
607          var elementName   = element.attr('name'); 
608          var elementForm   = element.parents('form');
609          
610          //if(jQuery('html').hasClass('isAdmSC')) {
611          //  console.log('autocomplete: select');
612          //}    
613          /*
614          console.log(ui.item ?
615          "Selected: " + ui.item.label :
616          "Nothing selected, input was " + this.value);
617          */
618          //console.log(ui.item);              
619          //console.log(ui.item.itemData);   
620               
621          tarifeAddOrRemoveEmpty(element, '', 'remove');
622           
623          wAdaptConditionalFormData();        
624        },
625        create: function(event, ui) {                                         
626          //console.log('autocomplete CREATE');
627          jQuery(this).parent().addClass('autocompleteCreated');  
628        },
629        open: function(event, ui) {                   
630          //console.log('autocomplete OPEN');                    
631          //console.log('autocomplete OPEN autocompleteFirstItem: '+autocompleteFirstItem);
632          jQuery(this).parent().addClass('autocompleteOpened'); 
633          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').addClass('autocompleteOpened');
634        },
635        close: function(event, ui) {      
636          //console.log('autocomplete CLOSE');         
637          //console.log('autocomplete CLOSE autocompleteFirstItem: '+autocompleteFirstItem);
638          jQuery(this).parent().removeClass('autocompleteOpened');        
639          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').removeClass('autocompleteOpened');
640        },
641        change: function (event, ui) {            
642          //console.log('autocomplete: change');
643          var element     = jQuery(this);                  
644          var elementName = element.attr('name');           
645          var elementVal  = element.val();     
646          var elementForm = element.parents('form');
647          //console.log('name: '+elementName);
648
649          if(elementVal != undefined && elementVal != null && elementVal != '') { 
650            tarifeAddOrRemoveEmpty(element, elementVal, 'remove');
651          }
652        }
653      }).data("ui-autocomplete")._renderItem = function(ul, item) {
654         return jQuery("<li></li>")
655											             .data("item.autocomplete", item)
656											             .append("<span>" + item.label + "</span>")
657											             .appendTo(ul);
658    	};
659    }
660  } else if(name == 'versorger') {         
661    var selector = form.find('input[name="'+name+'"]');   
662    //alert('name: '+name+' : '+selector.length);
663    if(selector.length > 0) {
664      selector.parent().addClass('autocompleteContainer'); 
665      selector.parent().addClass('autocompleteContainerVersorger'); 
666      jQuery('<span class="opener">&#160;</span>').insertAfter(selector);                                     
667      form.find('input[name="'+name+'"]').autocomplete({
668        source: function(request, response) {   
669          var element       = jQuery(this.element);                     
670          var elementName   = element.attr('name');  
671          var elementForm   = element.parents('form');                  
672          var elementVal    = element.val();        
673
674          var produktsparte = elementForm.find('select[name="produktsparte"]').val();  
675          //console.log('name: '+jQuery(this.element).attr('name')+' => '+produktsparte);     
676
677          //console.log('name: '+jQuery(this.element).attr('name'));     
678          //console.log('tarifeVersorger: '+JSON.stringify(tarifeVersorger));
679          if(tarifeVersorger !== undefined && tarifeVersorger !== null) {
680            if(request.term == 'SHOWALL') {             
681              var c=0;
682                            
683              //console.log('tarifeVersorger: '+JSON.stringify(tarifeVersorger));
684              var allData = (jQuery.map(tarifeVersorger, function(item) {                               
685                //console.log('c: '+produktsparte+' => '+item.sparte);
686                if(produktsparte != '' && item.sparte == produktsparte) {
687                  if(c == 0) {
688                    tarifeAutocompleteItems[elementName] = item;
689                  }
690                  c++;
691                
692                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
693                  //var label = item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : '');
694                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.anbieter != undefined && item.anbieter != null && item.anbieter != '' && item.anbieter != 'false') ? tarifeUnEntity(item.anbieter) : '')).trim();
695                  var value = tarifeUnEntity(item.anbieter);
696                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
697                		var replace = '(.*)('+item.regexp+')(.*)';
698                  	//console.log('label: '+label);
699                  	//console.log('replace: '+replace);
700                		var re = new RegExp(replace, "gi");
701                  	label = label.replace(re, '$1<strong>$2</strong>$3');
702                  	//console.log('label: '+label);
703                  }
704                     
705                  return {
706                    label: label,
707                    value: value,
708                    itemData: item
709                  }
710                } else {
711                  return null;
712                }
713              }));                                              
714              //console.log('c: '+c); 
715              //console.log('allData: '+JSON.stringify(allData)); 
716              response(allData);
717            } else {           
718              var c=0;
719              var allData = (jQuery.map(tarifeVersorger, function(item) {  
720                var anbieter  = item.anbieter.toLowerCase();     
721                var term      = request.term.toLowerCase();
722                //console.log(term+': '+anbieter);
723                //if(anbieter.startsWith(term) || term == 'showall') {
724                if(anbieter.indexOf(term) >= 0 || term == 'showall') {  
725                  if(produktsparte != '' && item.sparte == produktsparte) {
726                    if(c == 0) {
727                      tarifeAutocompleteItems[elementName] = item;
728                    }
729                    c++;
730                    
731	                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
732	                  //var label = item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : '');
733	                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.anbieter != undefined && item.anbieter != null && item.anbieter != '' && item.anbieter != 'false') ? tarifeUnEntity(item.anbieter) : '')).trim();
734	                  var value = tarifeUnEntity(item.anbieter);
735	                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
736	                		var replace = '(.*)('+item.regexp+')(.*)';
737	                  	//console.log('label: '+label);
738	                  	//console.log('replace: '+replace);
739	                		var re = new RegExp(replace, "gi");
740	                  	label = label.replace(re, '$1<strong>$2</strong>$3');
741	                  	//console.log('label: '+label);
742	                  } else if(term !== undefined && term !== null && term !== '') {
743	                		var replace = '(.*)('+term+')(.*)';
744	                  	//console.log('label: '+label);
745	                  	//console.log('replace: '+replace);
746	                		var re = new RegExp(replace, "gi");
747	                  	label = label.replace(re, '$1<strong>$2</strong>$3');
748	                  	//console.log('label: '+label);
749	                  }
750	                     
751	                  return {
752	                    label: label,
753	                    value: value,
754	                    itemData: item
755	                  }
756                  } else {
757                    return null;
758                  } 
759                } else {
760                  return null;
761                }
762              })); 
763              //console.log('allData: '+JSON.stringify(allData));
764              response(jQuery.ui.autocomplete.filter(allData, request.term));
765            }
766          } else {
767            jQuery.ajax({
768              url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
769              dataType: 'json',
770              data: {
771                viewmode: 'tarifBestellstreckeVersorger',
772                val: 'SHOWALL',                                                  
773                plz: elementForm.find('input[name="plz"]').val(),
774                ort: elementForm.find('input[name="ort"]').val(),                      
775                bestandskunde: elementForm.find('input[name="bestandskunde"]').val(), 
776                produktsparte: elementForm.find('input[name="produktsparte"]').val(),  
777              },
778              success: function(json) {
779                //response(json.data);
780                if(json.success == true) {         
781                  tarifeVersorger = json.dataPrep;
782                  //console.log('tarifeVersorger: '+JSON.stringify(tarifeVersorger));
783                  
784                  if(request.term == 'SHOWALL') {             
785                    var c=0;
786                    var allData = (jQuery.map(tarifeVersorger, function(item) {  
787                      if(produktsparte != '' && item.sparte == produktsparte) {
788                        if(c == 0) {
789                          tarifeAutocompleteItems[elementName] = item;
790                        }
791                        c++;
792                      
793			                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
794			                  //var label = item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : '');
795			                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.anbieter != undefined && item.anbieter != null && item.anbieter != '' && item.anbieter != 'false') ? tarifeUnEntity(item.anbieter) : '')).trim();
796			                  var value = tarifeUnEntity(item.anbieter);
797			                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
798			                		var replace = '(.*)('+item.regexp+')(.*)';
799			                  	//console.log('label: '+label);
800			                  	//console.log('replace: '+replace);
801			                		var re = new RegExp(replace, "gi");
802			                  	label = label.replace(re, '$1<strong>$2</strong>$3');
803			                  	//console.log('label: '+label);
804			                  }
805			                     
806			                  return {
807			                    label: label,
808			                    value: value,
809			                    itemData: item
810			                  }
811                      } else {
812                        return null;
813                      }
814                    })); 
815                    response(allData);
816                  } else {           
817                    var c=0;
818                    var allData = (jQuery.map(tarifeVersorger, function(item) {  
819                      var anbieter  = item.anbieter.toLowerCase();     
820                      var term      = request.term.toLowerCase();
821                      //console.log(term+': '+anbieter);
822                      //if(anbieter.startsWith(term) || term == 'showall') {
823                      if(anbieter.indexOf(term) >= 0 || term == 'showall') { 
824                        if(produktsparte != '' && item.sparte == produktsparte) {
825                          if(c == 0) {
826                            tarifeAutocompleteItems[elementName] = item;
827                          }
828                          c++;
829                          
830				                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
831				                  //var label = item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : '');
832				                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.anbieter != undefined && item.anbieter != null && item.anbieter != '' && item.anbieter != 'false') ? tarifeUnEntity(item.anbieter) : '')).trim();
833				                  var value = tarifeUnEntity(item.anbieter);
834				                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
835				                		var replace = '(.*)('+item.regexp+')(.*)';
836				                  	//console.log('label: '+label);
837				                  	//console.log('replace: '+replace);
838				                		var re = new RegExp(replace, "gi");
839				                  	label = label.replace(re, '$1<strong>$2</strong>$3');
840				                  	//console.log('label: '+label);
841				                  } else if(term !== undefined && term !== null && term !== '') {
842				                		var replace = '(.*)('+term+')(.*)';
843				                  	//console.log('label: '+label);
844				                  	//console.log('replace: '+replace);
845				                		var re = new RegExp(replace, "gi");
846				                  	label = label.replace(re, '$1<strong>$2</strong>$3');
847				                  	//console.log('label: '+label);
848				                  }
849				                     
850				                  return {
851				                    label: label,
852				                    value: value,
853				                    itemData: item
854			                  	}
855                        } else {
856                          return null;
857                        } 
858                      } else {
859                        return null;
860                      }
861                    })); 
862                    response(jQuery.ui.autocomplete.filter(allData, request.term));
863                  }
864                }
865              }
866            });
867        
867  }
868          
869          /*
870          jQuery.ajax({
871            url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
872            dataType: 'json',
873            data: {
874              viewmode: 'tarifBestellstreckeVersorger',
875              val: request.term,                                                  
876              plz: form.find('input[name="plz"]').val(),
877              ort: form.find('input[name="ort"]').val(),
878              produktsparte: form.find('select[name="produktsparte"]').val(),  
879            },
880            success: function(json) {
881              //response(json.data);
882              if(json.success == true) {         
883                var c=0;
884                response(jQuery.map(json.dataPrep, function(item) {
885                  //alert(item.strong+"\n"+item.standard+"\n"+((item.standard != '') ? item.standard+'' : '')+"\n"+((item.standard !== '') ? item.standard+'' : ''));
886                  c++;
887                  
888                  return {
889                    //label: '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : ''),
890                    label: item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? tarifeUnEntity(item.standard) : ''),
891                    value: tarifeUnEntity(item.anbieter),
892                    itemData: item
893                  }   
894                }));
895                //response(json.data);
896              }
897            }
898          });
899          */  
900        },
901        minLength: 0,
902        autoFocus: true,
903        //appendTo: '#plzContainer',                          
904        appendTo: selector.parent(), 
905        select: function(event, ui) {  
906          var element       = jQuery(this);                  
907          var elementName   = element.attr('name'); 
908          var elementForm   = element.parents('form');
909          
910          //if(jQuery('html').hasClass('isAdmSC')) {
911          //  console.log('autocomplete: select');
912          //}    
913          /*
914          console.log(ui.item ?
915          "Selected: " + ui.item.label :
916          "Nothing selected, input was " + this.value);
917          */
918          //console.log(ui.item);     
919          //console.log(ui.item.itemData);
920                              
921          tarifeAddOrRemoveEmpty(element, this.value, 'remove');
922          
923          if(ui.item.itemData !== undefined && ui.item.itemData !== null) {
924            //console.log('versorgerID:'+ui.item.itemData.id);
925            if(elementForm.find('input[name="versorgerID"]').length > 0) {
926              var inpVersorgerID = elementForm.find('input[name="versorgerID"]');    
927              inpVersorgerID.val(ui.item.itemData.id);
928              //console.log('versorgerID-SET:'+ui.item.itemData.id+' ==> '+inpVersorgerID.val());
929            }
930          }
931          
932          wAdaptConditionalFormData();        
933        },
934        create: function(event, ui) {                                         
935          //console.log('autocomplete CREATE');
936          jQuery(this).parent().addClass('autocompleteCreated');  
937        },
938        open: function(event, ui) {                   
939          //console.log('autocomplete OPEN');                    
940          //console.log('autocomplete OPEN autocompleteFirstItem: '+autocompleteFirstItem);
941          jQuery(this).parent().addClass('autocompleteOpened'); 
942          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').addClass('autocompleteOpened');
943        },
944        close: function(event, ui) {      
945          //console.log('autocomplete CLOSE');         
946          //console.log('autocomplete CLOSE autocompleteFirstItem: '+autocompleteFirstItem);
947          jQuery(this).parent().removeClass('autocompleteOpened');        
948          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').removeClass('autocompleteOpened');
949        },
950        change: function (event, ui) {            
951          //console.log('autocomplete: change');
952          var element     = jQuery(this);                  
953          var elementName = element.attr('name');           
954          var elementVal  = element.val();     
955          var elementForm = element.parents('form');
956          //console.log('name: '+elementName);
957
958          var valEmpty = false;
959          if(ui.item === null) {     
960            if(elementVal != undefined && elementVal != null && elementVal != '') {
961             if(tarifeAutocompleteItems[elementName] !== undefined && tarifeAutocompleteItems[elementName] !== null && tarifeAutocompleteItems[elementName] !== '') {  
962                //console.log('autocomplete ('+elementName+'): '+JSON.stringify(tarifeAutocompleteItems[elementName]));
963                if(tarifeAutocompleteItems[elementName]['anbieter'] != undefined && tarifeAutocompleteItems[elementName]['anbieter'] != null && tarifeAutocompleteItems[elementName]['anbieter'] != '') {
964                  element.val(tarifeAutocompleteItems[elementName]['anbieter']);
965                  tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);
966                  //element.trigger('blur');
967                  if(tarifeAutocompleteItems[elementName]['id'] != undefined && tarifeAutocompleteItems[elementName]['id'] != null && tarifeAutocompleteItems[elementName]['id'] != '') {
968                    //console.log('versorgerID:'+ui.item.itemData.id);
969                    if(elementForm.find('input[name="versorgerID"]').length > 0) {
970                      var inpVersorgerID = elementForm.find('input[name="versorgerID"]');    
971                      inpVersorgerID.val(tarifeAutocompleteItems[elementName]['id']);
972                    }
973                  }
974                }
975              } else {
976                valEmpty = true;
977              }
978            } else {
979              valEmpty = true;
980            }
981          }
982          
983          if(valEmpty == true) {  
984            element.val('');  
985            tarifeAddOrRemoveEmpty(element, '', 'remove');
986            tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);  
987               
988            //console.log('versorgerID:'+ui.item.itemData.id);
989            if(elementForm.find('input[name="versorgerID"]').length > 0) {
990              var inpVersorgerID = elementForm.find('input[name="versorgerID"]');    
991              inpVersorgerID.val('');
992            }
993          } else {      
994            tarifeAddOrRemoveEmpty(element, '', 'remove');
995          }
996        }
997      }).data("ui-autocomplete")._renderItem = function(ul, item) {
998         return jQuery("<li></li>")
999											             .data("item.autocomplete", item)
1000											             .append("<span>" + item.label + "</span>")
1001											             .appendTo(ul);
1002    	};
1003    }
1004  } else if(name == 'produkt_alt' || name == 'produkt_alt_crm') {     
1005    var selector = form.find('input[name="'+name+'"]');   
1006    //alert('name: '+name+' : '+selector.length);
1007    console.log('tarifeCreateAutocomplete::: name: '+name+' : '+selector.length);
1008    if(selector.length > 0) {
1009      selector.parent().addClass('autocompleteContainer'); 
1010      selector.parent().addClass('autocompleteContainerProduktAlt');                                    
1011      form.find('input[name="'+name+'"]').autocomplete({
1012        source: function(request, response) {   
1013          var element       = jQuery(this.element);                     
1014          var elementName   = element.attr('name');  
1015          var elementForm   = element.parents('form');                    
1016          var elementVal    = element.val();     
1017
1018          //console.log('name: '+elementName);  
1019          //console.log('elementVal: '+elementVal);
1020
1021          jQuery.ajax({
1022            url: '/wLayout/wGlobal/scripts/php/items/formular.generator.php',
1023            dataType: 'json',
1024            data: {
1025              viewmode: 'tarifProduct',
1026              val: request.term,                                                  
1027              bestandskunde: jQuery('form.frmTarifCockpitAdministration select[name="bestandskunde"]').val(),   
1028              group: jQuery('form.frmTarifCockpitAdministration select[name="kundengruppe"]').val(),
1029              type: jQuery('form.frmTarifCockpitAdministration select[name="produktsparte"]').val(),  
1030            },
1031            success: function(json) {
1032              //response(json.data);
1033              if(json.success == true) {         
1034                var c=0;
1035                response(jQuery.map(json.dataPrep, function(item) {
1036                  //alert(item.strong+"\n"+item.standard+"\n"+((item.standard != '') ? item.standard+'' : '')+"\n"+((item.standard !== '') ? item.standard+'' : ''));
1037                  if(c == 0) {
1038                    tarifeAutocompleteItems[elementName] = item;
1039                  }
1040                  c++;
1041                         
1042                  tarifeProduktAlt[item.produktCRM] = item.produkt;
1043                  
1044                  //var label = '<strong>'+item.strong+'</strong>'+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '')+((item.name != undefined && item.name != null && item.name != '' && item.name != 'false') ? ' '+item.name : '');
1045                  //var label = item.strong+((item.standard != undefined && item.standard != null && item.standard != '' && item.standard != 'false') ? item.standard : '');
1046                  var label = ((item.label != undefined && item.label != null && item.label != '' && item.label != 'false') ? tarifeUnEntity(item.label) : ((item.produktCRM != undefined && item.produktCRM != null && item.produktCRM != '' && item.produktCRM != 'false') ? tarifeUnEntity(item.produktCRM) : '')).trim();
1047                  var value = tarifeUnEntity(item.produktCRM);
1048                  if(item.regexp !== undefined && item.regexp !== null && item.regexp !== '') {
1049                		var replace = '(.*)('+item.regexp+')(.*)';
1050                  	//console.log('label: '+label);
1051                  	//console.log('replace: '+replace);
1052                		var re = new RegExp(replace, "gi");
1053                  	label = label.replace(re, '$1<strong>$2</strong>$3');
1054                  	//console.log('label: '+label);
1055                  }
1056                     
1057                  return {
1058                    label: label,
1059                    value: value,
1060                    itemData: item
1061                  }
1062                }));
1063                //response(json.data);
1064              }
1065            }
1066          });
1067        },
1068        minLength: 1,
1069        autoFocus: true,
1070        //appendTo: '#plzContainer',                     
1071        appendTo: selector.parent(), 
1072        select: function(event, ui) {    
1073          var element       = jQuery(this);                  
1074          var elementName   = element.attr('name'); 
1075          var elementForm   = element.parents('form');
1076          
1077          //if(jQuery('html').hasClass('isAdmSC')) {
1078          //  console.log('autocomplete: select');
1079          //}    
1080          /*
1081          console.log(ui.item ?
1082          "Selected: " + ui.item.label :
1083          "Nothing selected, input was " + this.value);
1084          */
1085          //console.log(ui.item);              
1086          //console.log(ui.item.itemData);   
1087               
1088          tarifeAddOrRemoveEmpty(element, '', 'remove');
1089
1090          if(elementForm.find('input[name="doppeltarifzaehler[]"]').length > 0) {
1091            //console.log('ui.item.itemData.dtz: '+ui.item.itemData.dtz);  
1092            if(ui.item.itemData.dtz == 1) {
1093              elementForm.find('input[name="doppeltarifzaehler[]"]').prop('checked', true);
1094            } else {
1095              elementForm.find('input[name="doppeltarifzaehler[]"]').prop('checked', false);
1096            }
1097          } 
1098          if(elementForm.find('input[name="produkt_alt"]').length > 0) {
1099            elementForm.find('input[name="produkt_alt"]').val(ui.item.itemData.produkt);
1100          }
1101          calculateTarifButton(elementForm.find('select[name="produktsparte"]'), false);
1102
1103          //var changed = updateZaehlerstaende4Kundennummer(ui.item.value, 'autocomplete-select');  
1104          //if(changed = true) {
1105            wAdaptConditionalFormData();
1106          //}       
1107        },
1108        create: function(event, ui) {                                         
1109          //console.log('autocomplete CREATE');
1110          jQuery(this).parent().addClass('autocompleteCreated');  
1111        },
1112        open: function(event, ui) {                   
1113          //console.log('autocomplete OPEN');                    
1114          //console.log('autocomplete OPEN autocompleteFirstItem: '+autocompleteFirstItem);
1115          jQuery(this).parent().addClass('autocompleteOpened'); 
1116          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').addClass('autocompleteOpened');
1117        },
1118        close: function(event, ui) {      
1119          //console.log('autocomplete CLOSE');         
1120          //console.log('autocomplete CLOSE autocompleteFirstItem: '+autocompleteFirstItem);
1121          jQuery(this).parent().removeClass('autocompleteOpened');        
1122          jQuery(this).parents('form.formCheck4AutocompleteButton').find('button').removeClass('autocompleteOpened');
1123        },
1124        change: function (event, ui) {            
1125          //console.log('autocomplete: change');
1126          var element     = jQuery(this);                  
1127          var elementName = element.attr('name');           
1128          var elementVal  = element.val();     
1129          var elementForm = element.parents('form');
1130          //console.log('autocomplete: change | name: '+elementName+' | '+elementVal);
1131
1132          if(ui.item === null) {     
1133            if(elementVal != undefined && elementVal != null && elementVal != '') {
1134             if(tarifeAutocompleteItems[elementName] !== undefined && tarifeAutocompleteItems[elementName] !== null && tarifeAutocompleteItems[elementName] !== '') {     
1135                tarifeAddOrRemoveEmpty(element, '', 'remove');
1136              } else {
1137                //console.log(elementName+': tarifeAutocompleteItems[elementName] undefined');
1138                //element.val('');  
1139                //tarifeAddOrRemoveEmpty(element, '', 'add', 'autocomplete-change-strleer');
1140                //tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);  
1141              }
1142            } else {
1143              element.val('');       
1144              tarifeAddOrRemoveEmpty(element, '', 'add', 'autocomplete-change-strvalleer');
1145              tarifeTriggerValidationEvent(elementForm, element, 'change', false, 'autocomplete-change-'+elementName);
1146            }
1147          }
1148        }
1149      }).data("ui-autocomplete")._renderItem = function(ul, item) {
1150         return jQuery("<li></li>")
1151											             .data("item.autocomplete", item)
1152											             .append("<span>" + item.label + "</span>")
1153											             .appendTo(ul);
1154    	};
1155    }
1156  }
1157}
1158      
1159function tarifeAddOrRemoveEmpty(item, value, mode, initiator) {   
1160  if(item !== undefined && item !== null) {  
1161    //console.log('tarifeAddOrRemoveEmpty: '+item.attr('name')+' : '+value+' : ('+mode+')'+' <=> ('+initiator+')');
1162    if(mode == 'remove') {
1163      item.parent().parent().removeClass('empty');
1164    } else {
1165      item.parent().parent().addClass('empty');
1166    }
1167  }
1168}   
1169
1170
1171function tarifeAddOrRemoveInvalid(item, value, mode, initiator) {  
1172  if(item !== undefined && item !== null) {   
1173    //console.log('tarifeAddOrRemoveInvalid: '+item.attr('name')+' : '+value+' : ('+mode+')'+' <=> ('+initiator+')');
1174    if(mode == 'remove') {
1175      item.parent().find('label').removeClass('wglIsInvalid');  
1176      item.removeClass('wglIsInvalid');
1177    } else {
1178      item.parent().find('label').addClass('wglIsInvalid');  
1179      item.addClass('wglIsInvalid');
1180    }
1181  }
1182}
1183            
1184function tarifeTriggerValidationEvent(form, element, type, silent, callFrom) {
1185  if(element !== undefined && element !== null) {
1186    if(silent == true) {                   
1187      //console.log('tarifeTriggerValidationEvent : '+callFrom+' : ('+element.attr('name')+'): '+type+' (silent)');
1188      //wglValidateElementInline('#geburtsdatum', {'userinfo' : false, 'clientside' : true}); 
1189      //wglValidateElementInline('#plz', {'userinfo' : false, 'clientside' : true});      
1190      wglValidateElementInline(element, {'userinfo' : false, 'clientside' : true});
1191
1192      //tarifeShowDebugInfo('tarifeTriggerValidationEvent-silent', element, type, silent, callFrom);
1193 
1194      //wglValidateElementInline('#field_1', {'clientside' : true, 'userinfo' : false})  
1195      //wglValidateElementInline(element.get(0), {'userinfo' : false, 'clientside' : form.attr('action').indexOf('/weblication/grid5/tmpHTTP/wF
1195orm-') == -1});
1196      //wglValidateElementInline(element.get(0), {'clientside' : form.attr('action').indexOf('/weblication/grid5/tmpHTTP/wForm-') == -1});
1197    } else {     
1198      //console.log('tarifeTriggerValidationEvent : '+callFrom+' :  ('+element.attr('name')+'): '+type);
1199      element.trigger(type);  
1200      
1201      //tarifeShowDebugInfo('tarifeTriggerValidationEvent-not-silent', element, type, silent, callFrom);
1202    }
1203  }
1204} 
1205
1206function tarifeShowDebugInfo(message, element, type, silent, callFrom) {
1207	//console.log(message);
1208	if(jQuery('#showDebugInfo').length == 0) {
1209		jQuery('body').append('<div id="showDebugInfo" style="position:absolute;bottom:0;left:0;padding:4px;background-color:red;color:#fff;font-size:12px;line-height:1.05;"><div></div></div>');
1210	}
1211	if(jQuery('#showDebugInfo').length > 0) {
1212		var newMessage = jQuery('#showDebugInfo').find('> div').html();
1213		newMessage += element.attr('name')+': '+message+'<br />';
1214		jQuery('#showDebugInfo').find('> div').html(newMessage);
1215	}
1216}
1217
1218function tarifeCheckPLZ4Street(form, name, callFrom) {        
1219  var fieldNames  = tarifeGetPLZ4StreetFieldNames(name);   
1220  var fieldInputs = tarifeGetPLZ4StreetFieldInputs(form, fieldNames); 
1221  var fieldValues = tarifeGetPLZ4StreetFieldValues(fieldInputs);
1222  //console.log('tarifeCheckPLZ4Street: '+name+' ('+callFrom+'): '+JSON.stringify(fieldNames)); 
1223  //console.log('tarifeCheckPLZ4Street: '+name+': '+JSON.stringify(fieldValues));
1224
1225  //if(fieldNames['plz'] != '' && fieldNames['ort'] != '' && fieldNames['strasse'] != '' && fieldNames['hausnummer'] != '') {                                                                                         
1226    if(fieldInputs['plz'] != null && fieldInputs['plz'].length > 0 && fieldInputs['ort'] != null && fieldInputs['ort'].length > 0 && fieldInputs['strasse'] != null && fieldInputs['strasse'].length > 0 && fieldInputs['hausnummer'] != null && fieldInputs['hausnummer'].length > 0) {  
1227      
1228      //console.log('plz: '+fieldValues['plz']+' | ort: '+fieldValues['ort']);
1229
1230      if(fieldValues['plz'] != '') { 
1231        if(fieldValues['ort'] != '') {                                        
1232          fieldInputs['ort'].parent().parent().removeClass('formElementInputReadonlyTmp'); 
1233          tarifeAddOrRemoveEmpty(fieldInputs['ort'], '', 'remove');
1234          fieldInputs['strasse'].parent().parent().removeClass('formElementInputReadonlyTmp');
1235          if(fieldValues['strasse'] != '') {           
1236            tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'remove');
1237          } else {                                    
1238            tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'add');
1239          }          
1240          fieldInputs['hausnummer'].parent().parent().removeClass('formElementInputReadonlyTmp'); 
1241          if(fieldValues['hausnummer'] != '') {        
1242            tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], fieldValues['hausnummer'], 'remove');
1243          } else {                                 
1244            tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], fieldValues['hausnummer'], 'add');   
1245          }
1246          //fieldInputs['ort'].removeAttr('readonly'); 
1247          fieldInputs['strasse'].removeAttr('readonly'); 
1248          fieldInputs['hausnummer'].removeAttr('readonly');    
1249          fieldInputs['ort'].removeAttr('placeholder'); 
1250          fieldInputs['strasse'].removeAttr('placeholder'); 
1251
1252          tarifeTriggerValidationEvent(form, fieldInputs['ort'], 'blur', false, 'tarifeCheckPLZ4Street-'+name); 
1253          tarifeTriggerValidationEvent(form, fieldInputs['strasse'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1254          tarifeTriggerValidationEvent(form, fieldInputs['hausnummer'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1255          
1256        } else { 
1257          if(fieldInputs['ort'].parent().parent().hasClass('formElementInputReadonly')) {
1258            tarifeAddOrRemoveEmpty(fieldInputs['ort'], fieldValues['ort'], 'remove');
1259          } else {
1260            fieldInputs['ort'].parent().parent().addClass('formElementInputReadonlyTmp');  
1261            tarifeAddOrRemoveEmpty(fieldInputs['ort'], fieldValues['ort'], 'remove');
1262          }   
1263          if(fieldInputs['strasse'].parent().parent().hasClass('formElementInputReadonly')) {
1264            tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'remove');
1265          } else {
1266            fieldInputs['strasse'].parent().parent().addClass('formElementInputReadonlyTmp');    
1267            tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'remove');
1268          }    
1269          if(fieldInputs['hausnummer'].parent().parent().hasClass('formElementInputReadonly')) {               
1270            tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], fieldValues['hausnummer'], 'remove');
1271          }
1272          //fieldInputs['ort'].attr('readonly', true); 
1273          fieldInputs['strasse'].attr('readonly', true); 
1274          fieldInputs['hausnummer'].attr('readonly', true);
1275          fieldInputs['ort'].attr('placeholder', 'Bitte erst PLZ eingeben*');
1276          fieldInputs['strasse'].attr('placeholder', 'Bitte erst PLZ eingeben*'); 
1277                                         
1278          tarifeTriggerValidationEvent(form, fieldInputs['ort'], 'blur', true, 'tarifeCheckPLZ4Street-'+name); 
1279          tarifeTriggerValidationEvent(form, fieldInputs['strasse'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1280          tarifeTriggerValidationEvent(form, fieldInputs['hausnummer'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1281        }
1282      } else {                                                     
1283        if(fieldInputs['ort'].parent().parent().hasClass('formElementInputReadonly')) {             
1284          tarifeAddOrRemoveEmpty(fieldInputs['ort'], fieldValues['ort'], 'remove');
1285        } else {
1286          fieldInputs['ort'].parent().parent().addClass('formElementInputReadonlyTmp');      
1287          tarifeAddOrRemoveEmpty(fieldInputs['ort'], fieldValues['ort'], 'remove');
1288        }   
1289        if(fieldInputs['strasse'].parent().parent().hasClass('formElementInputReadonly')) {                     
1290          tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'remove');
1291        } else {
1292          fieldInputs['strasse'].parent().parent().addClass('formElementInputReadonlyTmp');                
1293          tarifeAddOrRemoveEmpty(fieldInputs['strasse'], fieldValues['strasse'], 'remove');
1294        }    
1295        if(fieldInputs['hausnummer'].parent().parent().hasClass('formElementInputReadonly')) {             
1296          tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], fieldValues['hausnummer'], 'remove');
1297        } else {
1298          fieldInputs['hausnummer'].parent().parent().addClass('formElementInputReadonlyTmp');            
1299          tarifeAddOrRemoveEmpty(fieldInputs['hausnummer'], fieldValues['hausnummer'], 'remove');
1300        } 
1301        fieldInputs['ort'].attr('readonly', true); 
1302        fieldInputs['strasse'].attr('readonly', true); 
1303        fieldInputs['hausnummer'].attr('readonly', true);  
1304        fieldInputs['ort'].attr('placeholder', 'Bitte erst PLZ eingeben*');
1305        fieldInputs['strasse'].attr('placeholder', 'Bitte erst PLZ eingeben*');  
1306                                                                        
1307        tarifeTriggerValidationEvent(form, fieldInputs['plz'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1308        tarifeTriggerValidationEvent(form, fieldInputs['ort'], 'blur', true, 'tarifeCheckPLZ4Street-'+name); 
1309        tarifeTriggerValidationEvent(form, fieldInputs['strasse'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1310        tarifeTriggerValidationEvent(form, fieldInputs['hausnummer'], 'blur', true, 'tarifeCheckPLZ4Street-'+name);
1311      }
1312    }
1313  //} 
1314}
1315
1316function tarifeGetPLZ4StreetFieldNames(name) {
1317  var fieldNames  = {'plz': '', 'ort': '', 'strasse': '', 'hausnummer': ''};
1318  if(name == 'plz') { 
1319    fieldNames = {'plz': 'plz', 'ort': 'ort', 'strasse': 'strasse', 'hausnummer': 'hausnummer'};
1320  } else if(name == 'rechnungsanschrift_plz') { 
1321    fieldNames = {'plz': 'rechnungsanschrift_plz', 'ort': 'rechnungsanschrift_ort', 'strasse': 'rechnungsanschrift_strasse', 'hausnummer': 'rechnungsanschrift_hausnummer'};
1322  } else if(name == 'kontoinhaber_plz') { 
1323    fieldNames = {'plz': 'kontoinhaber_plz', 'ort': 'kontoinhaber_ort', 'strasse': 'kontoinhaber_strasse', 'hausnummer': 'kontoinhaber_hausnummer'};
1324  }
1325  return fieldNames;
1326} 
1327        
1328function tarifeGetPLZ4StreetFieldInputs(form, fieldNames) { 
1329  var fieldInputs = {'plz': null, 'ort': null, 'strasse': null, 'hausnummer': null};
1330  
1331  if(fieldNames['plz'] != '' && fieldNames['ort'] != '' && fieldNames['strasse'] != '' && fieldNames['hausnummer'] != '') {
1332    fieldInputs['plz']        = form.find('input[name="'+fieldNames['plz']+'"]');                            
1333    fieldInputs['ort']        = form.find('input[name="'+fieldNames['ort']+'"]');                            
1334    fieldInputs['strasse']    = form.find('input[name="'+fieldNames['strasse']+'"]');                           
1335    fieldInputs['hausnummer'] = form.find('input[name="'+fieldNames['hausnummer']+'"]');
1336  }
1337 
1338  return fieldInputs;
1339}
1340
1341function tarifeGetPLZ4StreetFieldValues(inputs) { 
1342  var fieldValues = {'plz': '', 'ort': '', 'strasse': '', 'hausnummer': ''};
1343  if(inputs['plz'] != null && inputs['plz'].length > 0 && inputs['ort'] != null && inputs['ort'].length > 0 && inputs['strasse'] != null && inputs['strasse'].length > 0 && inputs['hausnummer'] != null && inputs['hausnummer'].length > 0) {          
1344    //if(inputs['plz'].length > 0 && inpOrt.length > 0 && inpStr.length > 0 && inpHnr.length > 0) {  
1345      fieldValues['plz']        = inputs['plz'].val();  
1346      fieldValues['ort']        = inputs['ort'].val();
1347      fieldValues['strasse']    = inputs['strasse'].val();  
1348      fieldValues['hausnummer'] = inputs['hausnummer'].val();
1349    //}
1350  }
1351 
1352  return fieldValues;
1353}
1354
1355function tarifeGetInpOrtName(elementName) {
1356  var inpOrt = '';     
1357  if(elementName == 'plz') {
1358    inpOrt = 'ort';
1359  } else if(elementName == 'rechnungsanschrift_plz') {
1360    inpOrt = 'rechnungsanschrift_ort';
1361  } else if(elementName == 'kontoinhaber_plz') {      
1362    inpOrt = 'kontoinhaber_ort';
1363  }
1364  return inpOrt;  
1365}    
1366
1367function tarifeGetInpHausnummerName(elementName) {
1368  var hausnummer = '';     
1369  if(elementName == 'strasse') {
1370    hausnummer = 'hausnummer';
1371  } else if(elementName == 'rechnungsanschrift_strasse') {
1372    hausnummer = 'rechnungsanschrift_hausnummer';
1373  } else if(elementName == 'kontoinhaber_strasse') {      
1374    hausnummer = 'kontoinhaber_hausnummer';
1375  }
1376  return hausnummer;  
1377}
1378        
1379function tarifeIbanInputAction(input, mode, e) {
1380  if(mode == 'keyup') {
1381    tarifeIbanFormat(input, e.keyCode, e);
1382  } else if(mode == 'blur') {
1383    tarifeIbanValidateFormat(input, e.keyCode, e);
1384  }
1385}      
1386
1387function tarifeIbanFormat(input, keyCode, e) {   
1388  var sendBack = false;
1389  
1390  var val = input.val();   
1391  
1392  if(keyCode == 16) {
1393    tarifeDateIsShift = true;
1394  }
1395           
1396  var target    = e.target, 
1397      position  = target.selectionEnd,  
1398      length    = val.length;
1399
1400  val = val.toUpperCase().replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim();
1401  
1402  var patternAndLength = tarifeIbanGetPatternAndLength(val);
1403             
1404  /*
1405  var target    = e.target, 
1406      position  = target.selectionEnd,
1407      length    = val.length;
1408  //target.selectionEnd = position += ((val.charAt(position - 1) === ' ' && val.charAt(length - 1) === ' ' && length !== val.length) ? 1 : 0);
1409  */
1410  
1411  if(patternAndLength.maxLength > 0) {
1412    var spaces = Math.floor(patternAndLength.maxLength / 4);
1413    //console.log(spaces);
1414    input.attr('maxlength', (spaces + patternAndLength.maxLength));
1415  } else {       
1416    input.removeAttr('maxlength');
1417  }           
1418  //console.log('iban: '+val+' => '+position+' ||| '+JSON.stringify(patternAndLength));
1419  
1420  input.val(val);   
1421  
1422  return sendBack;
1423}
1424
1425function tarifeIbanValidateFormat(input, keyCode, e) {   
1426  var sendBack = false;
1427                       
1428  var val = input.val();  
1429  
1430  var isValid = tarifeValidateIBAN(val, input);                 
1431  console.log('iban: '+val+' => '+isValid);
1432
1433}
1434
1435function tarifeDateInputAction(input, mode, e) {               
1436  if(mode == 'keyup') {
1437    tarifeDateIsNumeric(input, e.keyCode);
1438  } else if(mode == 'blur') {
1439    tarifeDateValidateFormat(input, e.keyCode);
1440  }
1441}
1442                          
1443function tarifeDateIsNumeric(input, keyCode) { 
1444  var sendBack = false;
1445  
1446  var val = input.val();   
1447  
1448  if(keyCode == 16) {
1449    tarifeDateIsShift = true;
1450  }
1451  
1452  //console.log('dateIsNumeric: '+val+' ('+keyCode+')');
1453  
1454  //Allow only Numeric Keys.
1455  if(((keyCode >= 48 && keyCode <= 57) || keyCode == 8 || keyCode <= 37 || keyCode <= 39 || (keyCode >= 96 && keyCode <= 105)) && tarifeDateIsShift == false) {    
1456    var len = val.length;
1457                      
1458    //var regexp = /^(((0|1)[0-9]|2[0-9]|3[0-1])\.(0[1-9]|1[0-2])\.((18|19|20)\d\d))$/;
1459    var regexp        = '';       
1460    var regexpAfter3  = '';
1461    var regexpAfter6  = '';
1462    //Erste Stelle nur 0, 1, 2, 3
1463    if(len >= 1) {      
1464      regexp += '^';
1465      regexp += '(0|1|2|3)';
1466    }
1467    if(len >= 2) {   
1468      regexp  = '^';      
1469      regexp += '((0|1)[0-9]|2[0-9]|3[0-1])';
1470    }
1471    if(len >= 3) {         
1472      regexp += '\\.';
1473    }
1474    regexpAfter3 = regexp;
1475    
1476    if(len == 4) {         
1477      regexp += '(0|1)';
1478    }
1479       
1480    if(len >= 5) {      
1481      regexp = regexpAfter3;
1482      regexp += '(0[1-9]|1[0-2])';
1483    }      
1484    if(len >= 6) {         
1485      regexp += '\\.';
1486    }           
1487    regexpAfter6 = regexp;
1488             
1489    if(len == 7) {         
1490      regexp += '(1|2)';
1491    }
1492    if(len >= 8) {   
1493      regexp = regexpAfter6;      
1494      regexp += '(1[8-9]|20)';
1495    }
1496             
1497    if(len >= 9) {         
1498      regexp += '\\d';
1499    }         
1500    if(len >= 10) {         
1501      regexp += '\\d';
1502    }
1503
1504    if(regexp !== '') {    
1505      regexp += '$';  
1506      //console.log('dateIsNumeric regexp: '+regexp+' ('+keyCode+')');
1507    
1508      var re = new RegExp(regexp);
1509      if(re.test(val)) {     
1510        sendBack = true;
1511        
1512        if((len == 2 || len == 5) && keyCode != 8) {
1513          val += tarifeDateSeperator;
1514        }
1515      }
1516    }
1517    
1518    if(sendBack == false) {
1519      val = val.substr(0, (len-1));
1520    }  
1521         
1522    //console.log('dateIsNumeric '+((sendBack == true) ? 'TRUE' : 'FALSE')+': '+val+' ('+keyCode+')');
1523    
1524
1525  } else {     
1526    //console.log('dateIsNumeric FALSE: '+val+' ('+keyCode+')');
1527    val = val.replace(/\D/g, '');  
1528    var len = val.length;
1529    
1530    var valNew = '';
1531    if(len >= 4) {
1532      valNew = val.substr(0, 2)+tarifeDateSeperator+val.substr(2, 2)+tarifeDateSeperator+val.substr(4, (len - 4));
1533    } else if(len >=2) {
1534      valNew = val.substr(0, 2)+tarifeDateSeperator+val.substr(2, (len - 2));
1535    } else if(len > 0) {
1536      valNew = val.substr(0, l);
1537    }
1538    
1539    val = valNew;
1540  }
1541  
1542  input.val(val);   
1543  
1544  return sendBack;
1545}
1546
1547function tarifeDateValidateFormat(input, keyCode) {
1548  var val = input.val();
1549     
1550  if(keyCode == 16) {
1551    tarifeDateIsShift = false;
1552  }   
1553  //console.log('dateValidateFormat: '+val+' | '+val.length);
1554  
1555  var regex = /^(((0|1)[0-9]|2[0-9]|3[0-1])\.(0[1-9]|1[0-2])\.((18|19|20)\d\d))$/;
1556  //Check whether valid dd/MM/yyyy Date Format.
1557  if(regex.test(val) || val.length == 0) {
1558    //console.log('dateValidateFormat: OK');
1559    
1560    //input.parent().find('label').removeClass('wglIsInvalid');  
1561    //input.removeClass('wglIsInvalid');
1562        
1563    var vlr = wGetValidationInfoInput(input);  
1564    if(vlr['isValid']) {
1565      tarifeAddOrRemoveInvalid(input, val, 'remove', 'dateValidateFormat');
1566    }
1567    
1568  } else {
1569    //input.val('');            
1570    //console.log('dateValidateFormat: ERROR');   
1571    tarifeAddOrRemoveInvalid(input, val, 'add', 'dateValidateFormat');
1572    var vlr = wGetValidationInfoInput(input);  
1573    if(!vlr['isValid']) {           
1574      tarifeAddOrRemoveInvalid(input, val, 'add', 'dateValidateFormat');
1575    }
1576  }
1577}
1578
1579jQuery.fn.tarifeBestellstreckeSimulateClick = function() {
1580  return this.each(function() {
1581    if('createEvent' in document) {
1582      var doc = this.ownerDocument,
1583          evt = doc.createEvent('MouseEvents');
1584      evt.initMouseEvent('click', true, true, doc.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
1585      this.dispatchEvent(evt);
1586    } else {
1587        this.click(); // IE Boss!
1588    }
1589  });
1590}
1591
1592
1593
1594/**
1595 * IBAN is the international bank account number.
1596 * It has a country - specific format, that is checked here too
1597 *
1598 * Validation is case-insensitive. Please make sure to normalize input yourself.
1599 */
1600//$.validator.addMethod( "iban", , "Please specify a valid IBAN." )   
1601function tarifeIbanGetPatternAndLength(value) {
1602  var sendBack = {pattern: false, maxLength:0};
1603  
1604	var iban = value.replace(/ /g, '').toUpperCase().trim();
1605      
1606	if(iban.length < 2) {
1607		return sendBack;
1608	}
1609
1610	// Check the country code and find the country specific format
1611	var countrycode = iban.substring(0, 2);
1612
1613	var bbancountrypatterns = {
1614		"AL": "\\d{8}[\\dA-Z]{16}",
1615		"AD": "\\d{8}[\\dA-Z]{12}",
1616		"AT": "\\d{16}",
1617		"AZ": "[\\dA-Z]{4}\\d{20}",
1618		"BE": "\\d{12}",
1619		"BH": "[A-Z]{4}[\\dA-Z]{14}",
1620		"BA": "\\d{16}",
1621		"BR": "\\d{23}[A-Z][\\dA-Z]",
1622		"BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
1623		"CR": "\\d{17}",
1624		"HR": "\\d{17}",
1625		"CY": "\\d{8}[\\dA-Z]{16}",
1626		"CZ": "\\d{20}",
1627		"DK": "\\d{14}",
1628		"DO": "[A-Z]{4}\\d{20}",
1629		"EE": "\\d{16}",
1630		"FO": "\\d{14}",
1631		"FI": "\\d{14}",
1632		"FR": "\\d{10}[\\dA-Z]{11}\\d{2}",
1633		"GE": "[\\dA-Z]{2}\\d{16}",
1634		"DE": "\\d{18}",
1635		"GI": "[A-Z]{4}[\\dA-Z]{15}",
1636		"GR": "\\d{7}[\\dA-Z]{16}",
1637		"GL": "\\d{14}",
1638		"GT": "[\\dA-Z]{4}[\\dA-Z]{20}",
1639		"HU": "\\d{24}",
1640		"IS": "\\d{22}",
1641		"IE": "[\\dA-Z]{4}\\d{14}",
1642		"IL": "\\d{19}",
1643		"IT": "[A-Z]\\d{10}[\\dA-Z]{12}",
1644		"KZ": "\\d{3}[\\dA-Z]{13}",
1645		"KW": "[A-Z]{4}[\\dA-Z]{22}",
1646		"LV": "[A-Z]{4}[\\dA-Z]{13}",
1647		"LB": "\\d{4}[\\dA-Z]{20}",
1648		"LI": "\\d{5}[\\dA-Z]{12}",
1649		"LT": "\\d{16}",
1650		"LU": "\\d{3}[\\dA-Z]{13}",
1651		"MK": "\\d{3}[\\dA-Z]{10}\\d{2}",
1652		"MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
1653		"MR": "\\d{23}",
1654		"MU": "[A-Z]{4}\\d{19}[A-Z]{3}",
1655		"MC": "\\d{10}[\\dA-Z]{11}\\d{2}",
1656		"MD": "[\\dA-Z]{2}\\d{18}",
1657		"ME": "\\d{18}",
1658		"NL": "[A-Z]{4}\\d{10}",
1659		"NO": "\\d{11}",
1660		"PK": "[\\dA-Z]{4}\\d{16}",
1661		"PS": "[\\dA-Z]{4}\\d{21}",
1662		"PL": "\\d{24}",
1663		"PT": "\\d{21}",
1664		"RO": "[A-Z]{4}[\\dA-Z]{16}",
1665		"SM": "[A-Z]\\d{10}[\\dA-Z]{12}",
1666		"SA": "\\d{2}[\\dA-Z]{18}",
1667		"RS": "\\d{18}",
1668		"SK": "\\d{20}",
1669		"SI": "\\d{15}",
1670		"ES": "\\d{20}",
1671		"SE": "\\d{20}",
1672		"CH": "\\d{5}[\\dA-Z]{12}",
1673		"TN": "\\d{20}",
1674		"TR": "\\d{5}[\\dA-Z]{17}",
1675		"AE": "\\d{3}\\d{16}",
1676		"GB": "[A-Z]{4}\\d{14}",
1677		"VG": "[\\dA-Z]{4}\\d{16}"
1678	};
1679
1680	var bbancountrylengths = {
1681		"AL": 28,
1682		"AD": 24,
1683		"AT": 20,
1684		"AZ": 28,
1685		"BE": 16,
1686		"BH": 22,
1687		"BA": 20,
1688		"BR": 29,
1689		"BG": 22,
1690		"CR": 21,
1691		"HR": 21,
1692		"CY": 28,
1693		"CZ": 24,
1694		"DK": 18,
1695		"DO": 28,
1696		"EE": 20,
1697		"FO": 18,
1698		"FI": 18,
1699		"FR": 27,
1700		"GE": 22,
1701		"DE": 22,
1702		"GI": 23,
1703		"GR": 27,
1704		"GL": 18,
1705		"GT": 28,
1706		"HU": 28,
1707		"IS": 26,
1708		"IE": 22,
1709		"IL": 23,
1710		"IT": 27,
1711		"KZ": 20,
1712		"KW": 30,
1713		"LV": 21,
1714		"LB": 28,
1715		"LI": 21,
1716		"LT": 20,
1717		"LU": 20,
1718		"MK": 19,
1719		"MT": 31,
1720		"MR": 27,
1721		"MU": 30,
1722		"MC": 27,
1723		"MD": 24,
1724		"ME": 22,
1725		"NL": 18,
1726		"NO": 15,
1727		"PK": 23,
1728		"PS": 29,
1729		"PL": 28,
1730		"PT": 25,
1731		"RO": 24,
1732		"SM": 27,
1733		"SA": 24,
1734		"RS": 22,
1735		"SK": 24,
1736		"SI": 19,
1737		"ES": 24,
1738		"SE": 24,
1739		"CH": 21,
1740		"TN": 24,
1741		"TR": 26,
1742		"AE": 23,
1743		"GB": 22,
1744		"VG": 24
1745	};
1746   
1747	var pattern = bbancountrypatterns[countrycode];
1748	if(typeof pattern !== "undefined") { 
1749    sendBack.pattern = pattern;
1750  }
1751   
1752	var maxLength = bbancountrylengths[countrycode];
1753	if(typeof maxLength !== "undefined") { 
1754    sendBack.maxLength = maxLength;
1755  }
1756  
1757  return sendBack;
1758}
1759
1760function tarifeValidateIBAN(value, element) {
1761	// Some quick simple tests to prevent needless work
1762	//if(this.optional(element)) {
1763	//	return true;
1764	//}
1765
1766	//Remove spaces and to upper case
1767	var iban = value.replace(/ /g, "").toUpperCase(),
1768  		ibancheckdigits = "",
1769  		leadingZeroes = true,
1770  		cRest = "",
1771  		cOperator = "",
1772  		countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;
1773
1774	// Check for IBAN code length.
1775	// It contains:
1776	// country code ISO 3166-1 - two letters,
1777	// two check digits,
1778	// Basic Bank Account Number (BBAN) - up to 30 chars
1779	var minimalIBANlength = 5;
1780	if(iban.length < minimalIBANlength) {
1781		return false;
1782	}
1783
1784  var patternAndLength = tarifeIbanGetPatternAndLength(iban);
1785	bbanpattern = patternAndLength.pattern;
1786
1787	// As new countries will start using IBAN in the
1788	// future, we only check if the countrycode is known.
1789	// This prevents false negatives, while almost all
1790	// false positives introduced by this, will be caught
1791	// by the checksum validation below anyway.
1792	// Strict checking should return FALSE for unknown
1793	// countries.
1794	if(typeof bbanpattern !== "undefined") {
1795		ibanregexp = new RegExp("^[A-Z]{2}\\d{2}"+bbanpattern+"$", "");
1796		if(!(ibanregexp.test(iban))) {
1797			return false; // Invalid country specific format
1798		}
1799	}
1800
1801	//Now check the checksum, first convert to digits
1802	ibancheck = iban.substring(4, iban.length) + iban.substring(0, 4);
1803	for(i=0; i<ibancheck.length; i++) {
1804		charAt = ibancheck.charAt(i);
1805		if(charAt !== "0") {
1806			leadingZeroes = false;
1807		}
1808		if(!leadingZeroes) {
1809			ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt);
1810		}
1811	}
1812
1813	// Calculate the result of: ibancheckdigits % 97
1814	for(p=0; p<ibancheckdigits.length; p++) {
1815		cChar = ibancheckdigits.charAt(p);
1816		cOperator = ""+cRest+""+cChar;
1817		cRest = cOperator % 97;
1818	}
1819	return cRest === 1;
1820}
1821

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.