var hidden=false;
var timer;
var oheight;
$(document).ready(function(){
	//timer = setTimeout("show_hide()", 2500);		
	oheight = $('#gallery-featured-image #image_copy').outerHeight(); 
	switcher();
});

function show_hide(){
	if(!hidden) hide();
	$('#gallery-featured-image').hover(function(){
		clearTimeout(timer);
		show();
	},
	function(){
		timer = setTimeout("hide();", 1500);
	});
}

function hide(){
	$('#gallery-featured-image #image_copy').animate({height:'0px'},'fast', function(){
		$('#gallery-featured-image #image_copy *').hide();
	});
}
function show(){
	$('#gallery-featured-image #image_copy').animate({height:oheight+'px'},'fast', function(){
		$('#gallery-featured-image #image_copy *').show();
	});
}

function switcher(){
	$('a[rel=movetolightbox]').click(function(){
		$(this).find('img').css('background', 'url(/images/cms/indicator.gif) no-repeat center center');
		var p = this
		$(this).fadeTo('fast', '0.1',function(){			
			var at=this;
			var divc = $(p).attr('class');
			var isrc = $(p).attr('href');
			$('#featured_image img').fadeTo('fast', '0', function(){
				$(this).attr('src', isrc);
				$('#image_copy').html($('div.'+divc).html());
				$(this).fadeTo(2000, '1', function(){$(this).css('background-image', 'none');});				
				$(at).fadeTo( 'slow', '1', function(){$(this).css('background-image', 'none');});				
			});
			
		});
	
		return false;
	});
}
