jQuery.noConflict();

var plauditSite = (function($){
	
	return {
		init: function(){
			this.defaultMethod();
			this.customElements.init();
		},
		
		defaultMethod: function(){
			$("body").addClass("jsEnabled");
//			$("tr:odd").addClass("odd");
			$(".searchForm input#query").focus(function(){ $(this).select(); });
		},
		
		customElements: {
			
			init: function(){
				this.setupLightBox();
				this.gallerySlider();
				this.quickSand();
				this.homePageGallery();
				this.faq();
			},
		
			setupLightBox: function(context){
				var options = {
					animationSpeed: 'normal',
					allowresize: false,
					showTitle: false,
					theme: 'light_rounded'	
				};
				
				if ( context ) {
					$("a[rel^='lightbox']", context).prettyPhoto(options);
				} else {
					$("a[rel^='lightbox']").prettyPhoto(options);
				}
			},
			
			gallerySlider: function(){
				var options = {
					size: 1,
					clickable: false,
					next: "#next",
					prev: "#prev"
				};
				
				$("#imageGallery").scrollable(options);
				
			},
			
			quickSand: function(){
				var $this = this; // Cache object context
				
				$('a', $("#categoryOptions li")).click(function(e) {
					e.preventDefault();
				    $('#display').quicksand( $($(this).attr("href") + " li"),{easing: 'easeInOutQuad', useScaling: false}, function(){
				    	$this.setupLightBox($("#display"));
				    });
				    $this.setupLightBox($("#display"));
				    
				    $("a.active", $("#categoryOptions li")).removeClass("active");
				    $(this).addClass("active");
				});
				
				$("#categoryOptionsLoading").hide();
				$("#categoryOptions").fadeIn();
				
				$("#categoryOptions li:first a").click();
			},
			
			homePageGallery: function(){
				$("#animationInner").cycle({
					fx: 'scrollRight',
					timeout: '3500',
					speed: '1500',
					pager: '#animationPager',
					pause: true,
					pauseOnPagerHover: true,
					activePagerClass: 'active'
				});
			},
			
			faq: function(){
				var baseHref = $("head base").attr("href");
				$("#faq h3").toggle(
					function(e){
						var target = $(e.target);
						if (target.attr("href")){ //Check to see if the target element has an href if so go to the page
							window.location.href = baseHref + target.attr("href");
							return false;
						}
						$(this).addClass("open").next(".answer").slideDown();
					},function(e){
						var target = $(e.target);
						if (target.attr("href")){
							window.location.href = baseHref + target.attr("href");
							return false;
						}
						$(this).removeClass("open").next(".answer").hide();
					}
				);
			}
			
		} // Custom Elements
			
	};
	
})(jQuery);

plauditSite.init();


