jQuery(document).ready(function($){
	/* 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: 280,
		            nudgeVertical: 0,
					arrowHeight: 12,
					arrowInset: 26,
					text: "<h3>Hi there...</h3>Thank you kindly for your visit and for taking the time to comment here. Your feedback is greatly appreciated. <div class='right'><em>Evita</em> :)</div>"
				});
			}
		)
		.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();
			}); 
        } 
	});
});

