// -----------------------------------------------------------------
//								 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 selectBox(divSelectBox) {

	var m_divSelectBox = divSelectBox;
	var m_bInProgressSelect = false;

	var m_iStartXSelect = null;
	var m_iStartYSelect = null;
	var m_iEndXSelect = null;
	var m_iEndYSelect = null;

	this.isInProgressSelect = isInProgressSelect;

	this.getStartXSelect = getStartXSelect;
	this.getStartYSelect = getStartYSelect;
	this.getEndXSelect = getEndXSelect;
	this.getEndYSelect = getEndYSelect;

	this.startSelect = startSelect;
	this.updateSelect = updateSelect;
	this.stopSelect = stopSelect;
	
	this.showSelect = showSelect;
	this.hideSelect = hideSelect;

  // ***********************************************
	// *************** Methods ***********************
	// ***********************************************

	function startSelect(x, y) {

		m_iStartXSelect = x;
		m_iStartYSelect = y;
		m_iEndXSelect = x;
		m_iEndYSelect = y;

		m_divSelectBox.style.left = m_iStartXSelect;
		m_divSelectBox.style.top = m_iStartYSelect;

		m_divSelectBox.style.width = 0;
		m_divSelectBox.style.height = 0;

		m_bInProgressSelect = true;		

	}

	function updateSelect(x, y) {

		// This method should not be called unless
		// the zoomBox is in progress.  

		if (!(m_bInProgressSelect)) {
			return false;
		}

		m_iEndXSelect = x;
		m_iEndYSelect = y;

		// Determine current width and height of the
		// zoomBox.

		var iWidthSelect = m_iEndXSelect - m_iStartXSelect;
		var iHeightSelect = m_iEndYSelect - m_iStartYSelect;
		
		// Determine the direction in which the zoom
		// box is currently being drawn and set the
		// appropriate left and top properties.

		if (iWidthSelect > 0) {
			m_divSelectBox.style.left = m_iStartXSelect;
		} else {
			m_divSelectBox.style.left = m_iEndXSelect;
		}

		if (iHeightSelect > 0) {
			m_divSelectBox.style.top = m_iStartYSelect;
		} else {
			m_divSelectBox.style.top = m_iEndYSelect;
		}

		// Set the width and height of the zoomBox.
        //iWidth=0
        //iWidth=0;
        //iHeight=0;
        
		m_divSelectBox.style.width = Math.abs(iWidthSelect);
		m_divSelectBox.style.height = Math.abs(iHeightSelect);
		
		//if (m_sClientBrowserType == 'Netscape') {
		 //  alert('width=' +m_divSelectBox.style.width);
		 //  alert('height=' +m_divSelectBox.style.height);
			//m_divSelectBox.style.width = Math.abs(iWidthSelect);
			//m_divSelectBox.style.height = Math.abs(iHeightSelect);
		
		//};
		window.status = 'width='+ m_divSelectBox.style.width + ', height='+ m_divSelectBox.style.height;

	}

	function stopSelect() {
		m_bInProgressSelect = false;
	}

	function showSelect() {
		m_divSelectBox.style.visibility = 'visible';		
	}

	function hideSelect() {
		m_divSelectBox.style.visibility = 'hidden';
	}

  // ***********************************************
	// *********** Accessor Methods ******************
	// ***********************************************


	function getStartXSelect() {
		return m_iStartXSelect;
	}

	function getStartYSelect() {
		return m_iStartYSelect;
	}

	function getEndXSelect() {
		return m_iEndXSelect;
	}

	function getEndYSelect() {
		return m_iEndYSelect;
	}

	function isInProgressSelect() {
		return m_bInProgressSelect;
	}

}
