﻿// Javascript file for Web Mapping Application
var arcgisWebApp;
var isRTL = (document.documentElement.dir=="rtl"); // find out if the document has been set to right-to-left
var isIE = (Sys.Browser.agent == Sys.Browser.InternetExplorer);
/// <reference assembly="System.Web.Extensions" name="MicrosoftAjax.js"/>
Type.registerNamespace('ESRI.ADF.WebMappingApplication');


var webPrintStatus = null;
var currentTool = "MapZoomIn"; 
var reloadTimer;
var webMapAppLeftPanelWidth = 282;

var webMapAppToggleWidth = 10;
var webMapAppTopBannerHeight = 110;
var newLoad = false;
var webMapAppCloseCallback = "";
var webMapAppCopyrightCallback = "";
var webMapAppMoveFunction = null;
var webMapAppMapDisplay = null;
var webMapAppPanelDisplay = null;
var webMapAppPanelDisplayCell = null;
var webMapAppPanelDisplayTableCell = null;
var webMapAppPanelScrollDiv = null;
var webMapAppToggleDisplay = null;
var webMapAppSpacerDiv = null;
var webMapAppBottomPanelDiv = null;
var webMapAppBottomPanelHeight = 0;

var webMapAppPanelBottomSlider = null;
var webMapAppScaleBar = null;
var webMapAppCopyrightText = null;
var webMapAppWindowWidth = 500;
var webMapAppLeftOffsetX = 0;
var webMapAppRightOffsetX = 0
var webMapAppDefaultMinDockWidth = 125;
var webMapAppMinDockWidth = webMapAppDefaultMinDockWidth;
var webMapAppMapLeft = 282;
var webMapAppHasScroll = false;
var webMapAppLastHasScroll = false;
var webHeaderDisplay ;
var webLinkDisplay;
var rightDisplay;
var errorDisplay = null;
var dockedImage;
var undockedImage;

var webMapAppDownload = null;
var webSelectInstruction = null;
var webLabelInstruction = null;



// function to set initial sizes of page elements
function setPageElementSizes() {
        // set body style 
        document.body.style.overflow = "hidden";
        document.body.style.height = "100%"; 
        // get necessary elements
        
        webMapAppDownload = document.getElementById('divshowdownload');
        
        webPrintStatus = document.getElementById("loadImg"); //("PrintImg");
        webMapAppMapDisplay = document.getElementById("Map_Panel");
        webMapAppPanelDisplay = document.getElementById("LeftPanelCellDiv");
        webMapAppPanelDisplayCell = document.getElementById("LeftPanelCell");
        webMapAppPanelScrollDiv = document.getElementById("LeftPanelScrollDiv");
        webMapAppToggleDisplay = document.getElementById("ToggleCell");
        webMapAppPanelSlider = document.getElementById("PanelSlider");
        webMapAppPanelDisplayTableCell = document.getElementById("LeftPanelTableCell");
        webMapAppPanelBottomSlider = document.getElementById("PanelSliderBottom");
        webMapAppScaleBar = document.getElementById("ScaleBar1");
        webMapAppCopyrightText = document.getElementById("CopyrightTextHolder");
        var headerDisplay = document.getElementById("PageHeader");
        var linkDisplay = document.getElementById("LinkBar");
        webMapAppBottomPanelDiv = document.getElementById("bottomPanel");
        // set scroll on Dock
        webMapAppPanelScrollDiv.style.overflowY = "auto";
        if (isIE) {
            webMapAppPanelDisplay.style.overflowY = "hidden"; //"auto"; //
        } 
        // get the set widths and heights
        webMapAppLeftPanelWidth = webMapAppPanelDisplay.clientWidth;
        webMapAppToggleWidth = parseInt(webMapAppToggleDisplay.style.width);
        webMapAppTopBannerHeight = headerDisplay.clientHeight + linkDisplay.clientHeight;
        // get browser window dimensions
        
        var sWidth = getWinWidth();
        
        if(webMapAppBottomPanelDiv.style.visibility=="hidden"){
            webMapAppBottomPanelHeight = 0;}else{
            webMapAppBottomPanelHeight = 200;}            
        var sHeight = getWinHeight()- webMapAppBottomPanelHeight;
        
        // set map display dimensions
        var mWidth = sWidth - webMapAppPanelDisplayCell.clientWidth;
        
        //var mWidth = sWidth - webMapAppLeftPanelWidth - webMapAppToggleWidth;
        var mHeight = sHeight - webMapAppTopBannerHeight;
        webMapAppMapLeft = webMapAppLeftPanelWidth + webMapAppToggleWidth;
        webMapAppMapDisplay.style.width =  mWidth + "px";
        webMapAppMapDisplay.style.height = mHeight  + "px";
        if (webMapAppScaleBar!=null) {
            var sbWidth = webMapAppScaleBar.clientWidth;
            var sbHeight = webMapAppScaleBar.clientHeight;
            webMapAppScaleBar.style.left = 10 + "px";
            webMapAppScaleBar.style.top = (sHeight - sbHeight - 10) + "px";
            webMapAppScaleBar.style.width = "auto";
            webMapAppScaleBar.style.height = "auto";
        } 
        if (webMapAppCopyrightText!=null) {
            webMapAppCopyrightText.onmousedown = webMapAppGetCopyrightText;
            var crtHeight = webMapAppCopyrightText.clientHeight;
            webMapAppCopyrightText.style.left = (webMapAppMapLeft + 10) + "px";
            webMapAppCopyrightText.style.top = (sHeight - crtHeight - 10) + "px";
        }
        // set heights of left panel and toggle bar
        webMapAppToggleDisplay.style.height = sHeight  + "px";
        webMapAppPanelScrollDiv.style.height = sHeight  + "px";
        
        //get header elements
        webHeaderDisplay = document.getElementById("PageHeader");
        webLinkDisplay = document.getElementById("LinkBar");
        rightDisplay = document.getElementById("right");
        errorDisplay = document.getElementById("inputerror");
        webSelectInstruction = document.getElementById("divInstruction");
        webLabelInstruction =  document.getElementById("lblInstruction");       
        
}

