var    	el = null;
var		l = null;
var		c_w = null;
var		h = null;
var 	open = false;
var 	act = false;

	function captionSlideIn() {
		$("#caption").stop();
		el = $("a.advance-link img");
		l = el.position().left;	
		c_w = el.width();
		h = el.height();

		if(act == false) {
			$("#caption").css({
				left: l+(c_w) + "px",
				height: h + "px"
			});
			act = true;
		}
	
		if(open) {
			t_w = 0;
			t_l = l+(c_w);
			dur = 200;
			t_opa = 0.0;
			$(".caption").fadeOut(20);
			open = false;
		} else {
			t_w = c_w/2;
			t_l = l+(c_w)-(c_w/2);
			dur = 1000;
			t_opa = 1.0;
			$(".caption").fadeIn(1000);
			open = true;
		}
		
		$("#caption").animate({ width: t_w + "px", left: t_l+6 + "px"});

	}

$(window).load(function(){
	
	$("#dia").galleriffic({
		delay:                     5000,
		imageContainerSel: '#slideshow',
		captionContainerSel:       '#caption',
		controlsContainerSel:      '#diaarrows',
		autoStart:				   true,
		syncTransitions:		   true,
		playLinkText:              '',
		pauseLinkText:             '',
		prevLinkText:              '',
		nextLinkText:              '',
		defaultTransitionDuration: 900

	});

	$('#slideshow').hover(
		function(e) {
			captionSlideIn();
		},
		function() {
			open = true;
			captionSlideIn();
		}
	);

});
