﻿// JScript File
var busy;
var currentZoomIndex;
var originalMapSizeIndex;

function saveMapSizeIndex()
{
  var mapSizeElem = document.getElementById("selectMapSize");
  originalMapSizeIndex =mapSizeElem.selectedIndex;
}
 
function alertContents(http_request)
{
  try
  {
    var requestStatus = document.getElementById("Status");
    var mapImage = document.getElementById("MapControl1_Image");

    if (http_request.readyState == 4)
    { 
      
      busy = false;
      if (http_request.status == 200)
      {
        
        if (http_request.responseText.indexOf("GIF")!= -1)
        {
          //requestStatus.innerHTML = "";
          //mapImage.src = 'data:image/gif,base64;' + http_request.responseText;
         
        }
        else if (http_request.responseText.indexOf("Site") != -1)
        {          
          var cmdZoomToState = new ZoomToStateCommand("MapControl1_Image");
          cmdZoomToState.ZoomToState("ZoomToState","Site");
          requestStatus.innerHTML = "The site can not be mapped.";
        }
        else //if (http_request.responseText.indexOf("Cannot find instance of StateManager in the ASP.NET session.") != -1)
        {
          
          requestStatus.innerHTML= "There was a problem with the request. Please try again.";
          //requestStatus.innerHTML="session problem";
        }
              
      }
      else 
      {        
        requestStatus.innerHTML= "There was a problem with the request. Please try again.";
      }
    }
    else
    {
      busy = true;
    }
  }
  catch(e)
  {
    //alert('Exception: ' + e.description);
    //alert("Exception");
  }
}

function UpdateStatus()
{	
 
  var requestStatus = document.getElementById("Status");
  if (requestStatus != null)
  {
    requestStatus.innerHTML ="Processing request, Please wait...";
  }
}
    
function ApplyChanges2(obj, command)
{

  if (!busy)
  {
      UpdateStatus();
      if (!obj.layerAlias) obj.layerAlias = obj.attributes["layerAlias"].value;
     
     	var mapImage = document.getElementById("MapControl1_Image");	 
      var url = "UpdateLayersHandler.ashx?Command=" + command +
          "&MapAlias=" + mapImage.mapAlias +					
				  "&LayerAlias=" + obj.layerAlias +
  			  "&Visible=" + obj.checked +
				  "&Width=" + mapImage.width +
				  "&Height=" + mapImage.height +
				  "&ExportFormat=" + mapImage.exportFormat +
				  "&Left=0"+
				  "&Top=0"+
				  "&Right="+ mapImage.width +
				  "&Bottom="+ mapImage.height +
				  "&R=" + Math.random();

      var lblOption = document.getElementById("chkLblVisible" + obj.layerAlias);
    
      if (lblOption != null) 
      {  
        url = url + "&LabelOption=" + lblOption.checked;
	    }
	    else
      {
        url = url;
      }


      var xmlhttp = CreateXMLHttp();
	    xmlhttp.onreadystatechange = function()
      { alertContents(xmlhttp);  }
	    xmlhttp.open("GET",url,true)
      xmlhttp.send(null)
  
      mapImage.src = url;
      
      return true;   
  }
  else
  {
     alert("Server is processing request. Please be patient.");
     return false;
  }
    
 
	 
}

