// JavaScript Document

$(document).ready(function(){
		 $('#gray').height($('#wrap').outerHeight(true));
		$('.colour_grey').click(function(){
		$('body').toggleClass('gray');
			var $target = $('#gray');
			var $btn    = $(this);
			if($target.hasClass('hide')) {
				$target.fadeIn(200, function(){
					$btn.addClass('active');
					$(this).removeClass('hide');
				});
			} else {
				$('#gray').fadeOut(200, function(){
					$btn.removeClass('active');
					$(this).addClass('hide');
				});	
			}
			
			return false;
		});
		
			var galleryNumber = 0;
		$(".fade-cycel").each(function(e){
		
		$(this).append('<div class="ctl"></div><div class="ctr"></div><div class="cbr"></div><div class="cbl"></div>');
		
			galleryNumber++;
			
			var $gallery = $(this).find('.gallery');
			var $prev    = $(this).find('.prev2');
			var $next    = $(this).find('.next2');
			
			$prev.find('a').attr('id','prev'+galleryNumber).hide();
			$next.find('a').attr('id','next'+galleryNumber).hide();
			
			$gallery.cycle({ 
			    fx:     'fade', 
				speed:  'fast', 
		    	timeout: 0, 
		    	next:    '#'+$next.find('a').attr('id'), 
		    	prev:    '#'+$prev.find('a').attr('id')
			});
			
			$prev.hover(function(){
				$(this).find('a').stop(true,true).fadeIn(200);
			},function(){
				$(this).find('a').stop(true,true).fadeOut(200);
			});
			
			$next.hover(function(){
				$(this).find('a').stop(true,true).fadeIn(200);
			},function(){
				$(this).find('a').stop(true,true).fadeOut(200);
			});
			
		});		

$('a.infobox-link').click(function(){
$(this).parents('.fade-cycel').find('.infobox').animate({opacity: 'toggle'}, 200);
return false;

});
	});

