/**
 * Focus Educational 
 */

var application = {
	
	start: function() {
		forms.init();
		programmeList.init();
		corners.render();
	}
	
};
$(document).ready( application.start );




var forms = {
	
	init: function() {
		forms.init_login_form();
	}
	
	,init_login_form: function() {
		
		$('#username').focus();
		$('#login-form').submit(function() {
			if( $('#username').val() == '' ) {
				alert('Please enter your username before continuing');
				$('#username').focus();
				return false;
			}
			if( $('#password').val() == '' ) {
				alert('Please enter your password before continuing');
				$('#password').focus();
				return false;
			}
		});
		
	}
	
};




var programmeList = {
	
	init: function() {
		programmeList.init_list();
		programmeList.init_logoutlink();
	}

	,init_list: function() {
		
		$('.my-programmes .list > li > ul a').each(function() {
			if( $(this).parent().find('ul').length ) {
				$(this).addClass('noicon');
			}
		});
		
		$('.my-programmes .list > li > a').click(function() {
			if( $(this).attr('href') != '#' ) {
				return true;
			}
			
			if( $(this).hasClass('selected') ) {
				$(this).parent().find('ul:first').slideUp('normal');
				$(this).removeClass('selected').blur();
				return false;
			}

			$('.my-programmes .list > li > ul').slideUp('normal');
			$('.my-programmes .list > li > a').removeClass('selected');
			
			$(this).addClass('selected').blur();
			$(this).parent().find('ul:first').slideDown('normal');
			
			return false;
		});
		
		$('.my-programmes .list > li > ul a').click(function() {
			if( $(this).attr('href') == '#' || $(this).attr('href') == '' ) {
				return false;
			} else {
				return true;
			}
		});

	}

	,init_logoutlink: function() {
		
		$('.logout-link a').click(function() {
			if( confirm('Are you sure you want to log out?') ) {
				return true;
			} else {
				return false;
			}
		});
		
	}
	
};



var corners = {
	
	render: function() {
		
		
		
	}
	
};


