$(function() {
    $('.fuscated').defuscate();
    $('.emptyonclick, .search').emptyonclick({
		changeClass: 'changed'
	});
	
	$('.main-menu li').each(function() {
		if($(this).hasClass('parent')) {
			var tm = null;
			var that = this;
			$(this).hover(function(ev) {
				if(tm) {
					clearTimeout(tm);
					tm = null;
				}
				$(that).addClass('active').find('.sub-menu').show();//css('visibility', 'visible');
				
			}, function(ev) {
				tm = setTimeout(function() {
					$(that).removeClass('active').find('.sub-menu').hide();//css('visibility', 'hidden');
					tm = null;
				}, 250);
			});
		}
	});

	$('a').each(function() {
	   	var a = new RegExp('/' + window.location.host + '/');
	   	if(!a.test(this.href)) {
	       	$(this).click(function(event) {
	           	event.preventDefault();
	           	event.stopPropagation();
	           	window.open(this.href, '_blank');
	       	});
	   	}
	});
});

var Calendar = {
	page: function(vars) {
		$('.calendar-wrapper').load('/agenda/calendar?'+vars);
	}
};

