$(document).ready(function(){
	var _timer;
	var _timer2;
	$('.pop-up').css({
		width:'0px'
	});
	$('.green-box a.btn').hover(function(){
		clearTimeout(_timer);
		var _id = this.rel;
		_timer = setTimeout(function(){
			$('.pop-up').each(function(){
				if ($(this).hasClass('visible-popup')) {
					$('.scroll-box').css('overflow','hidden');
					$(this).animate({
						width:'0px'
					},{duration:1000,queue:false});
					$(this).removeClass('visible-popup');
				}
			});
			$('#'+_id).animate({
				width:'457px'
			},{duration:1000,queue:false}).addClass('visible-popup').css('z-index',2);
			clearTimeout(_timer2);
			_timer2 = setTimeout(function(){
				$('.scroll-box').css('overflow','auto');
			},1000);
		},500);
	},function(){
		clearTimeout(_timer);
		_timer = setTimeout(function(){
			clearTimeout(_timer2);
			$('.scroll-box').css('overflow','hidden');
			$('.pop-up').animate({
				width:'0px'
			},{duration:1000,queue:false});
			$('.pop-up').each(function(){
				$(this).removeClass('visible-popup').css('z-index',1);
			});
		},500);
	});
	$('.pop-up').hover(function(){
		clearTimeout(_timer);
	},function(){
		clearTimeout(_timer);
		_timer = setTimeout(function(){
			clearTimeout(_timer2);
			$('.scroll-box').css('overflow','auto');
			$('.pop-up').animate({
				width:'0px'
			},{duration:1000,queue:false});
			$('.scroll-box').css('overflow','hidden');
			$('.pop-up').each(function(){
				$(this).removeClass('visible-popup');
			});
		},500);
	});
	$('#header .box').galleryScroll({

		autoSlide:5000
	});
});