jQuery.noConflict()
$jq = jQuery

Saucy = {
  replace_text : function(elems){
    $jq.each(elems, function(i,clss) {
      $jq(clss).each(function(j) {
        if(!this.replaced) {
          this.replaced = this.innerHTML;
          this.style.backgroundImage = 'url("' + Saucy.textUrl(clss, this.innerHTML) + '")'
          this.style.backgroundRepeat = 'no-repeat'
          this.innerHTML = "&nbsp;"
        }
      })
    })
  },
  replace_gradient : function(elems){
    $jq.each(elems, function(i,clss) {
      $jq(clss).each(function(j) {
        this.style.backgroundImage = 'url("' + Saucy.gradientUrl(clss) + '")'
      })
    })
  },
  textUrl : function(clss, text) {
    if(Saucy.mode=="active")
      return Saucy.controller + "text/" + Base64.encode(clss) + "_" + Base64.encode($jq.trim(text))
    else
      return Saucy.imageStore + Base64.encode(clss) + "_" + Base64.encode($jq.trim(text)) + ".png"
  },
  gradientUrl : function(clss) {
    if(Saucy.mode=="active")
      return Saucy.controller + "gradient/" + Base64.encode(clss)
    else
      return Saucy.imageStore + Base64.encode(clss) + ".png"
  },
  mode : "passive",
  controller : "/saucy/",
  imageStore : "/images/saucy/"
}

