 // -----------------------------------------------
  function StartCode(){
    MapMain_Startup();
    

   // var MapMain=document.getElementById('MapMain');      //added to comply with W3C
   // window.status=MapMain.id;

    MapMain.SetStatusText = MySetStatusText;
    MapMain.Tracker.OnMouseUp = MyMapTracker_MouseUp;
    
   MapOverview_Startup();
    MapOverview.SetStatusText = MySetStatusText;

    document.onmousedown = MapOnMouseDown;
    document.onmouseup	 = MapOnMouseUp;
    //document.getElementById('MapMain').onmouseover = MapOnMouseMove;
    document.onmousemove = MapOnMouseMove;
   
    window.status = 'Finished receiving from server...';
    return false;
  }
 // ----------------------------------------------- 
  function MySetStatusText(Text)  //this is the function that will be called by the client to diaply text  -ie replacing the default one
{
	//window.status = Text;
	//window.status = 'My Custom messages';
	var textString = Text;
	
	 var n = parseFloat(Text);
	 if (n > 0)
		{
		var sa = textString.split(",");
		window.status = 'NZTM coordinates: ' + Math.round(sa[0]) + ' E , ' + Math.round(sa[1]) + ' N';
		}
	else {if (textString == 'MouseOut')
		{
		window.status = '';
		}
		else 
		{
		window.status = textString;
		}
		//window.status='code run';   //test to see if code has been processed
		}
	return false;
}
 // ----------------------------------------------- 
function MyMapTracker_MouseUp(e){
switch(this.Mode){
	case 1:{
		this.Mode = 3; //prospective ZoomBox or ZoomIn (but could still be an ID)
		//window.status = 'pros';
		setTimeout(this.VarName + '.RectOrPoint();',this.DoubleClickTime);
		break;
		}
	case 2:{
		this.Mode = 0;
		this.Offset.MakeRelative(this.MapElement);
		this.Map.OnMapOffset(this.Offset)
		break;

		}
	case 3:{
		this.Mode = 0;
		this.RectTrack.MakeRelative(this.MapElement);	
		this.Map.OnMapDoubleClick(new CPoint(this.RectTrack.Left,this.RectTrack.Bottom));
		break;
		}
	case 4:{
		if(this.DoubleClickPending){
			this.Mode = 0;
			if(this.ForceUI == 4)
				this.Map.OnCaptureLine(this.CaptureShape.GetCoordList(this.MapElement));
			else
				this.Map.OnCapturePolygon(this.CaptureShape.GetCoordList(this.MapElement));
			}
		else{
			this.DoubleClickPending = true;
			setTimeout(this.VarName + '.CancelPendingDoubleClick();',this.DoubleClickTime); //was hard coded to 200
			}
		}		
}
return (e.srcElement == this.MapElement);
}
 // ----------------------------------------------- 
  function MapOnMouseDown(){
    MapMainOnMouseDown();
    MapOverviewOnMouseDown();
    return false;
  }
 // ----------------------------------------------- 
  function MapOnMouseUp(){
	   MapMainOnMouseUp();
	   MapOverviewOnMouseUp();
	   return false;
	   }
 // ----------------------------------------------- 
  function MapOnMouseMove(){
	   MapMainOnMouseMove();
	   MapOverviewOnMouseMove();
	   return false;
	   }
 // ----------------------------------------------- 
  function window_onresize() {
	   return SetSizing1()
	   docWidth  = document.body.clientWidth;
	   docHeight = document.body.clientHeight;
	   if (docWidth < 400)	{ docWidth = 400; }
	   if (docHeight < 400) { docHeight = 400; }
	   javascript:_PostBack('MapMain','99,RESIZE,' + docWidth + ',' + docHeight);
	   return false;
	   }
 // ----------------------------------------------- 
  function Arr(Item){
		var arrayNew = new Array(1);
		arrayNew[0] = Item;
		return arrayNew;
		}
 // ----------------------------------------------- 
function myOpenWindow(winURL, winName, winFeatures, winOpen)
{
  //alert('running myOpenWindow')
  // var theWin; // this will hold our opened window 

  // first check to see if the window already exists
  if (winOpen == 'true')
  {
		alert('win really is open!! WinName is ' + winName);
      document.getElementsByName(winName).focus();
      alert('win focussed!!');
      winName.location=winURL;
      winName.blur();
      return winName;
    } 
    // otherwise fall through to the code below to re-open the window
  else
  {
  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
 // theWin = window.open(winURL, winName, winFeatures); 
  window.open(winURL, winName, winFeatures);
  //return 0;
  }
} 
// ----------------------------------------------- 

