$(document).ready(function(){

	$('#login-form').hover(
		function()
		{
			$('#login-notifications').show().animate({
				opacity:1,
				left:225
			}, 200);
		},
		function()
		{
			setTimeout(closeNotifications, 500);
		}
	);
	
	function closeNotifications()
	{
		$('#login-notifications').animate({
			opacity:0,
			left:230
		}, 200, function(){
			$('#login-notifications').hide();
		});
	}
	
	// business banking checkbox
	state = $.cookies.get( $('#login-form').find(':checkbox').attr('name') ); // box should be checked
	if(state)
	{
		$('#login-form').find(':checkbox').attr( 'checked', 'checked' );
	}
	
	login_check = $('<div id="login-form-check"></div>');
	state ? login_check.addClass('active') : null ;
	$('#login-form').find(':checkbox').css({
		'display':'none'
	}).before(login_check);
	
	$('#login-form-check').click(function(){
		date = new Date();
		if($(this).next().attr('checked')) // is checked
		{
			//console.log('no longer checked');
			$(this).removeClass('active');
			$(this).next().removeAttr('checked');
			$.cookies.del( $(this).next().attr('name') );
			return false;
		}else{
			//console.log('now checked');
			$(this).addClass('active');
			$(this).next().attr( 'checked', 'checked' );
			$.cookies.set( $(this).next().attr('name'), 1, {expiresAt:new Date(date.getFullYear()+2, date.getMonth(), date.getDate())} );
			return false;
		}
	});
	// end business banking checkbox

	$('#app-center div').toggle(
		function(){
			if($(this).parent().find('ul').is(':animated')){ return }
			$(this).parent().find('.arrow').attr('src', path.template_path+'images/arrow-white-down.gif');
			$(this).parent().find('ul').slideToggle();
		},
		function()
		{
			if($(this).parent().find('ul').is(':animated')){ return }
			$(this).parent().find('.arrow').attr('src', path.template_path+'images/arrow-white.gif');
			$(this).parent().find('ul').slideToggle();
		}
	);
	
});