// JavaScript Document
$(function () {
	$('.list_art').each(function () {
		var distance = 10;
		var showtime = 200;
		var hidetime = 200;
		var hideDelay = 0;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var triggerwidth = $('.trigger', this).width();
		var triggerheight = $('.trigger', this).height();
		var info = $('.popup', this).css('opacity', 0);
		
		var popwidth = $('.popup', this).width();
		var popheight = $('.popup', this).height();
		var poptop = popheight/2 - triggerheight/2;
		var popleft = popwidth/2 - triggerwidth/2;
		
		$([trigger.get(0), info.get(0)]).click(function () {
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				// reset position of info box
				beingShown = true;

				info.css({
					top:-poptop,
					left:-popleft,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, showtime, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		});
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			trigger.css('border', '1px solid #F0E8E5');	
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			return false;
		}).mouseout(function () {
			trigger.css('border', '1px solid #fff');	
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, hidetime, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
});


$(function () {
	$('.list_artb').each(function () {
		var distance = 10;
		var showtime = 200;
		var hidetime = 200;
		var hideDelay = 0;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var triggerwidth = $('.trigger', this).width();
		var triggerheight = $('.trigger', this).height();
		var info = $('.popup', this).css('opacity', 0);
		
		var popwidth = $('.popup', this).width();
		var popheight = $('.popup', this).height();
		var poptop = popheight/2 - triggerheight/2;
		var popleft = popwidth/2 - triggerwidth/2;
		
		$([trigger.get(0), info.get(0)]).click(function () {
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				
				// reset position of info box
				beingShown = true;
				$(this).parent().css('z-index', '50');
				info.css({
					top:-poptop,
					left:-popleft,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, showtime, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		});
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			trigger.css('border', '1px solid #F0E8E5');	
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			return false;
		}).mouseout(function () {
			trigger.css('border', '1px solid #fff');
			
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, hidetime, 'swing', function () {
					shown = false;
					info.css('display', 'none');
					$(this).parent().css('z-index','1');
				});

			}, hideDelay);

			return false;
		});
	});
});




$(function () {
	$('.list_artc').each(function () {
		var distance = 10;
		var showtime = 200;
		var hidetime = 200;
		var hideDelay = 0;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var triggerwidth = $('.trigger', this).width();
		var triggerheight = $('.trigger', this).height();
		var info = $('.popup', this).css('opacity', 0);
		
		var popwidth = $('.popup', this).width();
		var popheight = $('.popup', this).height();
		//var poptop = popheight/2 - triggerheight/2;
		//var popleft = popwidth/2 - triggerwidth/2;
		var poptop = 30;
		var popleft = 50;
		
		$([trigger.get(0), info.get(0)]).hover(function () {
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				
				// reset position of info box
				beingShown = true;
				$(this).parent().css('z-index', '99999');
				info.css({
					top:-poptop,
					left:-popleft,
					//top:300,
					//left:400,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, showtime, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		});
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			trigger.css('border', '1px solid #F0E8E5');	
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			return false;
		}).mouseout(function () {
			trigger.css('border', '1px solid #fff');
			
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, hidetime, 'swing', function () {
					shown = false;
					info.css('display', 'none');
					$(this).parent().css('z-index','1');
				});

			}, hideDelay);

			return false;
		});
	});
});


