var lngInfoId;
var winInfo;

function popup(f, nom, w, h)
{	winInfo=window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=no,status=yes,width=' + w + ',height=' + h);
	winInfo.focus();
}

function popuppt2(f,nom,w,h)
{	var winInfo=window.open(f,nom,'resizable,screenX=0,screenY=0,scrollbars=yes,statusbar=true,width='+w+',height='+h);
	if(winInfo != null)
	{	winInfo.focus();
	}
	return winInfo;
}

function ShowText(strText)
{	window.status=strText;
}

function setCurrentTool(toolindex)
{	if (toolcur != -1)
	{	if (document.all) eval("t = document.all.tool" + toolcur);
		else eval("t = document.tool" + toolcur);
		if (t == null)
		{	return;
		}
		t.src = pathToolImg+tabToolsImgOff[toolcur];
	}

	toolcur  = toolindex;
	if (document.all) eval("t = document.all.tool" + toolcur);
	else eval("t = document.tool" + toolcur);
	if (t == null)
	{	return;
	}
	t.src = pathToolImg+tabToolsImgOn[toolcur];

	if (IMMap.Obj != null)
		IMMap.Obj.setCurrentTool(toolindex);
}

function setPrefCoord(bln)
{	if (IMMap.Obj != null)
		IMMap.Obj.setPrefCoord(bln);
}

function setPrefLabel(bln)
{	if (IMMap.Obj != null)
		IMMap.Obj.setPrefLabel(bln);
}

function setStat(i)
{	
if (IMMap != null)
	if (IMMap.Obj != null)
		IMMap.Obj.setStat(i);
}

function setScale()
{	if (document.all) var txtScale = document.all['echelle'];
	else var txtScale = document.echelle;
	if (txtScale == null)
	{	return;
	}
	
	var s = txtScale.value;
	if (isNaN(s) || (s == ""))
	{	alert("Valeur d'echelle incorrecte !");
		txtScale.value = parseInt(IMMap.GetScale()/lngScaleRapport);
		return;
	}

	s = parseFloat(parseInt(s)*lngScaleRapport);
	IMMap.ZoomToScale(s);
}

function updateScale(scale)
{	if (document.all) var txtScale = document.all['echelle'];
	else  var txtScale = document.echelle;
	if (txtScale == null)
	{	return;
	}
	txtScale.value = parseInt(scale/lngScaleRapport);
}

function setThematic(nb,tabColor,tabTreshold, tabData, tabStat)
{	if (document.all) var thematic = document.all['thematicsvg'];
	else var thematic = document.thematicsvg;
	if (thematic == null)
	{	return;
	}
	thematic.window.Draw(nb,tabColor,tabTreshold, tabData, tabStat);
}

function setInfo(id)
{	if((id=='') || (tabIn.length==0))
	{	return 0;
	}

	if(winInfo != null)
	{	winInfo.close();
	}

	lngInfoId=id;

	winInfo=popuppt2("info.htm","info",250,400);
	if(winInfo== null)
	{	return 0;
	}
}

function constituerCarteSituation(t)
{	if (document.all) var situationsvg = document.all['navigsvg'];
	else var situationsvg = document.navigsvg;
	if (situationsvg == null)
	{	return;
	}

	situationsvg.window.constituerCarte(t);
}

function surligner(id, onoff)
{	if (document.all) var mapsvg = document.all['map'];
	else var mapsvg = document.map;
	if (mapsvg == null)
	{	return;
	}
	mapsvg.window.surligner(id, onoff);
}

/*******************************************************************************
* Class       : IM_Rect
* Date        : 10/05/2002
* Author      : Didier CAILLON
* Website     : http://www.netency.com
* 
* Constructor : IM_Rect(x, y, w, h)
* 
* Proprerties : .X
*				.Y
*				.Width
*				.Height
* 
* Methods     : ._init(x, y, w, h)
*******************************************************************************/

IM_Rect.prototype.constructor = IM_Rect;
function IM_Rect(x, y, w, h)
{	if (arguments.length > 0)
	{	this._Init(x, y, w, h);
	}
}

IM_Rect.prototype._Init = function(x, y, w, h)
{	this.X      = x;
	this.Y      = y;
	this.Width  = w;
	this.Height = h;
}

/*******************************************************************************
* Class       : IM_Map
* Date        : 10/05/2002
* Author      : Didier CAILLON
* Website     : http://www.netency.com
* 
* Constructor : IM_Map(obj, type)
* 
* Proprerties : .Obj
*				.Width
*				.Height
*				.Extent
*				.FullExtent
*				._type
*				._varname
*				._mapPrincipal
*				._mapSituation
* 
* Methods     : ._init(x, y, w, h)
*				.IsLoaded()
*				.setMapPrincipal(m)
*				.GetMapPrincipal()
*				.setMapSituation(m)
*				.GetMapSituation()
*				.ZoomFull()
*				.UpdateScale(s)
*******************************************************************************/

IM_Map.prototype.constructor = IM_Map;
IM_Map.MAP       = 0;
IM_Map.SITUATION = 1;
function IM_Map(obj, type)
{	this.Obj   = obj.window;  // objet dans le document HTML
	this._type = type; // [IM_Map.MAP|IM_Map.SITUATION]
}

IM_Map.prototype.IsLoaded = function()
{	if (this.Obj == null)
	{	return(0);
	}

	return(this.Obj.IsLoaded() == 1);
}

IM_Map.prototype.Init = function(v)
{	this._varname = v;
	this.Extent = new IM_Rect(0, 0, 0, 0);
	this.FullExtent = new IM_Rect(0, 0, 0, 0);
	this.Width  = 0;
	this.Height = 0;
	this._scale = 0;

	if (this.IsLoaded() != 1)
	{	aCmd = this._varname + '.Init(\"'+this._varname+'\")';
		setTimeout(aCmd,100);
		return;
	}
	this.Obj.Init(v);
}

IM_Map.prototype.GetMapSituation = function()
{	if (this._type == IM_Map.MAP)
	{	return this._mapSituation; }
	else
	{	return null; }
} 
IM_Map.prototype.setMapSituation = function(m)
{	if (this._type == IM_Map.MAP)
	{	this._mapSituation = m; }
}

IM_Map.prototype.GetMapPrincipal = function()
{	if (this._type == IM_Map.SITUATION)
	{	return this._mapPrincipal; }
	else
	{	return null; }
}
IM_Map.prototype.setMapPrincipal = function(m)
{	if (this._type == IM_Map.SITUATION)
	{	this._mapPrincipal = m; }
}

IM_Map.prototype.ZoomFull = function()
{	if (IMMap.Obj != null)
		IMMap.Obj.ZoomFull();
}

IM_Map.prototype.ZoomToId = function(id)
{	if (IMMap.Obj != null)
		IMMap.Obj.ZoomToId(id);
}

IM_Map.prototype.updateScale = function(s)
{	updateScale(s);
}

