(function() {
  var SlideThumb, SlideThumbs, SlideThumbsContainer;

  SlideThumbsContainer = (function() {

    SlideThumbsContainer.prototype.limit = null;

    SlideThumbsContainer.prototype.max = 0;

    SlideThumbsContainer.prototype.current_id = 0;

    SlideThumbsContainer.prototype.current_m_id = 0;

    SlideThumbsContainer.prototype.isClick = false;

    SlideThumbsContainer.prototype.isMove = true;

    SlideThumbsContainer.prototype.isInterval = false;

    SlideThumbsContainer.prototype.intervalId = null;

    function SlideThumbsContainer(target, limit, width, margin, isClick) {
      var owner;
      if (width == null) width = 220;
      if (margin == null) margin = 4;
      if (isClick == null) isClick = false;
      owner = this;
      this.limit = limit;
      this.isClick = isClick;
      this.slide = new SlideThumbs(target, this, width, margin);
      this.max = this.slide.getMax();
      if (this.limit !== null && this.max <= this.limit) {
        this.isMove = false;
        this.slide.hidePaginate();
      }
      this.slide.setup();
      $(this.slide).bind({
        over: function(data, id) {
          owner.current_id = id;
          if (owner.intervalId) clearInterval(owner.intervalId);
          owner.slide.select(id);
          owner.wait();
          return $(owner).trigger('onOver', [owner.current_id]);
        },
        click: function(data, id) {
          if (owner.isClick) {
            owner.current_id = id;
            $(owner).trigger('onClick', [owner.current_id]);
            owner.slide.select(id);
            return false;
          }
        },
        onNext: function(data) {
          if (!owner.isMove) return;
          return owner.next();
        },
        onPrev: function(data) {
          if (!owner.isMove) return;
          return owner.prev();
        }
      });
    }

    SlideThumbsContainer.prototype.startInterval = function() {
      this.isInterval = true;
      return this.wait();
    };

    SlideThumbsContainer.prototype.wait = function() {
      var owner;
      if (!this.isInterval) return;
      owner = this;
      if (this.intervalId) clearInterval(this.intervalId);
      return this.intervalId = setTimeout(function() {
        return owner.next();
      }, 4000);
    };

    SlideThumbsContainer.prototype.next = function() {
      if (this.current_m_id >= this.max - 1) {
        this.current_m_id = 0;
      } else {
        this.current_m_id += 1;
      }
      if (this.current_id >= this.max - 1) {
        this.current_id = 0;
      } else {
        this.current_id += 1;
      }
      if (this.isMove) this.slide.next(this.current_m_id);
      this.slide.select(this.current_id);
      $(this).trigger('onNext', [this.current_id]);
      if (this.isInterval) return this.wait();
    };

    SlideThumbsContainer.prototype.prev = function() {
      if (this.current_m_id <= 0) {
        this.current_m_id = this.max - 1;
      } else {
        this.current_m_id += -1;
      }
      if (this.current_id <= 0) {
        this.current_id = this.max - 1;
      } else {
        this.current_id += -1;
      }
      if (this.isMove) this.slide.prev(this.current_m_id);
      this.slide.select(this.current_id);
      $(this).trigger('onPrev', [this.current_id]);
      if (this.isInterval) return this.wait();
    };

    return SlideThumbsContainer;

  })();

  SlideThumbs = (function() {

    SlideThumbs.prototype.thumb_width = 0;

    SlideThumbs.prototype.wrapper = null;

    SlideThumbs.prototype.target = null;

    SlideThumbs.prototype.items = null;

    SlideThumbs.prototype.pagenates = null;

    SlideThumbs.prototype.pagenate_left = null;

    SlideThumbs.prototype.pagenate_right = null;

    SlideThumbs.prototype.thumbsList = null;

    SlideThumbs.prototype.current_id = 0;

    function SlideThumbs(target, wrapper, width, margin) {
      var len, owner;
      owner = this;
      this.target = target;
      this.wrapper = wrapper;
      this.items = $(target).find('.items');
      this.pagenates = $(target).find('.pagenates');
      this.pagenate_left = this.pagenates.find('.pagenates_left');
      this.pagenate_right = this.pagenates.find('.pagenates_right');
      len = this.items.find('li').length;
      this.items.css({
        width: (width + margin) * len + 50
      });
      this.thumb_width = width + margin;
    }

    SlideThumbs.prototype.getMax = function() {
      return this.items.find('li').length;
    };

    SlideThumbs.prototype.setup = function() {
      var owner;
      owner = this;
      this.pagenate_left.bind({
        click: function() {
          $(owner).trigger('onPrev');
          return false;
        }
      });
      this.pagenate_right.bind({
        click: function() {
          $(owner).trigger('onNext');
          return false;
        }
      });
      this.thumbsList = [];
      return this.items.find('li').each(function(i) {
        var thumb;
        thumb = new SlideThumb($(this), i, owner.wrapper.isClick);
        if (i === 0) thumb.addCurrent();
        owner.thumbsList.push(thumb);
        return $(thumb).bind({
          over: function(data, id) {
            return owner.onThumbOver(id);
          },
          click: function(data, id) {
            return owner.onThumbClick(id);
          }
        });
      });
    };

    SlideThumbs.prototype.hidePaginate = function() {
      this._hidePaginate(this.pagenate_left);
      return this._hidePaginate(this.pagenate_right);
    };

    SlideThumbs.prototype._hidePaginate = function(target) {
      var anc, img, src;
      target.addClass('disable');
      target.css({
        cursor: 'default'
      });
      target.bind({
        click: function() {
          return false;
        }
      });
      anc = target.find('a');
      img = target.find('img');
      src = img.attr('src');
      anc.css({
        cursor: 'default'
      });
      return img.attr('src', src.replace('.png', '_disable.png'));
    };

    SlideThumbs.prototype.select = function(id) {
      var thumb, _i, _len, _ref, _results;
      _ref = this.thumbsList;
      _results = [];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        thumb = _ref[_i];
        _results.push((function(thumb) {
          if (thumb.id === id) {
            return thumb.addCurrent();
          } else {
            return thumb.removeCurrent();
          }
        })(thumb));
      }
      return _results;
    };

    SlideThumbs.prototype.next = function(id) {
      var i, len, thumb, tmpList;
      tmpList = this.getSortIdList(id);
      tmpList.unshift(tmpList.pop());
      len = tmpList.length - 1;
      for (i = 0; 0 <= len ? i <= len : i >= len; 0 <= len ? i++ : i--) {
        thumb = this.thumbsList[tmpList[i]];
        this.items.append(thumb.target);
      }
      return this.items.stop().css({
        marginLeft: 0
      }).animate({
        marginLeft: -this.thumb_width
      }, 500, 'easeOutQuart');
    };

    SlideThumbs.prototype.prev = function(id) {
      var i, len, thumb, tmpList;
      tmpList = this.getSortIdList(id);
      len = tmpList.length - 1;
      for (i = 0; 0 <= len ? i <= len : i >= len; 0 <= len ? i++ : i--) {
        thumb = this.thumbsList[tmpList[i]];
        this.items.append(thumb.target);
      }
      return this.items.stop().css({
        marginLeft: -this.thumb_width
      }).animate({
        marginLeft: 0
      }, 500, 'easeOutQuart');
    };

    SlideThumbs.prototype.getSortIdList = function(id) {
      var len, thumb, tmpList, _fn, _i, _len, _ref;
      len = this.thumbsList.length;
      tmpList = [];
      _ref = this.thumbsList;
      _fn = function(thumb) {
        var tmpId;
        tmpId = thumb.id + id;
        if (tmpId >= len) tmpId = tmpId - len;
        return tmpList.push(tmpId);
      };
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        thumb = _ref[_i];
        _fn(thumb);
      }
      return tmpList;
    };

    SlideThumbs.prototype.onThumbOver = function(id) {
      return $(this).trigger('over', id);
    };

    SlideThumbs.prototype.onThumbClick = function(id) {
      return $(this).trigger('click', id);
    };

    return SlideThumbs;

  })();

  SlideThumb = (function() {

    SlideThumb.prototype.target = null;

    SlideThumb.prototype.id = null;

    SlideThumb.prototype.isSelected = false;

    function SlideThumb(target, id, isClick) {
      var owner;
      owner = this;
      this.target = target;
      this.id = id;
      /*
      		@target.css
      			marginLeft : 0
      			marginRight : 4
      */
      this.target.bind({
        mouseenter: function() {
          if (!isClick) {
            return $(owner).trigger('over', [id]);
          } else {

          }
        },
        mouseleave: function() {
          if (!owner.isSelected) return owner.target.removeClass('current');
        },
        click: function() {
          if (isClick) {
            $(owner).trigger('click', [id]);
            return false;
          }
        }
      });
    }

    SlideThumb.prototype.addCurrent = function() {
      this.isSelected = true;
      return this.target.addClass('current');
    };

    SlideThumb.prototype.removeCurrent = function() {
      this.isSelected = false;
      return this.target.removeClass('current');
    };

    return SlideThumb;

  })();

  if (!window.SlideThumbsContainer) {
    window.SlideThumbsContainer = SlideThumbsContainer;
  }

  if (!window.SlideThumbs) window.SlideThumbs = SlideThumbs;

}).call(this);
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.6
 * 
 * Requires: 1.2.2+
 */