// function to toggle Dock visibility
function togglePanelDock() {
    if (webMapAppPanelDisplay.style.display=="none") {
        expandPanelDock();
    } else {
        collapsePanelDock();
    }     
}

function expandPanelDock() {
    var image = document.images["CollapseImage"];
    webMapAppPanelDisplay.style.display = "block";
    image.src = "images/expand_right.gif";
    image.alt = "Collapse";
    webMapAppPanelSlider.style.cursor = "e-resize";
    webMapAppPanelBottomSlider.style.cursor = "e-resize"; 
    
    //modify here
    webMapAppMapLeft = webMapAppLeftPanelWidth + webMapAppToggleWidth + 17;
    webMapAppMapDisplay.style.right =  webMapAppMapLeft + "px";
    
     
    webHeaderDisplay.style.right = webMapAppMapLeft + "px";
    webLinkDisplay.style.right = webMapAppMapLeft + "px";
    rightDisplay.style.width = webMapAppMapLeft + "px";
    //
    AdjustMapSize(); 
}

function collapsePanelDock() {
    var image = document.images["CollapseImage"];
    dockWidthString = webMapAppPanelDisplayCell.clientWidth + "px";
    webMapAppPanelDisplay.style.display = "none";
    //webMapAppPanelDisplayCell.style.width = "1px";
    image.src = "images/expand_left.gif";
    image.alt = "Expand";
    
     webMapAppPanelSlider.style.cursor = "default"; 
    webMapAppPanelBottomSlider.style.cursor = "default"; 
    
    //modify
    
    
    webMapAppMapDisplay.style.right = webMapAppToggleWidth;
     
    webHeaderDisplay.style.right = webMapAppToggleWidth;
    webLinkDisplay.style.right = webMapAppToggleWidth;
    rightDisplay.style.width = webMapAppToggleWidth;
    //webMapAppMapLeft = webMapAppToggleWidth; 
    //webMapAppMapDisplay.style.left =  webMapAppMapLeft + "px";  
    //end
   
    
    AdjustMapSize();  
   
}  

// function for adjusting element sizes when brower is resized
function AdjustMapSize() {
   // set element widths 
    webMapAppPanelDisplay.style.width =  webMapAppLeftPanelWidth + "px";
    webMapAppToggleDisplay.style.width = webMapAppToggleWidth + "px";
   // get browser window dimensions 
    var sWidth = getWinWidth();
    
    if(webMapAppBottomPanelDiv.style.visibility=="hidden"){
            webMapAppBottomPanelHeight = 0;}else{
            webMapAppBottomPanelHeight = 200;} 
    var sHeight = getWinHeight()- webMapAppBottomPanelHeight;
    
    // calc dimensions needed for map
    var mWidth = sWidth - webMapAppPanelDisplayCell.clientWidth;
    var mHeight = sHeight - webMapAppTopBannerHeight;
    if (mWidth<5) mWidth = 5;
    if (mHeight<5) mHeight = 5;  
    webMapAppMapDisplay.style.width =  mWidth + "px";
    webMapAppMapDisplay.style.right =  webMapAppPanelDisplayCell.clientWidth + "px"; 
   // set heights on elements 
    webMapAppMapDisplay.style.height = mHeight  + "px";
    webMapAppToggleDisplay.style.height = sHeight  + "px";
    webMapAppPanelScrollDiv.style.height = sHeight  + "px";
    if (webMapAppScaleBar!=null) {
        var sbWidth = webMapAppScaleBar.clientWidth;
        var sbHeight = webMapAppScaleBar.clientHeight;
        webMapAppScaleBar.style.left = 10 + "px";
        webMapAppScaleBar.style.top = (sHeight - sbHeight - 10) + "px";
    } 
   // resize the map 
    window.setTimeout("resizeTheMap(" + mWidth + ", " + mHeight + ", false);", 500);
   // update map properties 
     
    var box = calcElementPosition("Map_Panel"); 
    map.containerLeft = box.left;
	map.containerTop = box.top;
    if (webMapAppCopyrightText!=null) {
        var crtHeight = webMapAppCopyrightText.clientHeight;
        webMapAppCopyrightText.style.left = (box.left + 10) + "px";
        webMapAppCopyrightText.style.top = (sHeight - crtHeight - 10) + "px";
    }
    return false;
}

