// pointOverlayImg class prototype affichage des images clydeb 09/03/2007
function pointOverlayImg( p_icon, p_infoSkin, p_title, p_x, p_y, p_item_name, p_item_value, lien )
{
  var _msMap = null;
  var _img   = null;	//document.createElement('img');
  var _shd   = null;	//document.createElement('img');
  var _x     = parseFloat(p_x);	// Real coord X
  var _y     = parseFloat(p_y);	// Real coord Y
  var _title = p_title;
  var _icon  = p_icon;
  var _infoSkin = p_infoSkin;
  var _item_name = p_item_name; var _item_value = p_item_value;
  var _offsetX = 7;  var _offsetY = 22;

  if (_title == null) { _title = 'Info'; }
  if (_infoSkin == null)
  {
    // Create a default Info-window icon object...
    _infoSkin = new msInfoSkin( '/img/angolo_a.png', '/img/angolo_b.png',
                                '/img/angolo_c.png', '/img/angolo_d.png',
                                '/img/report_t.png', '/img/report_d.png',
                                '/img/report_l.png', '/img/report_r.png',
                                '/img/report_x.png', '/img/close.png',
                                '/img/report_arrow.png' );
  }
  if (_icon == null) {_icon = new msIcon(null, null);}

  // Functions...
  this.setMap = function(m) { _msMap = m; }
  this.getMap = function()  { return _msMap; }
  this.getImg = function()  { return _img; }
  this.getShd = function()  { return _shd; }
  this.getX   = function()  { return _x; }
  this.getY   = function()  { return _y; }
  this.getHtmlAttributes = function()
  {
    var ret = "<table>";
    for (var j=0; j<_item_name.length; j++)
    {
      // css
      if (_item_name[j]=='codesite') {codesite=_item_value[j];}
      if (_item_name[j]=='ticosite') {ticosite=_item_value[j];}
      if (_item_name[j]=='adressageecran')
      {
        adressageecran=_item_value[j];
        test=adressageecran.split(".");
        adressageecran=test[0];
        if (test.length>2)
        {
          for (var s=1;s<test.length-1;s++)
          {
            adressageecran+="."+test[s];
          }
        }
        adressageecran+="_vign.jpg";
      }
      if (_item_name[j]=='idimage') {idimage=_item_value[j];}

    }
    ret += "<tr><td class=\"mscross_report_attr_name\">" +
           "<a href=\""+lien+"pg-html/bases_doc/inventaire/fiche.php?idfic="+codesite+"\" onclick=\"window.open(this.href);return false;\">"+ticosite+"</a>"
           +"</td><td class=\"mscross_report_attr_value\" "+
           "style='padding-left: 8px;'>";
    ret+=  "<a href=\""+lien+"pg-html/bases_doc/icono/ficheicono.php?idimage="+idimage+"\" onclick=\"window.open(this.href);return false;\"><img src=\""+lien+"images/"+adressageecran+"\" alt=\"\"></a>"
    ret += "</td></tr>";
    ret += "</table>";
    return ret;
  }
  this.getInfoX = function() { return _msMap.xReal2pixel(_x); }
  this.getInfoY = function() { return Math.round(_msMap.yReal2pixel(_y) - (parseInt(_img.offsetHeight)/2) ); }
  this.getInfoSkin = function() { return _infoSkin; }
  this.getWidth  = function() { return parseInt(_img.style.width); }
  this.getHeight = function() { return parseInt(_img.style.height); }

  this.redraw = function()
  {
    // se e` visibile (coordinate del punto interne al box della mappa)...
    if ( _msMap.isPointInMap( _x - _msMap.wPixel2real(_offsetX),
                              _y + _msMap.hPixel2real(_offsetY),
                              _msMap.wPixel2real(_offsetX),
                              _msMap.hPixel2real(_offsetY) ) )
    {
      setPos(_img, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
      setPos(_shd, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
    } else
    { this.setVisible(false); }
  }

  this.setVisible = function(p_bool)
  {
    var str = null;
    if (p_bool) {str = '';} else {str = 'none';}
    _img.style.display = str;
    _shd.style.display = str;
  }

  this.showReport = function()
  {
    var pnt = new msReport(this, _title);
    _msMap.setReport(pnt);
  }

  // Initialization...
  _img = _icon.getImage(); _shd = _icon.getShadow();
  _offsetX = _icon.getShiftX() -1;
  _offsetY = _icon.getShiftY() -1;
//////////////////////////////////////////////////////////////////
// xxx Etichetta del punto, visualizzata al passaggio del mouse...
//  if (p_title != null) { _img.title = p_title; }
//////////////////////////////////////////////////////////////////
  _img.objRef = this;

  add_event(_img, 'click', function(event){pointOverlayEvent(event);});
}
function pointCalqueImgcoll(p_x, p_y, p_item_name, p_item_value, lien )
{
  var _msMap = null;
  var _img   = null;	//document.createElement('img');
  var _shd   = null;	//document.createElement('img');
  var _x     = parseFloat(p_x);	// Real coord X
  var _y     = parseFloat(p_y);	// Real coord Y
  var _item_name = p_item_name; var _item_value = p_item_value;
  var _offsetX = 0;  var _offsetY = 0;
  for (var j=0; j<_item_name.length; j++)
  {
    if (_item_name[j]=='typecoll')
    {
      var typecoll=_item_value[j];
      var a = '/img/'+typecoll+'-pict.png';
      var b = '/img/shadow.png';
//      var a = '/img/mm_20_red.png';
//      var b = '/img/mm_20_shadow.png';
      var _icon = new msIcon(a, b, 7, 22);
      var _infoSkin = new msInfoSkin( '/img/'+typecoll+'-hg.png', '/img/'+typecoll+'-hd.png',
                             '/img/'+typecoll+'-bd.png', '/img/'+typecoll+'-bg.png',
                             '/img/'+typecoll+'-1px-h.png', '/img/'+typecoll+'-1px-b.png',
                             '/img/'+typecoll+'-1px-g.png', '/img/'+typecoll+'-1px-d.png',
                             '/img/'+typecoll+'-1px.png', '/img/close.png',
                             '/img/'+typecoll+'-queu-de-bulle.png' );
      if (typecoll=='colla') {var _title='Collège ancien';}
      if (typecoll=='collr') {var _title='Collège récent';}
      if (typecoll=='collmt') {var _title='Collège modèle-type';}
      if (typecoll=='collmtr') {var _title='Collège modèle-type restructuré';}
    }
  }

  // Functions...
  this.setMap = function(m) { _msMap = m; }
  this.getMap = function()  { return _msMap; }
  this.getImg = function()  { return _img; }
  this.getShd = function()  { return _shd; }
  this.getX   = function()  { return _x; }
  this.getY   = function()  { return _y; }
  this.getHtmlAttributes = function()
  {
    var ret = "<table>";
    for (var j=0; j<_item_name.length; j++)
    {
      // css
      if (_item_name[j]=='codesite') {codesite=_item_value[j];}
      if (_item_name[j]=='nom') {nom=_item_value[j];}
      if (_item_name[j]=='codeia') {codeia=_item_value[j];}
      if (_item_name[j]=='typecoll') {typecoll=_item_value[j];}
      if (_item_name[j]=='adressageecran')
      {
        adressageecran=_item_value[j];
        test=adressageecran.split(".");
        adressageecran=test[0];
        if (test.length>2)
        {
          for (var s=1;s<test.length-1;s++)
          {
            adressageecran+="."+test[s];
          }
        }
        adressageecran+="_vign.jpg";
      }
      if (_item_name[j]=='idimage') {idimage=_item_value[j];}

    }
    ret += "<tr><td class=\"mscross_report_attr_name\">" +
           "<a href=\""+lien+"pg-html/bases_doc/inventaire/fichecollege.php?idfic="+codesite+"&codeia="+codeia+"\" onclick=\"window.open(this.href);return false;\">"+nom+"</a>";
    ret+= "<br/><br/>";
//           +"</td><td class=\"mscross_report_attr_value\" "+"style='padding-left: 8px;'>";
    ret+=  "<a href=\""+lien+"pg-html/bases_doc/inventaire/fichecollege.php?idfic="+codesite+"&codeia="+codeia+"\" onclick=\"window.open(this.href);return false;\"><img src=\""+lien+"images/"+adressageecran+"\" alt=\"\"></a>"
    ret += "</td></tr>";
    ret += "</table>";
    return ret;
  }
  this.getInfoX = function() { return _msMap.xReal2pixel(_x); }
  this.getInfoY = function() { return Math.round(_msMap.yReal2pixel(_y) - (parseInt(_img.offsetHeight)/2) ); }
  this.getInfoSkin = function() { return _infoSkin; }
  this.getWidth  = function() { return parseInt(_img.style.width); }
  this.getHeight = function() { return parseInt(_img.style.height); }

  this.redraw = function()
  {
    // se e` visibile (coordinate del punto interne al box della mappa)...
    if ( _msMap.isPointInMap( _x - _msMap.wPixel2real(_offsetX),
                              _y + _msMap.hPixel2real(_offsetY),
                              _msMap.wPixel2real(_offsetX),
                              _msMap.hPixel2real(_offsetY) ) )
    {
      setPos(_img, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
      setPos(_shd, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
    } else
    { this.setVisible(false); }
  }

  this.setVisible = function(p_bool)
  {
    var str = null;
    if (p_bool) {str = '';} else {str = 'none';}
    _img.style.display = str;
    _shd.style.display = str;
  }

  this.showReport = function()
  {
    var pnt = new msReport(this, _title);
    _msMap.setReport(pnt);
  }

  // Initialization...
  _img = _icon.getImage(); _shd = _icon.getShadow();
  _offsetX = _icon.getShiftX() -1;
  _offsetY = _icon.getShiftY() -1;
//////////////////////////////////////////////////////////////////
// xxx Etichetta del punto, visualizzata al passaggio del mouse...
//  if (p_title != null) { _img.title = p_title; }
//////////////////////////////////////////////////////////////////
  _img.objRef = this;

  add_event(_img, 'click', function(event){pointOverlayEvent(event);});
}

function pointCalqueLegcoll(p_x, p_y, p_item_name, p_item_value, lien )
{
  var _msMap = null;
  var _img   = null;	//document.createElement('img');
  var _shd   = null;	//document.createElement('img');
  var _x     = parseFloat(p_x);	// Real coord X
  var _y     = parseFloat(p_y);	// Real coord Y
  var _item_name = p_item_name; var _item_value = p_item_value;
  var _offsetX = 0;  var _offsetY = 0;
  for (var j=0; j<_item_name.length; j++)
  {
    if (_item_name[j]=='typecoll')
    {
      var typecoll=_item_value[j];
      var a = '/img/'+typecoll+'-pict.png';
      var b = '/img/shadow.png';
      var _icon = new msIcon(a, b, 7, 22);
      var _infoSkin = new msInfoSkin( '/img/'+typecoll+'-hg.png', '/img/'+typecoll+'-hd.png',
                             '/img/'+typecoll+'-bd.png', '/img/'+typecoll+'-bg.png',
                             '/img/'+typecoll+'-1px-h.png', '/img/'+typecoll+'-1px-b.png',
                             '/img/'+typecoll+'-1px-g.png', '/img/'+typecoll+'-1px-d.png',
                             '/img/'+typecoll+'-1px.png', '/img/close.png',
                             '/img/'+typecoll+'-queu-de-bulle.png' );
      if (typecoll=='colla') {var _title='Collège ancien';}
      if (typecoll=='collr') {var _title='Collège récent';}
      if (typecoll=='collmt') {var _title='Collège modèle-type';}
      if (typecoll=='collmtr') {var _title='Collège modèle-type restructuré';}
    }
  }

  // Functions...
  this.setMap = function(m) { _msMap = m; }
  this.getMap = function()  { return _msMap; }
  this.getImg = function()  { return _img; }
  this.getShd = function()  { return _shd; }
  this.getX   = function()  { return _x; }
  this.getY   = function()  { return _y; }
  this.getHtmlAttributes = function()
  {
    var ret = "<table>";
    for (var j=0; j<_item_name.length; j++)
    {
      // css
      if (_item_name[j]=='codesite') {codesite=_item_value[j];}
      if (_item_name[j]=='nom') {nom=_item_value[j];}
      if (_item_name[j]=='codeia') {codeia=_item_value[j];}
      if (_item_name[j]=='typecoll') {typecoll=_item_value[j];}
      if (_item_name[j]=='adressageecran')
      {
        adressageecran=_item_value[j];
        test=adressageecran.split(".");
        adressageecran=test[0];
        if (test.length>2)
        {
          for (var s=1;s<test.length-1;s++)
          {
            adressageecran+="."+test[s];
          }
        }
        adressageecran+="_vign.jpg";
      }
      if (_item_name[j]=='idimage') {idimage=_item_value[j];}

    }
    ret += "<tr><td class=\"mscross_report_attr_name\">" +
           "<a href=\""+lien+"pg-html/bases_doc/inventaire/fichecollege.php?idfic="+codesite+"&codeia="+codeia+"\" onclick=\"window.open(this.href);return false;\">"+nom+"</a>";
    ret+= "<br/><br/>";
//           +"</td><td class=\"mscross_report_attr_value\" "+"style='padding-left: 8px;'>";
    ret+=  "<a href=\""+lien+"pg-html/bases_doc/inventaire/fichecollege.php?idfic="+codesite+"&codeia="+codeia+"\" onclick=\"window.open(this.href);return false;\"><img src=\""+lien+"images/"+adressageecran+"\" alt=\"\"></a>"
    ret += "</td></tr>";
    ret += "</table>";
    return ret;
  }
  this.getInfoX = function() { return _msMap.xReal2pixel(_x); }
  this.getInfoY = function() { return Math.round(_msMap.yReal2pixel(_y) - (parseInt(_img.offsetHeight)/2) ); }
  this.getInfoSkin = function() { return _infoSkin; }
  this.getWidth  = function() { return parseInt(_img.style.width); }
  this.getHeight = function() { return parseInt(_img.style.height); }

  this.redraw = function()
  {
    // se e` visibile (coordinate del punto interne al box della mappa)...
    if ( _msMap.isPointInMap( _x - _msMap.wPixel2real(_offsetX),
                              _y + _msMap.hPixel2real(_offsetY),
                              _msMap.wPixel2real(_offsetX),
                              _msMap.hPixel2real(_offsetY) ) )
    {
      setPos(_img, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
      setPos(_shd, _msMap.xReal2pixel(_x) - _offsetX,
                   _msMap.yReal2pixel(_y) - _offsetY);
    } else
    { this.setVisible(false); }
  }

  this.setVisible = function(p_bool)
  {
    var str = null;
    if (p_bool) {str = '';} else {str = 'none';}
    _img.style.display = str;
    _shd.style.display = str;
  }

  this.showReport = function()
  {
    var pnt = new msReport(this, _title);
    _msMap.setReport(pnt);
  }

  // Initialization...
  _img = _icon.getImage(); _shd = _icon.getShadow();
  _offsetX = _icon.getShiftX() -1;
  _offsetY = _icon.getShiftY() -1;
//////////////////////////////////////////////////////////////////
// xxx Etichetta del punto, visualizzata al passaggio del mouse...
//  if (p_title != null) { _img.title = p_title; }
//////////////////////////////////////////////////////////////////
  _img.objRef = this;

  add_event(_img, 'click', function(event){pointOverlayEvent(event);});
}
