

jQuery(document).ready(
	function()
	{

var $ = jQuery;	
var FbiSite = 
{
	onReady:	function()
	{
		
//		if (Lightbox != undefined)
//		{
//			this.initLightbox();
//		}
		
		if ($.thickbox != undefined)
		{
			this.initThickbox();
		}
		
		
		for (var selector in this.elements)
		{
			var $elms = $(selector);
			
			if ($elms != null && $elms.length > 0)
			{
				this.elements[selector]($elms);
			}
		}
		
	},
	
	initLightbox: function()
	{
		Lightbox.autohideElements = 'select, embed[id!=soundtrax], object[id!=soundtrax]';
		Lightbox.onHideElements = function()
		{
			$('embed, object').css('visibility','hidden');
		}
		Lightbox.onShowElements = function()
		{
			$('embed, object').css('visibility','visible');
		}
		
		// deploys automatically on rel="lightbox" links
	},
	
	initThickbox: function()
	{
		$('a.thickbox').thickbox();
	},
	
	elements:
	{
		'#ApplicationAddForm': function($elms)
		{
			var setAutoSaveTimer;
			var doAutoSave = function()
			{
				var data = $elms.serialize();
				
				$.post('/applications/autosave', data,
					function()
					{
						setAutoSaveTimer();
					}
				);
			}
		
			setAutoSaveTimer = function()
			{
				setTimeout(doAutoSave, 60 * 1000);
			}
			
			setAutoSaveTimer();
			
			$(window).unload(doAutoSave);
		
			$('#toggle_section_dkt').toggle(
				function() {
					$('#section_dkt').slideDown(500);
				},
				function() {
					$('#section_dkt').slideUp(500);
				}
			);
			
			$('#toggle_section_bkt').toggle(
				function() {
					$('#section_bkt').slideDown(500);
				},
				function() {
					$('#section_bkt').slideUp(500);
				}
			);
			
			$('#section_dkt, #section_bkt').hide();
		},
	
		'.menu_pane': function ($elms) 
		{
			$elms.children('div.menu').children('.children').hide();
			
			/*
			$elms.children('div.menu').children('.menu_category').css('cursor','pointer').mouseover(
				function(e)
				{
					$('div.menu .children', $elms).slideUp(10);
					$(this).siblings('.children').slideDown();
					
					return false;
				}
			);
			*/
			
			/* Hover intent compatible code */
			$elms.children('div.menu').hoverIntent(
				function()
				{ 
					$elm = $(this).children('.children');
					$('div.menu > .children:visible').not($elm).hide();
					$elm.not(':visible').not(':animated').css('height', 'auto').slideDown();
					
					return false;
				},
				function()
				{
					$(this).children('.children').hide();
					return false;
				}
			);
			
			/* Non-Hover intent compatible code */
			/*
			$elms.children('div.menu').hover(
				function()
				{ 
					$elm = $(this).children('.children');
					
					$('div.menu > .children:visible').not($elm).hide();
					
					var q = $elm.queue();
					
					if (q && (q.length > 0))
					{
						for (var i=0; i<q.length; i++)
						{
							$elm.stop();
						}
					}
					
					$elm.not(':visible').css('height', 'auto').slideDown();
					
					return false;
				},
				function()
				{
					//$(this).children('.children').animate({opacity:1.0},1125).slideUp();
					
					var _this = this;
					var delayedHideFunction = function()
					{
						$(_this).children('.children:visible').hide();
					}
					setTimeout(delayedHideFunction, 1000);
					
					return false;
				}
			);
			*/
			
/*
			$elms.children('div.menu').mouseover(
				function(e)
				{
					if ($(this).hasClass('menu'))
					{
						var $c = $('.children', this);
					}
					else
					{
						var $c = $('.children', $(this).parents('div.menu'));
					}
					console.log($c);
					
					var q = $c.queue();
					
					if (q && (q.length > 0))
					{
						for (var i=0; i<q.length; i++)
						{
							$c.stop();
						}
					}
					$c.slideDown('slow');
					
					e.stopPropagation();
					e.preventDefault();
					return true;
				});
				
			$('#content').mouseover(
				function()
				{
					var $m = $('.menu', $elms).not('.current').not(':hover');
					
					var $c = $('.children', $m);
					
					$c.slideUp('slow');
					return false;
				});
	*/				
				
				
		},
		
		'img.frame': function($elms)
		{
			$elms.removeClass('frame').wrap('<a href="#" class="frame"></a>')
			$elms.after("<span class='tl'></span><span class='tr'></span><span class='bl'></span><span class='br'></span>");
			$elms.after("<span class='v'><span class='b'></span><span class='t'></span></span><span class='h'><span class='l'></span><span class='r'></span></span>");
			
		},
		
		'disabled .course_group_pane .course h3 a': function($elms)
		{
			$elms.each(
				function()
				{
					var $this = $(this);
					
					//	Hide rest of pane
					var $details = $this.parent().siblings('.notes, .description').hide();
					
					$this.toggle(
						function(e)
						{
							$details.slideDown();
							
							return false;
						},
						function(e)
						{
							$details.slideUp();
							
							return false;
						}
					);
				}
			);
			
			
		},
		
		'disabled .testimonial_group_pane .testimonial': function($elms)
		{
			var open_count = 3;
			$elms.each(
				function()
				{
					var $this = $(this).css('cursor','pointer');
					var $details = $this.children('.notes, .description');
					
					if (open_count > 0)
					{
						open_count--;
					}
					else
					{
						//	Hide rest of pane
						$details.hide();
					}
					
					$this.toggle(
						function(e)
						{
							$details.slideDown();
							
							return false;
						},
						function(e)
						{
							$details.slideUp();
							
							return false;
						}
					);
				}
			);
			
			
		}
	}
};


		FbiSite.onReady();
	}
);
	
