$(document).ready(function() 
{	
	$("a[href='#']").click( function()
	{
		return false;
	});	

	$("ul.sf-menu").supersubs({ 
		minWidth: 15,
		maxWidth: 15,
		extraWidth: 1
	}).superfish({ 
		delay: 300,
		animation: {opacity:'show', height:'show'},
		speed: 300,
		autoArrows: true,
		dropShadows: true
	});http://www.leadershipfoundations.org.php5-13.dfw1-2.websitetestlink.com/wp-content/themes/leadershipfoundations/images/background_1.jpg
	
	$("ul.sf-menu a").attr('title', '');
	
	$("#footer .callouts a")
		.mouseover(function()
		{
			//$(this).find('img').stop().css({opacity: 0.5}).animate({opacity:1}, {duration:500});
		})
		.mouseout(function()
		{
			//$(this).css({opacity: 1});
		});
	
	$('.scrollable').jScrollPane(
	{
		scrollbarWidth	: 10, 
		scrollbarMargin	: 20, 
		dragMinHeight	: 50,
		wheelSpeed		: 20,
		showArrows		: false, 
		animateTo		: true,
		animateInterval	: 500,
		animateStep		: 3,
		reinitialiseOnImageLoad: true
	});
	
	$('.grid a.cell').click(function()
	{
		var popup = $(this).parent().find('.popup');
		popup.stop().css({display:'block', opacity:0}).animate({opacity:1}, {duration:200});
		
		popup.find('.content').jScrollPane(
		{
			scrollbarWidth	: 10, 
			scrollbarMargin	: 20, 
			dragMinHeight	: 50,
			wheelSpeed		: 20,
			showArrows		: false, 
			animateTo		: true,
			animateInterval	: 500,
			animateStep		: 3,
			reinitialiseOnImageLoad: true
		});
	});
	
	$('.grid a.close').click(function()
	{
		//alert('Show '+$(this).attr('title')+'\'s popup');
		var popup = $(this).parent();
		popup.animate({opacity:0}, 100, function() { popup.css({display:'none'}); });
	});
	
	
	$('#footer .callouts a').hover(function()
	{
		//$(this).stop().animate({ left: "+=8px" }, 150);
	},
	function()
	{
		//$(this).stop().animate({ left: "-10px" }, 150);
	});
	
	var FullscreenrOptions = { width: 1200, height: 800, bgID: '#background' };
	jQuery.fn.fullscreenr(FullscreenrOptions);
		
});

// ----------------------------------------------------------- fullscreenr

(function($)
{
	
	$.fn.fullscreenr = function(options) 
	{
		var defaults = { width: 1280,  height: 1024, bgID: 'background' };
		var options = $.extend({}, defaults, options); 
		
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });	
		$(options.bgID).fullscreenrResizer(options);
		
		return this; 		
	};
	
	$.fn.fullscreenrResizer = function(options) 
	{
		var ratio = options.height / options.width;	
		
		var browserwidth = $(window).width();
		var browserheight = $(window).height();
		
		if ((browserheight/browserwidth) > ratio){
		    $(this).height(browserheight);
		    $(this).width(browserheight / ratio);
		} else {
		    $(this).width(browserwidth);
		    $(this).height(browserwidth * ratio);
		}
		
		$(this).css('left', (browserwidth - $(this).width())/2);
		//$(this).css('top', (browserheight - $(this).height())/2);
		$(this).css('top', 0);
		
		return this; 		
	};
	
})(jQuery);

// ----------------------------------------------------------- clearOnFocus

(function($) 
{
	$.fn.clearOnFocus = function() 
	{	
		function clearOnFocusFocus(event)
		{
			if($(this).val() == $(this).data('clearOnFocus'))
			{
				$(this).val('');
			}
		}
		
		function clearOnFocusBlur(event)
		{
			if($.trim($(this).val()) == '')
			{
				$(this).val($(this).data('clearOnFocus'));
			}
		}
		
		return this.each(function()
			{
				$(this).data('clearOnFocus', $(this).attr('value'));
				
				//	unbind any previous listeners
				$(this).unbind('focus', clearOnFocusFocus);
				$(this).unbind('blur', clearOnFocusBlur);
				
				//	bind listeners to the functions
				$(this).bind('focus', clearOnFocusFocus);
				$(this).bind('blur', clearOnFocusBlur);
			}
		);
	};
	
})(jQuery);
