/*
  An Ajax-ready Sliding Gallery
  Licenses:
  (c) Creative Commons 2006
  http://creativecommons.org/licenses/by-sa/2.5/

  Free to use with my prior permission
  Author: Kevin Hoang Le | http://pragmaticobjects.org
  Date: 2006-07-15
  Version: 1.01 : Fixed side effects associated with double-clicking
  Version: 1.02: Add hooks for customizing pagers' looks
*/
function getParameter ( queryString, parameterName ) {
  // Add "=" to the parameter name (i.e. parameterName=value)
  var parameterName = parameterName + "=";
  if ( queryString.length > 0 ) {
  // Find the beginning of the string
    begin = queryString.indexOf ( parameterName );
  // If the parameter name is not found, skip it, otherwise return the value
  if ( begin != -1 ) {
    // Add the length (integer) to the beginning
    begin += parameterName.length;
    // Multiple parameters are separated by the "&" sign
    end = queryString.indexOf ( "&" , begin );
    if ( end == -1 ) {
      end = queryString.length
  }
  // Return the string
  return unescape ( queryString.substring ( begin, end ) );
}
// Return "null" if no parameter has been found
return "null";
}
}
  function set_cookie ( name, value, exp_y, exp_m, exp_d, path,
    domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );

  if ( secure )
        cookie_string += "; secure";

  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}