// function for resizing map in Web Map App
function resizeTheMap(width, height, resizeExtent) {
    if (resizeExtent==null) resizeExtent = true;
    map.resize(width, height, resizeExtent);
    var div = document.getElementById("LeftPanelCellDiv"); 
    // update overview, if doc panel is expanded 
    if (ov!=null && div.style.display!="none") { 
        var argument = "ControlType=OverviewMap&EventArg=OverviewZoom";
        var context = ov.controlName; 
        eval(ov.callBackFunctionString);
    }
    return false; 
}

// handler for window resize
function AdjustMapSizeHandler(e) {
    window.clearTimeout(reloadTimer);
	reloadTimer = window.setTimeout("AdjustMapSize();",1000);
}


// function run at startup
function startUp() {
             
        map = $find('Map1');
        map.add_onProgress(customProgress);
        
        // set window resize event handler : 93     
        //window.setTimeout('$addHandler(window,"resize", arcgisWebApp.adjustMapSizeHandler);', 1000);
        
         window.onresize = AdjustMapSizeHandler;
         
         for (var fp in FloatingPanels) {
            FloatingPanels[fp].onDockFunction = scrollDockToPanel;
       } 
         
          resetFloatingPanels();   
 
} 

  function customProgress(sender, pendingTiles)
	    {
		    if (sender != null){
			    window.status = "Pending tiles: " + pendingTiles;
			    if (pendingTiles > 0)
			    {
				    // showLayer and hideLayer are part of the Web ADF JS library
				    // in the display_common.js
				    showLayer("loadImg");
			    } else {
				     hideLayer("loadImg");
			    }
		    }
	    } 

// function to request closing of session items.... only called if at least one resource is local non-pooled
function CloseOut() {
	var argument = "ControlID=Map1&ControlType=Map&EventArg=CloseOutApplication";
	var context = map.controlName;
	eval(webMapAppCloseCallback);
}

// response function to close out browser ... request sent to server by CloseOut()
function CloseOutResponse(response, context) {
    window.close(); 
    // if user selects Cancel in close dialog, send to close page 
    document.location = response; 
}


function startWebMapAppDockDrag(e) {
    webMapAppMoveFunction = document.onmousemove;
    document.onmouseup = stopWebMapAppDocDrag;  
    if (webMapAppPanelDisplay.style.display!="none") {
        webMapAppWindowWidth = getWinWidth();
        getXY(e); 
        webMapAppLeftOffsetX = mouseX + webMapAppPanelDisplay.clientWidth; // mouseX - webMapAppPanelDisplay.clientWidth  ;
        
        var box = calcElementPosition("Map_Panel");
        webMapAppRightOffsetX = box.left - mouseX; 
        document.onmousemove = moveWebMapAppDockDrag;
        var ovPanel = document.getElementById("OverviewMap_Panel_BodyRow");
        var ovDisplay =  document.getElementById("OVDiv_OverviewMap_Panel_OverviewMap1");
        // because the panel cell will be as wide as the overview map image, keep the element width larger than the image. 
        
        var j;
        for (var i=0;i<FloatingPanels.length;i++)
        {
            fp=FloatingPanels[i];
            if(fp.id == "OverviewMap_Panel"){j=i;break;};
        } 
    
        if (FloatingPanels[j]!=null &&FloatingPanels[j].docked)
            webMapAppMinDockWidth = parseInt(ovDisplay.style.width) + 20;
        else    
            webMapAppMinDockWidth = webMapAppDefaultMinDockWidth; 
    }    
    
    return false;  
}

function moveWebMapAppDockDrag(e) {
    getXY(e);
    webMapAppLeftPanelWidth =  webMapAppLeftOffsetX - mouseX; 
   if (webMapAppLeftPanelWidth < webMapAppMinDockWidth) webMapAppLeftPanelWidth = webMapAppMinDockWidth; 
    var mapLeftString = (webMapAppLeftPanelWidth + webMapAppToggleDisplay.clientWidth + 17 ) + "px";
    //if (webMapAppPanelDisplayTableCell.clientWidth - webMapAppToggleDisplay.clientWidth > webMapAppLeftPanelWidth) webMapAppLeftPanelWidth = webMapAppPanelDisplayTableCell.clientWidth - webMapAppToggleDisplay.clientWidth;
    var widthString =  webMapAppLeftPanelWidth + "px";
    webMapAppPanelDisplay.style.width = widthString;
    //var width =  webMapAppWindowWidth - webMapAppMapDisplay.clientWidth;
    var width = webMapAppWindowWidth - webMapAppPanelDisplayCell.clientWidth  ; 
    webMapAppMapDisplay.style.width = width + "px";
    //webMapAppMapDisplay.style.right = mapLeftString;
   
    
    
    //modify header width    
    webHeaderDisplay.style.right = mapLeftString;
    webLinkDisplay.style.right = mapLeftString;
    rightDisplay.style.width = mapLeftString;
    
    
    window.status ="mousex: " + mouseX + " offset: " + webMapAppRightOffsetX + " Win:" + webMapAppWindowWidth + "  Map: " + width + " Map right: " + mapLeftString + "  PanelCell: " + webMapAppPanelDisplayCell.clientWidth + "  Panel: " + webMapAppLeftPanelWidth ; 
    return false;
}



