
/*  Global variables
_________________________________________________________________________________ */

var gyShowNavigation = true;

/* Onload
_________________________________________________________________________________ */

$(document).ready(function(){
	$("#about").fadeOut(100);
	$("#charity").fadeOut(100);
	$("#contact").fadeOut(100);

	
	// Admin onclick handler:
	$('#openAdmin').click( function (event) { event.stopPropagation(); $('#admin').fadeToggle(); return false; } );
	$('#closeAdmin').click( function () { $('#admin').fadeOut(); return false; } );
	$('#header').click( function () { $('#admin').fadeOut('', function (event) { if(! gyShowNavigation) { $('#navigation').slideUp(); } } ); } );
	$('#navigation').click( function () { $('#admin').fadeOut('', function (event) { if(! gyShowNavigation) { $('#navigation').slideUp(); } } ); } );
	$('#content').click( function () { $('#admin').fadeOut('', function (event) { if(! gyShowNavigation) { $('#navigation').slideUp(); } } ); } );
	
	//Activate FancyBox
	$("a#videoLink1").fancybox({
		'frameWidth' : 400,
		'frameHeight' : 302,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#loginLink").fancybox({
		'frameWidth' : 320,
		'frameHeight' : 200,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#newsletterLink1").fancybox({
		'frameWidth' : 470,
		'frameHeight' : 340,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#newsletterLink2").fancybox({
		'frameWidth' : 470,
		'frameHeight' : 340,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#newsletterLink3").fancybox({
		'frameWidth' : 470,
		'frameHeight' : 340,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#signupLink1").fancybox({
		'frameWidth' : 670,
		'frameHeight' : 520,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#signupLink2").fancybox({
		'frameWidth' : 670,
		'frameHeight' : 520,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#signupLink3").fancybox({
		'frameWidth' : 670,
		'frameHeight' : 620,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
	
	$("a#signupLink4").fancybox({
		'frameWidth' : 670,
		'frameHeight' : 520,
		'overlayShow' :	true,
		'overlayOpacity' : 0.9
	});
});


	


/* Extend jQuery
_________________________________________________________________________________ */

jQuery.fn.fadeToggle = function(speed, easing, callback) { 
   return this.animate({opacity: 'toggle'}, speed, easing, callback); 
};

(function($) {
	/* jQuery class extension methods */
	$.extend({
		/* method for logging an object or message */
		consoleInfo: function (message) {
			if ($.browser.mozilla && !(typeof(window["console"]) == "undefined")) {
				console.info(message);
			}
		},

		/* method for logging an object or message */
		consoleWarn: function (message) {
			if ($.browser.mozilla && !(typeof(window["console"]) == "undefined")) {
				console.warn(message);
			}
		}
	});
})(jQuery);


/* Footer navigation - this is pure art!
_________________________________________________________________________________ */

var $aboutStatus = "off";
var $charityStatus = "off";
var $contactStatus = "off";

function footerNav( what ) {
	
	var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
	var scrollTo = scrollHeight;

	
	if( what == "#about" )
	{
		if( $aboutStatus == "off" )
		{
			$(what).fadeIn(100);
			$aboutStatus = "on";
			
			$("#charity").fadeOut(100);
			$charityStatus = "off";
			$("#contact").fadeOut(100);
			$contactStatus = "off";
			
			window.scrollTo(0, scrollTo - 600);
		}
		else
		{
			$(what).fadeOut(100);
			$aboutStatus = "off";
		}
	}
	
	if( what == "#charity" )
	{
		if( $charityStatus == "off" )
		{
			$(what).fadeIn(100);
			$charityStatus = "on";
			
			$("#about").fadeOut(100);
			$aboutStatus = "off";
			$("#contact").fadeOut(100);
			$contactStatus = "off";
			
			window.scrollTo(0, scrollTo);
		}
		else
		{
			$(what).fadeOut(100);
			$charityStatus = "off";
		}
	}
	
	if( what == "#contact" )
	{
		if( $contactStatus == "off" )
		{
			$(what).fadeIn(100);
			$contactStatus = "on";
			
			$("#about").fadeOut(100);
			$aboutStatus = "off";
			$("#charity").fadeOut(100);
			$charityStatus = "off";
			
			window.scrollTo(0, scrollTo);
		}
		else
		{
			$(what).fadeOut(100);
			$contactStatus = "off";
		}
	}

  };



