(function(){
    jQuery.getScript(('https:' == document.location.protocol ? 'https:' : 'http:') + '//connect.facebook.net/en_US/all.js', function(){
        FB.init({status: true, cookie: true, xfbml: true});
    });
})();

jQuery().ready(function(){
    // expand and collapse cart
    jQuery(".cart-top a").click(function(){
        if(jQuery(".block-cart").hasClass("expanded")){
            jQuery(".block-cart").removeClass("expanded");
            jQuery(".cart-top .qty span").html("Expand");
        } else {
            jQuery(".block-cart").addClass("expanded");
            jQuery(".cart-top .qty span").html("Collapse");
        }
        return false;
    });
});

(function($){
    var checkImages = {
      src : '',
      check : function() {
         var img = new Image(), count = 0, obj = this;
         var t = setInterval(
             function() {
                return function() {
                  if(img.complete) {
                     clearInterval(t);
                     obj.setClass(Boolean(img.width));
                  } else {
                     if(count == 10) {
                        obj.setClass(false);
                        img.onload = function() {
                          obj.setClass(true);
                        };
                        clearInterval(t);
                     } else {
                        count++;
                     }
                  }
                }
             }(), 30);
         img.onerror = function() {
             obj.setClass(false);
         };
         img.src = checkImages.src;
      },
      setClass :function(imagesEnabled){
          if(!imagesEnabled){
              $('html').removeClass('images').addClass('no-images');
          } else {
              $('html').removeClass('no-images').addClass('images');
          }
      }
    }
    checkImages.src = SKIN_URL + '/images/toms.png';
    checkImages.check();
})(this.jQuery);