var gallerySlide = Class.create();
gallerySlide.prototype = {
  catalog : 0,
  slide : 0,
  pager : 0,
  prevImage : 0,
  nextImage : 0,
  scrollBy : 0,
  startDisplayIndex : 0,
  displayImages : 0,
  activePage : 0,
  PAGE_ID_PREFIX : "page",
  PADDING : 16, //galleryInnerBox's padding-right + padding-left + 2
  backImg : 0,
  backHoverImg : 0,
  backDisabledImg : 0,
  forwardImg : 0,
  forwardHoverImg : 0,
  forwardDisabledImg : 0,
  pageColor : 0,
  pageCurrentColor : 0,
  imageClickEvt : 0,
  imageMouseOverEvt : 0,
  imageMouseOutEvt : 0,
  pagerMouseOverEvt : 0,
  pagerMouseOutEvt : 0,
  nameClickEvt : 0,
  nameMouseOverEvt : 0,
  nameMouseOutEvt : 0,
  initialize : function(boxWidth, scrollPixels, displayImages, backImg,
  backHoverImg, backDisabledImg,
  forwardImg, forwardHoverImg, forwardDisabledImg, pageColor,
  pageCurrentColor, imageClickEvt,
  imageMouseOverEvt, imageMouseOutEvt, pagerMouseOverEvt,
  pagerMouseOutEvt,
  nameClickEvt, nameMouseOverEvt, nameMouseOutEvt) {
    var self = this;
    this.scrollBy = scrollPixels + this.PADDING;
    this.displayImages = displayImages;
    this.backImg = backImg;
    this.backHoverImg = backHoverImg;
    this.backDisabledImg = backDisabledImg;
    this.forwardImg = forwardImg;
    this.forwardHoverImg = forwardHoverImg;
    this.forwardDisabledImg = forwardDisabledImg;
    this.pageColor = pageColor;
    this.pageCurrentColor = pageCurrentColor;
    this.imageClickEvt = imageClickEvt;
    this.imageMouseOverEvt = imageMouseOverEvt;
    this.imageMouseOutEvt = imageMouseOutEvt;
    this.pagerMouseOverEvt = pagerMouseOverEvt;
    this.pagerMouseOutEvt = pagerMouseOutEvt;
    this.nameClickEvt = nameClickEvt;
    this.nameMouseOverEvt = nameMouseOverEvt;
    this.nameMouseOutEvt = nameMouseOutEvt;

    this.constructDivs();
// reversing  function of next and previous in line with common standards - changing image names on mainPage js and function name below
    // create arrow divs for the gallery
    var eDivLeft = $("galleryScrollNext");
    var a = document.createElement("a");
    this.prevImage = document.createElement("img");
    this.prevImage.src = this.backImg;
    this.prevImage.style.border = "none";
    this.prevImage.onmouseover = function() { this.src = self.backHoverImg;  };
    this.prevImage.onmouseout = function() { this.src = self.backImg; };
    a.style.cursor = "pointer";
    a.appendChild(this.prevImage);
    eDivLeft.appendChild(a);

    var eDivRight = $("galleryScrollPrevious");
    var a = document.createElement("a");
    this.nextImage = document.createElement("img");
    this.nextImage.src = this.forwardDisabledImg;
    this.nextImage.style.border = "none";
    this.nextImage.onmouseover = function() {
      if (self.startDisplayIndex > 0)
        this.src = self.forwardHoverImg;
    };
    this.nextImage.onmouseout = function() {
      if (self.startDisplayIndex > 0)
        this.src = self.forwardImg;
    };
    a.style.cursor = "pointer";
    a.appendChild(this.nextImage);
    eDivRight.appendChild(a);

    $("galleryOuterBox").style.width = boxWidth + "px";
  },

  constructDivs : function() {
    Element.removeAllChildren("gallerySlide") ;

    var eDivGalleryScrollPrevious = document.createElement("div");
    eDivGalleryScrollPrevious.setAttribute("id", "galleryScrollPrevious");
    $("gallerySlide").appendChild(eDivGalleryScrollPrevious);

    var eDiv = document.createElement("div");
    var eDivGalleryOuterBox = document.createElement("div");
    eDivGalleryOuterBox.setAttribute("id", "galleryOuterBox");
    var eDivGalleryInnerBox = document.createElement("div");
    eDivGalleryInnerBox.setAttribute("id", "galleryInnerBox");
    var eDivGalleryIEHack = document.createElement("div");
    eDivGalleryIEHack.setAttribute("id", "galleryIEHack");
    eDivGalleryInnerBox.appendChild(eDivGalleryIEHack);
    eDivGalleryOuterBox.appendChild(eDivGalleryInnerBox);
    eDiv.appendChild(eDivGalleryOuterBox);
    $("gallerySlide").appendChild(eDiv);

    var eDivGalleryScrollNext = document.createElement("div");
    eDivGalleryScrollNext.setAttribute("id", "galleryScrollNext");
    $("gallerySlide").appendChild(eDivGalleryScrollNext);
  },

  render : function(catalog) {

    var self = this;

    Element.removeAllChildren("galleryIEHack");
    var eDivIEHack = $("galleryIEHack");

    var itemIndex = 0 ;
    var ul = document.createElement("ul");

    catalog.item.each(function(item, i)
    {
      if (catalog.item[i] == null) return ;

      itemIndex = itemIndex + 1 ;
      var li = document.createElement("li");
      var a = document.createElement("a");
      li.setAttribute("id", catalog.item[i].id);
      var image = document.createElement("img");
      image.src = catalog.item[i].img;
      image.onmouseover = function()
      {
        if (self.imageMouseOverEvt != null) {
          self.imageMouseOverEvt(item, i, this);
        } else {
          this.style.border = "1px solid #333";
        }
      };
      image.onmouseout = function()
      {
        if (self.imageMouseOutEvt != null)
        {
          self.imageMouseOutEvt(item, i, this);
        }
        else
        {
          this.style.border = "1px solid #CCC";
        };
      }

      image.onclick = function()
      {
        if (self.imageClickEvt != null)
        {
          self.imageClickEvt(item, i, this);
        }

        // add in photo uploader info if this is a group
        var qstr = window.top.location.search.substring(1) ;
        var group_id = getParameter(qstr, 'group_id') ; // null if none
        if (group_id != "null")
        {
          Element.removeAllChildren("uploader_info") ;
          Element.removeAllChildren("uploader_avatar") ;

          var avatar_img = document.createElement("img") ;
          avatar_img.setAttribute("src", catalog.item[i].added_by_avatar)
          $("uploader_avatar").appendChild(avatar_img) ;

          var profile_nic_text = document.createElement("label") ;
          profile_nic_text.innerHTML = "&nbsp; Added by: " ;
          $("uploader_info").appendChild(profile_nic_text)

          var profile_nic = document.createElement("a") ;
           profile_nic.setAttribute("href",
            "sn_profile.php?control_profile_id=" + catalog.item[i].added_by_id) ;
          profile_nic.innerHTML = catalog.item[i].added_by ;
          $("uploader_info").appendChild(profile_nic) ;
         }

          // JRS - added in retrieve comments support
          var galleryId = i ;
          var fileId = catalog.item[i].fileId ;

          var qstr = window.top.location.search.substring(1) ;
          var control_profile_id = getParameter(qstr, 'control_profile_id') ;
          var group_id = getParameter(qstr, 'group_id') ;

          if (control_profile_id == "null")
            control_profile_id = getParameter(qstr, 'profile_id') ;

          var cookie_declaration = "xomai-last-pic-" ;

          if (typeof group_id != "undefined" && group_id != "null")
            cookie_declaration = cookie_declaration
              + group_id ;

          if (control_profile_id != "null")
            cookie_declaration = cookie_declaration
              + control_profile_id
              ;

         cookie_declaration = cookie_declaration
              + "-" + catalog.item[i].gallery_id + "=" + fileId ;

          document.cookie = cookie_declaration ;

          var url = 'getImgComments_view.php?fileId='+fileId
            +'&galleryId='+ catalog.item[i].gallery_id ;
          var myAjax = new Ajax.Request
          (url,
            {
              method: 'get',
              onSuccess: function(transport)
              {
                var response =
                  transport.responseText || "No comments -- yet!";

                 var gsc = $('gallerySlideComments') ;
                   gsc.update(response) ;
              },
              onFailure: function() { alert('Error retrieving comments') }
            }
          ) ;
        }

      a.style.cursor = "pointer";
      a.appendChild(image);
      li.appendChild(a);

      if (catalog.item[i] != null
        && catalog.item[i].name != null)
      {
        var divCaption = document.createElement("div");
        var aCaption = document.createElement("a");
        aCaption.style.cursor = "pointer";
        aCaption.appendChild(document.createTextNode(catalog.item[i].name));
        aCaption.onmouseover = function() {
          if (self.nameMouseOverEvt != null)
          {
            self.nameMouseOverEvt(item, i, this);
          }
          else
          {
            this.style.textDecoration = "underline";
          }
        };
        aCaption.onmouseout = function() {
          if (self.nameMouseOutEvt != null) {
            self.nameMouseOutEvt(item, i, this);
          } else {
            this.style.textDecoration = "none";
          }
        };
        aCaption.onclick = function() {
          if (self.nameClickEvt != null) {
            self.nameClickEvt(item, i, this);
          }
        }
        divCaption.appendChild(aCaption);
        li.appendChild(divCaption);
      }

      if (catalog.item[i].detail != null) {
        var price = document.createTextNode(catalog.item[i].detail);
        li.appendChild(price);
      }

      // if there are images in the gallery display the first
      var qstr = window.top.location.search.substring(1) ;
      var control_profile_id = getParameter(qstr, 'control_profile_id') ;
      var group_id = getParameter(qstr, 'group_id') ;
      var gallery_id = getParameter(qstr, 'gallery_id') ;

      if (control_profile_id == "null")
        control_profile_id = getParameter(qstr, 'profile_id') ;

      cookie_name = 'xomai-last-pic-' ;

      if (group_id == "null")
        cookie_name = cookie_name + control_profile_id ;
      else
        cookie_name = cookie_name + group_id ;

      if (typeof currGeneratedGalleryId != "undefined" )
      {
         cookie_name = cookie_name + '-' + currGeneratedGalleryId ;
      }

      var last_pic_viewed = get_cookie(cookie_name) ;

      if ((last_pic_viewed == null || last_pic_viewed == -1 )
        && itemIndex == 1)
      { image.onclick() ; }

      if ( (last_pic_viewed != null && last_pic_viewed != -1)
         && catalog.item[i].fileId == last_pic_viewed)
      {
            image.onclick() ;
                  }

       ul.appendChild(li);
    }
    );

    eDivIEHack.appendChild(ul);

    this.prevImage.onclick = function() {
      if (self.startDisplayIndex < catalog.item.length - self.displayImages)
      {
        self.slide(catalog, self, -1);
        self.startDisplayIndex++;
        self.adjustArrowsAndPager(catalog);
        self.prevImage.onmouseover = function()
        {
          if (self.startDisplayIndex < catalog.item.length - self.displayImages)
            this.src = self.backHoverImg;
        };
        self.prevImage.onmouseout = function()
        {
          if (self.startDisplayIndex < catalog.item.length - self.displayImages)
            this.src = self.backImg;
        };
      }
    }

    this.nextImage.onclick = function() {
      if (self.startDisplayIndex > 0) {
        self.slide(catalog, self, 1);
        self.startDisplayIndex--;
        self.adjustArrowsAndPager(catalog);
      }
    }

    Element.removeAllChildren("galleryPager");
        //$("galleryPager").appendChild(document.createTextNode("page:\u00a0\u00a0"));

    var totalPages = Math.ceil(catalog.item.length / this.displayImages);
    if (totalPages == 0) return ;

    var pages = new Array(totalPages);
    for (i = 0; i < totalPages; i++) {
      pages[i] = i + 1;
    }

    pages.each(function(item, i) {

      var a = document.createElement("a");
      a.setAttribute("id", self.PAGE_ID_PREFIX + i);
      a.style.cursor = "pointer";
      a.style.paddingRight = "1em";
      a.style.color = self.pageColor;
      if (totalPages>1)
      a.appendChild(document.createTextNode(pages[i]));
      a.onmouseover = function() {
        if (self.pagerMouseOverEvt != null) {
          self.pagerMouseOverEvt(item, i, this, self.activePage);
        } else {
          this.style.textDecoration = "underline";
        }
      };
      a.onmouseout = function() {
        if (self.pagerMouseOutEvt != null) {
          self.pagerMouseOutEvt(item, i, this, self.activePage);
        } else {
          this.style.textDecoration = "none";
        }
      };
      a.onclick = function() {
        var units = self.startDisplayIndex - i * self.displayImages;
        self.slide(catalog, self, units, pages);
        self.startDisplayIndex -= units;
        self.adjustArrowsAndPager(catalog);
      }
      $("galleryPager").appendChild(a);
    });

    this.activePage = 0;
    $(this.PAGE_ID_PREFIX + this.activePage).style.color = this.pageCurrentColor;
  },

renderMetaGallery : function(catalog) {

    var self = this;

      Element.removeAllChildren("metaGalleryIEHack") ;
      var eDivIEHack = $("metaGalleryIEHack") ;


      var itemIndex = 0 ;
      var ul = document.createElement("ul");
    catalog.item.each(function(item, i)
    {
      if (catalog.item[i] == null) return ;

      itemIndex = itemIndex + 1 ;
      var li = document.createElement("li");
      var a = document.createElement("a");
      li.setAttribute("id", catalog.item[i].id);
      var image = document.createElement("img");
      image.src = catalog.item[i].img;
      image.onmouseover = function()
      {
        if (self.imageMouseOverEvt != null) {
          self.imageMouseOverEvt(item, i, this);
        } else {
          this.style.border = "1px solid #333";
        }
      };
      image.onmouseout = function()
      {
        if (self.imageMouseOutEvt != null)
        {
          self.imageMouseOutEvt(item, i, this);
        }
        else
        {
          this.style.border = "1px solid #CCC";
        };
        }

      image.onclick = function()
      {
        if (self.imageClickEvt != null)
        {
          self.imageClickEvt(item, i, this);
        }

        }

      a.style.cursor = "pointer";
      a.appendChild(image);
      li.appendChild(a);

      if (catalog.item[i] != null
        && catalog.item[i].name != null)
      {
        var divCaption = document.createElement("div");
        var aCaption = document.createElement("a");
        aCaption.style.cursor = "pointer";
        aCaption.appendChild(document.createTextNode(catalog.item[i].name));
        aCaption.onmouseover = function() {
          if (self.nameMouseOverEvt != null)
          {
            self.nameMouseOverEvt(item, i, this);
          }
          else
          {
            this.style.textDecoration = "underline";
          }
        };
        aCaption.onmouseout = function() {
          if (self.nameMouseOutEvt != null) {
            self.nameMouseOutEvt(item, i, this);
          } else {
            this.style.textDecoration = "none";
          }
        };
        aCaption.onclick = function() {
          if (self.nameClickEvt != null) {
            self.nameClickEvt(item, i, this);
          }
        }
        divCaption.appendChild(aCaption);
        li.appendChild(divCaption);
      }

      if (catalog.item[i].detail != null) {
        var price = document.createTextNode(catalog.item[i].detail);
        li.appendChild(price);
      }

       ul.appendChild(li);
    }
    );

    eDivIEHack.appendChild(ul);

    this.prevImage.onclick = function() {
      if (self.startDisplayIndex < catalog.item.length - self.displayImages)
      {
        self.slide(catalog, self, -1);
        self.startDisplayIndex++;
        self.adjustArrowsAndPager(catalog);
        self.prevImage.onmouseover = function()
        {
          if (self.startDisplayIndex < catalog.item.length
            - self.displayImages)
            this.src = self.backHoverImg;
        };
        self.prevImage.onmouseout = function()
        {
          if (self.startDisplayIndex < catalog.item.length - self.displayImages)
            this.src = self.backImg;
        };
      }
    }

    this.nextImage.onclick = function() {
      if (self.startDisplayIndex > 0) {
        self.slide(catalog, self, 1);
        self.startDisplayIndex--;
        self.adjustArrowsAndPager(catalog);
      }
    }

    Element.removeAllChildren("metaGalleryPager");
    //$("metaGalleryPager").appendChild(document.createTextNode("page:\u00a0\u00a0"));
    var totalPages = Math.ceil(catalog.item.length / this.displayImages);
    var pages = new Array(totalPages);
    for (i = 0; i < totalPages; i++) {
      pages[i] = i + 1;
    }

    pages.each(function(item, i) {
      var a = document.createElement("a");
      a.setAttribute("id", self.PAGE_ID_PREFIX + i);
      a.style.cursor = "pointer";
      a.style.paddingRight = "1em";
      a.style.color = self.pageColor;
      a.appendChild(document.createTextNode(pages[i]));
      a.onmouseover = function() {
        if (self.pagerMouseOverEvt != null) {
          self.pagerMouseOverEvt(item, i, this, self.activePage);
        } else {
          this.style.textDecoration = "underline";
        }
      };
      a.onmouseout = function() {
        if (self.pagerMouseOutEvt != null) {
          self.pagerMouseOutEvt(item, i, this, self.activePage);
        } else {
          this.style.textDecoration = "none";
        }
      };
      a.onclick = function() {
        var units = self.startDisplayIndex - i * self.displayImages;
        self.slide(catalog, self, units, pages);
        self.startDisplayIndex -= units;
        self.adjustArrowsAndPager(catalog);
      }
      $("metaGalleryPager").appendChild(a);
    });

    this.activePage = 0;
    $(this.PAGE_ID_PREFIX + this.activePage).style.color = this.pageCurrentColor;
  },
  disableTriggerPoints : function(self, pages) {
    if (pages != null) {
      pages.each(function(item, i) {
        $(self.PAGE_ID_PREFIX + i).onclick = function() { };
      });
    }

    this.prevImage.onclick = function() { };
    this.nextImage.onclick = function() { };

  },

  enableTriggerPoints : function(self, pages, catalog, units) {
    if (pages != null) {
      pages.each(function(item, i) {
        $(self.PAGE_ID_PREFIX + i).onclick = function() {
          var units = self.startDisplayIndex - i * self.displayImages;
          self.slide(catalog, self, units, pages);
          self.startDisplayIndex -= units;
          self.adjustArrowsAndPager(catalog);
        }
      });
    }

    self.prevImage.onclick = function()
    {
      if (self.startDisplayIndex
        < catalog.item.length - self.displayImages)
      {
        self.slide(catalog, self, -1);
        self.startDisplayIndex++;
        self.adjustArrowsAndPager(catalog);
        self.prevImage.onmouseover = function() {
          if (self.startDisplayIndex < catalog.item.length - self.displayImages)
            this.src = self.backHoverImg;
        };
        self.prevImage.onmouseout = function() {
          if (self.startDisplayIndex < catalog.item.length - self.displayImages)
            this.src = self.backImg;
        };
      }
    };

    self.nextImage.onclick = function() {
      if (self.startDisplayIndex > 0) {
        self.slide(catalog, self, 1);
        self.startDisplayIndex--;
        self.adjustArrowsAndPager(catalog);
      }
    };
  },
  slide : function(catalog, obj, units, pages)
  {
    obj.disableTriggerPoints(obj, pages);

    var self = this;
    var xDist = units * obj.scrollBy;
    //check if images are of different sizes
    if (obj.scrollBy == self.PADDING)
    {
      xDist = 0;
      if (units > 0)
      {
        for (index = self.startDisplayIndex - 1;
          index >= self.startDisplayIndex - units; index--)
        {
          xDist += (eval(catalog.item[index].imgWidth) + this.PADDING);
        }
      }
      else
      {
        units = Math.abs(units);
        for (index = self.startDisplayIndex;
          index < self.startDisplayIndex + units; index++) {
          xDist -= (eval(catalog.item[index].imgWidth) + this.PADDING);
        }
      }
    }

    catalog.item.each(function(item, i)
    {
      if (catalog.item[i] != null)
      {
        new Effect.MoveBy ($(catalog.item[i].id), 0, xDist,
        {
          duration: 1,
          afterFinish: function()
          {
            if (i == catalog.item.length - 1)
            {
              self.enableTriggerPoints(self, pages, catalog, units);
            }
          }
        }
        );
       }// if
       else self.enableTriggerPoints(self, pages, catalog, units);
    });
  },

  adjustArrowsAndPager : function(catalog)
  {
    if (this.startDisplayIndex == 0)
    {
      this.nextImage.src = this.forwardDisabledImg;
    }
    else if (this.startDisplayIndex
      >= catalog.item.length - this.displayImages)
    {
      this.prevImage.src = this.backDisabledImg;
    }
    else
    {
      this.nextImage.src = this.forwardImg;
      this.prevImage.src = this.backImg;
    }

    var quotient = this.startDisplayIndex / this.displayImages;
    var quotientFloor = Math.floor(quotient);

    if (quotientFloor != this.activePage) {
      $(this.PAGE_ID_PREFIX + this.activePage).style.color = this.pageColor;
      this.activePage = quotientFloor;
      $(this.PAGE_ID_PREFIX + this.activePage).style.color = this.pageCurrentColor;
    }
  }
}

