/**
 * DenkXweb, Version 1.0.0
 * Copyright (c) 2005 rjm business solutions GmbH
 * All rights reserved, license restrictions apply
 *
 * $Id$
 *
 * Repräsentation der Kartenanzeige auf der DenkXweb-Ergebnisseite
 */



/**
 * Class Map
 *
 * Factory-Klasse zum Verwalten von Mausereignissen auf der 
 * Kartenanzeige.
 *
 * @attr mapId     ID-Wert des img-HTML-Elements, mit dem die Karte 
 *                 angezeigt wird
 * @attr mapSize   Kartengröße in Pixeln (Breite und Höhe des 
 *                 img-HTML-Elements, mit dem die Karte angezeigt wird)
 */
function Map(mapId, mapSize) {
  this.mapId = mapId;
  this.mapSize = mapSize;
  this.scaling = 1.0;

  
  this.getImg = function() {
    return document.getElementById(this.mapId);
  }

  this.setImgCursor = function(cursor) {
    var img = this.getImg();
    setCursor(img, cursor);
  }

  this.getImgPos = function() {
    return getElemPos(this.getImg());
  }

  this.isMouseOver = function(mouseEvent) {
    return mouseEvent.getTarget() == this.getImg();
  }

  this.getMapPos = function(mouseEvent) {
    var mapImgPos = this.getImgPos();
    return new Point(mouseEvent.getPageX() - mapImgPos.x,
                     mouseEvent.getPageY() - mapImgPos.y);

  }

  this.isPosOnMap = function(pos) {
    return ((pos.x >= 0) && (pos.y >= 0) &&
            (pos.y <= this.mapSize) && (pos.y <= this.mapSize));
  }

  this.getScaling = function() {
    return this.scaling;
  }
  
  this.setScaling = function(scaling) {
    this.scaling = scaling;
  }

}


