
function print(msg)
{
   document.write(msg, "<BR>");
}

function View_miniFile()
{
   return(this.dataset + "mini/" + this.cmap + "/" +
          4 + "/" + 7 + "/" +
          this.cmap + 4 + 7 +
	  this.lat + Math.floor(this.lon/10) + this.lon%10 + ".jpg");
}

function View_imgFile()
{
   return(this.dataset + "/" + this.cmap + "/" +
          this.pos + "/" + this.zoom + "/" +
          this.cmap + this.pos + this.zoom +
	  this.lat + Math.floor(this.lon/10) + this.lon%10 + ".jpg");
}

function View_flush()
{
	if (document.outwin) {
		document.outwin.src = this.imgFile();
	}
	if (document.miniwin) {
		document.miniwin.src = this.miniFile();
	}
}

function View_reset()
{
   this.dataset = "vhm";
   this.cmap = "al";
   this.pos = 0;
   this.zoom = 6;
   this.lat = 3;
   this.lon = 0;
   
   this.flush();
}

function View_change_dataset(_dataset)
{
   this.dataset = _dataset;

   this.flush();
}

function View_change_cmap(_cmap)
{
   this.cmap = _cmap;
   if (_cmap != "al") {
      if (this.zoom < 5) {
         this.zoom = 5;
      }
   }
   
   this.flush();
}

function View_change_zoom(dir)
{
   if(dir > 0) {
      this.zoom++;
   } else  if (dir < 0) {
      this.zoom--;
   }

   if (this.zoom > 6) {
      this.zoom = 6;
   }

   if (this.cmap == "al") {
      if (this.zoom < 0) {
         this.zoom = 0;
      }
   } else {
      if (this.zoom < 5) {
         this.zoom = 5;
      }
   }
   
   this.flush();
}

function View_change_pos(dir)
{
   if(dir > 0) {
      this.pos++;
      if (this.pos > 6) {
         this.pos = 6;
      }
   } else if (dir < 0) {
      this.pos--;
      if (this.pos < 0) {
         this.pos = 0;
      }
   }
   
   this.flush();
}

function View_change_lat(dir)
{
   if(dir > 0) {
      this.lat++;
      if (this.lat > 6) {
         this.lat = 6;
      }
   } else if (dir < 0) {
      this.lat--;
      if (this.lat < 0) {
         this.lat = 0;
      }
   }
   
   this.flush();
}

function View_change_lon(dir)
{
   if(dir > 0) {
      this.lon++;
      if (this.lon > 11) {
         this.lon = 0;
      }
   } else if (dir < 0) {
      this.lon--;
      if (this.lon < 0) {
         this.lon = 11;
      }
   }
   
   this.flush();
}

function View()
{
   this.imgFile = View_imgFile;
   this.miniFile = View_miniFile;
   this.reset = View_reset;
   this.toString = View_imgFile;
   this.flush = View_flush;

   this.change_dataset = View_change_dataset;
   this.change_cmap = View_change_cmap;
   this.change_zoom = View_change_zoom;
   this.change_pos = View_change_pos;
   this.change_lat = View_change_lat;
   this.change_lon = View_change_lon;
   
   this.init = false;

   this.reset();
}

myView = new View();