function displayNewComments(fid, gid, newComment) {
    var url = 'getImgComments_view.php?fileId='
     + fid
        + '&galleryId='
        + gid
        + '&newComment='
        + newComment
        ;
    var myAjax = new Ajax.Request (url, { method: 'get',
          onSuccess: function(transport) {
                    var response =
                    transport.responseText || "No comments -- yet!";

                    var gsc = $('gallerySlideComments') ;
                    gsc.update(response) ;
                },
              onFailure: function() { alert('Error retrieving comments') }
        }) ;
    }


//
//
//

function genericDisplayNewComments(rsp_item_type, item_id, comment_parent_id,
  newComment)
{
//alert("in genericDisplayNewComments") ;
    var url = 'genericImgComments_view.php?item_type_id='
         + rsp_item_type
        + '&item_id='
        + item_id
        + '&newComment='
        + newComment
        + '&comment_parent_id='
        + comment_parent_id
        ;
    var myAjax = new Ajax.Request (url, { method: 'get',
          onSuccess: function(transport) {
                    var response =
                    transport.responseText || "No comments -- yet!";

                    var gsc = $('gallerySlideComments') ;
                    gsc.update(response) ;
                },
              onFailure: function() { alert('Error retrieving comments') }
        }) ;
    }

//
// generic delete comment function
//

