$(document).ready(function(){
	
	if($('.faq-title').length > 0) {
		
		$('.faq-title a').live('click', function(){
			var $href = $($(this).attr('href'));
			
			if($href.is(':visible')) {
				$href.slideUp();
			} else {
				$href.slideDown();
			}
			
			return false;
		});
		
		$('.faq-hidden p:first-child').attr('style','margin-top: 0;');
		
	}
	
	if($('.gallery').length > 0) {
		$('.gallery-thumbnails a').live('click', function(){
			var href = $(this).attr('href').replace('#','');
			$('.gallery-images li').hide();
			$('#gallery-image-'+href).show();
			
			$('.current-img').removeClass('current-img');
			$(this).addClass('current-img');
			
		});
		
		$('.gallery-thumbnails a:first').addClass('current-img');
		
		$('.gallery-forward').live('click', function(e){
			var $next = $('.gallery-thumbnails .current-img').parent().next();
			if($next.length > 0)
				$next.find('a').trigger('click');
				
			e.preventDefault();
		});
		
		$('.gallery-back').live('click', function(e){
			var $prev = $('.gallery-thumbnails .current-img').parent().prev();
			if($prev.length > 0)
				$prev.find('a').trigger('click');

			e.preventDefault();
		});
	}
});
