(function ($) {
  Drupal.behaviors.customOmegaSubthemeJS = {
    attach: function(context, settings) {
      // you can implement your custom javascript/jquery here,
      // and also create other attached behaviors
      
      eventbinding(); // initial eventbinding
      // AFTER AJAX ACTIONS
      $(document).ajaxComplete(function(){
        eventbinding(); // rebind events
        // alert("Ajax Event fired")
      });
     
      
      
      // Bei Pressstimmen die Views-row im Anker ID in der Url bereits aufklappen
      if ( $(".view-pressestimmen.view-display-id-page").length > 0 ) {
        if (getUrlChunck(1)) {
          var anker = getUrlChunck(1);
          $("#"+anker).closest(".views-row").find(".more-details, .less-details, .views-field-body, .views-field-body-1").toggle();
        }
      }
      
    
     
      
    }
  };
  
// get the anker id (e.g. for pressestimmen) (simple helper function)
function getUrlChunck(n) {
    var fullurl = document.location.href;
    var parts = fullurl.split("#");
    return parts[n]; 
}


function eventbinding() {
  $('.more-details').unbind().bind('click', function(){
    $(this).closest(".views-row").find(".more-details, .less-details, .views-field-body, .views-field-body-1, .views-field-field-aufnahme-audiofiles").toggle();
  }); 
      
  $('.less-details').unbind().bind('click', function(){
    $(this).closest(".views-row").find(".more-details, .less-details, .views-field-body, .views-field-body-1, .views-field-field-aufnahme-audiofiles").toggle();
  });
}

})(jQuery);



  ;

