/**
 *	JavaScript | jQuery
 *	apsbb
 *  Author: Dion Snoeijen
 * 	Date: 04/07/2011
 */
$(document).ready(function () {					
	// -------------------------
	//	Block Info Containers
	// -------------------------
	$('.block_info').mouseenter(function () {$(this).find('p').slideDown();}).mouseleave(function () {$(this).find('p').slideUp();});
	
	// -------------------------
	//	Menu Expand
	// -------------------------
	$('.menu_expand').hide();
	
	// -------------------------
	//	Make sure slideback doesn't happend when hovering the expanded menu
	// -------------------------
	var slideback = false;
	$('.menu_expand').mouseenter(function () {
		// Dont slide back on leaving menu item
		slideback = false;
	}).mouseleave(function () {
	// -------------------------
	//	When leaving the expanded, move it back up
	// -------------------------
		$(this).slideUp();
		slideback = false;
	});
	
	// -------------------------
	//	When hovering the menu, see if we can open up something
	// -------------------------
	var currentId;
	var selector;
	$('ul#main_menu li a').hoverIntent(function () {
		currentId = $(this).attr('id');
		// If something is open, close it
		$('.menu_expand').slideUp();
		if(currentId)
		{
			selector = '#expand_' + currentId;
			$(selector).slideDown();
		}
	},function () {
	// -------------------------
	//	Do we have clearance to slide back?
	// -------------------------
		if(currentId && slideback)
		{
			// Strange, slideback is never set to true... but this works.
			$(selector).slideUp();
			slideback = false;
		}
	});
	
	$('#header_visual').cycle();
});
