/*
 * A generic base-class for Surgery & CarPark classes
 * Useful enough to be used on its own
 */

function Location( elem, icon )
{
	if( Location.arguments.length == 0 ) return;
	this.xml = elem;
	this.name = elem.getAttribute( "name" );
	this.coords = new GLatLng(
		parseFloat( elem.getAttribute( "lat" ) ),
		parseFloat( elem.getAttribute( "long" ) ) );

	this.marker = this.createMarker( icon );
}

Location.prototype.createMarker = function( icon )
{
	var opts = { clickable: true, title: this.name };
	if( icon != null ) opts.icon = icon;
	return new GMarker( this.coords, opts );
}

Location.prototype.addBalloon = function( text )
{
	GEvent.addListener( this.getMarker(), "click", function() {
		this.openInfoWindowHtml( text );
	});
}

Location.prototype.getName= function() { return this.name; }
Location.prototype.getCoords= function() { return this.coords; }
Location.prototype.getMarker= function() { return this.marker; }
