// initialize menu &  lightbox
$(document).ready(function(){ 
  $("ul.sf-menu").superfish(); 
  $('.lightbox-link').lightBox({fixedNavigation:true});
  if ($('#category-menu')[0]) categoryMenu();
});

// swap in function
function swapIn (previewURL,imageURL,title) { 
	if (document.lightbox_rollover) document.lightbox_rollover.src = previewURL;
	if ($('.lightbox-link')[0]) {
		$('.lightbox-link')[0].href = imageURL;
		if (title != undefined) $('.lightbox-link')[0].title = title;
	}
  return true;
}

// category menu
function categoryMenu () {
  var depth = 0;							
  $menu = [$('#category-menu').children()];

	// hide everything first
	$hidden = $('#category-menu ul').hide();

	for (var i=0; i<current.length; i++) {
		var inx = current[i] - 1;													
		if ($menu[depth]) {
		  var active = $($menu[depth][inx]);
		  active.addClass('open');
		  active.children('ul').show();
	  }									
		depth++;
		if (active.children('ul').children()[0] && (i+1) < current.length) {
		  $menu[depth] = active.children('ul').children();
	  } else {
	      active.addClass('active');
		  /*if (depth <= 2) { active.addClass('active');}
			else if (depth == 3) { active.parent().parent().addClass('active');}
		  else {active.parent().parent().parent().parent().addClass('active'); }
		  */
		  $(active).children('a').addClass('selected');
	  }
	}
	
	return true;
}
