/* @author mbacou
 ------------------------------------------- */
var $j = jQuery.noConflict();

$j(document).ready(function(){

  //equalize heights
  $j('.cols').equalHeights();
  
  //scrollable RSS
  $j('div.scroll').vTicker({
    speed: 800,
    pause: 6000,
    showItems: 5,
    animation: 'fade',
    mousePause: true
  });
  
  //side navigation
  $j('ul#nav li:has(ul)').css({
    background: 'url(/wp-content/themes/meze/img/nav-close.png) no-repeat 0 0',
    cursor: 'pointer'
  });
  
  
  $j('ul#nav li:has(ul)', this).click(function(){
    var checkElement = $j(this).children('ul');
    if (checkElement.is(':visible')) {
      checkElement.slideUp('normal');
    }
    else {
      $j('#nav ul:visible').slideUp('normal');
      checkElement.slideDown('normal');
    }
    return false;
  });
  $j('ul#nav ul li a', this).click(function(){
    window.location = $j(this).attr('href');
    return false;
  });
  $j('ul#nav li:has(ul) a', this).click(function(){
    window.location = $j(this).attr('href');
    return false;
  });
  
  //display captions
  $j('p.wp-caption-text', this).each(function(){
    $j(this).hide()
            .width($j(this).prev('img').width()-8);
  });
  $j('div.wp-caption', this).mouseenter(function(){
    $j(this).children('p.wp-caption-text').slideDown('normal')
  }).mouseleave(function(){
    $j(this).children('p.wp-caption-text').slideUp('normal')
  });
  
  //display photo captions
  $j('img.captify', this).captify({
    speedOver: 'fast',
    speedOut: 'normal',
    hideDelay: 500,
    animation: 'slide',
    prefix: '',
    opacity: '0.8',
    className: 'caption-bottom',
    position: 'bottom',
    spanWidth: 'auto'
  });
  
});
