/* vim: set ts=2 sw=2 sts=2 et: */
/**
 * Functions for the Flyout menus module
 * 
 * @category   X-Cart
 * @package    X-Cart
 * @subpackage JS Library
 * @author     Ruslan R. Fazlyev <rrf@x-cart.com> 
 * @version    $Id: func.js,v 1.2 2010/05/27 14:09:39 igoryan Exp $
 * @link       http://www.x-cart.com/
 * @see        ____file_see____
 */

// $('ul li ul', $('a').filter(function() { return this.href.search(/home\.php\?cat=75/) != -1; }).eq(0).parents('li').eq(0)).eq(0).css('display')

function switchSubcatLayer(obj) {
  $(obj.parentNode).toggleClass('closed');
  return false;
}

$(document).ready(
  function() {

    // Parent categories of current category are expanded
    if (typeof(window.catexp) != 'undefined' && catexp > 0) {
      $('#catrootmenu .fancycat-icons-c #cat-layer-' + catexp).parents('li.closed').removeClass('closed');
    }

    // Root categories are always expanded
    $('#catrootmenu.fancycat-icons-c .fancycat-icons-level-0 > .sub-link').removeClass('closed');

    // Show "expand" links for each 1-st level section
    $('#catrootmenu.fancycat-icons-c .toggle-link').css('display', 'block')
    .find('.box')
    .toggle(
      function () {
        $(this).parent().parent().find('.sub-link.closed').removeClass('closed').addClass('expanded');
        $(this).find('.collapse').show().end().find('.expand').hide();
      },
      function () {
        $(this).parent().parent().find('.sub-link.expanded').addClass('closed');
        $(this).find('.collapse').hide().end().find('.expand').show();
      }
    );

  }
);

