//Generic functions
function e(id) {
	return document.getElementById(id);	
}

function onRollOver(obj_img){
	obj_img.src =obj_img.src.split("-off").join("-on");	
}

function onRollOut(obj_img){
	obj_img.src = obj_img.src.split("-on").join("-off");
}

/* START GOOGLE MAPS */

var geocoder = null;
var window_content = "<div style='height: 150px; line-height: 140%; top: 0; left: 0; position: relative; color: #000;'>85 Lewis Street<br />Woolloongabba,<br />QLD 4102<br />Australia<br /><br />Tel: +61 7 3334 8320<br />Come say hello!<img style='display: block; right: 0; bottom: 20; position: absolute;' src='Images/img-mettro-google-maps.gif' width='80' height='15' /></div>";
function initialize()
{
	if (GBrowserIsCompatible())
	{
		map = new GMap2(document.getElementById("map_canvas"));
		geocoder = new GClientGeocoder();
		showAddress();
	}
}

function showAddress()
{
	var address = '85 Lewis Street, Woolloongabba, QLD, Australia';

	if (geocoder)
	{
		geocoder.getLatLng(
			address,
			function(point)
			{
				if (!point) {
				  alert(address + " not found");
		} else {
			map.setCenter(point, 14);
			map.addControl(new GMapTypeControl());
			map.addControl(new GSmallMapControl());
			var jicon = new GIcon(G_DEFAULT_ICON);
			jicon.image = "http://www.mettromagic.com/clients/mettro_digital/Images/icon-google-maps.png";
			jicon.shadow = "http://www.google.com/mapfiles/shadow50.png"; 
			jicon.iconSize = new GSize(32, 32); 
			jicon.shadowSize = new GSize(37, 34);
			var marker = new GMarker(point, jicon);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(window_content);
			
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(window_content);
			});

			
		}
	  }
	);
  }
}	

/* END GOOGLE MAPS */

// homepage tile rollovers
$(function() { 
	$('.featured-column a, .work-item a').live("mouseenter",
		function() {
			var id = $(this).attr('rel');
			$('#link-' + id).fadeIn(400);				
		}
	).live("mouseleave",
		function() {
			var id = $(this).attr('rel');
			$('#link-' + id).fadeOut(400);
		}
	);
});

// split sidenav text so we can get half bold
$(function() {
	$('.sidenav li a.link').each(function() {
		var linkText = $(this).html();
		var splitLinkText = linkText.split(' ', 2);
								
		if (splitLinkText.length == 1) { splitLinkText[1] = ''; }

		$(this).html(splitLinkText[0] + ' <span style="font-weight: 600;">' + splitLinkText[1] +'</span>');
	});
});
