
/* - ++resource++zhp.skin.scripts/zhp.js - */
$(document).ready(function() {
  
  //carousel add numbers
  jq('.carouselWrapper .carousel').bind('resized.carousel', function(event, newheight) {
    jq('.navi a').each(function(index){
      jq(this).text(index+1);
    });
  });
  
  
  // masonry
  jq('#viewlet-above-content #portletsAboveContent').masonry({itemSelector:'.portletWrapper', singleMode:true});
  jq('#viewlet-below-content #portletsBelowContent').masonry({itemSelector:'.portletWrapper', singleMode:true});
  
  
  //faq
  function verstecker(obj, theid) {
    var alle = jq('.hide');
    alle.each(function() {
      if ( jq(this).is(':hidden') ) {
          
      }
      else {
        if ( jq(this).attr('id') == theid ){            
                    
        }
        else {
          jq(this).hide();
        }
      }                  
    })    
  }
  
  function klapper(obj, theid) {
    var newo = obj.next();
    if(newo.length == 1 && newo.not('h4.switch').length == 1) {
        newo.attr('id', theid);
        if(newo.is(':hidden')) {
            verstecker(newo, theid);
            newo.show();            
        } else {
            newo.hide();
        }
        klapper(newo, theid);
    }
  }
  
  jq('h4.switch').click(function() {
    jq('h4.active_question').each(function(){
        jq(this).removeClass('active_question')
    });
    jq(this).addClass('active_question');
    var rndid = Math.ceil(Math.random()*1000)
    jq(this).attr('id', rndid); 
    klapper(jq(this), rndid);                                          
  });
                                     
});