function stopWebMapAppDocDrag(e) {
    document.onmousemove = webMapAppMoveFunction;
    document.onmouseup = null;   
    webMapAppCheckPanelWidths();
    AdjustMapSize();  
    return false;
}

function OpenWindow(url) {
    window.open(url);
}

function webMapAppCheckPanelScroll() {
    if (webMapAppPanelScrollDiv.scrollHeight>webMapAppPanelScrollDiv.clientHeight) {
        webMapAppHasScroll = true;
    }  else {
        webMapAppHasScroll = false;
    }  
    //webMapAppCheckPanelWidths(); 
    if (webMapAppHasScroll!=webMapAppLastHasScroll)
        AdjustMapSize();
    webMapAppLastHasScroll = webMapAppHasScroll;    
    return false; 
}

function webMapAppCheckPanelWidths() {
    var maxWidth = 0;
    var node; 
    for (var i=0; i< webMapAppPanelDisplay.childNodes.length; i++) {
        if (webMapAppPanelDisplay.childNodes[i].tagName=="TABLE") {
            node = webMapAppPanelDisplay.childNodes[i];
            if (node.clientWidth>maxWidth) maxWidth = node.clientWidth; 
        }
    }  
     webMapAppPanelDisplay.style.width = maxWidth + "px";
    return false;
}

function webMapAppGetCopyrightText() {
	var argument = "ControlID=Map1&ControlType=Map&EventArg=GetCopyrightText";
	var context = map.controlName;
	eval(webMapAppCopyrightCallback);
	showFloatingPanel('CopyrightText_Panel');
}

function scrollDockToPanel(panelElement) {
    if (panelElement==null) return;
    var yPos = panelElement.offsetTop;
    webMapAppPanelScrollDiv.scrollTop = 0; // yPos;      
}

function toggleMagnifier() {
    var mag = document.getElementById("Magnifier1");
    if (mag!=null) { 
            toggleFloatingPanelVisibility('Magnifier1'); 
    } else 
        alert("Magnifier is not available"); 
    
}


function resetFloatingPanels(){
//modified here
        dockedImage = FloatingPanels[0].undockedImage; //FloatingPanels['fpAOI'].undockedImage;
        undockedImage =  FloatingPanels[0].dockedImage; // FloatingPanels['fpAOI'].dockedImage;
       
        
         //for (var i=0;i<FloatingPanelNames.length;i++)
         for (var i=0;i<FloatingPanels.length;i++)
        {
            //var id=FloatingPanelNames[i];
            //fp=FloatingPanels[id];
            fp=FloatingPanels[i];
            var id = fp.id;
        
            if (fp!=null)
            {  
               var dockButton=document.getElementById(id+"_DockButton");
               if (dockButton!=null){
                    fp.onDockFunction = null;
                    fp.dockedImage = dockedImage;
                    fp.undockedImage = undockedImage;
                    
                    dockButton.onclick = function(){
                        var id2 = this.id;
                        var idx = id2.indexOf("_DockButton");
                        
                        var fp_id = id2.substr(0, idx);
                        MytoggleFloatingPanelDockState(fp_id);
                        
                    }
              
               } 
                           
            }
        }
        
        FloatingPanels[0].dockedImage = dockedImage;
        FloatingPanels[0].undockedImage = undockedImage;
        
        //FloatingPanels['fpAOI'].dockedImage = dockedImage;
        //FloatingPanels['fpAOI'].undockedImage = undockedImage;
        //
}

