window.addEvent('domready', function() {

	var status = {
		'true': 'Hide map',
		'false': 'View map'
	};
	
	var mapLoaded = false;
	
	// Initialise the slide effect for the element that requires it
	var verticalSlide = new Fx.Slide('map');
	
	$('view_map').addEvent('click', function(e){
		e.stop();
		$('map').set('styles', {
			'display':'block'
		});
		verticalSlide.toggle();
	});
	
	// When Vertical Slide ends its transition, we check for its status
	// note that complete will not affect 'hide' and 'show' methods
	verticalSlide.addEvent('complete', function() {
		$('view_map').set('html', status[verticalSlide.open]);
		if($('view_map').get('html') == status['true'] && !mapLoaded) {
			// Load the map
			url="http://www.google.com/maps/ms?source=embed&ie=UTF8&hl=en&msa=0&msid=117926481065029729845.000469d09f878e368f690&ll=55.90116,-3.73758&spn=0.538926,1.167297&z=9&output=embed";
			window.frames['map_iframe'].location = url;
			mapLoaded = true;
		}
	});
	
	verticalSlide.hide();
	
});
