 
function PopOut(sURL,sTitle,iHeight,iWidth,ynScroll,ynResize) {
var objWin;
  objWin = window.open(sURL, sTitle, "height="+iHeight+",width="+iWidth+",scrollbars="+ynScroll+",resizable="+ynResize+"");
  if (parseInt(navigator.appVersion) >=4) objWin.window.focus();
}


function PrintPage() {
if (window.print != null) { 
	window.print(); 
	} 
else { 
	alert('Your browser does not support this shortcut.  Please select Print from the File menu.'); 
	}
};

function getLayer(name) {
	  /*if (m_sClientBrowserType == 'Netscape')
	  {
	    return(document.layers[name]);
	  }
	  else
	  {
		var theObj = document.getElementById(name);
		return theObj.style;
	  }	  */
	if (document.layers)
		return(document.layers[name]);
	else if (document.getElementById)
	{
		var theObj = document.getElementById(name);
		return theObj.style;
	}
	else
		return null;
}
		
// move layer to x,y
function moveLayer(name, x, y) {		
		
	//DisplayDebug('x : ' + x + ' y: ' + y);
	
  	var layer = getLayer(name);
  	
  	//alert('moveLayer!');
  			
  	/*if (m_sClientBrowserType == 'Netscape')
    	layer.moveTo(x, y);
	 else {
    	layer.left = x + 15; // Added 15 for the navigation cells 
   		layer.top  = y + 15;
   		//DisplayDebug('layer.left: ' + layer.left + ' layer.top: ' + layer.top);
  	}*/
  	
  	/*if (layer.moveTo)
		layer.moveTo(x + 15, y + 15);
	 else {
    	layer.left = x + 15; // Added 15 for the navigation cells 
   		layer.top  = y + 15;*/

   		
   	if (layer.moveTo)
	{
		layer.moveTo(x + parseInt(m_BorderOffset.value), y + parseInt(m_BorderOffset.value));
	}
	 else {
    		layer.left = x +  parseInt(m_BorderOffset.value); // Added 15 for the navigation cells 
   		layer.top  = y +  parseInt(m_BorderOffset.value);
   	}
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
	// Not working with Mozilla Milestone 12 (Nav5)
function clipLayer2(name, clipleft, cliptop, clipright, clipbottom) {		
	  var layer = getLayer(name);		
	  
	  if (m_sClientBrowserType == 'Netscape') {
			
		    //layer.clip.left   = clipleft;
		    //layer.clip.top    = cliptop;
		    //layer.clip.right  = clipright;
		    //layer.clip.bottom = clipbottom;
		layer.clip = 'rect(' + cliptop + 'px ' +  clipright + 'px ' + clipbottom + 'px ' + clipleft +'px)';
		//alert(layer.clip);


	  }
	  //if (document.all)
	  else {
		    layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
		    //DisplayDebug("layer Clip: " +  layer.clip);	
	  }
}

function resetLayer()
{
	clipLayer2("mapLayer", 0, 0,  m_imgMapCanvas.width, m_imgMapCanvas.height);
	moveLayer("mapLayer", 0, 0);	  
}

var mouseX;
var mouseY;

var panLayer;

// move map image with mouse
function panMouse(newX, newY) {
	var xMove = newX-mouseX;
	var yMove = newY-mouseY;
	
	var cLeft = -xMove;
	var cTop = -yMove;
	
	var cRight = m_imgMapCanvas.width;
	var cBottom = m_imgMapCanvas.height;
	
	if (xMove>0) {
		cLeft = 0;
		cRight = m_imgMapCanvas.width - xMove;
	}
	if (yMove>0) {
		cTop = 0;
		cBottom = m_imgMapCanvas.height - yMove;
	}
	
	//alert('cLeft: ' + cLeft + ' cTop: ' + cTop + ' cRight: ' + cRight + ' cBottom: ' + cBottom);
	clipLayer2("mapLayer",cLeft,cTop,cRight,cBottom);
	moveLayer("mapLayer",xMove,yMove);
}

function StartPan(startX, startY) {
	
	mouseX = startX;
	mouseY = startY;

	DisplayDebug('Start Pan!');

	//if (panLayer==null)
	//	panLayer = getLayer("mapLayer");
}

function StopPan(newX, newY)
{
	DisplayDebug('End Pan!');
	m_IsPanning = false;
	
	var tempLeft=m_mapViewer.getExtent().getLeft();;
	var tempRight=m_mapViewer.getExtent().getRight();;
	var tempTop=m_mapViewer.getExtent().getTop();;
	var tempBottom=m_mapViewer.getExtent().getBottom();;
	
	//DisplayDebug('tempTop: ' + tempTop + ' tempRight: ' + tempRight + ' tempLeft: ' + tempLeft + ' tempBottom: ' + tempBottom);
	
	var ixOffset = newX-mouseX;;
	var iyOffset = mouseY-newY;
	
	//alert ('ixOffset: ' + ixOffset);
	//alert ('iyOffset: ' + iyOffset);
	
	pixelX = Math.abs(tempRight-tempLeft) / m_imgMapCanvas.width;
	pixelY = Math.abs(tempBottom-tempTop) / m_imgMapCanvas.height;
	
	var xOffset = pixelX * ixOffset;
	var yOffset = pixelY * iyOffset;
	
	var eTop = tempTop - yOffset;
	var eRight = tempRight - xOffset;
	var eLeft = tempLeft - xOffset;
	var eBottom = tempBottom - yOffset;
	
	//DisplayDebug('eTop: ' + eTop + ' eRight: ' + eRight + ' eLeft: ' + eLeft + ' eBottom: ' + eBottom);

	// Save the extents
	m_mapViewer.setExtent(new rect(eLeft,eTop,eRight,eBottom));

	submit();
	
	//resetLayer();
	
	return true;
}
