﻿// JScript File

function ZoomIn()      //The function called when the user clicks the top of the 
{         
    var zum=0;           //set the new zoom level.
    zum=getZoomValue()/2;
    //if (zum>10)
    //{
        startProcessingMap();    
        UpdateMapZoom(zum);
    //}
    //else
    //{
        //alert("daha fazla yakınlaşamazsın.");
    //}    
    //finishProcessingMap();
}

function ZoomOut()         //The function called when the user clicks the bottom of the 
{  
    startProcessingMap();                       //zoom slider
    var zum=0;           //set the new zoom level.
    zum=getZoomValue()*2;
    UpdateMapZoom(zum);                           //get the new map image.
    //finishProcessingMap();

}

function UpdateMapZoom(zoomLevel)   //this function gets the new map image from the server
{           
   //Let the page know that updates are coming
	var mapImage = FindElement("MapControl1_Image");    //get the map image from the DOM
	 
	if (!mapImage.mapAlias) mapImage.mapAlias = mapImage.attributes["mapAlias"].value;
	if (!mapImage.exportFormat) mapImage.exportFormat = mapImage.attributes["exportFormat"].value;
    var w;
    var h;
    w=mapImage.width;
    h=mapImage.height;    
    //build the URL command to get a new image from the server.
	var url = "MapController.ashx?Command=ZoomToLevel" + 
	"&Width=" + w +
	"&Height=" + h +
	"&ExportFormat=" + mapImage.exportFormat + "&ZoomLevel=" + zoomLevel +
	"&includeBorder=false" +
	"&Ran=" + Math.random();
	mapImage.style.left = 0;
	mapImage.style.top = 0;
	mapImage.style.clip = 'rect(' + 0 + ' ' + mapImage.width + ' ' + mapImage.height + ' ' + 0 +')';
	try     //change the image source to the new URL
	{
		mapImage.src = url;
	} 
	catch(e) 
	{  
	}         
 
}


function getZoomValue()
{
	//create url to send to server, server command name is "ZoomValue"
	var url = "MapController.ashx?Command=ZoomValue&Ran=" + Math.random();
	var mapImage = document.getElementById("MapControl1_Image");                        
	if (mapImage.mapAlias) 
		url +=  "&MapAlias=" + mapImage.mapAlias;	
	var xmlHttp = CreateXMLHttp();
	xmlHttp.open("GET", url, false);
	xmlHttp.send(null);
	var result = xmlHttp.responseText;	
	
	var deger = 0;	
	deger = result;
	var div = FindElement("ZoomValue");
	div.innerHTML = "<font size=1 face=Arial><b><font color=blue>" + deger + "</font> metre</font></b></font>";
	return deger;
	
};	