//new in 93
// Common webpage object for manipulating page elements
//ESRI.ADF.WebMappingApplication.WebPage = function() {
//    this.MapId = "Map1";
//    this.map = null; 
//	this.MapDisplay = $get("Map_Panel");
//	this.PanelDisplay = $get("LeftPanelCellDiv");
//	this.PanelDisplayCell = $get("LeftPanelCell");
//	this.PanelScrollDiv = $get("LeftPanelScrollDiv");
//	this.ToggleDisplay = $get("ToggleCell");
//	this.PanelSlider = $get("PanelSlider");
//	this.PanelDisplayTableCell = $get("LeftPanelTableCell");
//	this.PanelBottomSlider = $get("PanelSliderBottom");
//	this.ResultsPanel = $get("Results");
//	this.TocPanel = $get("Toc_Panel");
//	this.Results = $get("TaskResults1");
//	this.Toc = $get("Toc1");
//	this.ResultsPanelContents = $get("Results_Panel_Body");
//	this.TocPanelContents = $get("Toc_Panel_Body");
//	this.ResultsPanelResize = $find("Results_Panel_ResizeBehavior");
//	this.TocPanelResize = $find("Toc_Panel_ResizeBehavior");
//	this.NavigationTool = $get("Navigation1");
//	this.CopyrightText = $get("Copyright_Panel");
//	this.ZoomLevel = $get("ZoomLevel1");
//	
//	this.LeftPanelWidth = 262;
//	this.ToggleWidth = 10;
//	this.TopBannerHeight = 80;
//	this.WindowWidth = 500;
//	this.LeftOffsetX = 0;
//	this.RightOffsetX = 0
//	this.NavigationLeft = 0;
//	this.CopyrightTextLeft = 0;
//	this.DefaultMinDockWidth = 125;
//	this.MinDockWidth = this.DefaultMinDockWidth;
//	this.MapLeft = 262;
//	this.LastMapWidth = 512;
//	this.LastMapHeight = 512;
//	this.CurrentMapWidth = 512;
//	this.CurrentMapHeight = 512;
//	this.HasScroll = false;
//	this.LastHasScroll = false;
//	this.DockMoving = false;
//	this.reloadTimer = null;
//	this.hasMeasure = false;
//	this.Measure = null;
//	this.MapUnits = null;
//	this.CoordsDecimals = 3;
//	this.currentMode = "Pan";
//	this.lastMode = "Pan";
//	
//	this.setPageElementSizes = function() {
//        // set body style 
//        if (document.documentElement) {
//            document.documentElement.style.overflow = "hidden";
//            document.documentElement.style.height = "100%"; 
//            this.PanelDisplay.style.overflow = "hidden";
//        } else {
//            document.body.style.overflow = "hidden";
//            document.body.style.height = "100%";
//        }  
//        this.PanelScrollDiv.style.overflow = "hidden";
//        var headerDisplay = $get("PageHeader");
//        var linkDisplay = $get("LinkBar");
//        // get the set widths and heights
//        this.LeftPanelWidth = this.PanelDisplay.clientWidth;
//        this.ToggleWidth = parseInt(this.ToggleDisplay.style.width);
//        this.TopBannerHeight = headerDisplay.clientHeight + linkDisplay.clientHeight;
//        // get browser window dimensions
//        var sWidth = this.getPageWidth();
//        var sHeight = this.getPageHeight();
//        // set map display dimensions
//        var mHeight = sHeight - this.TopBannerHeight;
//        this.MapLeft = this.LeftPanelWidth + this.ToggleWidth;
//        var mWidth = getMapWidth();
//        this.MapDisplay.style.width =  mWidth + "px";
//        this.MapDisplay.style.height = mHeight  + "px";
//        this.CurrentMapWidth = mWidth;
//        this.CurrentMapHeight = mHeight;
//        // set heights of left panel and toggle bar
//        this.ToggleDisplay.style.height = mHeight  + "px";
//        this.PanelScrollDiv.style.height = mHeight  + "px";
//		
//        esriMaxFloatingPanelDragRight = sWidth - 15;
//        esriMaxFloatingPanelDragBottom = sHeight - 15;
//		
//		$addHandler(document.images["CollapseImage"], "mousedown", this.togglePanelDock);
//		$addHandler(this.PanelBottomSlider, "mousedown", this.startDockDrag);
//		$addHandler(this.PanelSlider, "mousedown", this.startDockDrag);
//	    var widthString = this.LeftPanelWidth + "px";
//        this.ResultsPanel.style.width = widthString;
//        this.TocPanel.style.width = widthString;
//		if (isRTL) {
//		    this.PanelDisplayCell.style.left = mWidth + "px";
//        }
//	}

