
function _ptxGallery1_initValues(activeGalleryValues, gallery_id, count_int, image_str, width_str, height_str, big_width_str, big_height_str, caption_str)
{
  // Initialisierungswerte in die Galeriedaten setzen
  activeGalleryValues.gallery_id = gallery_id;
  activeGalleryValues.caption_arr = caption_str.split("|");
  activeGalleryValues.small_img_name_array = image_str.split(",");
  activeGalleryValues.small_img_width_array = width_str.split(",");
  activeGalleryValues.small_img_height_array = height_str.split(",");
  activeGalleryValues.big_img_width_array = big_width_str.split(",");
  activeGalleryValues.big_img_height_array = big_height_str.split(",");
  activeGalleryValues.curr_index = 0;
  activeGalleryValues.count = count_int;
}

function _ptxGallery1_setNewImage(activeGalleryValues)
{
  for (i = 0; i < activeGalleryValues.count; i++)
  {
    //var image = document.getElementsByName('ie_img_name_' + i + '_' + activeGalleryValues.gallery_id)[i];
    var image = document.getElementById('ie_img_name_' + i + '_' + activeGalleryValues.gallery_id);

    if(image == null)
    {
      window.alert("Element not found");
    }

    var width;
    var height;
    var src;
    // Bild unsichtbar schalten, falls ausserhalb des Bereiches
    if (activeGalleryValues.curr_index + i >= activeGalleryValues.small_img_name_array.length)
    {
       // Unischtbares Bild
       width = 1;
       height = 1;
       src = "ptx/rsrc/dot.gif";
       image.style.visibility = "hidden";
    }
    else
    {
        // Sichtbares Bild
        width = activeGalleryValues.small_img_width_array[activeGalleryValues.curr_index + i];
        height = activeGalleryValues.small_img_height_array[activeGalleryValues.curr_index + i];
        src = "ptx/media/action.get_media.php?id="+activeGalleryValues.small_img_name_array[activeGalleryValues.curr_index + i]+"&w="+width+"&h="+height;
        image.style.visibility = "visible";
    }

    // Werte in das Bild eintragen
    image.width = width;
    image.height = height;
    image.src = src;

    var caption_div = document.getElementById('caption_div_' + i + '_' + activeGalleryValues.gallery_id);
    if(caption_div != null)
    {
      if (activeGalleryValues.curr_index + i >= activeGalleryValues.small_img_name_array.length)
      {
        caption_div.visibility = 'hidden';
        caption_div.innerHTML = '&nbsp;';
      }
      else if (activeGalleryValues.caption_arr[activeGalleryValues.curr_index + i] == "")
        caption_div.innerHTML = '&nbsp;';
      else
        caption_div.innerHTML = activeGalleryValues.caption_arr[activeGalleryValues.curr_index + i];
    }
  }
}

function _ptxGallery1_moveForward(activeGalleryValues)
{
  activeGalleryValues.curr_index = activeGalleryValues.curr_index + activeGalleryValues.count;

  if (activeGalleryValues.small_img_name_array.length <= activeGalleryValues.curr_index)
    activeGalleryValues.curr_index = 0;

  _ptxGallery1_setNewImage(activeGalleryValues);
}

function _ptxGallery1_moveBack(activeGalleryValues)
{
  activeGalleryValues.curr_index = activeGalleryValues.curr_index - activeGalleryValues.count;

  if (activeGalleryValues.curr_index < 0)
  {
    if (activeGalleryValues.small_img_name_array.length % activeGalleryValues.count == 0)
      activeGalleryValues.curr_index = activeGalleryValues.small_img_name_array.length - activeGalleryValues.count;
    else
      activeGalleryValues.curr_index = activeGalleryValues.small_img_name_array.length - activeGalleryValues.small_img_name_array.length % activeGalleryValues.count;
   }
  _ptxGallery1_setNewImage(activeGalleryValues);
}


function _ptxGallery1_showBigImage(activeGalleryValues, index)
{
  index = activeGalleryValues.curr_index + index;
  width = parseInt(activeGalleryValues.big_img_width_array[index]);
  height = parseInt(activeGalleryValues.big_img_height_array[index]);
  //url = "ptx/media/action.get_media.php?id="+activeGalleryValues.small_img_name_array[index]+"&w="+width+"&h="+height;
  url = "ptx/image_preview/action.preview_client_image.php?id="+activeGalleryValues.small_img_name_array[index]+"&width="+width+"&height="+height;
  _ptxGallery1_openPreviewWindow(url, width, height);
}


function _ptxGallery1_openPreviewWindow(url, width, height)
{
  var options = "directories=no";
  options += ", menubar=no";
  options += ", toolbar=no";
  options += ", location=no";
  options += ", status=no";
  options += ", scrollbars=no";
  options += ", resizable=yes";
  options += ", width=" + String(width);
  options += ", height=" + String(height);

  w = window.open(url, 'Vorschau', options);
  w.focus();

}
