
(function($) {

	var methods = {


		/**
		 *
		 *	Initilialises interface elements
		 *
		 */
		initInterface : function() {

			// allow any link with a 'modal' class to use a modal window
			$('.modal').fancybox({
				'centerOnScroll' : false,
				'type' : 'iframe',
				'width' : 960,
				'height' : '85%'
			});

			// any div's classed with "freedomTabs" will be made into tabs
			$('.renderedTabs').organicTabs();

			return true;

		}

	}

	$.fn.Freedom = function(method) {
		return methods[method].apply(this);
	}

})(jQuery);


// this is ran on every page load 
$(document).ready(function() {


	// initialise the interface
	$('body').Freedom('initInterface');


	// Toggle the dropdown menu's
	$(".dropdown .button, .dropdown button").click(function () {
		$(this).parent().find('.dropdown-slider').slideToggle('fast');
		$(this).find('span.toggle').toggleClass('active');
		return false;
	});

	// Close open dropdown slider by clicking elsewhwere on page
	$(document).bind('click', function (e) {
		if (e.target.id != $('.dropdown').attr('class')) {
			$('.dropdown-slider').slideUp();
			$('span.toggle').removeClass('active');
		}
	});


});