//	// function for adjusting element sizes when brower is resized
//	this.adjustMapSize = function() {
//	   // set element widths 
//	    this.PanelDisplay.style.width =  this.LeftPanelWidth + "px";
//	    this.ToggleDisplay.style.width = this.ToggleWidth + "px";
//	   // get browser window dimensions 
//	    var sWidth = this.getPageWidth();
//	    var sHeight = this.getPageHeight();
//	    var mHeight = sHeight - this.TopBannerHeight;
//        this.LastMapWidth = this.CurrentMapWidth;
//        this.LastMapHeight = this.CurrentMapHeight;
//	    this.MapDisplay.style.height = mHeight  + "px";
//	    this.ToggleDisplay.style.height = mHeight  + "px";
//	    this.PanelScrollDiv.style.height = mHeight  + "px";
//        this.CurrentMapHeight = mHeight;
//	    this.setTocHeight();
//	    // calc dimensions needed for map
//	    var mWidth = getMapWidth();
//	    if (mWidth<5) mWidth = 5;
//	    if (mHeight<5) mHeight = 5;  
//	    setMapLeftPosition();
//	   // set heights on elements 
//	    var widthString = this.PanelDisplay.style.width;
//        this.ResultsPanel.style.width = widthString;
//        this.TocPanel.style.width = widthString;
//	    this.ResultsPanelResize.set_MinimumWidth(this.LeftPanelWidth);
//	    this.TocPanelResize.set_MinimumWidth(this.LeftPanelWidth);
//	    this.ResultsPanelResize.set_MaximumWidth(this.LeftPanelWidth);
//	    this.TocPanelResize.set_MaximumWidth(this.LeftPanelWidth);
//	    this.ResultsPanelResize._handle.style.width = this.LeftPanelWidth + "px";
//	    this.TocPanelResize._handle.style.width = this.LeftPanelWidth + "px";
//	    this.ResultsPanelContents.style.width = widthString;
//	    this.TocPanelContents.style.width =widthString;
//	    if (this.LastMapWidth!=this.CurrentMapWidth || this.LastMapHeight!=this.CurrentMapHeight) {
//	        var cr = $find("MapCopyrightText1");
//            if (cr!=null)
//                cr.get_callout().hide();
//	        if (arcgisIdentifyTool!=null) closeIdentifyPanel(); 
//	    }
//	    // refresh the map 
//	    var m =  $find(this.MapId);
//	    if (this.map!=null) {
//	        if (this.LastMapWidth!=this.CurrentMapWidth || this.LastMapHeight!=this.CurrentMapHeight) {
//	            this.map.checkMapsize();
//	        }
//	    } else 
//	        window.setTimeout("arcgisWebApp.adjustMapSize();", 1000); 	  
//	    if (isRTL) adjustRTLElements();    
//	    return false;
//	}

//	// handler for window resize
//	this.adjustMapSizeHandler = function(e) {
//	    window.clearTimeout(arcgisWebApp.reloadTimer);
//		arcgisWebApp.reloadTimer = window.setTimeout("arcgisWebApp.adjustMapSize();",1000);
//	}

//	// get the page width
//	this.getPageWidth = function() {
//		var width = window.innerWidth;
//		if (width == null) {
//			if (document.documentElement && document.documentElement.clientWidth)
//				width = document.documentElement.clientWidth
//			else	
//				width = document.body.clientWidth;
//		}
//		return width;
//	}
//	
//	 //get the page height
//	this.getPageHeight = function() {
//		var height = window.innerHeight;
//		if (height == null) {
//			if (document.documentElement && document.documentElement.clientHeight)
//				height = document.documentElement.clientHeight;
//			else
//				height = document.body.clientHeight;
//		}
//		return height;	
//		
//	}
//	
//	// sets the height of the Map Contents panel
//	this.setTocHeight = function(){
//	    var tocLocation = Sys.UI.DomElement.getLocation(this.TocPanelContents);
//	    var leftLocation = Sys.UI.DomElement.getLocation(this.PanelDisplayCell);
//	    var pHeight = this.getPageHeight();
//        var tHeight = pHeight - tocLocation.y - 13;
//        if (isNaN(tHeight) || tHeight<5) tHeight = 5;
//        this.TocPanelContents.style.height = tHeight + "px";
//	    
//	}

