jQuery(document).ready(function($) {

	$("img").filter(".gallery_thumbnail_image").click(function() {
    imgid = this.id.toString().split("_");
    displayGalleryImage(imgid[1], imgid[2], imgid[3]);
	});

  $("a").filter(".add_clip_review").click(function() {
    clipid = this.id.toString().split("_");
    $("#divAddReview_" + clipid[1]).toggle();
	});

  $("input").filter(".add_review_button").click(function() {
    if (document.frmAddReview.txtReviewTitle.value.toString().length > 0)
      {
      document.frmAddReview.submit();
      }
    else
      {
      alert("You must enter a title for your review.");
      }
	});

  $("input").filter(".close_review_button").click(function() {
    clipid = this.id.toString().split("_");
    $("#divAddReview_" + clipid[1]).toggle();
	});

  $(".editable").hover(function () {jQuery(this).addClass("editable_bg");},
                       function () {jQuery(this).removeClass("editable_bg");});

  $(".editable").click(function () {
    myid = this.id.toString().split("_");
    $(this).hide();
    $("#spnEdit_" + myid[1] + "_" + myid[2]).show();
    });
  $(".save_editable_text").click(function () {
    myid = this.id.toString().split("_");
    fname = myid[1] + "_" + myid[2];
    myvalue = document.getElementById(fname.toString()).value.toString().replace(/\n/g, "<br>");
    $("#spnDisplay_" + fname.toString()).attr("innerHTML", myvalue);
    $("#spnEdit_" + fname.toString()).hide();
    $("#spnDisplay_" + fname.toString()).show();
    });
}); // jQuery.ready()

/* removed 2009-07-20 -mde [bugzilla #1765]
function linkToMe(cid)
  {
  if (document.getElementById("divLinkToMe").style.display == "block")
    {
    document.getElementById("divLinkToMe").style.display = "none";
    }
  else
    {
    document.getElementById("divLinkToMe").style.display = "block";
    }
  } // linkToMe()
*/

function displayGalleryImage(galleryid, imgwidth, imgheight)
  {
  winwidth  = new Number(imgwidth);
  winheight = new Number(imgheight);
  winwidth  = winwidth + 25;
  winheight = winheight + 25;
  if (winwidth > 800)
    {
    winwidth = 800;
    }
  if (winheight > 600)
    {
    winheight = 600;
    }
  window.open('http://www.clips.com/showimage.php?g=' + galleryid.toString(), '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + winwidth.toString() + ',height=' + winheight.toString());
  } // displayGalleryImage()