var objMapView = document.getElementById("objMapView");	

// SGL 27-jul-09: Change the function getRectangle by getRectangleProp
//    This function only works for SVG. This funcion is defined in 

//==========================================================
function zoomarea_onclick()
{	
	 // set coordinate units to storage units
	 setCoordinateUnits(1);
	// Get point from user
	// SGL 27-jul-09: getRectangleProp
	getRectangleProp(zoomarea_callback);
	
}

function zoomarea_repeat()
{
	// set coordinate units to storage units
	setCoordinateUnits(1);
	// Get point from user
	// SGL 27-jul-09: getRectangleProp
	var ret = getRectangleProp(zoomarea_callback);	
}

function zoomarea_callback(sIOBuf)
{
	var iTmp = sIOBuf.indexOf( ":" );
 	var repeatCommand = "";
	if (iTmp==-1)
  	{
		alert(sIOBuf);
	}
	else
  	{
		// Get X,Y Values
		var jTmp = sIOBuf.indexOf( ";" );
		var newxMin = sIOBuf.substring(0, iTmp); //Get X
		var newyMin = sIOBuf.substring(iTmp+1, jTmp); //Get Y
		sIOBuf = sIOBuf.substring(jTmp+1, sIOBuf.length);
		iTmp = sIOBuf.indexOf( ":" );
		jTmp = sIOBuf.indexOf( ";" );
		var newxMax = sIOBuf.substring(0, iTmp); //Get X
		var newyMax = sIOBuf.substring(iTmp+1, jTmp); //Get Y
		// add temp redline
		addRectangle(newxMin, newyMin, newxMax, newyMax, false);		
		/*if (newxMin!=newxMax && newyMin!=newyMax)
    	{			
			ValidateRange(newxMin,newyMin,newxMax,newyMax,1);			
			CalcMapScale();
			//Get features to display in map
			strFeatureList = GetDisplayedLegendEntries(true);
	    if (document.globals.commandautorepeat.value == "1")
	    {
        repeatCommand = "zoomarea";
	    }			
		MakeMap(strFeatureList,"NEW","STND","","","",true,repeatCommand);
		}*/
		var x1 = newxMin;
		var x2 = newxMax;
		var y1 = newyMin;
		var y2 = newyMax;
		//var newxMin	= (Math.min(x1, x2)).toString().replace('.',',');
		//var newyMin	= (Math.min(y1, y2)).toString().replace('.',',');
		//var newxMax	= (Math.max(x1, x2)).toString().replace('.',',');
		//var newyMax	= (Math.max(y1, y2)).toString().replace('.',',');
		var newxMin	= parseInt(Math.min(x1, x2));
		var newyMin	= parseInt(Math.min(y1, y2));
		var newxMax	= parseInt(Math.max(x1, x2));
		var newyMax	= parseInt(Math.max(y1, y2));
		 
		//Capas nuevas a visualizar
		var mensa =  estado("");		
		location = "AytoMaqueta.asp?estado=I&xmin=" + newxMin + "&ymin=" + newyMin + "&xmax=" + newxMax + "&ymax=" + newyMax + "&prexmin=" + globals.xmin.value + "&preymin=" + globals.ymin.value + "&prexmax=" + globals.xmax.value + "&preymax=" + globals.ymax.value + "&xminINI=" + globals.xminINI.value + "&yminINI=" + globals.yminINI.value + "&xmaxINI=" + globals.xmaxINI.value + "&ymaxINI=" + globals.ymaxINI.value + mensa;
		

	}
}
