// -----------------------------------------------------------------
//								 ArcWeb USA Site Starters 
//            Environmental Systems Research Institute
//                   Redlands, CA
// -----------------------------------------------------------------
// Class    : zoomBox 
// Purpose  : Abstracts map extent management issues.
// -----------------------------------------------------------------
// Calls    :
// Called by:
// -----------------------------------------------------------------
// Arguments:
// Globals  :
// Returns  :
// -----------------------------------------------------------------
// Notes    :
// -----------------------------------------------------------------
// History  :
// =================================================================

function zoomBox(divZoomBox) {

	var m_divZoomBox = divZoomBox;
	var m_bInProgress = false;

	var m_iStartX = null;
	var m_iStartY = null;
	var m_iEndX = null;
	var m_iEndY = null;

	this.isInProgress = isInProgress;

	this.getStartX = getStartX;
	this.getStartY = getStartY;
	this.getEndX = getEndX;
	this.getEndY = getEndY;

	this.start = start;
	this.update = update;
	this.stop = stop;
	
	this.show = show;
	this.hide = hide;

  // ***********************************************
	// *************** Methods ***********************
	// ***********************************************

	function start(x, y) {

		m_iStartX = x;
		m_iStartY = y;
		m_iEndX = x;
		m_iEndY = y;

		m_divZoomBox.style.left = m_iStartX;
		m_divZoomBox.style.top = m_iStartY;

		m_divZoomBox.style.width = 0;
		m_divZoomBox.style.height = 0;

		m_bInProgress = true;		

	}

	function update(x, y) {

		// This method should not be called unless
		// the zoomBox is in progress.  

		if (!(m_bInProgress)) {
			return false;
		}

		m_iEndX = x;
		m_iEndY = y;

		// Determine current width and height of the
		// zoomBox.

		var iWidth = m_iEndX - m_iStartX;
		var iHeight = m_iEndY - m_iStartY;
		
		// Determine the direction in which the zoom
		// box is currently being drawn and set the
		// appropriate left and top properties.

		if (iWidth > 0) {
			m_divZoomBox.style.left = m_iStartX;
		} else {
			m_divZoomBox.style.left = m_iEndX;
		}

		if (iHeight > 0) {
			m_divZoomBox.style.top = m_iStartY;
		} else {
			m_divZoomBox.style.top = m_iEndY;
		}

		// Set the width and height of the zoomBox.
        //iWidth=0
        //iWidth=0;
        //iHeight=0;
        
		m_divZoomBox.style.width = Math.abs(iWidth);
		m_divZoomBox.style.height = Math.abs(iHeight);

	}

	function stop() {
		m_bInProgress = false;
	}

	function show() {
		m_divZoomBox.style.visibility = 'visible';		
	}

	function hide() {
		m_divZoomBox.style.visibility = 'hidden';
	}

  // ***********************************************
	// *********** Accessor Methods ******************
	// ***********************************************


	function getStartX() {
		return m_iStartX;
	}

	function getStartY() {
		return m_iStartY;
	}

	function getEndX() {
		return m_iEndX;
	}

	function getEndY() {
		return m_iEndY;
	}

	function isInProgress() {
		return m_bInProgress;
	}

}
