// JavaScript Document


		try{Typekit.load();}catch(e){}
		
		//------ Hide, progressively.
		$('html').addClass('init');

		//------ Animation direction used in change events.
		var direction = 1;
		var mapsInitiated;
				
		

		$.address.change(function(event) {
			var target = $("#" + event.pathNames[0]);
			
			if(!target.length && event.pathNames[0] != "-") 
			{
				//------ If no match, bounce out after collapsing all sections, and removing expanded classes.
				$("#sections .collapsable").hide();
				$("#sections .expanded").removeClass("expanded");
				$('.team .grid').hide();
				return;
			}

			var people = $("#people .team");
			var index = people.index(target);
			
			if(index > -1)
			{	
				
				//------ We're displaying a person. First, update shuttle controls.
				var prev = (index == 0) ? people.eq(people.length - 1) : target.prev();
				var next = (index < people.length - 1) ? target.next() : people.eq(0);

				//------ Apply...
				$("#prev").attr("href", "#" + prev.attr("id"));
				$("#next").attr("href", "#" + next.attr("id"));				
				
				//------ Look up the index of the currently displayed person.
				var current = $("#people .current");
				
				//------ Determine animation targets based on right-left or left-right targets.
				var w = $('#people').width();
				
				//------ Is the container expanded?
				if($("#sections li:eq(0)").hasClass("expanded")) 
				{	
					//------ Show the team information, as it is hidden by the init class.
					target.find(".grid").show();
				} else {
					//------ Otherwise, reveal it with animation.
					$('#persons').addClass('expanded').find('.collapsable').slideDown(400, "easeInCubic");
					target.find(".grid").slideDown(400, "easeInCubic");
				}
				
				//------ Animate, but if somehow the target is currently displayed don't pan.
				if(current.attr('id') != target.attr('id')) 
				{
				
					//$.address.title(current.attr('id') + " --> " + target.attr('id'));	

					//------ Exit right.
					current.removeClass("current");
					current.show().css({ left: 0 }).animate({ left: (w * direction) },600, "easeOutCubic");
					
					//------ Bring on from left.
					target.addClass("current");
					target.show().css({ left: (-1 * w * direction) }).stop().animate({ left: "0" },600, "easeOutCubic");
				}

			} else if($('#sections li').index(target) > -1) {
				target.addClass('expanded').find('.collapsable').slideDown(400, "easeInCubic");				
				
		    }

			var title = (event.pathNames[0]) ? " - " + event.pathNames[0].toUpperCase() : "";
			//$.address.title(title);
		});




	
		$(document).ready(function() {
	
			//------ Sniff for whether to use html or body element for scrolling.
			$('html, body').each(function () {
				var initScrollTop = $(this).attr('scrollTop');
				$(this).attr('scrollTop', initScrollTop + 1);
				if ($(this).attr('scrollTop') == initScrollTop + 1) {
					SCROLLELEMENT = this.nodeName.toLowerCase();
					$(this).attr('scrollTop', initScrollTop);
					return false;
				}
			});
	
			$('#maria_anagnostou .details p').each(function(idx) {
				var p = $(this);
				if(idx == 0) {
					p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
						e.preventDefault();
						p.hide().next().fadeIn();
					}));
				} else {
					p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
						e.preventDefault();
						p.hide().prev().fadeIn();						
					})).hide();
				}
			});
			$('#george_vlachodimos .details p').each(function(idx) {
				var p = $(this);
				if(idx == 0) {
					p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
						e.preventDefault();
						p.hide().next().fadeIn();
					}));
				} else {
					p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
						e.preventDefault();
						p.hide().prev().fadeIn();						
					})).hide();
				}
				
			});
			$('#matina_koloniari .details p').each(function(idx) {
				var p = $(this);
				if(idx == 0) {
					p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
						e.preventDefault();
						p.hide().next().fadeIn();
					}));
				} else {
					p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
						e.preventDefault();
						p.hide().prev().fadeIn();						
					})).hide();
				}
				
			});
			$('#Christina_Petsiou .details p').each(function(idx) {
				var p = $(this);
				if(idx == 0) {
					p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
						e.preventDefault();
						p.hide().next().fadeIn();
					}));
				} else {
					p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
						e.preventDefault();
						p.hide().prev().fadeIn();						
					})).hide();
				}
				
			});
			$('#christianna_tsigkou .details p').each(function(idx) {
				var p = $(this);
				if(idx == 0) {
					p.append($(' <a href="#more" class="more">Read on&hellip;<\/a>').click(function(e){
						e.preventDefault();
						p.hide().next().fadeIn();
					}));
				} else {
					p.prepend($('<a href="#less" class="more">(continued)<\/a> &hellip;').click(function(e){
						e.preventDefault();
						p.hide().prev().fadeIn();						
					})).hide();
				}
				
			});
			//------ Establish events on the shuttle controls.
			$("#shuttle").click(function(event) {
				//------ Set our animation direction based on which control was clicked.
				direction = ($(event.target).attr('id') == "prev") ? -1 : 1;
				//------ Send the event through our Address API, sans hash sign.
				$.address.value(event.target.hash.replace(/^#/,''));
				event.preventDefault();
			});
			
			$("#archi").click(function(event) {
				//------ Close everything down when clicking on the logo.
				$.address.value("index.html");
			});
			
			
			var browse = $('#browse li:eq(0)');
			
			//------ If these aren't displayed there is a bit of a stutter when animating the first time.
			$('.team').show().css({ left: "1200px" }).each(function() {
				//------ Build out the persons menu.
				var person = $(this);
				var item = $('<li>' + person.find('h3:eq(0)').text() + '<\/li>');
				
				item.click(function(e) {
					e.stopPropagation();
					$.address.value(person.attr('id'));
				});
				
				browse.after(item);
			});
						

			//------ On load, check our address value to see if we shouldn't display a certain image.
			switch($.address.value().replace(/^\//,'')) 
			{
				case "alexios_vandoros":
					$("#alexios_vandoros").addClass("current").css({ left: "0" });
					break;
				case "patty_psarrou":
					$("#patty_psarrou").addClass("current").css({ left: "0" });
					break;
				case "sandra_kalliagra":
					$("#sandra_kalliagra").addClass("current").css({ left: "0" });
					break;
				case "maria_anagnostou":
					$("#maria_anagnostou").addClass("current").css({ left: "0" });
					break;
				case "virginia_giagkou":
					$("#virginia_giagkou").addClass("current").css({ left: "0" });
					break;
				case "christianna_tsigkou":
					$("#christianna_tsigkou").addClass("current").css({ left: "0" });
					break;
				case "gavogianni_kiriaki":
					$("#gavogianni_kiriaki").addClass("current").css({ left: "0" });
					break;
				case "Christina_Petsiou":
					$("#Christina_Petsiou").addClass("current").css({ left: "0" });
					break;
				case "Marianna_Chrapana":
					$("#Marianna_Chrapana").addClass("current").css({ left: "0" });
					break;
				case "george_vlachodimos":
					$("#george_vlachodimos").addClass("current").css({ left: "0" });
					break;
				default:
					$("#architeam").addClass("current").css({ left: "0" });
			}
					
					
			//------ Interrupt events going to the actions menu; anchors behave unpredicably in overflowed containers.
			$('.actions').click(function(event) {
				var target = $(event.target.hash);
				
				if(target.length) {
					$(SCROLLELEMENT).stop().animate(
						{ scrollTop: target.offset().top },
						600
					);				
					event.preventDefault();
				}
			});
			
			
			$('#geocode').click(function() {
				findNearAddress();
			});
			
					
			//------ Clicking on any header should toggle that section.
			$("#sections h2").click(function() {
				var section = $(this).parent();
				//------ If the section is expanded, close it.
				if(section.hasClass("expanded")) 
				{
					section.removeClass("expanded");
					section.find('.collapsable').slideUp(400, "easeOutCubic");

					//------ If we're closing the team display, also tell the grid to slide up.
					if(section.attr('id') == "persons") $('.current .grid').slideUp(400, "easeOutCubic");
					
					$.address.value("-");
				} else {
					//------ Otherwise, send the section ID to the Address API for opening.
					var path = (section.attr('id') == "persons") ? $('#people .current').attr('id') : $(this).parent().attr('id');
					$.address.value(path);
				}
				//event.preventDefault();
				//event.stopPropagation();
			});		

			
			$('a[href^=https]').click(function() {
				if(pageTracker != undefined) {
					pageTracker._trackEvent(category, action);
				}
			});
		});
