jQuery.fn.extend({
	silGalleryFilters: function(options) {
		return this.each(function() {
			new jQuery.silGalleryFilters(this, options);
		});
	}
});

jQuery.silGalleryFilters = function(obj, opt) {

  var opt = opt || {};
  opt.fadeTime = opt.fadeTime || 1000;
  opt.firstLayerName = opt.firstLayerName || "first-layer"
  opt.firstLayerText = opt.firstLayerText || ""
  opt.secondLayerName = opt.secondLayerName || "second-layer"
  opt.secondLayerText= opt.secondLayerText || ""
  
  opt.fade = opt.fade || 0;
  opt.private = {Count:0};
  var $select = $(obj);
  
  var html = $select.html();
  var width = $select.children("img:first").width()+8;
  var height = $select.children("img:first").height()+8;
  
  $select.html("<div class=\"silGallery-relative\">"+html+"</div>");
  $select.children(".silGallery-relative").css("position","relative");
  $select.children(".silGallery-relative").css("width",width);
  $select.children(".silGallery-relative").css("height",height);
  $select.children(".silGallery-relative").hover(
    function () {
      $(this).append("<div class='" + opt.firstLayerName + "'>" + opt.firstLayerText + "</div>");
      $(this).children("." + opt.firstLayerName).fadeIn(opt.fadeTime);
      $(this).append("<div class='" + opt.secondLayerName + "'>" + opt.secondLayerText + "</div>");
      $(this).children("." + opt.secondLayerName).fadeTo(opt.fadeTime, opt.fade);
    },
    function () {
      $(this).find("." + opt.firstLayerName).remove();
      $(this).find("." + opt.secondLayerName).remove();
    });
}