function genericDeleteComment(rsp_item_type, item_id, comment_id)
{
  var url = 'genericImgComments_view.php?'
    + 'item_type_id=' + rsp_item_type
    + '&item_id=' + item_id
    + '&deleteId=' + comment_id
  ;

  var myAjax = new Ajax.Request (url, { method: 'get',
    onSuccess: function(transport) {
                    var response =
                    transport.responseText || "";

                    var gsc = $('gallerySlideComments') ;
                    gsc.update(response) ;
                },
              onFailure: function() { alert('Error deleting	 comment') }
        });
}
//
//
//

function deleteComment(fid,gid,comment_id)
{
  var url = 'getImgComments_view.php?'
    + 'fileId=' + fid
    + '&galleryId=' + gid
    + '&deleteId=' + comment_id
  ;
  var myAjax = new Ajax.Request (url, { method: 'get',
    onSuccess: function(transport) {
                    var response =
                    transport.responseText || "";

                    var gsc = $('gallerySlideComments') ;
                    gsc.update(response) ;
                },
              onFailure: function() { alert('Error deleting	 comment') }
        });
}

//
// find out the current style of the object
//

function getStyleObject(objectId)
{
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
  return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {
  return document.all(objectId).style;
   }
   else if (document.layers && document.layers[objectId]) {
  return document.layers[objectId];
   } else {
  return false;
   }
}

//
// toggles the visibility of the id'd object to the specified value
//
// param1: object id
// param2: either "visible" or "hidden" (deprecated)
//
function changeObjectVisibility(objectId, newVisibility)
{
  var style_obj = getStyleObject(objectId) ;

    if (style_obj)
    {
      if (style_obj.display == 'none')
        style_obj.display = 'block' ;
      else
        style_obj.display = 'none' ;

      return true ;
    }
    else
    {
      return false;
    }
}
