function popUpWindow(URLStr, left, top, width, height) {
  window.open(URLStr, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// setze korrekte Höhen
function resizeGrid() {

  $("#main-content").height("auto");

  if($("#main-content").height() < 380){
    $("#main-content").height(380);
  }
  
  if($("#main-content").height() < $("#column-left .content").height()){
    $("#main-content").height($("#column-left .content").height() - 30);
  }
  
  // ie7 specific
  if($.browser.msie && $.browser.version.substr(0,1)=="7"){
    $("div#column-left div.content span.vertical").each( function() {
      $(this).height($(this).parent().height());
    });
  }

  // ie6 specific
  if($.browser.msie && $.browser.version.substr(0,1)=="6"){
    $("span.vertical").each( function() {
      $(this).height($(this).parent().height());
    });
  }
  
}


jQuery(function($) {
  //resizeGrid();
  $(".corners").corner("6px");
});

// search
jQuery(function($) {
  $("#search-button").click(function() {
      if($.trim($("#searchterm").val()) != "" ) {
        $("#search-form").submit();
      } else {
        $("#searchterm").focus();
      }
  });
});

// Template Suche
jQuery(function($) {
  $("div.search-result h1.h1-search").hover(
    function() {
      $(this).parent().find("div.search-result-icon").addClass("search-result-icon-active");
    },
    function() {
      $(this).parent().find("div.search-result-icon").removeClass("search-result-icon-active");
    }
  );
});

// Template Pressebild
jQuery(function($) {

  // scrollable thumbnails
  $(".presse-scrollable-thumbs").each(function() {
    var currId = $(this).attr("id");
    
    $thumbnails = $(this).find("div.pressebild-thumb");
    
    // add scrollable if more than 2 thumbs
    if($thumbnails.size() > 3) {
      $(this).scrollable({
        size: 2,
        clickable: false,
        loop:true,
        circular: true, 
        next:".next-img", 
        prev:".prev-img"
      });
    }
    // hides prev next buttons if there are less than 3 images
    else
    {
      $(this).parent().find(".navi").css("visibility", "hidden");
    }

    // add overlay for thumbnails
    $thumbnails.each(function() {
      var posTop = -1500;
      var posLeft = 337;
      var overlayTargetId = $(this).attr("rel");
      if($(overlayTargetId).hasClass("horizontal")) {
        var posLeft = 625;
      }
      $(this).overlay({
          top:posTop,
          left: posLeft,
          onLoad: function() {
            var offset = this.getTrigger().offset();
            var offsetTop = offset.top - 285;
            this.getOverlay().css("top",  offsetTop + "px");
          }
      });
		});
		
  });
  
});


// Template Team
jQuery(function($) {
  $("div.team div.artikel-expandable span.icon-expandable-link").each(function(i) {
    if(i > 2){
      $(this).parent().toggleClass("inactive");
      $(".artikel-expandable-content", $(this).parent().parent()).hide();
    }
  
    $(this).click(function(){
      $("#main-content").height("auto");
      $(this).parent().toggleClass("inactive");
      $(".artikel-expandable-content", $(this).parent().parent()).slideToggle("normal");
    });
    $(this).parent().find("h1").click(function() {
      $("#main-content").height("auto");
      $(this).parent().toggleClass("inactive");
      $(".artikel-expandable-content", $(this).parent().parent()).slideToggle("normal");
    });
  });
});

// Template Standard
jQuery(function($) {
  var expandableAvailable = $("div.standard div.artikel-expandable h1.h1-expandable").size();
  
  if(expandableAvailable && expandableAvailable > 1) {
    $("div.standard div.artikel-expandable h1.h1-expandable").each(function(i) {
      
      // hide all
      $(".artikel-expandable-content", $(this).parent().parent()).hide();
      
      // click event
      $(this).click(function(){
        $(this).toggleClass("active");
        $(".artikel-expandable-content", $(this).parent().parent()).slideToggle("normal").toggleClass("expandable-line");
      });
    });
    }
});


jQuery(function($) {
  var imgGallery = $("div.img a.overlay-single").size(); 
   
  if (imgGallery) { 
    // select the thumbnails and make them trigger our overlay
    $("div.img").each(function() {
    
      $("a.overlay-single", this).each(function(i){
          $(this).overlay({
            
            // each trigger uses the same overlay with the id "gallery" 
            target: '#gallery', 
         
            // optional exposing effect 
            expose: '#f1f1f1' 
         
        // let the gallery plugin do its magic! 
        }).gallery({ 
         
            // the plugin accepts its own set of configuration options 
            speed: 800 
        });
      });
    });
  }
});

jQuery(function($) {

  var imgGallery = $("div.scrollable a.overlay-multiple").size(); 
   
  if (imgGallery) { 
    $("div.scrollable").each(function(){
      
      $(this).scrollable({
        size: 3
      }).find("a.overlay-multiple").overlay({ 
       
          // each trigger uses the same overlay with id "gallery" 
          target: '#gallery', 
       
          // optional exposing effect with custom color 
          expose: '#f1f1f1', 
       
          // clicking outside the overlay does not close it 
          closeOnClick: false 
       
      // gallery plugin 
      }).gallery({ 
       
          // do not use the same disabled class name as scrollable 
          disabledClass: 'inactive',
          speed: 800 
      });
    });
  }

});


