(function($){


var Core = {
	ondomready: function(){
	// page functions go here
		Core.linkLogo();
		Core.fixNav();
		Core.buildMap();
	},
	
	fixNav: function() {
		$("#nav>ul>li:first").toggleClass("first", true);
	},
	
	linkLogo: function() {
		$("#logo").click(function(e) {
			e.preventDefault();
			document.location = "/";
		});
	},
	
	buildMap: function() {
		$("#locations .location").each(function() {
			var x = $(this).find(".x").html();
			var y = $(this).find(".y").html();
			$(this).css({"left": x+"px", "top": y+"px"});


//			alert(x);
			
			var link = $(this).find("a").attr("href");
			if (link != "")
				var html = "<div class='marker marker_active'></div>";
			else 
				var html = "<div class='marker'></div>";
			$(this).append(html);
			
			
			$(this).children(".marker").hover(function() {
				//$(this).parent().toggleClass("location_hover", true);
				$(this).parent().children("h3").fadeIn("fast");
			}, function() {
				//$(this).parent().toggleClass("location_hover", false);
				$(this).parent().children("h3").fadeOut("fast");
			});
			
			$(this).children(".marker_active").click(function(e) {
				e.preventDefault();
				
				window.location = link;
			});
		
			$(this).toggleClass("active_location", true);
			
			if ($(".workdetail h2").length > 0) {
				// detail page
				var name = $(".workdetail h2").html();
				name = name.replace("Location: ", "");
				
				$(".location h3 a:contains('"+name+"')").parent().parent().toggleClass("current_location", true);
				
			
			}
		});
		
		
	}
		
}

window.Core = Core;

$(document).ready(function(){Core.ondomready()});

})(jQuery);




