/* ******************************************************************** */
  /*
  
  project:          FILA - Homepage Rebuild
  file:             fila.css
  creator:          Planit Advertising
  creation date:    Tue Jan 11 10:18:27 EST 2011
  copyright:        (c) 2011 - Planit Advertising
                    All rights reserved.      

  info:             Homepage Specific Rebuild CSS.
              
  
  */
/* ******************************************************************** */

/*= Plugins
    Taken from Paul Irish’s HTML5 Boilerplate
/*-------------------------------------------------------- */
(function($){

})(this.jQuery);
window.log = function(){
  log.history = log.history || [];   
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};
/*-------------------------------------------------------- */
/*= [end] Plugins */

$(function(){
  $('#billboard-content').find('.quickviewbutton').hide();
  $('#billboard-content-small').find('.quickviewbutton').hide();
  $('.image').hover(function(){
    $(this).find('.quickviewbutton').show();
  },function(){
    $(this).find('.quickviewbutton').hide();
  })
  /* Basic Cycle Playback */
  var billboard_controls = "<ul id='billboard-ctl'><li id='billboard-ctl-prev'><a href='#' class='irspan ir'>Previous<span></span></a></li><li id='billboard-ctl-next'><a href='#' class='irspan ir'>Next<span></span></a></li></ul>", billboard_nav = '<div id="billboard-nav"><a href="#prev" id="billboard-nav-prev" class="ir">Previous<span></span></a><div id="billboard-nav-pager-wrap"><ul id="billboard-nav-pager"/></div><a href="#next" id="billboard-nav-next" class="ir">Next<span></span></a></div>',slide_index=0,hash=window.location.hash;
  if (hash) {
		slide_index = /\d+/.exec(hash)[0];
		slide_index = (parseInt(slide_index) || 1) - 1; 
		
  }
  /* slides are zero-based */
  
  function clothesExplorer(target){
    var id="#"+target, clothesExplorerNav = '<ul id="'+target+'-nav" class="clothes-explorer-nav">', space = 110; /* margin of nav + 20px height of buttons */
    
    $(id).find('.clothes-explore-item').each(function(index){
      var text = $(this).find('h3').text();
      $(this).find('h3').remove();
      clothesExplorerNav += '<li><a class="ir" href="#'+target+'-'+index+'">'+text+'</a></li>';
      $(this).attr('id',target+'-'+index)
        .css('top',space*index);
    });
    
    clothesExplorerNav +='</ul>';
    
    $(id)
      .prepend(clothesExplorerNav)
      .tabs({ collapsible: true, selected: -1, 
        fx:
          {width: 'show',height: 'show',opacity: 'show', duration: 200}
      });
    
      
  };
  
  function billboardPager(idx,slide){
    return '<li><a class="irspan" href="#panel-'+idx+'">'+idx+'<span></span></a></li>';
  }
  
  function billboardBuild(){
    $('#billboard-content')
      .find('.billboard-item')
        .append('<div class="billboard-fade billboard-fade-l" /><div class="billboard-fade billboard-fade-r" />')
      .end()
      .after(billboard_controls)
      .after(billboard_nav)
      .cycle({
        startingSlide     : slide_index,
        speed             : 500,
        nowrap            : 0,
        fx                : 'scrollHorz',
        easing            : 'easeOutExpo',
        manualTrump       : true,
        containerResize   : false,
        timeout           : 0,
        pager             : '#billboard-nav-pager',
        prev              : '#billboard-ctl-prev a,#billboard-nav-prev',
        next              : '#billboard-ctl-next a,#billboard-nav-next',
        pagerAnchorBuilder: billboardPager,
        after             : function(curr,next,opts) {
          window.location.hash = opts.currSlide + 1;
          // $('#billboard-content')
          //   .css('overflow','visible');
          /*if ($(curr).hasClass('clothing-explorer'))
          {
            clothesExplorer($(curr).find('.clothes-explore'))
          }*/
          /*  at the beginning of the page load, callout out
              each element that is being a clothing explorer, 
              by their ID.
              clothesExplorer('clothes-explore-01')
          */
        }
    });
    
    $('#billboard-content-small')
    .after(billboard_controls)
    .after(billboard_nav)
    .cycle({
      startingSlide     : slide_index,
      speed             : 500,
      nowrap            : 0,
      fx                : 'scrollHorz',
      easing            : 'easeOutExpo',
      manualTrump       : true,
      containerResize   : false,
      timeout           : 0,
      pager             : '#billboard-nav-pager',
      prev              : '#billboard-ctl-prev a,#billboard-nav-prev',
      next              : '#billboard-ctl-next a,#billboard-nav-next',
      pagerAnchorBuilder: billboardPager,
      after             : function(curr,next,opts) {
        window.location.hash = opts.currSlide + 1;
        // $('#billboard-content')
        //   .css('overflow','visible');
        /*if ($(curr).hasClass('clothing-explorer'))
        {
          clothesExplorer($(curr).find('.clothes-explore'))
        }*/
        /*  at the beginning of the page load, callout out
            each element that is being a clothing explorer, 
            by their ID.
            clothesExplorer('clothes-explore-01')
        */
      }
  });
  }
  
  function billBoardNavCenter(){
    var totals = $('#billboard-content li').length == 0 ? $('#billboard-content-small li').length : $('#billboard-content li').length, width = "";
    width = (totals*15)+108;
    $('#billboard-nav').css({'width':width,'margin-left':-(width/2)});
  }
  
  billboardBuild();
  billBoardNavCenter();
  clothesExplorer('clothes-explore-01');
})
