//search-suggest "alle ergebnisse"-event behandeln
function submitSearchForm()
{
  document.getElementById('siteSearchForm').submit();
}

window.addEvent('domready', function() {

  // Druckansicht in neuem Fenster
  $$('a.print').setProperty("target", "blank");

  // Suchbegriff Satnav

  if($('search'))
  {
    var elem = $('search');


    elem.addEvent('click',function(ev){

      if(elem.getProperty('value') == conf['i18n']['skeleton']['suchbegriff'])
      {
        elem.setProperty('value','');
      }
      else
      {
        if(elem.getProperty('value') == '')
        {
          elem.setProperty('value', conf['i18n']['skeleton']['suchbegriff']);
        }
      }
    }.bind(elem));

    elem.addEvent('blur',function(ev){
      if(elem.getProperty('value') == '')
      {
        elem.setProperty('value', conf['i18n']['skeleton']['suchbegriff']);
      }
    }.bind(elem));

    elem.addEvent('keyup', function(ev){
      var e = new Event(ev);

      if(ev.key == "enter")
      {
        this.form.submit();
      }
    })
  }

  if(	$('sitelanguage') )
  {
    //Sprach-Navi Submit-Button entfernen
    $('langSubmit').dispose();
  }


});


// not in mootools domready method
// see http://mediavrog.net/blog/2008/04/09/browser/internetexplorer/probleme-mit-sifr-3-und-swfobject-auf-einer-seite-im-ie-6-und-7/

if(sIFR)
{
  var font = {
    src: "/media/flash/gentinum-italic.swf"
  };
  var mainMenuFont = {
    src: "/media/flash/din-medium.swf"
  };

  // One setting you probably want to use is `sIFR.useStyleCheck`. Before you do that,
  // read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad>.

  //sIFR.useStyleCheck = true;
  sIFR.fixHover =false;
    
  sIFR.activate(font);
  sIFR.activate(mainMenuFont);

  if($('teaserContainer'))
  {
    sIFR.replace(font, {
      selector: '#teaserContainer h2:not(.nosifr)',
      css: '.sIFR-root { font-style: italic; font-size: 22px; background-color: #F9F9F9; color: ' + $$('body h2')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: 0,
      offsetTop: 1,
      ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
    });

  //
  //        sIFR.debug.ratios({
  //            src: "/media/flash/gentinum-italic.swf",
  //            selector: '#teaserContainer h2',
  //            css: '.sIFR-root { font-size: 22px; font-style: italic; }',
  //            wmode: 'transparent'
  //        });
  }

  if($$('h2')[0])
  {
    sIFR.replace(font, {
      selector: 'h2:not(.nosifr):not(.pageHead)',
      css: '.sIFR-root { font-style: italic; font-size: 30px; background-color: #F9F9F9; color: ' + $$('body h2')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: -1,
      offsetTop: 4,
      ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
    });
  }

  if($$('h2.pageHead')[0])
  {
    sIFR.replace(font, {
      selector: 'h2.pageHead:not(.nosifr)',
      css: '.sIFR-root { font-style: italic; font-size: 30px; background-color: #F9F9F9; color: ' + $$('body h2')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: -1,
      offsetTop: 4,
      ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
    });
  }

  if($('list'))
  {
    sIFR.replace(font, {
      selector: '#list h3:not(.nosifr)',
      css: '.sIFR-root { font-style: italic; font-size: 30px; background-color: #F9F9F9; color: ' + $$('body h3')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: 0,
      offsetTop: 4,
      ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
    });
  }

  if($$('h3')[0])
  {
    sIFR.replace(font, {
      selector: 'h3:not(.nosifr)',
      css: '.sIFR-root { font-style: italic; font-size: 24px; background-color: #F9F9F9; color: ' + $$('body h3')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: -1,
      offsetTop: 4,
      ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
    });
  }


  if($$('h4')[0])
  {
    /*
    if($$('.av_firm h4'))
    {
      sIFR.replace(font, {
        selector: '.av_firm h4',
        css: '.sIFR-root { font-style: italic; font-size: 17px; background-color: #F9F9F9; color: ' + $$('body h4')[0].getStyle("color") + ' }',
        wmode: 'transparent',
        tuneHeight: -2,
        offsetTop: 1,
        onRelease: function(fi){
          console.log(fi);
          alert(fi.getAncestor());
          alert(fi.getAncestor().getParent(".av_toggle"));
          $(fi.getAncestor()).getParent(".av_toggle").fireEvent("click");
          
        },
        ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
      });
    }else{
      sIFR.replace(font, {
        selector: 'h4:not(.nosifr,.av_firm h4)',
        css: '.sIFR-root { font-style: italic; font-size: 17px; background-color: #F9F9F9; color: ' + $$('body h4')[0].getStyle("color") + ' }',
        wmode: 'transparent',
        tuneHeight: -2,
        offsetTop: 1,
        ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
      });
    }
    */
   sIFR.replace(font, {
        selector: 'h4:not(.nosifr)',
        css: '.sIFR-root { font-style: italic; font-size: 17px; background-color: #F9F9F9; color: ' + $$('body h4')[0].getStyle("color") + ' }',
        wmode: 'transparent',
        tuneHeight: -2,
        offsetTop: 1,
        ratios: [8, 1.3, 9, 1.22, 10, 1.25, 11, 1.22, 17, 1.2, 28, 1.16, 31, 1.15, 40, 1.14, 46, 1.13, 47, 1.14, 60, 1.13, 61, 1.12, 67, 1.13, 121, 1.12, 122, 1.11, 1.12]
      });
  }

  if($('mainTeaser'))
  {
    sIFR.replace(mainMenuFont, {
      selector: '#mainTeaser #containerNavigation > ul li > a:not(.nosifr)',
      css: '.sIFR-root { cursor: pointer; font-size: 14px; color: #ffffff }',
      wmode: 'transparent',
      tuneHeight: -4,
      ratios: [8, 1.42, 9, 1.33, 12, 1.35, 19, 1.3, 27, 1.27, 28, 1.25, 32, 1.26, 33, 1.24, 38, 1.25, 53, 1.24, 56, 1.23, 57, 1.24, 83, 1.23, 85, 1.22, 87, 1.23, 94, 1.22, 95, 1.23, 1.22]
    });
  }

  //Datumsangaben VA-Kalender
  if($$('.vaDate')[0])
  {
    sIFR.replace(font, {
      selector: 'span.vaDate:not(.nosifr)',
      css: '.sIFR-root { font-style: italic; font-size: 15px; background-color: #F9F9F9; color: ' + $$('body h2')[0].getStyle("color") + ' }',
      wmode: 'transparent',
      tuneHeight: -7,
      ratios: [8, 1.42, 9, 1.33, 12, 1.35, 19, 1.3, 27, 1.27, 28, 1.25, 32, 1.26, 33, 1.24, 38, 1.25, 53, 1.24, 56, 1.23, 57, 1.24, 83, 1.23, 85, 1.22, 87, 1.23, 94, 1.22, 95, 1.23, 1.22]
    });
  }
}