var initFormStoreView = function() {
	$('#storeIndexViewBg').css('display', 'none').fadeTo(0, 0);
	$('#storeIndexView').css('display', 'none');		
	$('.storeViewTarget').each(function() {
		$(this).css('cursor', 'pointer').click(function() {
			var target = $(this).attr('id').split('store_')[1];
			$('#storeView').load(target + '.html', function() {
				var leftOffset = ($(document).width() / 2) - ($(this).width() / 2);
				$(this).css({left:leftOffset + 'px'});
				
				$('select').hide();
				
				$('.closeBtn').css('cursor', 'pointer').click(closeStoreView);
				$('#storeViewBg').css('cursor', 'pointer').click(closeStoreView);
				$('#storeViewBg').css('display', 'block').fadeTo(300, 1);
				$(this).fadeIn(400);
			});
		})
	});
}

$(document).ready(
	function() {
		$('#storeIndexViewBg').css('display', 'none').fadeTo(0, 0);
		$('#storeIndexView').css('display', 'none');	
		$('.storeIndexViewTarget').each(function() {
			$(this).css('cursor', 'pointer').click(function() {
				var target = $(this).attr('id').split('storeIndex_')[1];
				$('#storeIndexView').load(target + '.html', function() {
					var leftOffset = ($(document).width() / 2) - ($(this).width() / 2);
					$(this).css({left:leftOffset + 'px'});
					
					$('.closeBtn').css('cursor', 'pointer').click(closeStoreView);
					$('#storeIndexViewBg').css('cursor', 'pointer').click(closeStoreView);
					$('#storeIndexViewBg').css('display', 'block').fadeTo(300, 1);
					$(this).fadeIn(400);
				});
			})
		});
	}
);

var trace = function(target) {
	console.log(target);
}

var closeStoreView = function() {
	$('#storeViewBg').fadeOut(300, function() {$('#storeViewBg').css('display', 'none');});
	$('#storeView').fadeOut(400);
	$('#storeIndexViewBg').fadeOut(300, function() {$('#storeViewBg').css('display', 'none');});
	$('#storeIndexView').fadeOut(400);
	$('select').show();	
}

