// round bottom corners 
// DD_roundies.addRule('.rounded_button', '0 0 7px 7px', true);
DD_roundies.addRule('.round_border_all', '7px 7px 7px 7px', true);

// jQuery konfilkt mit mootools

var $j = jQuery.noConflict();

// image preloader
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}



// Klasse zuerst entfernen

/*
ddaccordion.init({ //top level headers initialization
  headerclass: "expandable", //Shared CSS class name of headers group that are expandable
  contentclass: "categoryitems", //Shared CSS class name of contents group
  revealtype: "clickgo", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
  mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
  collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
  defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
  onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
  animatedefault: false, //Should contents open by default be animated into view?
  persiststate: true, //persist state of opened contents within browser session?
  toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
  togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
  animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
  oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
    //do nothing
  },
  onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
    //do nothing
  }
})

ddaccordion.init({ //2nd level headers initialization
  headerclass: "subexpandable", //Shared CSS class name of sub headers group that are expandable
  contentclass: "subcategoryitems", //Shared CSS class name of sub contents group
  revealtype: "clickgo", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
  mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
  collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
  defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
  onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
  animatedefault: false, //Should contents open by default be animated into view?
  persiststate: true, //persist state of opened contents within browser session?
  toggleclass: ["opensubheader", "closedsubheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
  togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
  animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
  oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
    //do nothing
  },
  onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
    //do nothing
  }
})
*/



// sync height and add classes

$j(document).ready(function(){

  // code begin for dropdown menu

  
  // insert div after body tag for Background
//  $j('ul#skiplinks').before('<div class="dropdownbackground"></div>');
  $j('div#main').before('<div class="borderbeforemain"></div>');
  $j('div#main').css({ 
          borderTopWidth: "0"
          });
  
          
  $j('div.dropdowndiv div').css({ 
            display: "none"
            });

  // dropdown function
  var laenge = $j("li.animatedown").length;
  var i = 1;

  var tim = 750;
  var delai = 500;

    // mouse over listitem
    $j('li.animatedown').hover(function() {
        $j('div.dropdowndiv div').css({ 
          display: "none"
        });
        var i = $j("li.animatedown").index(this);
        
        $j('div.dropdowndiv div:eq('+ i +')').css({ 
          display: "block"
        });
        $j('.dropdownbackground').stop().animate({ 
          height: "82px"
          }, tim );
        $j('.dropdowndiv').stop().animate({ 
          height: "82px"
          }, tim );
        $j('.borderbeforemain').stop().animate({ 
          height: "148px"
          }, tim );
          
      }, function() {

        $j('.dropdownbackground').stop().animate({ 
          height: "0"
          }, tim );
        $j('.dropdowndiv').stop().animate({ 
          height: "0px"
          }, tim );
        $j('.borderbeforemain').stop().animate({ 
          height: "66px"
          }, tim );
      });

    // mouse over dropdowndiv
    $j('.dropdowndiv').hover(function() {

        $j('.dropdownbackground').stop().animate({ 
          height: "82px"
          }, tim );
        $j('.dropdowndiv').stop().animate({ 
          height: "82px"
          }, tim );
        $j('.borderbeforemain').stop().animate({ 
          height: "148px"
          }, tim );
          
      }, function() {

        $j('.dropdownbackground').stop().animate({ 
          height: "0"
          }, tim );
        $j('.dropdowndiv').stop().animate({ 
          height: "0px"
          }, tim );
        $j('.borderbeforemain').stop().animate({ 
          height: "66px"
          }, tim );
      });



  // code end for dropdown menu

  
  // .hlist menu soll immer erste ebene vom ddaccordion menue oeffnen - ?expandable=0 anhaengen
  // hat doppelte Einträge ?expandable=999?expandable=999 erzeugt im Dropdown-Menu
  // $j('.hlist a', .dropdowndiv div a).each(
  $j('.hlist a').each(
    function( intIndex ){
      // Anhang beim Link auf einen Blaetterkatalog 
      // (soll automatisch angehaengt werden, damit der BK mit entsprechenden Parametern aufgerufen wird)
      // var bkValue = "?expandable=999";
      var bkValue = "";
      var newHREF = $j( this ).attr('href') + bkValue;
        $j( this ).attr('href', newHREF);
    }
  );





  // IMG Preloader
  $j.preloadImages(
    "fileadmin/template/images/flag_en_ro.gif",
    "fileadmin/template/images/flag_de_ro.gif",
    "fileadmin/template/searchbox/bg_go_hover.gif"
  ); 
  
  // Langmenu hover
    $j("#lng_en").hover(
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_en_ro.gif");
      }, 
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_en.gif");
      }
    );
    $j("#lng_de").hover(
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_de_ro.gif");
      }, 
      function () {
        $j(this).attr("src","fileadmin/template/images/flag_de.gif");
      }
    );  
  


  $j('.sameheight').syncHeight();
  $j(window).resize(function(){ 
    $j('.sameheight').syncHeight();
  });
});
