$(document).ready(function() {
		window.hideCursorTimeout=0;

		$('#detailContent').css({overflow: 'hidden'});
		$('#detail').css({opacity: 0, display: 'none'});
		/* Horizontal bar didn't work in WYSIWYG */		
		$('#detailSlider').css({width: '6000px', height: '184px'});
		$('#detailSlider .item').css({margin: '0px 25px'}); 

		// Metro
		$('#metro').mouseenter(function() {
				if (window.hideCursorTimeout) {
				  clearTimeout(window.hideCursorTimeout);
				  window.hideCursorTimeout=0;				  
				} else {
					$(this).css({backgroundPosition: ($('a:first', this).get(0).offsetLeft + 15)+'px 0px'});
					$('#detail').stop(true).css({display: 'block'}).animate({opacity: 1});
				}
			});

		$('#metro, #detail').mouseenter(function() {
				clearTimeout(window.hideCursorTimeout);
			});

		$('#metro, #detail').mouseleave(function() {
				var metro=$('#metro');
				window.hideCursorTimeout=setTimeout(function() {
						metro.css({backgroundPosition: '-200px 0px'});
					    $('#detail').stop(true).animate({opacity: 0}, 'fast', function() {$(this).css({display: 'none'});});
						window.hideCursorTimeout=0;
					}, 500);
			});

		$('#metro a').mouseenter(function() {
				$('#goLink').attr('href', $(this).attr('href')).hide('fast');

				// Detail
				var detail=$('#detailContent .item').eq($(this).parent().prevAll().length);
				$('#detailContent').stop(true).animate({'scrollTop': detail.get(0).offsetTop, 'scrollLeft': detail.get(0).offsetLeft},
													   function() {$('#goLink').show('slow');});
				// Cursor
				$(this).parent().parent().parent().stop(true).animate({'background-position': ($(this).get(0).offsetLeft + 15)+'px'});
			});
	});
