window.onload = function () {
	var links = $A($('map').getElementsByTagName('a'));
	var offices = $A($('offices').getElementsByClassName('office'));
	links.each(function(link){
		link.onclick = function() {
			city = this.innerHTML;
			var href = this.href.substring(this.href.lastIndexOf('#')+1);
			//alert(href);
			new Effect.ScrollTo(href, {offset: -20, queue: 'front', duration: 0.5});
			
			offices.each(function(office){ // clear the highlighting
				office.style.backgroundColor ='#ffffff';
				if (office.className.indexOf(city) != -1) {
					new Effect.Highlight(office,{duration: 0.3, queue: 'end'});
					new Effect.Highlight(office,{duration: 0.3, startcolor: '#ffffff', endcolor: '#ffff99', restorecolor: '#ffff99', duration: 0.5, queue: 'end'});
				}
			});	
			return false;
		}
	});

}