function openSiteDetail()
{
  if (isSiteSelected())
  {
    var url = 'sitedetail.aspx?sitekey=' + document.getElementsByName('SiteList')[0].value;
    window.open(url, "", "menubar=yes,toolbar=yes,scrollbars=yes,status=yes,resizable=yes,location=yes,top=100,left=200");
  }
}
function isSiteSelected()
{
  if (document.getElementsByName('SiteList')[0].value.length == 0)
  {  
    alert('Please select a site.');
    return false;
  }
  return true;
}
function getZoomValue()
{
  var status  = document.getElementById("Status");
  var txtMapWidth = document.getElementById("txtMapWidth");
	//create url to send to server, server command name is "ZoomValue"
	var url = "MyMapController.ashx?Command=ZoomValue&Ran=" + Math.random();
	var mapImage = document.getElementById("MapControl1_Image");     
                  
	if (mapImage.mapAlias) 
		url +=  "&MapAlias=" + mapImage.mapAlias;
		
	var xmlhttp = CreateXMLHttp();
	//xmlhttp.onreadystatechange = function(){ alertContents(xmlhttp);  }
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	
	var result = xmlhttp.responseText;		
	var div = FindElement("ZoomValue");
  
  if (result.indexOf("Cannot find instance of StateManager in the ASP.NET session.") != -1)
  {
    alert(result);
    div.innerHTML ="<b>Map center (Long, Lat):&nbsp;&nbsp;</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Map Width:&nbsp;&nbsp;</b> mile(s)";
    txtMapWidth.value ="";
  }
  else
  { 
    if (result == "")
    {
      div.innerHTML ="<b>Map center (Long, Lat):&nbsp;&nbsp;</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Map Width:&nbsp;&nbsp;</b> mile(s)";
      txtMapWidth.value ="";
    }
    else
    {
      var temp = new Array();
	    temp = result.split(',');
	    div.innerHTML ="<b>Map center (Long, Lat):&nbsp;&nbsp;</b>" + temp[1] + " , " + temp[2] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Map Width:&nbsp;&nbsp;</b>" + temp[0] + " mile(s)";
   
      txtMapWidth.value=temp[0];
	    UpdateZoomSlider(temp[0]);
    }
  }
  status.innerHTML ="";
}	
function UpdateZoomSlider(zoomLevel)
{
    UpdateStatus();
    var myTool;
    var zoomIndex = GetZoomSliderSelectedIndex(zoomLevel);
    var i = 1;
    for (i=1;i<=12;i++)
    {
      myTool = document.getElementById("ZoomBarTool" + i + "_Image");
   
      if (i == zoomIndex)
      {         
        myTool.src ="resources/images/map/zoomslider/zoom_slider_brown.gif";
      }
      else
      {
        myTool.src="resources/images/map/zoomslider/zoom_tick.gif";
      }    
    } 
}

