(function() {
  Window.implement({
    '$log': function() {
      if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
        console.log(arguments.length <= 1 ? arguments[0] : arguments);
      } else {
        alert('D:BUG! ' + arguments[0]);
      }
    }
  });
})();

var DT = this.DT = {
    setupPage: function() {
        $$('html')[0].removeClass('no-js');
        // Wrapper anpassen
        var contentSize = window.getScrollSize().y - 322;
        $('content').setStyle('min-height', contentSize);
        this.setupGallery();
        this.freecapFix();
    },

    setupGallery: function() {
        var hasSlider = $$('.gallery');
        if (hasSlider.length) {
            hasSlider.each(function(el) {
                var gallery = new slideGallery(el, {
                    speed: 500,
                    autoplay: true,
                    duration: 5000
                });
            });
        }
    },
    
    freecapFix: function(){
        var pForm = $$('.tx_powermail_pi1_form')[0];
        var fc = $$('.powermail_captcha')[0];
        
        if(pForm != undefined){
            pForm.addEvent('submit', function(){
                fc.value.toLowerCase();
                fc.value = fc.value.toLowerCase();
            });
        }
    }
}

// Window-Events.
window.addEvent('domready', function() {
    DT.setupPage();
});

//Kontaktformular anpassen (PLZ-Feld)
var plz = $$('.plz');
if(plz.length){
  //plz.setStyles({'width':69 , 'margin-right': 11}).getParent('div').setStyle('float', 'left').getNext('div.tx_powermail_pi1_fieldwrap_html_text input').setStyle('width', 135);
  plz.getParent('div').addClass('plz-parent').getNext('div').addClass('plz-after');
}

// Powermail Fehlerausgaben anpassen

