(function($){

  var sliderInterval = setInterval(switchToNext, 7500);

  $(document).ready(function() {
    switchTo($("#slider-controls .slider-control:first-child").attr("nid"));
    $(".slider-control").click(function() {
      switchTo($(this).attr("nid"));
    });
  });
  
  function getNext() {
    var nid = $(".slider-control.current").next().attr("nid");
    if (nid == undefined) {
      nid = $("#slider-controls .slider-control:first-child").attr("nid");
    }
    return nid;
  }

  function switchTo(nid) {
    clearInterval(sliderInterval);
    var nextPanel = $(".slider-panel[nid=" + nid + "]");
    var nextControl = $(".slider-control[nid=" + nid + "]");
    $(".slider-control").removeClass("current");
    nextControl.addClass("current");
    if (nextPanel.html() == "") {
      $.getJSON("/promo/" + nid, function (data) {
        nextPanel.html(data);
	slideTo(nextPanel, nextControl);
      });
    } else {
      slideTo(nextPanel, nextControl);
    }
    sliderInterval = setInterval(switchToNext, 7500);
  }

  function slideTo(nextPanel, nextControl) {
    nextPanel.css('visibility','visible').hide().fadeIn("fast", "linear", function() {
      $("#slider-panels").stop().animate({left: '-' + nextPanel.position().left + 'px'}, 1000);
    });
  }

  function switchToNext() {
    switchTo(getNext());
  }
})(jQuery);
;
(function($){
  $(window).load(function () {
    $.getScript('/sites/all/modules/custom/lc_retail_hp/js/twitter.widget.js', function () {
      $.getScript('/sites/all/modules/custom/lc_retail_hp/js/twitter.js');
    });
  });
})(jQuery);
;
(function($){
  $(document).ready(function () {
    setTimeout(updateCount, 2000);
    if ($("body").hasClass("logged-in")) {
      var interval = setInterval(updateCount, 5000);
    }
  });
    
  function updateCount() {
    $.getJSON("/problemsolved/count", function (data) {
      $(".digit").each(function (i) {
        var digit = $(this);
        var valNow = parseInt(digit.attr("val"));
        var valNext = data[i];
        if (valNow != valNext) {
          digit.hide(0, function () {
            $(this).attr("val", valNext).removeClass("digit" + valNow).addClass("digit" + valNext).show("clip");
          });
        }
      });
    });
  }
})(jQuery);
;

/*
 * jQuery UI Effects Clip 1.8.7
 *
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Effects/Clip
 *
 * Depends:
 *	jquery.effects.core.js
 */
(function(b){b.effects.clip=function(e){return this.queue(function(){var a=b(this),i=["position","top","left","height","width"],f=b.effects.setMode(a,e.options.mode||"hide"),c=e.options.direction||"vertical";b.effects.save(a,i);a.show();var d=b.effects.createWrapper(a).css({overflow:"hidden"});d=a[0].tagName=="IMG"?d:a;var g={size:c=="vertical"?"height":"width",position:c=="vertical"?"top":"left"};c=c=="vertical"?d.height():d.width();if(f=="show"){d.css(g.size,0);d.css(g.position,c/2)}var h={};h[g.size]=
f=="show"?c:0;h[g.position]=f=="show"?0:c/2;d.animate(h,{queue:false,duration:e.duration,easing:e.options.easing,complete:function(){f=="hide"&&a.hide();b.effects.restore(a,i);b.effects.removeWrapper(a);e.callback&&e.callback.apply(a[0],arguments);a.dequeue()}})})}})(jQuery);
;

