/*
$Id: func.js,v 1.10 2008/11/06 16:53:56 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*/

function fcIconsLIOver() {
  this.className += " over";
}

function fcIconsLIOut() {
  this.className = this.className.replace(/ over/, "");
}

if ($.browser.msie) {
  $.event.add(
	  window,
  	'load',
	  function() {
      $('ul.fancycat-icons-level-0 li').hover(fcIconsLIOver, fcIconsLIOut);
  	}
  );
}

var fc_delay = 1000;
var doc_width = $(document).width();
var box_width = 195; // skin1/modules/Fancy_Categories/Icons/main.css: .fancycat-icons-scheme ul {}
var box_offset = 170;
var max_offset_x = doc_width - box_width;

function fcInit() {
	$('ul.fancycat-icons-level-0 li').each(function(){
		$(this).hover(
			function(){
				$(this).stopTime("menu_collapse");
				$(this).siblings().children("ul").css('display', 'none');
				$(this).children("ul").css('display', 'block');
				if ($(this).children("ul").offset()){
					if ($(this).children("ul").offset().left > max_offset_x) {
						$(this).children("ul").css("left","-"+box_offset+"px");
					}
				}
			},
			function(){
				$(this).oneTime(fc_delay, "menu_collapse", function(){$(this).children("ul").css('display', 'none');});
			}
		);
	});
}
$(document).ready(function(){
	fcInit();
});
