
window.addEvent('domready', function() {	
	
				
	$$('h1').each(function(e) { 
		e.set('html', '<img src="http://www.serenestudios.co.uk/wp-content/themes/serenestudios/font_heading.php?style=h1&amp;text=' + e.get('text') + '" alt="' + e.get('text') + '"/>');
	});
	
	$$('h2').each(function(e) { 
		if(!e.hasClass('lifestream_date'))
		{
			e.set('html', '<img src="http://www.serenestudios.co.uk/wp-content/themes/serenestudios/font_heading.php?style=h2&amp;text=' + e.get('text') + '" alt="' + e.get('text') + '"/>');
		}
	});
	
	$$("a").filter(function(el) {
		return el.href && !el.href.indexOf("http://www.flickr.com/photos/") && el.firstChild && el.firstChild.src;
	}).slimbox({}, function(el) {
		return [el.firstChild.src.replace(/_[mts]\.(\w+)$/, ".$1"),
			(el.title || el.firstChild.alt) + '<br /><a href="' + el.href + '">Flickr page</a>'];
	});
	
	
	
});

function createMarker(point,html) {
		var cpIcon = new GIcon();
	      cpIcon.image = "design/imgs/cp_icon.png";
	
		cpIcon.shadow = "";
		 cpIcon.iconSize = new GSize(24, 24);
		  cpIcon.shadowSize = new GSize(24, 24);
		   cpIcon.iconAnchor = new GPoint(24, 24);
		    cpIcon.infoWindowAnchor = new GPoint(12,2);
		     
		var markerd = new GMarker(point);
			GEvent.addListener(markerd, "click", function() {
				markerd.openInfoWindowHtml(html);
		});
		return markerd;
	}
	function showrandommarker() {
		var i = Math.floor(Math.random() * markers.length)
		markers[i].openInfoWindowHtml(mks_html[i]);
	
	}
	function addAddressToMapBL(response) {
	  if (!response || response.Status.code != 200) {
	    
	  } else {
	    place = response.Placemark[0];
	    point = new GLatLng(place.Point.coordinates[1],
	                        place.Point.coordinates[0]);
	    mks_html[0] = '<h3>The British Library</h3><p>The British Library is one of our favourite places to think and work. Its quiet, free, and a beautiful <br />building (inside, anyway). Oh, and they do wonderful chocolate cake in the cafe...</p>';
	    markers[0] = createMarker(point, mks_html[0]);
	    
	    map.addOverlay(markers[0]);
	    //marker[0].openInfoWindowHtml();
		
	  }
	}
	function addAddressToMapCL(response) {
	  if (!response || response.Status.code != 200) {
	    
	  } else {
	    place = response.Placemark[0];
	    point = new GLatLng(place.Point.coordinates[1],
	                        place.Point.coordinates[0]);
	                        
	    mks_html[1] =  '<h3>Clowns Cafe</h3><p>A lovely little Italian cafe in Cambridge. Sociable, full of fun Italians,<br /> great coffee. What more do you need?</p>'                  
	    markers[1] = createMarker(point, mks_html[1]);

	    map.addOverlay(markers[1]);
	    //marker[1].openInfoWindowHtml(		
	  }
	}
	function addAddressToMapKI(response) {
	  if (!response || response.Status.code != 200) {
	    
	  } else {
	    place = response.Placemark[0];
	    point = new GLatLng(place.Point.coordinates[1],
	                        place.Point.coordinates[0]);
	                        
	    mks_html[2] = '<h3>King\'s Coffee Shop</h3><p>Right in the middle of King\'s College is their coffee shop. 100% Fair-trade, <br />free Wifi, and an amazing view of King\'s Chapel.</p>';                 
	    markers[2] = createMarker(point, mks_html[2]);
	    map.addOverlay(markers[2]);
	    //marker[2].openInfoWindowHtml(
		
	  }
	}
	function addAddressToMapHP(response) {
	  if (!response || response.Status.code != 200) {
	    
	  } else {
	    place = response.Placemark[0];
	    point = new GLatLng(place.Point.coordinates[1],
	                        place.Point.coordinates[0]);
	    mks_html[3] = '<h3>Hyde Park</h3><p>With summer approaching, sitting outside with a MacBook is nearly unbeatable. Its almost scientifically<br /> proven that fresh coffee, sunshine, and the outdoors is the ultimate catalyst for work. </p>';                 
	    markers[3] = createMarker(point, mks_html[3]);
	    map.addOverlay(markers[3]);
	    //marker[3].openInfoWindowHtml(
		
	  }
	}