$(document).ready(function(){ 
	// prevent user from typing in anything but numeric
	$(".numeric").keydown(function(event) {
		
		if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 13 || event.keyCode == 16) {
			// do nothing
		} else {
			if (event.keyCode < 95) {
				if (event.keyCode < 48 || event.keyCode > 57 ) {
					event.preventDefault();
				}
			} else {
				if (event.keyCode < 96 || event.keyCode > 105 ) {
					event.preventDefault();
				}
			}
		}
	});
	
	$("#nav li a").each(function() {
		$("#courseDd li a").removeClass('active');
		if(this.href == window.location)
			$(this).addClass("active");
		});
	
	$(".aboutAccordionBtn").click(function () {
		 $('.aboutAccordionBtn').removeClass("acActive");
		    $(this).addClass("acActive");
	  });
	//pop bubble
	$('#courseHeader p, .stepsBtn, #mapCon a').tipsy({fade: true, gravity: 's'});
	
	//ads class to all odd coloums in tables
		$("tr:odd").addClass('odd');
		//removes margin from the last element on learners corner page
		$(".learnerThumbs:last").css({margin:'0'});
		//accordion
		$('.accBtn').click( function () {
			$('div#accordion div.content').removeClass('open');
			$('.accBtn').removeClass('over');
			$(this).addClass('over');
			$(this).next().addClass('open').slideDown('slow');
			$('div#accordion div.content:not(.open)').slideUp('fast');
			return false;
		});
	//dropdown menu
		// Remove the class of child and grandchild
		// This removes the CSS 'falback'
		$("#nav ul.child").removeClass("child");
		$("#nav ul.grandchild").removeClass("grandchild");
	
		// When a list item that contains an unordered list
		// is hovered on
		$("#nav li").has("ul").hover(function(){
	
			//Add a class of current and fade in the sub-menu
			$(this).addClass("current").children("ul").slideDown();
		}, function() {
	
			// On mouse off remove the class of current
			// Stop any sub-menu animation and set its display to none
			$(this).removeClass("current").children("ul").stop(true, true).slideUp();
		});
		$("#nav li #courseDd li a:last").addClass('lastMenuItem');
		$("#nav li #contactDd li a:last").addClass('lastMenuItem');
		
		if($('#nav').find('.active').length){
			  $('#nav .active').siblings().css({margin: '-13px 0 0 0', borderTop: 'none', padding: '20px 0 0 0'});
			}
		
		// date picker
		$.extend(DateInput.DEFAULT_OPTS, {
			stringToDate: function(string) {
				var matches;
				if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
					return new Date(matches[1], matches[2] - 1, matches[3]);
				} else {
					return null;
				};
			},
			dateToString: function(date) {
				var month = (date.getMonth() + 1).toString();
			    var dom = date.getDate().toString();
			    if (month.length == 1) month = "0" + month;
			    if (dom.length == 1) dom = "0" + dom;
			    return dom + "/" + month + "/" + date.getFullYear();
			}
		});
		//$("#per_birthday").date_input();
		
		//forgot password	
		$("#forgotPass").click(function() {
		  $("#forgot-box").css("display", "block");
		});
		$("#cancel").click(function() {
		  $("#forgot-box").css("display", "none");
		});
	});
