/**
 * This source code is part of the Midnatt Content Management Framework.
 *
 * Copyright (c) Midnatt.org | http://www.midnatt.org | mail@midnatt.org
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Constructor.
 */
Ping_Application = function() {
}

/**
 * Initializes external tools and libraries.
 */
Ping_Application.prototype.loadLibraries = function() {
	var application = this;

	$('.ping-datepicker').each(function() {
		$(this).datepicker();
	});

	var lightbox_theme = window.ping.config.lightbox_theme;
	$("a[rel^='ping-lightbox']").prettyPhoto({theme: lightbox_theme});
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: lightbox_theme});

	$(".ping-tooltipped[title], .ping-form-help[title]").tooltip({ position: "bottom center" });

	$('.ping-popup').popupWindow({ // TODO
		height: 720,
		width: 512,
		top: 50,
		left: 50
	});

	// jQuerySimpleDropDown
	var config = {
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 200,  // number = milliseconds for onMouseOver polling interval    
		over: doOpen,   // function = onMouseOver callback (REQUIRED)    
		timeout: 200,   // number = milliseconds delay before onMouseOut    
		out: doClose    // function = onMouseOut callback (REQUIRED)    
	};

	function doOpen() {
		$(this).addClass("hover");
		$('ul:first',this).css('visibility', 'visible');
	}

	function doClose() {
		$(this).removeClass("hover");
		$('ul:first',this).css('visibility', 'hidden');
	}

	//$("ul.dropdown li").hoverIntent(config);
	$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
	//
}

/**
 * Puts the application in a busy/idle state.
 */
Ping_Application.prototype.setBusy = function(on_or_off) {
	if (on_or_off) {
		$('#ping-indicator').show();
	} else {
		$('#ping-indicator').hide();
	}
}



