var eventDetailRules = {
	'img.secondary': function(el) {
		el.onclick = function() {
			if (!document.getElementById) return;
			var mainImg = document.getElementById('main');
			var mainImgSrc = mainImg.getAttribute('src');
			var newMain = el.getAttribute('src').replace('/thumbnails', '');
			mainImg.setAttribute('src', newMain);
			var lastSlash = mainImgSrc.lastIndexOf('/');
			var newThumbnail = mainImgSrc.substring(0, lastSlash) +
				'/thumbnails' + mainImgSrc.substring(lastSlash);
			el.setAttribute('src', newThumbnail);
		};

		el.onmouseover = function() {
			el.style.cursor = 'pointer';
			el.setAttribute('title', 'Click to enlarge this image');
		}
	},
	'#add_review_button': function (el) {
		el.onclick = function () {
			document.getElementById('add_review_button').style.display = "none";
			document.getElementById('review_form').style.display = "block";
		};
	},
	'#add_review_cancel': function (el) {
		el.onclick = function () {
			document.getElementById('add_review_textarea').value = "";
			document.getElementById('add_review_button').style.display = "inline";
			document.getElementById('review_form').style.display = "none";
		};
	}
};

Behaviour.register(eventDetailRules);

Behaviour.addLoadEvent(function () {
	var map = new GMap2(document.getElementById("event_google_map"));
	map.setCenter(mapLocation);
	map.setCenter(mapLocation, 14);
	
	var icon = new GIcon();
	icon.image = "/media/img/maps/marker.png";
	icon.shadow = "/media/img/maps/marker_shadow.png";
	icon.iconSize = new GSize(37, 36);
	icon.shadowSize = new GSize(39, 38);
	icon.iconAnchor = new GPoint(18, 18);

	var marker = new GMarker(mapLocation, icon);
	map.addOverlay(marker);
});
