/**
 * Copyright 2003, IMTEAM www.imteam.it
 * QUESTO PROGRAMMA E' COPERTO DA COPYRIGHT E NON PUO' ESSERE COPIATO O
 * MODIFICATO (NEMMENO PARZIALMENTE) SENZA ESPLICITO CONSENSO DEL PROPRIETARIO.
 * NON PUO' ESSERE UTILIZZATO AL DI FUORI DEL PRODOTTO CON CUI E' STATO FORNITO.
 */
/**
 * Gestione del resize per IE4 o IE5
 * questa funzione calcola la nuova larghezza della mappa e la applica alla
 * mappa, alle division della legenda e layers ed alla cella della table.
 */

// la distanza dal fondo puņ essere cambiata da un'altra parte (nel footer!)
var distBottom = 30; // sembra che 20 sia giusto il bordo mappa

function mapResize() {
	mappaLeft = toolGetNumberWithoutPx(layerGetStyle("theMap").left);
	mappaTop = toolGetNumberWithoutPx(layerGetStyle("theMap").top);
	var distLeft = toolGetNumberWithoutPx(layerGetStyle("layer_tab_struttura").left);
	var distRight = distLeft; // la distanza dal bordo dx e' uguale al bordo sx

  // la larghezza finale della pagina deve essere MINIMO 800px
	larghWin = (winGetWidth() > 800) ? winGetWidth() : 800;
  // questa e' la larghezza della division e dell'immamgine
	mappaWidth = larghWin - mappaLeft - 2 * hspcCella - 1;

    // l' altezza finale della pagina deve essere MINIMO 500px (c'e' anche il menu di explorer)
	altWin = (winGetHeight() > 500) ? winGetHeight() : 500;
	var legTop = toolGetNumberWithoutPx(layerGetStyle("tablegenda").top);
	mappaHeight = altWin - mappaTop - distBottom - 2 * vspcCella;
	var legendHeigth = altWin - legTop - distBottom;


  //alert(mappaWidth+" "+ mappaHeight);
	if (document.getElementById("ECWView") != null) {
		document.getElementById("ECWView").width = mappaWidth+100;
		document.getElementById("ECWView").height = mappaHeight+100;
	}
	document.images["laMappa"].width = mappaWidth;
	document.images["laMappa"].height = mappaHeight;
	
	
	document.images["laMappaBlend"].left = mappaLeft;
	document.images["laMappaBlend"].top = mappaTop;
	document.images["laMappaBlend"].width = mappaWidth;
	document.images["laMappaBlend"].height = mappaHeight;


	layerGetStyle("theMapBlend").left = mappaLeft;
	layerGetStyle("theMapBlend").top = mappaTop;
	
	layerGetStyle("imgscaladiv").left = mappaLeft+40;
	
	layerGetStyle("theVMLCanvas").left = mappaLeft;
	layerGetStyle("theVMLCanvas").top = mappaTop;
	layerGetStyle("theVMLCanvas").width = mappaWidth;
  	layerGetStyle("theVMLCanvas").height = mappaHeight;
	
	/*	
  document.getElementById("canvasSvg").width = mappaWidth;
  document.getElementById("canvasSvg").height = mappaHeight;
*/
	layerGetStyle("loadingDiv").left = mappaLeft;
	layerGetStyle("loadingDiv").top = mappaTop;
	layerGetStyle("loadingDiv").width = mappaWidth;
	layerGetStyle("loadingDiv").height = mappaHeight;
	
	document.images["loadingImg"].width = mappaWidth + 2 * hspcCella;
	document.images["loadingImg"].height = mappaHeight;
	
	/**
	document.getElementById("svgdiv").width = mappaWidth;
  document.getElementById("svgdiv").height = mappaHeight;
  document.getElementById("svgcanvas").width = mappaWidth;
  document.getElementById("svgcanvas").height = mappaHeight;
	**/
	layerGetStyle("tablegenda").height = legendHeigth;
	layerGetStyle("tablayers").height = legendHeigth;
  //layerClip2("theMap",0,0,mappaWidth,mappaHeight);
  //layerClip2("loadingDiv",0,0,document.images['loadingImg'].width,document.images['loadingImg'].height);
	layerGetStyle("cellamappa").width = mappaWidth + 2 * hspcCella;
	layerGetStyle("cellamappa").height = mappaHeight + 2 * vspcCella;// + distBottom;
	/* larghezza della division */
  //iWidth   = mappaWidth;
  //iHeight  = mappaHeight;
  // aggiorno le dimensioni dell'oggetto flash
  if (typeof(wantFlash)!="undefined" && wantFlash)
  {
    //flashResize('flash_edit','objEdit','theMap');
	  // aggiorno le dimensioni dell'oggetto flash
		resizeFMX_FlashFeatureEditor();
  }
	if (document.getElementById("ECWView") != null) {
		document.getElementById("ECWView").width = mappaWidth+100;
		document.getElementById("ECWView").height = mappaHeight+100;
	}
	document.processa.MapImageX.value = mappaWidth;
	document.processa.MapImageY.value = mappaHeight;
	layerGetStyle("imgscaladiv").top = mappaTop + mappaHeight - 40;
	
	layerGetStyle("miniCartina").left = mappaLeft+10;
	layerGetStyle("miniCartina").top = mappaTop+10;

}
