jQuery(document).ready(function($){
	/* To add the .plus class to any menu with children */
    $(".channels ul li:has(ul)").addClass("plus");
    $(".channels ul li ul li:has(ul)").addClass("plus");	

	/* Add callout message to the comment box */
	/** /
	$("#commentform #comment")
		.focus(
			function(e) {
				$(this).callout({
					className: "tooltip message-text",
					orient: "top",
					align: "left",
					width: 400,
	 	            nudgeHorizontal: -25,
		            nudgeVertical: 0,
					arrowHeight: 12,
					arrowInset: 26,
					text: "Hi. I will reply to your comment as soon as I come back from holiday. Thank you for taking the time to comment. Evita :)"
				});
			}
		)
		.blur(
			function(e) {
				$(this).closeCallout();
			}
		);
	/**/
	
	/* Initiate links to overlays that are right after the link and that has href="#overlay" */
	$("a[href='#overlay']").each(function(index) {
		var link = $(this);
		var overlay = link.parent().next();
		link.attr("rel", "#overlay-"+index).addClass("use-overlay");
		overlay.wrap('<div id="overlay-'+index+'" class="overlay"></div>');
	});
	
	/* Initiate normal overlays */
	$("a.use-overlay").overlay({
		effect: 'apple',
		speed: 'fast',
		expose: '#ddd'
	});
	
	/* Initiate overlays on all links that should use ajax */
	$("a.use-ajax-overlay").overlay({ 
	    target: '#ajax-overlay',
		effect: 'apple',
		speed: 'fast',
        onBeforeLoad: function() { 
            var wrap = this.getContent().find(".content-wrapper"); 
			var progress = this.getContent().find(".progress");
			var url = this.getTrigger().attr("href") + '?ajax=1';
			progress.show();
            wrap.empty().load(url, function() {
				progress.hide();
			}); 
        } 
	});
});