(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

if ($.event.fixHooks) {
    for ( var i=types.length; i; ) {
        $.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
    }
}

$.event.special.mousewheel = {
    setup: function() {
        if ( this.addEventListener ) {
            for ( var i=types.length; i; ) {
                this.addEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = handler;
        }
    },
    
    teardown: function() {
        if ( this.removeEventListener ) {
            for ( var i=types.length; i; ) {
                this.removeEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = null;
        }
    }
};

$.fn.extend({
    mousewheel: function(fn) {
        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },
    
    unmousewheel: function(fn) {
        return this.unbind("mousewheel", fn);
    }
});


function handler(event) {
    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
    event = $.event.fix(orgEvent);
    event.type = "mousewheel";
    
    // Old school scrollwheel delta
    if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
    if ( orgEvent.detail     ) { delta = -orgEvent.detail/3; }
    
    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;
    
    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
        deltaY = 0;
        deltaX = -1*delta;
    }
    
    // Webkit
    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
    
    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);
    
    return ($.event.dispatch || $.event.handle).apply(this, args);
}

})(jQuery);
(function() {
  var GlobalTop, GlobalTopMain, GlobalTopNews;

  GlobalTop = (function() {

    GlobalTop.prototype.campaignPickup = null;

    GlobalTop.prototype.news = null;

    GlobalTop.prototype.main = null;

    function GlobalTop() {
      this.campaignPickup = new SlideThumbsContainer('.slide_thumbs', 4);
      this.news = new GlobalTopNews();
      this.main = new GlobalTopMain();
    }

    return GlobalTop;

  })();

  GlobalTopMain = (function() {

    GlobalTopMain.prototype.WAIT_TIME = 6000;

    GlobalTopMain.prototype.ids = ['mens', 'womens', 'energizer'];

    GlobalTopMain.prototype.elements = {};

    GlobalTopMain.prototype.header = null;

    GlobalTopMain.prototype.items = null;

    GlobalTopMain.prototype.logo = null;

    GlobalTopMain.prototype.nav = null;

    GlobalTopMain.prototype.pagenates = null;

    GlobalTopMain.prototype.pagenate_left = null;

    GlobalTopMain.prototype.pagenate_right = null;

    GlobalTopMain.prototype.past = null;

    GlobalTopMain.prototype.intervalId = null;

    GlobalTopMain.prototype.isOpacity = null;

    function GlobalTopMain() {
      var agent, id, owner, past_obj, smart_phone, _fn, _i, _len, _ref;
      owner = this;
      agent = navigator.userAgent;
      smart_phone = false;
      if (agent.indexOf('Android ') !== -1 || agent.indexOf('iPhone') !== -1 || agent.indexOf('iPad') !== -1) {
        smart_phone = true;
      }
      this.header = $('header');
      this.items = this.header.find('.items');
      this.logo = this.header.find('.logo');
      this.nav = this.header.find('nav');
      this.pagenates = this.header.find('.pagenates');
      this.pagenate_left = this.pagenates.find('.pagenates_left');
      this.pagenate_right = this.pagenates.find('.pagenates_right');
      if (smart_phone) {
        this.pagenates.css({
          visibility: 'visible'
        });
      } else {
        this.pagenates.css({
          display: 'none'
        });
      }
      this.pagenate_left.bind({
        click: function() {
          owner.prev(true);
          return false;
        }
      });
      this.pagenate_right.bind({
        click: function() {
          owner.next(true);
          return false;
        }
      });
      this.items.bind({
        click: function() {
          return owner.next();
        }
      });
      if ($.browser.msie) {
        this.isOpacity = false;
      } else {
        this.isOpacity = true;
      }
      past_obj = null;
      _ref = this.ids;
      _fn = function(id) {
        var obj;
        obj = {
          id: id,
          item: owner.items.find('.' + id),
          logo: owner.logo.find('.' + id),
          nav: owner.nav.find('.' + id)
        };
        if (id !== 'mens') {
          obj['item'].css({
            opacity: 0,
            visibility: 'hidden'
          });
          obj['logo'].css({
            visibility: 'hidden'
          });
          if (owner.isOpacity) {
            obj['logo'].css({
              opacity: 0
            });
          }
          obj['nav'].css({
            visibility: 'hidden'
          });
        } else {
          owner.past = obj;
        }
        obj['logo'].bind({
          mouseenter: function() {
            return owner.stopInterval();
          },
          mouseleave: function() {
            return owner.wait();
          }
        });
        obj['nav'].bind({
          mouseenter: function() {
            return owner.stopInterval();
          },
          mouseleave: function() {
            return owner.wait();
          }
        });
        past_obj = obj;
        return owner.elements[id] = obj;
      };
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        id = _ref[_i];
        _fn(id);
      }
      this.elements['mens']['next'] = this.elements['womens'];
      this.elements['mens']['prev'] = this.elements['womens'];
      this.elements['mens']['next_a'] = this.elements['womens'];
      this.elements['mens']['prev_a'] = this.elements['energizer'];
      this.elements['womens']['next'] = this.elements['mens'];
      this.elements['womens']['prev'] = this.elements['mens'];
      this.elements['womens']['next_a'] = this.elements['energizer'];
      this.elements['womens']['prev_a'] = this.elements['mens'];
      this.elements['energizer']['next'] = this.elements['mens'];
      this.elements['energizer']['prev'] = this.elements['womens'];
      this.elements['energizer']['next_a'] = this.elements['mens'];
      this.elements['energizer']['prev_a'] = this.elements['womens'];
      this.nav.find('ol li a').each(function() {
        var img, img_src, over_src;
        img = $(this).find('img');
        img_src = img.attr('src');
        over_src = '';
        if (img_src.indexOf('on.png') !== -1) {
          over_src = img_src.replace('_on.png', '.png');
        } else {
          over_src = img_src.replace('.png', '_on.png');
        }
        $('<img>').attr('src', over_src);
        return $(this).bind({
          mouseenter: function() {
            var tmp_id;
            tmp_id = $(this).data('id');
            owner.select(tmp_id);
            return owner.stopInterval();
          },
          mouseleave: function() {
            return owner.wait();
          }
        });
      });
      this.wait();
    }

    GlobalTopMain.prototype.wait = function() {
      var owner;
      this.stopInterval();
      owner = this;
      return this.intervalId = setTimeout(function() {
        var tmp;
        tmp = owner.past['next'];
        return owner.select(tmp['id']);
      }, this.WAIT_TIME);
    };

    GlobalTopMain.prototype.stopInterval = function() {
      if (this.intervalId) return clearInterval(this.intervalId);
    };

    GlobalTopMain.prototype.hidePastNav = function(target) {
      return target.css({
        visibility: 'hidden'
      });
    };

    GlobalTopMain.prototype.hidePastLogo = function(target) {
      if (this.isOpacity) {
        return target.stop().animate({
          opacity: 0
        }, 600, 'easeOutQuart');
      } else {
        return target.css({
          visibility: 'hidden'
        });
      }
    };

    GlobalTopMain.prototype.changeNav = function(id) {
      return this.nav.find('ol li a').each(function() {
        var img, tmp_id;
        img = $(this).find('img');
        tmp_id = $(this).data('id');
        if (tmp_id === id) {
          return img.attr('src', 'assets/pages/home/btn_nav_' + tmp_id + '_on.png');
        } else {
          return img.attr('src', 'assets/pages/home/btn_nav_' + tmp_id + '.png');
        }
      });
    };

    GlobalTopMain.prototype.next = function(isA) {
      if (isA == null) isA = false;
      if (isA) {
        return this.select(this.past['next_a']['id']);
      } else {
        return this.select(this.past['next']['id']);
      }
    };

    GlobalTopMain.prototype.prev = function(isA) {
      if (isA == null) isA = false;
      if (isA) {
        return this.select(this.past['prev_a']['id']);
      } else {
        return this.select(this.past['prev']['id']);
      }
    };

    GlobalTopMain.prototype.select = function(id) {
      var item, obj, tmp_past;
      this.stopInterval();
      if (this.past['id'] === id) return;
      this.changeNav(id);
      tmp_past = this.past;
      this.hidePastNav(tmp_past['nav']);
      this.hidePastLogo(tmp_past['logo']);
      obj = this.elements[id];
      obj.nav.css({
        visibility: 'visible'
      });
      item = obj.item;
      this.items.append(item);
      if (window.ios) {
        item.css({
          opacity: 0,
          visibility: 'visible'
        });
        setTimeout(function() {
          return item.get(0).style.cssText = '-webkit-transition-property: opacity; -webkit-transition-duration: 1s; -webkit-transition-timing-function: initial; -webkit-transition-delay: initial; opacity : 1; -webkit-transition-timing-function:' + css_easing['easeOutQuart'] + ';';
        }, 1);
        obj.logo.css({
          opacity: 0,
          visibility: 'visible'
        });
        setTimeout(function() {
          return obj.logo.get(0).style.cssText = '-webkit-transition-property: opacity; -webkit-transition-duration: 0.6s; -webkit-transition-timing-function: initial; -webkit-transition-delay: initial; opacity : 1; -webkit-transition-timing-function:' + css_easing['easeOutQuart'] + ';';
        }, 1);
      } else {
        obj.logo.stop().css({
          visibility: 'visible'
        }).animate({
          opacity: 1
        }, 600, 'easeOutQuart');
        item.stop().css({
          opacity: 0,
          visibility: 'visible'
        });
        item.animate({
          opacity: 1
        }, 1000, 'easeOutQuart');
      }
      this.past = obj;
      return this.wait();
    };

    return GlobalTopMain;

  })();

  GlobalTopNews = (function() {

    GlobalTopNews.prototype.TOP_MARGIN = 30;

    GlobalTopNews.prototype.wrapper = null;

    GlobalTopNews.prototype.container = null;

    GlobalTopNews.prototype.control = null;

    GlobalTopNews.prototype.scroll_max = 0;

    GlobalTopNews.prototype.news_max = 0;

    GlobalTopNews.prototype.news_wrapper = null;

    GlobalTopNews.prototype.news_list = null;

    function GlobalTopNews() {
      var owner;
      owner = this;
      this.wrapper = $('.colums_news>.inner');
      this.container = $('.scrollbar');
      this.control = $('.scrollbar .control');
      this.scroll_max = this.container.height() - this.control.height();
      this.news_wrapper = this.wrapper.find('.inner');
      this.news_list = this.news_wrapper.find('ul');
      this.news_max = this.news_wrapper.height() - this.news_list.height() - this.TOP_MARGIN - 20;
      if (this.news_max >= 0) {
        this.container.css({
          display: 'none'
        });
      } else {
        this.control.draggable({
          axis: 'y',
          containment: this.container,
          drag: function(e, data) {
            return owner.update(data.position.top);
          }
        });
        this.wrapper.bind({
          'mousewheel': function(event, delta, deltaX, deltaY) {
            event.stopPropagation();
            event.preventDefault();
            owner.onScroll(deltaY);
            return false;
          }
        });
      }
    }

    GlobalTopNews.prototype.update = function(target_top) {
      var per;
      per = target_top / this.scroll_max;
      return this.news_list.css({
        top: this.TOP_MARGIN + this.news_max * per
      });
    };

    GlobalTopNews.prototype.onScroll = function(d) {
      var nextY;
      nextY = this.control.position().top - d * 3;
      if (nextY > this.scroll_max) {
        nextY = this.scroll_max;
      } else if (nextY < 0) {
        nextY = 0;
      }
      this.control.css({
        top: nextY
      });
      return this.update(this.control.position().top);
    };

    return GlobalTopNews;

  })();

  window.GlobalTop = GlobalTop;

}).call(this);

