/*
*
*/
function AcreatMapSelection(id, img_path, map_src, width, height, parentElement)
{
	if(!parentElement) parentElement = document.body; 
	this.id = id;
	this.img_path = img_path;
	this.map_src = map_src;
	this.width = width;
	this.height = height;
	this.parentElement = parentElement;
	
	this.zones = Array();
	this.CARTE = null;
	this.MAP = null;
	
	this.init();	
};

/* -----------------------------------------
*
*/
AcreatMapSelection.prototype.init = function()
{
	CARTE = document.createElement("DIV");
	CARTE.style.width = this.width + "px";
	CARTE.style.height = this.height + "px";
	CARTE.style.backgroundImage = "url(" + this.img_path + this.map_src + ")";
	CARTE.style.backgroundRepeat  = "no-repeat";
	this.parentElement.appendChild(CARTE);
	this.CARTE = CARTE;
	
	MAP = document.createElement("MAP");
	MAP.id = MAP.name = "map_" + this.id;
	CARTE.appendChild(MAP);
	this.MAP = MAP;
	
	IMG = document.createElement("IMG");
	IMG.src = this.img_path + "pixel.gif";
	IMG.style.position = "absolute";
	IMG.style.zIndex = 1;
	IMG.width = this.width;
	IMG.height = this.height;
	IMG.border = 0;
	IMG.useMap = "#" + MAP.name;
	this.CARTE.appendChild(IMG);
}

/* -----------------------------------------
*
*/
AcreatMapSelection.prototype.add_zone = function(img_src, href, coords)
{ 
	var ZONE = new Object();
	ZONE.src = img_src;
	ZONE.href = href;
	ZONE.coords = coords;
	this.zones.push(ZONE);
	/* --- */
	var ZONE_DIV = document.createElement("DIV");
	ZONE_DIV.style.position = "absolute";
	ZONE_DIV.style.zIndex = 0;
	ZONE_DIV.style.width = this.width + "px";
	ZONE_DIV.style.height = this.height + "px";
	ZONE_DIV.style.backgroundImage = "url(" + this.img_path + ZONE.src + ")";
	ZONE_DIV.style.backgroundRepeat  = "no-repeat";	
	ZONE_DIV.style.display = "none";
	this.CARTE.appendChild(ZONE_DIV);
	/* --- */
	var ZONE_AREA = document.createElement("AREA");
	ZONE_AREA.zone_div = ZONE_DIV;
	ZONE_AREA.shape = "poly";
	ZONE_AREA.coords = ZONE.coords;
	ZONE_AREA.href = ZONE.href;
	ZONE_AREA.onmouseover = function() { this.zone_div.style.display = ''; };
	ZONE_AREA.onmouseout = function() { this.zone_div.style.display = 'none'; };
	ZONE_AREA.onclick = function() { this.zone_div.style.display = ''; };
	this.MAP.appendChild(ZONE_AREA);
}




