var $j = jQuery.noConflict();

/************************************************
 * Function to validate well formed string date
 * 
 * @param string
 * @return bool
 */
function isValidDate(d)
{
	if (Object.prototype.toString.call(d) !== "[object Date]")
		return false;
	return !isNaN(d.getTime());
}

/**
 * Function to get year, month, day, hours and minutes from the date given in
 * yyyy-mm-dd hh:mm:ss Return an array indexed by: 'year', 'month', 'day',
 * 'hour', 'minutes'. Return null on error.
 * 
 * @param string
 * @return
 */
function parseDate(date)
{
	// Preconditions
	if (date == null)
	{
		return null;
	}

	var result = new Array();

	result['year'] = date.substring(0, 4);
	result['month'] = date.substring(5, 7);
	result['day'] = date.substring(8, 10);
	result['hour'] = date.substring(11, 13);
	result['minutes'] = date.substring(14, 16);

	return result;
}



/**
 * Callback function that must be called when the document is ready, containing the common initial actions 
 * (as initialize the header).
 * 
 * This function is called everytime masterTemplate is renderized.
 * 
 * @param args
 */
function initCommonActions(event)
{
	Event.stop(event);
	
	jQuery.noConflict();
	
	jQuery('.dropdown').each(function () {
		jQuery(this).parent().eq(0).hover(function () {
			jQuery('.dropdown:eq(0)', this).show();
		}, function () {
			jQuery('.dropdown:eq(0)', this).hide();
		});
	});
}