function GetZoomSliderSelectedIndex(zoomLevel)
{
  var zoomIndex;
 
  if (zoomLevel >3470 && zoomLevel<= 7700)
  {   
    zoomIndex = 12;
    if (zoomLevel > (3470 + 7700)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else  if (zoomLevel >1500 && zoomLevel<=3470)
  {  
    zoomIndex = 11;
    if (zoomLevel > (1500 + 3470)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel>1000 && zoomLevel<=1500)
  {  zoomIndex = 10;
     if (zoomLevel > (1000 + 1500)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel>500 && zoomLevel<=1000)
  {  
    zoomIndex = 9;
    if (zoomLevel > (500 + 1000)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1; 
  }
  else if (zoomLevel>200 && zoomLevel<=500)
  { 
    zoomIndex = 8;
    if (zoomLevel > (200 + 500)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel>100 && zoomLevel<=200)
  { 
    zoomIndex =7;
    if (zoomLevel > (100 + 200)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel>50 && zoomLevel<=100)
  {
    zoomIndex = 6;
    if (zoomLevel > (50 + 100)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1; 
  }
  else if (zoomLevel>8 && zoomLevel<=50)
  {  
    zoomIndex = 5;
    if (zoomLevel > (8 + 50)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel>3 && zoomLevel<=8)
  {
    zoomIndex = 4;
    if (zoomLevel > (3 + 8)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel >1 && zoomLevel<=3)
  {  
    zoomIndex = 3;
    if (zoomLevel > (1 + 3)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;}
  else if (zoomLevel > 0.5 && zoomLevel <=1)
  {
    zoomIndex =2;
    if (zoomLevel > (0.5 + 1)/2)
      zoomIndex = zoomIndex;
    else
      zoomIndex = zoomIndex -1;
  }
  else if (zoomLevel <= 0.5)
  {
    zoomIndex =1;
  }
  currentZoomIndex = zoomIndex;
  return zoomIndex;
}

function ZoomSliderInOut(flag)
{
  if(!busy)
  {
    UpdateStatus();
    var m;
    if (flag ==0)
    { 
      m = currentZoomIndex-1;
    }
    else
    {
      m=currentZoomIndex+1;
    }  
    var thisTool = document.getElementById("ZoomBarTool" + m + "_Image");
    
    if (thisTool != null)
    {
      
      var zoomTitle = thisTool.alt;
  	  var temp = new Array();
	    temp = zoomTitle.split(' ');
	    var currentZoom = temp[0];
	    //alert(currentZoom);
      var cmdZoomToMapWidth = new ZoomToMapWidthCommand("MapControl1_Image");
      cmdZoomToMapWidth.ZoomToMapWidth("ZoomToMapWidth",currentZoom);
      
      thisTool.src = "resources/images/map/zoomslider/zoom_slider_brown.gif";
     
      var i = 1;
      for (i=1;i<=12;i++)
      {
        myTool = document.getElementById("ZoomBarTool" + i + "_Image");
      
        if (i != m )
        {
          myTool.src="resources/images/map/zoomslider/zoom_tick.gif";
        }    
      } 
    }
  }
  else
    alert("Server is processing request. Please be patient.");
}

function ZoomToMapWidth(myEvent)
{
  
  var txtMapWidth = document.getElementById("txtMapWidth");
  if (!busy)
  {
    if(navigator.appName.toLowerCase().indexOf("netscape") >= 0 || navigator.appName.toLowerCase().indexOf("firefox") >= 0) //(myEvent != null)
    {
     
      if (myEvent.which == 13)
      {
      
        document.releaseEvents(Event.KEYPRESS);
      
        UpdateStatus();           
        
        var cmdZoomToMapWidth = new ZoomToMapWidthCommand("MapControl1_Image");
        cmdZoomToMapWidth.ZoomToMapWidth("ZoomToMapWidth",txtMapWidth.value);
        if (myEvent.stopPropagation) myEvent.stopPropagation(); return false;
        
        return true;
      }    
    }
    else
    {
      if (window.event.keyCode == 13) 
      {
          window.event.keyCode = 0;
          UpdateStatus();
          var cmdZoomToMapWidth = new ZoomToMapWidthCommand("MapControl1_Image");
          cmdZoomToMapWidth.ZoomToMapWidth("ZoomToMapWidth",txtMapWidth.value);
          return true;
       }
   }
 }
 else
 {
   alert("Server is processing request. Please be patient.");
   return false;
 }
}

function validateMapWidthTxtBox(mapwidth) 
{
   var isvalid = false; 
   
   if (mapwidth.length == 0) 
   {
     isvalid = true;
   }
   else if (isWidthNumberValid(mapwidth) == true)
   {
      isvalid = true;
   }
   return isvalid;
}
function isWidthNumberValid(testnumber)
{
  var regExp = /^[0-9]*(\.[0-9]+)?$/;
  if (regExp.test(testnumber))
  {
    return true;
  }   
  else 
    return false;
}

function RemoveFilter()
{
  var sitelistcaption = document.getElementById("SiteListCaption");
  sitelistcaption.innerHTML="all sites";
  var statelist = document.getElementById("States");
  statelist.selectedIndex=0;
  
  var status =document.getElementById('TargetAreaStatus');
  status.selectedIndex =0;
  GetSiteList("","","");
  //commented out by QM 02/12/07 no change of map view 
  //ZoomToState("");
}
function UpdateSiteList()
{
  var statelist = document.getElementById("States");
  var stateabb = statelist[statelist.selectedIndex].value;
  var statename= statelist[statelist.selectedIndex].text;
  
  var statuslist =document.getElementById("TargetAreaStatus");
  var statustext = statuslist[statuslist.selectedIndex].text;
  var statusvalue = statuslist[statuslist.selectedIndex].value;
  
  UpdateSiteListCaption(stateabb,statename,statusvalue,statustext);   
  GetSiteList(stateabb,statusvalue,statename);
  ZoomToState(stateabb);
}
function UpdateSiteListCaption(stateabb,statename,statusvalue,statustext)
{
  var str ="sites in ";
  var sitelistcaption = document.getElementById("SiteListCaption");
  
   if (stateabb == "")
  {
    if (statusvalue =="")
    {
      var all="all sites";
      sitelistcaption.innerHTML= all;
    }
    else
    {
      sitelistcaption.innerHTML = statustext.toLowerCase() + " sites";
    }  
  }
  else
  {
    if (statusvalue == "")
    {    
      sitelistcaption.innerHTML=str + stateabb;
    }
    else
    {
      var tempStatus;
      if (statusvalue =="A")
      {
        tempStatus ="active ";
      }
      else
      {
        tempStatus ="graduated ";
      }
      sitelistcaption.innerHTML = tempStatus + str + stateabb;  
    } 
  }
}
function GetSiteList(stateabb,status,statename)
{

  var url = "SiteListHandler.ashx?statestatus=" + stateabb + ","  + status  + "," + statename ;
  
  var xmlhttp = CreateXMLHttp();
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	var result = xmlhttp.responseText;			

	var sitelist = document.getElementById("SiteList");	
	var div = document.getElementById("NoSitesMsg");
	var b1 =document.getElementById("btnMapSite");
  var b2= document.getElementById("ViewSite");

	ClearListbox(sitelist);
	
	var delimiter  = result.indexOf("$",0,1)

	if (delimiter  == -1)
  {
  	ClearListbox(sitelist);
        
    div.style.visibility = "visible";
    //div.style.display= "inline";
	  div.innerHTML = result;
    b1.disabled =true;
	  b2.disabled =true;
	
	}
	else
	{
	    
	   b1.disabled =false;
	   b2.disabled =false;
	   div.style.visibility = "hidden";
	   //div.style.display = "none";
	 
	  var textField = result.substring(0,delimiter );
	
    var valueField = result.substring(delimiter + 1 ,result.length );
  
    var textFieldArray = new Array();
    textFieldArray = textField.split('|');
    
    var valueFieldArray = new Array();
    valueFieldArray = valueField.split(',');
    
    var m=0;
    for (var i = 0;i<= textFieldArray.length-1; i++ )
	  {
	   // works for IE only
	   // sitelist.add(new Option(textFieldArray[i],valueFieldArray[m])); 
	   
	   //works for IE and Netscape
	    sitelist.options[i]= new Option(textFieldArray[i],valueFieldArray[m]);
	    m=m+1;
      
	  }
	}
}
function ClearListbox(lb)
{
  for (var i=lb.options.length-1; i>=0; i--){
    lb.options[i] = null;
  }
  lb.selectedIndex = -1;
}
function ZoomToDefault()
{
  ZoomToState("");
}
function ZoomToState(statename)
{
  if (!busy)
  {
    UpdateStatus();
    var cmdZoomToState = new ZoomToStateCommand("MapControl1_Image");
    cmdZoomToState.ZoomToState("ZoomToState",statename);
  }
  else
    alert("Server is processing request. Please be patient.");
  
}
function StateChanged()
{
  var statelist = document.getElementById("States");
  var stateabb = statelist[statelist.selectedIndex].value;
  ZoomToState(stateabb);
}
function FindSite()
{
  if (!busy)
  {
    if (isSiteSelected())
    { 
      UpdateStatus();
      var cmdShowSite = new ShowSiteCommand("MapControl1_Image");
      cmdShowSite.ShowSite("ShowSite");
    }
  }
  else
    alert("Server is processing request. Please be patient.");
}
function ChangeMapSize(sel)
{
  if (!busy)
  {   
    UpdateStatus();
    var cmdChangeMapSize = new ChangeMapSizeCommand("MapControl1_Image");
    cmdChangeMapSize.ChangeMapSize("ChangeMapSize");
    originalMapSizeIndex = sel.selectedIndex;    
  }
  else
 {
    alert("Server is processing request. Please be patient.");
    sel.selectedIndex=originalMapSizeIndex;
 }
  
}
function GetInsetMap(e)
{
  if (!busy)
  {
    UpdateStatus();
    var cmdGetInsetMap = new GetInsetMapCommand("MapControl1_Image");
    cmdGetInsetMap.GetInsetMap("GetInsetMap",e);
  }
  else
    alert("Server is processing request. Please be patient.");
}

//CustomCommand definition, base class for ShowSiteCommand
function CustomCommand(mapImageID)
{
	
}
CustomCommand.prototype.CreateUrl = function()
{
	this.url = "MyMapController.ashx?Ran=" + Math.random();
					
	if (this.mapImage.mapAlias) this.AddParamToUrl("MapAlias", this.mapImage.mapAlias);

}
CustomCommand.prototype.AddParamToUrl = function(param, value)
{
	this.url += "&" + param + "=" + value;
	
}

//Width, Height, ExportFormat, Command are predefined names at server side to get request values
//So a couple of functions defined to hard-code these key names
CustomCommand.prototype.AddMapSizeToUrl = function(width, height)
{
	this.url += "&Width=" + width;
	this.url += "&Height=" + height;	
}

CustomCommand.prototype.AddMapExportFormatToUrl = function(format)
{
	this.url +=  "&ExportFormat=" + format;	
}

CustomCommand.prototype.AddSrvCommandNameToUrl = function(cmdName)
{
	
	this.url += "&Command=" + cmdName;	
}

CustomCommand.prototype.Init = function(mapImageID)
{
	this.mapImageID = mapImageID;
	this.mapImage = document.getElementById(mapImageID);
}

//ShowSiteCommand inherits CustomCommand
function ShowSiteCommand(mapImageID)
{
  if (arguments.length > 0) 
  {
		this.Init(mapImageID);
	}
}
ShowSiteCommand.prototype = new CustomCommand();
ShowSiteCommand.prototype.constructor = ShowSiteCommand;
ShowSiteCommand.superclass = CustomCommand.prototype;
ShowSiteCommand.prototype.Init = function(mapImageID)
{
	ShowSiteCommand.superclass.Init.call(this, mapImageID);
}
ShowSiteCommand.prototype.ShowSite = function(srvCmdName)
{
  this.CreateUrl();
  var sl = document.getElementById("SiteList");
  var sitekey = sl[sl.selectedIndex].value;
 
  this.AddMapSizeToUrl(this.mapImage.width, this.mapImage.height);
	this.AddMapExportFormatToUrl(this.mapImage.exportFormat);
	this.AddSrvCommandNameToUrl(srvCmdName);	
	this.AddParamToUrl("SiteID",sitekey);

	var xmlhttp = CreateXMLHttp();
	xmlhttp.onreadystatechange = function()
  { alertContents(xmlhttp);  }
	xmlhttp.open("GET",this.url,true)
  xmlhttp.send(null)

  try 
	{
    this.mapImage.src = this.url;
  } 
	catch(e) 
	{ 
		alert("ll"); 
	}					
}

function ChangeMapSizeCommand(mapImageID)
{
  if (arguments.length > 0) 
  {
		this.Init(mapImageID);
	}
	
}
ChangeMapSizeCommand.prototype = new CustomCommand();
ChangeMapSizeCommand.prototype.constructor = ChangeMapSizeCommand;
ChangeMapSizeCommand.superclass = CustomCommand.prototype;
ChangeMapSizeCommand.prototype.Init = function(mapImageID)
{

	ChangeMapSizeCommand.superclass.Init.call(this, mapImageID);
	
}
ChangeMapSizeCommand.prototype.ChangeMapSize = function(srvCmdName)
{
  this.CreateUrl();
 
  //var mapsize =document.getElementsByName('selectMapSize')[0].value;	
  var mapSizeElem = document.getElementById("selectMapSize");
  var mapsize = mapSizeElem[mapSizeElem.selectedIndex].value;
 
  var i = mapsize.indexOf("x", 0);
  var w = mapsize.substring(0, i);
  var h = mapsize.substring(i + 1, mapsize.length);
  this.AddMapSizeToUrl(w , h );
 	this.AddMapExportFormatToUrl(this.mapImage.exportFormat);
	this.AddSrvCommandNameToUrl(srvCmdName);	
  var spanElem = document.getElementById("MapControl1");
  
  var xmlhttp = CreateXMLHttp();
	xmlhttp.onreadystatechange = function()
  { alertContents(xmlhttp);  }
	xmlhttp.open("GET",this.url,true)
  xmlhttp.send(null)
	try 
	{
    this.mapImage.src = this.url;
   	this.mapImage.width = w;
    this.mapImage.height = h;
      
    spanElem.style.width = w + "px";
    spanElem.style.height = h + "px";
    

	} 
	catch(e) 
	{ 
		alert("ll"); 
	}					
}

function GetInsetMapCommand(mapImageID)
{
  if (arguments.length > 0) 
  {
		this.Init(mapImageID);
	}
	
}
GetInsetMapCommand.prototype = new CustomCommand();
GetInsetMapCommand.prototype.constructor = GetInsetMapCommand;
GetInsetMapCommand.superclass = CustomCommand.prototype;
GetInsetMapCommand.prototype.Init = function(mapImageID)
{
	GetInsetMapCommand.superclass.Init.call(this, mapImageID);
}
GetInsetMapCommand.prototype.GetInsetMap = function(srvCmdName,e)
{
  var xPosition;
  var yPosition;
  
  if(navigator.appName.toLowerCase().indexOf("netscape") >= 0 || navigator.appName.toLowerCase().indexOf("firefox") >= 0) 
  {
    xPosition = e.pageX - document.getElementById("MapInset").offsetLeft;
    yPosition = e.pageY - document.getElementById("MapInset").offsetTop;
	}
	else if (navigator.appName.toLowerCase().indexOf("microsoft") >= 0)
  {
		xPosition = event.offsetX;
		yPosition = event.offsetY;
  } 
  var xyValue = xPosition + "," + yPosition;

	this.CreateUrl();
  this.AddMapSizeToUrl(this.mapImage.width,this.mapImage.height);
	this.AddMapExportFormatToUrl(this.mapImage.exportFormat);
	this.AddSrvCommandNameToUrl(srvCmdName);	
  this.AddParamToUrl("InsetMap",xyValue);
 
 
  var xmlhttp = CreateXMLHttp();
	xmlhttp.onreadystatechange = function()
  { alertContents(xmlhttp);  }
	xmlhttp.open("GET",this.url,true)
  xmlhttp.send(null)
  
	try 
	{
    this.mapImage.src = this.url;
  } 
	catch(e) 
	{ 
		alert("ll"); 
	}					
}

function ZoomToStateCommand(mapImageID)
{
  if (arguments.length > 0) 
  {
		this.Init(mapImageID);
	}
}
ZoomToStateCommand.prototype = new CustomCommand();
ZoomToStateCommand.prototype.constructor = ZoomToStateCommand;
ZoomToStateCommand.superclass = CustomCommand.prototype;
ZoomToStateCommand.prototype.Init = function(mapImageID)
{
  ZoomToStateCommand.superclass.Init.call(this, mapImageID);
}
ZoomToStateCommand.prototype.ZoomToState= function(srvCmdName,statename)
{
  this.CreateUrl();
 	this.AddMapSizeToUrl(this.mapImage.width, this.mapImage.height);
	this.AddMapExportFormatToUrl(this.mapImage.exportFormat);
	this.AddSrvCommandNameToUrl(srvCmdName);	
	this.AddParamToUrl("State",statename);
	
	var xmlhttp = CreateXMLHttp();
	xmlhttp.onreadystatechange = function()
  { alertContents(xmlhttp);  }
	xmlhttp.open("GET",this.url,true)
  xmlhttp.send(null)

	try 
	{
   	this.mapImage.src = this.url;
	} 
	catch(e) 
	{ 
		alert("ll"); 
	}					
}

function ZoomToMapWidthCommand(mapImageID)
{
  if (arguments.length > 0) 
  {
		this.Init(mapImageID);
	}
}
ZoomToMapWidthCommand.prototype = new CustomCommand();
ZoomToMapWidthCommand.prototype.constructor = ZoomToMapWidthCommand;
ZoomToMapWidthCommand.superclass = CustomCommand.prototype;
ZoomToMapWidthCommand.prototype.Init = function(mapImageID)
{
	ZoomToMapWidthCommand.superclass.Init.call(this, mapImageID);
}
ZoomToMapWidthCommand.prototype.ZoomToMapWidth = function(srvCmdName,mapwidth)
{
  this.CreateUrl();
  this.AddMapSizeToUrl(this.mapImage.width,this.mapImage.height);
 	this.AddMapExportFormatToUrl(this.mapImage.exportFormat);
	this.AddSrvCommandNameToUrl(srvCmdName);
	this.AddParamToUrl("MapWidth",mapwidth);	
 
  var xmlhttp = CreateXMLHttp();
	xmlhttp.onreadystatechange = function()
  { alertContents(xmlhttp);  }
	xmlhttp.open("GET",this.url,true)
  xmlhttp.send(null)

	try 
	{
    this.mapImage.src = this.url;
  } 
	catch(e) 
	{ 
		alert("ll"); 
	}					
}
