function GenerateEmailAddress(address, domain, subject)
{
	document.write('<a href="mai' + 'lto:' + address + '@' + domain + "?sub" + "ject=" + subject + '">');
	document.write(address + '@' + domain + '</a>');
}

function GenerateEmailAddressWithName(address, domain, subject, name)
{
	document.write('<a href="mai' + 'lto:' + address + '@' + domain + "?sub" + "ject=" + subject + '">');
	document.write(name + '</a>');
}

function GenerateCopyright()
{
	document.write('<br>&copy; Copyright The Station House Motel, 2009-');
	document.write(new Date().getFullYear());
	document.write('. All rights reserved.');
}

function GenerateMenu(currentpage)
{
	var home       = new Array("Home", "index.html");
	var cottage    = new Array("Cottage Motels", "cottage.html");
	var studio     = new Array("Studio Units", "studio.html");
	var map        = new Array("Map", "map.html");
	var activities = new Array("Activities", "activities.html");
	var history    = new Array("House History", "history.html");
	var aboutus    = new Array("About Us", "aboutus.html");
	var contactus  = new Array("Contact Us", "contactus.html");

	var knownPagesInOrder = new Array
	(
		home,
		cottage,
		studio,
		map,
		activities,
		history,
		aboutus,
		contactus
	);
	
	document.write('<ul class="menu">');
	for (index in knownPagesInOrder)
	{
		if (knownPagesInOrder[index][0] == currentpage)
		{
			document.write('<li class="menuitem menuitemcurrent">' + knownPagesInOrder[index][0] + '</li>');
		}
		else
		{
			document.write('<li class="menuitem"><a class="menuitemlink" href="' + knownPagesInOrder[index][1] + '">' + knownPagesInOrder[index][0] + '</a></li>');
		}
	}
	document.write('</ul>');
}

function IsIE7OrLess()
{
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{ //test for MSIE x.x;
		var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion <= 7)
		{
		return true;
		}
	}
	return false;
}

function EnablePictureZoom(pictureZoomId, bigPictureURL, caption)
{
	if (!IsIE7OrLess())
	{
		document.getElementById(pictureZoomId).innerHTML=
			'<div class="picturezoombrowserpane"><img src="' + bigPictureURL + '" alt="" onclick="DisablePictureZoom(' + "'" + 
			pictureZoomId + "'" + ')"/><br><br>' + caption + '<br><a onclick="DisablePictureZoom(' + 
			"'" + pictureZoomId + "'" + ')">Return</a></div>';
		document.getElementById(pictureZoomId).style.display = "block";
	}
}

function DisablePictureZoom(pictureZoomId)
{
	if (!IsIE7OrLess())
	{
		document.getElementById(pictureZoomId).innerHTML="";
		document.getElementById(pictureZoomId).style.display = "none";
	}
}

function initializeLocationMap(canvasID)
{
	if (GBrowserIsCompatible())
	{
		map = new GMap2(document.getElementById(canvasID));
		map.setUIToDefault();

		// Collingwood
		var collingwood = new GLatLng(-40.67740, 172.68291);
		map.setCenter (collingwood, 11, G_PHYSICAL_MAP);
		map.addOverlay(createHomeMarker());
		//addImageMarkers(map, "gallery/mapimages.xml");
	}
}

function addImageMarkers(map, xmlUrl)
{
	// Download the data in data.xml and load it on the map. The format we
	// expect is:
	// <markers>
	//   <marker lat="37.441" lng="-122.141" img="url" caption="Text"/>
	// </markers>
	GDownloadUrl(xmlUrl, function(data, responseCode)
		{
			var xml = GXml.parse(data);
			var markers = xml.documentElement.getElementsByTagName("marker");
			for (var i = 0; i < markers.length; i++)
			{
				var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
										parseFloat(markers[i].getAttribute("lng")));
				var marker = new GMarker(point, {icon:createCameraIcon()})
				var img = markers[i].getAttribute("img");
				var cap = markers[i].getAttribute("caption");
				GEvent.addListener(marker, "click", 
					function()
					{
						EnablePictureZoom('PictureZoomId', img, cap);
					});
				map.addOverlay(marker);
			}
		});
}

function createCameraIcon()
{
	var icon = new GIcon();
	icon.image = "images/camera.gif";
	icon.iconSize = new GSize(33, 27);
	icon.iconAnchor = new GPoint(16, 13);
	icon.infoWindowAnchor = new GPoint(16, 13);
	return icon;
}

function createHomeIcon()
{
	var icon = new GIcon();
	icon.image = "images/home.gif";
	icon.iconSize = new GSize(20, 20);
	icon.iconAnchor = new GPoint(10, 10);
	icon.infoWindowAnchor = new GPoint(10, 10);
	return icon;
}

function createHomeMarker()
{
	var collingwood = new GLatLng(-40.67740, 172.68291);
	var marker = new GMarker(collingwood, {icon:createHomeIcon()});
	GEvent.addListener(marker, "click", function() { EnablePictureZoom('PictureZoomId','images/fullres/thestationhouse.jpg', 'The Station House Motel'); });
	return marker;
}

