$(function(){
  //Buttons erstellen
  $('.button').makeButtons({icon:'arrow-1-se'});
  $('.doButton').makeButtons({icon:'arrow-1-se'});

  //Accordion
  if($(".csc-accordion").length > 0){
    $.each($(".csc-accordion"),function(index,item){
      $(item).children("h3").wrapInner('<a href="#" />');
      $(item).children("ul").wrap('<div />');
      $(item).children("p").wrap('<div />');
      $(item).accordion({ header:'h3', autoHeight:false });
    });
  }
  
  //Anchorlinks
  $("a.scrolllink").click(function(event){
    event.preventDefault();
    var targetAr = this.href.split('#')
    var target = targetAr[1];
    var targetPos = $("#"+target+"").offset();
    $('html, body').animate({scrollTop:targetPos.top}, 1500);
  });
  
  //Lightbox mit Zoom-Icon
  $.each($('a[rel]'),function(index,item){
    if($(this).attr('rel').indexOf('lightbox') >= 0){
      imgWidth = parseInt( $(this).children('img').attr('width') );
      imgHeight = parseInt( $(this).children('img').attr('height') );
      $(this).append('<span id="zoomBtn" style="position:relative;top:-'+ imgHeight +'px;margin-bottom:-'+ imgHeight +'px;width:'+ imgWidth +'px;height:'+ imgHeight +'px;" />');
    }
  });
  
  if($.browser.msie){ if($.browser.version < 7.0){
    $('#rahmen').before('<div id="iemessage" style="background:#FFFFE1; padding:10px; font-weight:bold;">Sie nutzen einen veralteten und unsicheren Browser (Internet Explorer 6). Diese Seite wird daher nicht korrekt angezeigt.<br />Bitte nutzen Sie einen modernen Browser oder updaten Sie Ihren Internet Explorer.</div>');  
  }}


  //News-Bild Subline
  if($(".news-single-newstext img").length > 0)
  {
    var checkIMGTitle = $(".news-single-newstext img");
    var checkIMGTitleAnz = checkIMGTitle.length;
    for(var z=0; z<checkIMGTitleAnz; z++)
    {
      if($(checkIMGTitle[z]).attr("title") != "")
      {
        $(checkIMGTitle[z]).wrap('<div class="news-single-img-wrapSubhead"></div>');
        $(checkIMGTitle[z]).after('<span id="nsis'+z+'" class="news-single-img-subhead"></span>');
        tempID = '#nsis'+z+'';
        $(tempID).width($(checkIMGTitle[z]).width());
        $(tempID).html($(checkIMGTitle[z]).attr("title"));
      }
    }
  }
});
