// 
// The Europe maps do use geographical coordinates (longitude, latitude)
// Author: Piet Tutelaers
// Version: November 2002
//

// function for defining datapoint objects
function point(x, y, date, place, country, reference, leg) {
   this.x = x; this.y = y;  
   this.year = date.substr(0, 4);
   if (reference.length > 0) {
      var pattern = /\s\d{4}[a-z]?$/;
      if (pattern.test(reference))
         this.alt = "[" + reference + "]";
      else
         this.alt = "[" + reference + " " +  this.year + "]";
   }
   else {
      this.alt = "";
   }
   if (leg != "")
      this.alt += (this.alt ==""? "": " ") + place + " (" + country + "), " +
	          leg + " " + this.year;
   else if (place)
      this.alt += (this.alt ==""? "": " ") + place + " (" + country + ")";
   if (this.alt == "")
      this.alt = "year, reference and collector unknown";
}

function draw(points) {
   var isIE=document.all?1:0;
   var items = isIE?parent.navigation.items:parent.navigation.document.items;
   var species = items.species.value;
   var map = items.map.value;
   var R = items.raster.value;
   var w = items.w.value;
   var h = items.h.value;
   var llx = items.llx.value;
   var lly = items.lly.value;
   var urx = items.urx.value;
   var ury = items.ury.value;
   document.writeln('<div class="background">');
   document.writeln('<img src="images/' + map + '" name="Faktor" ' +
      'width="' + w + '" height="' + h + '">');
   document.writeln('</div>');
   var raster = "8x8/";
   if (R == 8) raster = "8x8/"; 
   if (R == 10) raster = "10x10/"; 
   if (R == 14) raster = "14x14/"; 
   // document.writeln('<div class="name">' + species + '</div>');
   for (var i = 0; i < points.length; i++) {
      var p = points[i];
      if (p.x < llx || p.x > urx) continue;
      if (p.y < lly || p.x > ury) continue;
      var left = Math.round((p.x-llx)/(urx-llx)*w - 0.5*R);
      var  top = Math.round(h - (p.y-lly)/(ury-lly)*h - 0.5*R);
      document.writeln('<div style="left:' +left+ 'px; top:' +top+ 'px;">');
      type = "grey.gif";
      if (p.year <  1900) type = "red.gif";
      if (p.year >= 1900 && p.year < 1950) type = "green.gif";
      if (p.year >= 1950 && p.year < 2000) type = "blue.gif";
      if (p.year >= 2000) type = "pink.gif";
      document.write('<img src="images/' + raster + type + '" title="'
         + p.alt + '"></div>');
   }
}

