$(function(){

  $("#left #categories li li a").each(function(){
    $(this).append(" &bull;")
  });
  
  $("#sneak_peep .brisa").each(function() {
     var content = $(this).find(":not(.edit, .editVerbiage)");
      $(content).wrapAll("<div class='text'>");
   
  })
  
  sIFR.replace(brisa, {
    selector: '#sneak_peep .brisa .text'
    ,css: '.sIFR-root { font-size: 23px; color: #006A3A; } a {color: #006A3A; text-decoration:none;} a:hover {color: #006A3A; text-decoration:none;}'
    
    ,tuneHeight:-15,
    offsetTop:-15,
    fitExactly: true,
    forceHeight:true
  });
  
  sIFR.replace(brisa, {
    selector: '#left h2',
    css: '.sIFR-root { font-size: 29px; color: #8CC63F; text-align:right; leading: -10;}',
    tuneWidth:2,
    tuneHeight:-12,
    fitExactly: false
  });
   sIFR.replace(brisa, {
    selector: 'h2.brissa',
    css: '.sIFR-root { font-size: 29px; color: #8CC63F; text-align:right;}',
    tuneWidth:2,
    tuneHeight:-12,
    fitExactly: true
  });
  sIFR.replace(brisa, {
    selector: '.category #right h1',
    css: '.sIFR-root { font-size: 39px; color: #6DB33F; leading:-10;}',
    tuneWidth:20,
    tuneHeight:-15,
    offsetLeft:5,
    forceClear:true
  });
  sIFR.replace(brisa, {
    selector: 'h1.contrast',
    css: '.sIFR-root { font-size: 39px; color: #F06C9A;}',

    forceWidth:true,
    forceSingleLine:true,
    tuneHeight:-15,
    offsetLeft:0,
    forceClear:true
  });
  sIFR.replace(brisa, {
    selector: 'h1',
    css: '.sIFR-root { font-size: 39px; color: #6DB33F;  leading:-17;}',
    tuneWidth:20,
    tuneHeight:-15,
    offsetLeft:3,
    forceClear:true
  });
  sIFR.replace(brisa, {
    selector: '#right h2',
    css: '.sIFR-root { font-size: 39px; color: #8CC63F;}',
    tuneWidth:20,
    tuneHeight:-15,
    offsetLeft:3,
    forceClear:true
  });
  sIFR.replace(brisa, {
    selector: '.product_description h3',
    css: '.sIFR-root { font-size: 31px; color: #6DB33F;}',
    tuneWidth:20,
    tuneHeight:-15,
    offsetLeft:3,
    forceClear:true
  });
  sIFR.replace(brisa, {
    selector: '#rabomstory h3',
    css: '.sIFR-root { font-size: 23px; color: #85B24A;}',

    forceClear:true
  });
  resizeIE6Background();
  
  $("#large_promo").cycle({slideExpr:"a:has(img), img:not(a img)"});
  
  /*<div id="promo1" class="promo">
  <a href="#"><h3><div class="background"></div><div>ribbon<strong>sale</strong></div></h3><img src="images/promo1.jpg" /></a>
</div> */
  
  $(".promo").each(function() {
    var promo = $(this);
    var text = jQuery.trim(promo.find("a:not('.edit')").text()).split(" ");
    text = jQuery.map(text, function(value, i){
      if (i % 2 == 1) {
        return "<strong>"+value+"</strong>";
      } else {
        return value;
      }
    })
    var image = promo.find("img")
    var link = promo.find("a:not('.edit')");
    var admin = promo.find(".editVerbiage");
    var edit = promo.find("a.edit");
    
    var html = "<a href='"+link.attr("href")+"'><h3><div class='background'></div><div>"+text.join("")+"</div></h3><img src='"+image.attr("src")+"'/></a>";
    
    if (admin.length > 0) {
      html = "<div class='editVerbiage'><a class='edit' href=\""+edit.attr("href")+"\">"+edit.text()+"</a>"+html+"</div>";
    }
    
    promo.html(html)
    
    promo.find(".background").each(function() {
      $(this).css({opacity:0.85});
    });
  });
});



function resizeIE6Background() {
  var page = $("#site");
  var page_background = $("#background");
  // IE6 Background stretch fix
  if($.browser.msie && $.browser.version == "6.0") {
    page_background.height(page.height() - 542);
  }

}

var brisa = {
      src: 'javascripts/sifr/brisa.swf',
      forceTextTransform: true,
			wmode:"transparent",
			useDomLoaded:true,
    onReplacement:function(fi) {resizeIE6Background();}
};
sIFR.useStyleCheck = true;
sIFR.activate(brisa);
