// JavaScript Document

function Area( shape, coords, href )
{
	this.shape = shape;
	this.coords = coords;
	this.href = href;
}

function ImageMap( name )
{
	this.name = name;
	this.list = new Array();
	this.parent = null;
}

ImageMap.prototype.setParent = function( parent )
{
	this.parent = parent;
}

ImageMap.prototype.addArea = function( shape, coords, href )
{
	var a = new Area( shape, coords, href );
	this.list[this.list.length] = a;
}

ImageMap.prototype.toMarkup = function()
{
	var markup = "";
	markup += "<map name='" + this.name + "'>";
	for ( var i = 0; i < this.list.length; i++ )
	{
		var a = this.list[i];
		markup += "<area" +
			" shape='" + a.shape + "'" +
			" coords='" + a.coords + "'" +
			" href='" + a.href + "'" + 
			" onClick=\"" + this.parent.action + ";return false;\"" +
			" onMouseOver=\"swapImage('" + this.parent.id + "','" + this.parent.over.src +
				"');\"" +
			" onMouseOut=\"swapImage('" + this.parent.id + "','" + this.parent.up.src +
				"');\" " +
			">";
	}
	markup += "</map>";
	
	return markup;
}
