

var menuTimer = 0;
var menuDelay = 600;

function showMainMenu() {
	clearTimeout(menuTimer);
	menuTimer = 0;
	$('#mainMenu').show();
}

function hideMainMenu() {
	clearTimeout(menuTimer);
	menuTimer = setTimeout(doHideMainMenu, menuDelay);
}

function doHideMainMenu() {
	$('#mainMenu').hide();
}


// init the admin area
$(document).ready(function() {
	$('#mainMenuLnk, #mainMenu, #mainMenu a').bind('mouseover', showMainMenu);
	$('#mainMenuLnk, #mainMenu, #mainMenu a').bind('mouseout', hideMainMenu);
	
	// Set Even/Odd Rows
	$('.contentTbl tr:nth-child(even)').not('.hdrRow, .contentTbl tr tr').addClass('evenRows');
	$('.contentTbl tr:nth-child(odd)').not('.hdrRow, .contentTbl tr tr').addClass('oddRows');	
	
	$(".datepicker").datepicker();
	
	// for any form assigned the "trackformchanges" class, detect if data has been changed and if so assign it a class of dirty.
	$('.trackformchanges input, .trackformchanges select').live("change", function() {$(this).closest('form').addClass('dirty')});

	// for dirty forms, that have a link of class warn within them, warn that clicking on that link will discard the 
	//  previously made changes.
	$('form.dirty a.warn').live("click", function(e) {
		var a = confirm('Clicking on this link now will discard the changes already made.\nIf you continue you will lose your changes.');
		if(!a)
			e.preventDefault();
	});
});