/* * * * CUSTOM JQUERY * * * * * * * * * * * * * * * * * * * * * * * * *

Author: Jimmy (18/11/2010)
Last Update: 19/07/2011 (Jimmy)

Requirements:

	js/jquery.js
	
	Other requirements based off jQuery modules used in this file.	

Purpose:

	This code allows all the website's jQuery to be stored in a single
	location for easy code changes. All code should use listeners and
	callback functions for easy control in once place.
	
	Standard modules should be launched from here (lightbox, cufon, etc.)
	for easy site-wide management.
	
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* Add element exists function */
jQuery.fn.exists = function() {
	return jQuery(this).length > 0;
}

$(document).ready(function() {
	
/* !Allows validating 
------------------------------------------*/
	$('a.new_window').attr('target', '_blank');
	$('input#search').attr('autocomplete', 'off');
	
/* !Fancybox (current lightbox implementation)
------------------------------------------*/	
	$('a.lightbox').fancybox({
		'type' : 'image',
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'titleShow'		: 	true,
	});	
	
/* !Menu system 
------------------------------------------*/
	$('ul#main_menu li a').hover(function() {	
		$(this).stop().animate({color: '#559e29'}, { queue: false, duration: 400 });
	}, function() {
		$(this).stop().animate({color: '#ffffff'}, { queue: false, duration: 200 });
	});
	
/* !Basic animated loading
------------------------------------------*/

	$('div.jsload').hide();
	$('div.jsload').slideDown(500, function() {
		// Do something
	});

/* !Simple tab system
------------------------------------------*/

	$('ul.tabs a').click(function() {
	
		$('ul.tabs a.current').removeClass('current');
		$(this).addClass('current');
		
		active_id = 'div' + $(this).attr('href');
		
		$('div.tab_container div.current').slideUp(function() {
			$(this).removeClass('current');
			$(active_id).addClass('current');
			$(active_id).slideDown();
		});

		return false;
	});
	
/* !Initalize AddThis module 
------------------------------------------*/

	//addthis.init();

});
