$(function() {
	
	// Map scroll functions
	var scrollMapUp = function(){
		$('#map').animate({ top : "0px" }, { easing: 'easeInOutQuint', duration: 1000});
	};
	
	var scrollMapDown = function(){
		$('#map').animate({ top : "-401px" }, { easing: 'easeInOutQuint', duration: 1000});
	};
	
	var showLocatorOnLoad = function(){
		$('.tyrianpop').fadeIn();
		$('.tyrianpop').addClass("open");
		$('.tyrian').css( "z-index", "1");
	};
	
	$('a.mapnav_up').click( function(){
		scrollMapUp();
		return false;
	});
	
	$('a.mapnav_down').click( function(){
		scrollMapDown();
		return false;
	});
	
	showLocatorOnLoad();
	
	// Locator box popups
	$('.map_item').click( function(){
		$('.map_item').css( "z-index", "1");
		if ( $('.locator_box_pop', this).hasClass("open") ) {
			$(this).css( "z-index", "1");
			$('.open').fadeOut();
			$('.locator_box_pop', this).removeClass("open");
		} else {
			$('.open').fadeOut();
			$('.open').removeClass('open');
			$('.locator_box_pop', this).fadeIn();
			$('.locator_box_pop', this).addClass("open");
			$(this).css( "z-index", "99");
		}
		//var links = $('.link a', this);
		//return false;
	});
	
	// Legend toggles
	$('.legend_all').click( function(){
			$('.nightlife, .casdining, .fashion, .business, .gallery, .attraction, .restaurant').show();
			$('.map_legend a').removeClass("current");
			return false;
	});
	
	$('.legend_r').click( function(){
			$('.restaurant').show();
			$('.nightlife, .casdining, .fashion, .business, .gallery, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_c').click( function(){
			$('.casdining').show();
			$('.nightlife, .restaurant, .fashion, .business, .gallery, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_n').click( function(){
			$('.nightlife').show();
			$('.casdining, .restaurant, .fashion, .business, .gallery, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_f').click( function(){
			$('.fashion').show();
			$('.casdining, .restaurant, .nightlife, .business, .gallery, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_b').click( function(){
			$('.business').show();
			$('.casdining, .restaurant, .nightlife, .fashion, .gallery, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_g').click( function(){
			$('.gallery').show();
			$('.casdining, .restaurant, .nightlife, .business, .fashion, .attraction').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.legend_a').click( function(){
			$('.attraction').show();
			$('.casdining, .restaurant, .nightlife, .business, .fashion, .gallery').hide();
			$('.map_legend a').removeClass("current");
			$(this).addClass("current");
			return false;
	});
	
	$('.content_wrap h4').each( function(){
		if($(this).text().replace(" ", "").length < 2) 
		$(this).height(0);
	});
	
	// $('.link > a').click(function(){
	// 	var URL = $(this).attr('href').val();
	// 	return URL.val();
	// });
	
});