$(document).ready(function(){
	$.fn.tagName = function() {
		return this.each(function() {
		  return this.tagName;
		});
	}
	$.fn.idle = function(time){
		var i = $(this);
		i.queue(function(){
			setTimeout(function(){
				i.dequeue();
			}, time);
		});
	};

	$('#menu a').hover(function(){
		var l = $(this).next().children('li').length;
		if(l > 0) {
			var o = $(this).offset();
			var h = 35;
			var d = parseInt($('body').width()) - parseInt($('#site').width());
			var off = parseInt( (d/2) );
			var left = parseInt(o.left)-off;
			var top = parseInt(o.top)+h;
			$(this).addClass('active_expanded').next().show().css({'left': left,'top': top}).addClass('submenu');
		}
	}, function(){
		$(this).idle(100).removeClass('active_expanded').removeClass('submenu').next().hide();
	});

	$('.submenu').hover(function(){
		$(this).prev().addClass('active_expanded').show();
	},function(){
		$(this).hide().prev().removeClass('active_expanded');
	});

	Cufon.replace("#menu");

	$('.cbox, .colorbox').colorbox();
});
