// Script to implement a photo gallery. For the VisAsp.Net project.
//
// Author:  OrdinaSoft
//          Patrick Lanz
//          Lausanne
//
// First version: May 19, 2006


var
  Img_NoImage,      // number of the current image
  Img_InImage = 0;  // indicates if we are in the image


// Display the menu for a photo.
//   No is the photo number.
//   PosX is the horizontal position of the mouse pointer
//   PosY is the vertical position of the mouse pointer

function Img_PhotoMenu (No, PosX, PosY) {

  var
    Menu = document.getElementById ('div_PhotoMenu'),
    Style = Menu.style,
    ScrollPos = GetScrollPosition ();

  Img_NoImage = No;
  Img_InImage = 1;

  // Display menu
  MakeAbsElmtVisible (Menu,
                      PosX + ScrollPos.x - Menu.offsetWidth / 2,
                      PosY + ScrollPos.y - Menu.offsetHeight / 2);
  Style.visibility = 'visible';
  return true;
}


// Called when we go outside of the image data

function Img_OutOfImage (Elmt) {
  if (Elmt)
    Elmt.style.backgroundColor = '#EFF8FD';
  Img_InImage = 0;
  return true;
}


// Hides the menu

function Img_HideMenu () {

  if (! Img_InImage) {
    var
      Style = document.getElementById ('div_PhotoMenu').style;

    Style.top = 0;
    Style.left = 0;
    Style.visibility = 'hidden';
  }
  return true;
}


// Display an image in low-resolution
//   Host is the host.

function Img_LowRes (Host) {
  open (Host + '/visasp/ShowImage.aspx?No=' + Img_NoImage + '&maxsize=500', '',
        'resizable=yes,scrollbars=no')
  return true;
}


// Display an image in high-resolution
//   Host is the host.

function Img_HighRes (Host) {
  open (Host + '/visasp/ShowImage.aspx?No=' + Img_NoImage, '', 'resizable=yes,scrollbars=no')
  return true;
}


// Make a vote on the image

function Img_Vote (Note) {

  var
    Img = (new Image).src = '/visasp/Image_Vote.aspx?No=' + Img_NoImage + '&Note=' + Note;

  Img_InImage = 0;
  Img_HideMenu ();
  alert ('Thank you for voting !');
  return true;
}
