var lastZoom = new Array();
function changeSvgSrc(spath)
{document.svgmap.setSrc(spath);
svgChanged();}
function svgChanged()
{setTimeout('setAllCheck()',1000);}
function setAllCheck(){var vCheck='cklay';
for (i=0;i<99;i++) {  vCheck='cklay'+i;
if (document.forms['frmLay'].elements[vCheck]) 
	{  document.forms['frmLay'].elements[vCheck].onclick();
		document.forms['frmLay'].elements[vCheck].onclick();}
}
if (document.forms['frmLay'].ckfd) 
	{	document.forms['frmLay'].ckfd.onclick();
		document.forms['frmLay'].ckfd.onclick();	
	}
}

function beforeZoom(){ 
	if(lastZoom!=null){
		root.currentTranslate.x = lastZoom["tX"];		 
		root.currentTranslate.y = lastZoom["tY"];		
		root.currentScale		= lastZoom["scale"];
	}
}

function layerShow(theCheckBox, theLayer)
{
var oLay = document.svgmap.getSVGDocument().getElementById(theLayer);
if (oLay) {
 if (theCheckBox.checked==false) VisState="hidden"; else VisState="visible";
 oLay.getStyle().setProperty("visibility", VisState); }
}
function zoomMap(k) { 
svgdoc=document.svgmap.getSVGDocument(); root=svgdoc.getDocumentElement();
lastZoom["tX"]		= root.currentTranslate.x;
lastZoom["tY"]		= root.currentTranslate.y;
lastZoom["scale"]	= root.currentScale;

sViewbox = root.getAttribute("viewBox");var vbox = sViewbox.split(' ');
x0 = parseInt(vbox[0]);y0 = parseInt(vbox[1]);
vboxW = parseInt(vbox[2]);vboxH = parseInt(vbox[3]);
svgW = parseInt(root.getAttribute("width"));svgH = parseInt(root.getAttribute("height"));
x1 = root.currentTranslate.x;
y1 =root.currentTranslate.y;
s1=root.currentScale;
px=(svgW/2);py=(svgH/2);
rx=(vboxW/svgW); ry=(vboxH/svgH);
if (k == 99) 
	{
	root.currentScale = 1;
	root.currentTranslate.x=1;
	root.currentTranslate.y=1;
	return;
	}
else
	{
	root.currentScale = root.currentScale * k;
	}

// Nouvelle étendue (pixel)
s2=root.currentScale;
// Calcul des coords reelles du centre de la fenêtre
cx1 = x0+(px-x1)*(rx/s1);
cy1 = y0+(py-y1)*(ry/s1);
// Calcul de la translation nécessaire pour replacer au centre le point cx1/cy1
x2 = px - ((cx1-x0)/(rx/s2));
y2 = py - ((cy1-y0)/(ry/s2));
root.currentTranslate.x=x2;
root.currentTranslate.y=y2;
}

function panMap(dx,dy) {
var decal = 100;
//SVGSTEP 
svgdoc=document.svgmap.getSVGDocument(); root=svgdoc.getDocumentElement();
lastZoom["tX"]		= root.currentTranslate.x;
lastZoom["tY"]		= root.currentTranslate.y;
lastZoom["scale"]	= root.currentScale;

if (dx!=0) root.currentTranslate.x=root.currentTranslate.x+(dx*decal);
if (dy!=0) root.currentTranslate.y = root.currentTranslate.y+(dy*decal);
}