//	// functions for Dock movement and sizing
//	this.togglePanelDock = function() {
//        if (arcgisIdentifyTool != null) {
//            var dropdown = $get("dropdown_" + arcgisIdentifyTool.get_uniqueID());
//            if (dropdown) dropdown.style.display = "none";
//        }             
//	    if (arcgisWebApp.PanelDisplay.style.display=="none") {
//	        arcgisWebApp.expandPanelDock();
//	    } else {
//	        arcgisWebApp.collapsePanelDock();
//	    }     
//	}
//	
//	this.expandPanelDock = function() {
//	    var image = document.images["CollapseImage"];
//	    var imgUrl = (isRTL) ? "images/expand_right.gif" : "images/collapse_left.gif";
//	    arcgisWebApp.PanelDisplay.style.display = "block";
//	    image.src = imgUrl;
//	    image.alt = "Collapse";
//	    arcgisWebApp.PanelSlider.style.cursor = "e-resize";
//	    arcgisWebApp.PanelBottomSlider.style.cursor = "e-resize"; 
//	    window.setTimeout('arcgisWebApp.adjustMapSize();',500); 
//	    
//	}
//	
//	this.collapsePanelDock = function() {
//	    var image = document.images["CollapseImage"];
//	    var imgUrl = (isRTL) ? "images/collapse_left.gif" : "images/expand_right.gif";
//	    dockWidthString = arcgisWebApp.PanelDisplayCell.clientWidth + "px";
//	    arcgisWebApp.PanelDisplay.style.display = "none";
//	    image.src = imgUrl;
//	    image.alt = "Expand";
//	    arcgisWebApp.PanelSlider.style.cursor = "default"; 
//	    arcgisWebApp.PanelBottomSlider.style.cursor = "default"; 
//	    window.setTimeout('arcgisWebApp.adjustMapSize();',500);  
// 
//	}  
//	
//	var startConsoleDragLeft = 0;
//	this.startDockDrag = function(e) {
//	    if (!arcgisWebApp.DockMoving) {
//	        arcgisWebApp.MoveFunction = document.onmousemove;
//	        arcgisWebApp.UpFunction = document.onmouseup; 
//	        arcgisWebApp.DockMoving = true;
//	        // hide the map addons while sliding the divider 
//	    }
//	    $addHandler(document, "mouseup",  arcgisWebApp.stopDockDrag);
//	    if (arcgisWebApp.PanelDisplay.style.display!="none") {
//	        arcgisWebApp.WindowWidth = arcgisWebApp.getPageWidth();
//	        if (isRTL) {
//                arcgisWebApp.LeftOffsetX = arcgisWebApp.PanelDisplay.clientWidth - e.clientX;
//	            var location = Sys.UI.DomElement.getLocation($get("LeftPanelTableCell"));
//	            arcgisWebApp.RightOffsetX = location.x - e.clientX;
//	            $addHandler(document, "mousemove", arcgisWebApp.moveDockDragRTL);
//	        } else {   
//                arcgisWebApp.LeftOffsetX = e.clientX - arcgisWebApp.PanelDisplay.clientWidth;
//	            var location = Sys.UI.DomElement.getLocation($get("Map_Panel"));
//	            arcgisWebApp.RightOffsetX = location.x - e.clientX;
//	            if (arcgisWebApp.CopyrightText) {
//	                arcgisWebApp.CopyrightTextLeft = parseInt(arcgisWebApp.CopyrightText.style.left);
//	                arcgisWebApp.CopyrightTextTop = parseInt(arcgisWebApp.CopyrightText.style.top);  
//	            }
//	            $addHandler(document, "mousemove", arcgisWebApp.moveDockDrag);
//	        } 
//	        startConsoleDragLeft = e.clientX;
//	         
//	    }
//        e.preventDefault();
//        e.stopPropagation();
//	}
//	
//	this.moveDockDrag = function(e) {
//	    var theButton = (Sys.Browser.agent == Sys.Browser.InternetExplorer) ? event.button : e.which;      
//	    if (theButton==0) arcgisWebApp.stopDockDrag(e);
//	    arcgisWebApp.LeftPanelWidth =  e.clientX - arcgisWebApp.LeftOffsetX;
//	    arcgisWebApp.DockMoving = true;
//	    var sWidth =  arcgisWebApp.getPageWidth();
//	    var x = e.clientX;
//	    var y = e.clientY;
//	    var rightWidth = 2;
//	    if (arcgisWebApp.CopyrightText) rightWidth = arcgisWebApp.CopyrightText.clientWidth + 10;
//	    if (x>=sWidth-rightWidth || y>=arcgisWebApp.getPageHeight()-2 || y<1 || x< arcgisWebApp.MinDockWidth) arcgisWebApp.stopDockDrag(e);
//	    if (arcgisWebApp.LeftPanelWidth>sWidth-arcgisWebApp.ToggleDisplay.clientWidth-rightWidth) arcgisWebApp.LeftPanelWidth=sWidth-arcgisWebApp.ToggleDisplay.clientWidth-rightWidth;
//	    if (arcgisWebApp.LeftPanelWidth < arcgisWebApp.MinDockWidth) arcgisWebApp.LeftPanelWidth = arcgisWebApp.MinDockWidth; 
//	    var mapLeftString =  (arcgisWebApp.LeftPanelWidth + arcgisWebApp.ToggleDisplay.clientWidth) + "px";
//	    var widthString =  arcgisWebApp.LeftPanelWidth + "px";
//	    arcgisWebApp.PanelDisplay.style.width = widthString;
//        arcgisWebApp.ResultsPanel.style.width = widthString;
//        arcgisWebApp.TocPanel.style.width = widthString;
//        var pWidth = arcgisWebApp.LeftPanelWidth;
//	    arcgisWebApp.ResultsPanelResize.set_MinimumWidth(pWidth);
//	    arcgisWebApp.TocPanelResize.set_MinimumWidth(pWidth);
//	    arcgisWebApp.ResultsPanelResize.set_MaximumWidth(pWidth);
//	    arcgisWebApp.TocPanelResize.set_MaximumWidth(pWidth);
//	    arcgisWebApp.ResultsPanelResize._handleHolder.style.width = pWidth + "px";
//	    arcgisWebApp.TocPanelResize._handleHolder.style.width = pWidth + "px";
//	    var width = getMapWidth();
//	    if (width<1) width = 1; 
//	    arcgisWebApp.MapDisplay.style.width = width + "px";
//	    arcgisWebApp.MapDisplay.style.left = mapLeftString;
//	    var leftDiff = e.clientX - startConsoleDragLeft;
//        if (arcgisWebApp.CopyrightText) {
//            var crLeft = arcgisWebApp.CopyrightTextLeft + leftDiff;
//            if (crLeft<sWidth - arcgisWebApp.CopyrightText.clientWidth) {
//                if (crLeft< arcgisWebApp.LeftPanelWidth + arcgisWebApp.ToggleDisplay.clientWidth) crLeft =  arcgisWebApp.LeftPanelWidth + arcgisWebApp.ToggleDisplay.clientWidth; 
//                arcgisWebApp.CopyrightText.style.left = crLeft + "px";
//                if (!isIE) arcgisWebApp.CopyrightText.style.top = arcgisWebApp.CopyrightTextTop + "px";
//            } 
//        }
//        if (arcgisIdentifyTool != null) {
//            var dropdown = $get("dropdown_" + arcgisIdentifyTool.get_uniqueID());
//            if (dropdown) dropdown.style.display = "none";
//        }             
//        e.preventDefault();
//        e.stopPropagation();
//	}
//	
//	this.moveDockDragRTL = function(e) {
//	    var theButton = (Sys.Browser.agent == Sys.Browser.InternetExplorer) ? event.button : e.which;      
//	    if (theButton==0) arcgisWebApp.stopDockDrag(e);
//	    var sWidth =  arcgisWebApp.getPageWidth();
//	    arcgisWebApp.LeftPanelWidth =  sWidth - (e.clientX + arcgisWebApp.RightOffsetX);
//	    arcgisWebApp.DockMoving = true;
//	    var x = e.clientX;
//	    var y = e.clientY;
//	    var rightWidth = 2;
//	    if (arcgisWebApp.CopyrightText) rightWidth = arcgisWebApp.CopyrightText.clientWidth + 10;
//	    if (x<=rightWidth || y>=arcgisWebApp.getPageHeight()-2 || y<1 || x>sWidth - arcgisWebApp.MinDockWidth) arcgisWebApp.stopDockDrag(e);
//	    if (arcgisWebApp.LeftPanelWidth>sWidth-arcgisWebApp.ToggleDisplay.clientWidth-rightWidth) arcgisWebApp.LeftPanelWidth=sWidth-arcgisWebApp.ToggleDisplay.clientWidth-rightWidth;
//	    if (arcgisWebApp.LeftPanelWidth < arcgisWebApp.MinDockWidth) arcgisWebApp.LeftPanelWidth = arcgisWebApp.MinDockWidth; 
//	    var mapLeftString =  (arcgisWebApp.LeftPanelWidth + arcgisWebApp.ToggleDisplay.clientWidth) + "px";
//	    var widthString =  arcgisWebApp.LeftPanelWidth + "px";
//	    arcgisWebApp.PanelDisplay.style.width = widthString;
//        arcgisWebApp.ResultsPanel.style.width = widthString;
//        arcgisWebApp.TocPanel.style.width = widthString;
//        var pWidth = arcgisWebApp.LeftPanelWidth;
//	    arcgisWebApp.ResultsPanelResize.set_MinimumWidth(pWidth);
//	    arcgisWebApp.TocPanelResize.set_MinimumWidth(pWidth);
//	    arcgisWebApp.ResultsPanelResize.set_MaximumWidth(pWidth);
//	    arcgisWebApp.TocPanelResize.set_MaximumWidth(pWidth);
//	    arcgisWebApp.ResultsPanelResize._handleHolder.style.width = pWidth + "px";
//	    arcgisWebApp.TocPanelResize._handleHolder.style.width = pWidth + "px";
//        var width = sWidth - (pWidth + arcgisWebApp.ToggleDisplay.clientWidth);
//	    if (width<5) width = 5; 
//	    arcgisWebApp.MapDisplay.style.width = width + "px";
//	    arcgisWebApp.PanelDisplayCell.style.left = width + "px";
//	    var leftDiff = e.clientX - startConsoleDragLeft;
//        if (arcgisIdentifyTool != null) {
//            var dropdown = $get("dropdown_" + arcgisIdentifyTool.get_uniqueID());
//            if (dropdown) dropdown.style.display = "none";
//        }             
//        e.preventDefault();
//        e.stopPropagation();
//	}
//	
//	this.stopDockDrag = function(e) {
//	    try {
//            $removeHandler(document, "mouseup", arcgisWebApp.stopDockDrag);
//            if (isRTL) 
//                $removeHandler(document, "mousemove", arcgisWebApp.moveDockDragRTL); 
//            else 
//                $removeHandler(document, "mousemove", arcgisWebApp.moveDockDrag);
//	    } catch (ex) {
//	        var dummy = ex;
//	    } 
//        if (arcgisWebApp.CopyrightText && !isIE) 
//            arcgisWebApp.CopyrightText.style.top = arcgisWebApp.CopyrightTextTop + "px";
//	    arcgisWebApp.DockMoving = false;    
//	    arcgisWebApp.adjustMapSize();
//	        e.preventDefault();
//	        e.stopPropagation();
//	}
//			
//	ESRI.ADF.WebMappingApplication.WebPage.initializeBase(this);
//}

//ESRI.ADF.WebMappingApplication.WebPage.registerClass('ESRI.ADF.WebMappingApplication.WebPage');

//arcgisWebApp = new ESRI.ADF.WebMappingApplication.WebPage();


//if (typeof(Sys) !== 'undefined') { Sys.Application.notifyScriptLoaded(); }