var root;
var __slice = Array.prototype.slice;
Number.prototype.seconds = function() {
  return this * 1000;
};
Number.prototype.minutes = function() {
  return this.seconds() * 60;
};
Number.prototype.minute = Number.prototype.minutes;
Number.prototype.hours = function() {
  return this.minutes() * 60;
};
Number.prototype.hour = Number.prototype.hours;
Number.prototype.ago = function() {
  return new Date(new Date().valueOf() - this);
};
Number.prototype.from_now = function() {
  return new Date(new Date().valueOf() + this);
};
window.module = function(target, name, block) {
  var item, top, _i, _len, _ref, _ref2;
  if (arguments.length < 3) {
    _ref = [(typeof exports !== 'undefined' ? exports : window)].concat(__slice.call(arguments)), target = _ref[0], name = _ref[1], block = _ref[2];
  }
  top = target;
  _ref2 = name.split('.');
  for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
    item = _ref2[_i];
    target = target[item] || (target[item] = {});
  }
  return block(target, top);
};
root = $('body').first().attr('root');
window.module("Constants", function(exports) {
  return exports.root = function() {
    return $('body').first().attr('root');
  };
});
window.module("Slideshow", function(exports) {
  exports.init = function() {
    this.home();
    this.projects();
    this.clients();
    this.services();
    return false;
  };
  exports.services = function() {
    $('#products .slide').show();
    $('#products .center').slides({
      play: 11000,
      generateNextPrev: false,
      generatePagination: false,
      hoverPause: true
    });
    return false;
  };
  exports.clients = function() {
    $('#clients .slide').show();
    $('#clients .center').slides({
      play: 11000,
      generateNextPrev: true,
      generatePagination: true,
      hoverPause: true
    });
    return false;
  };
  exports.projects = function() {
    $('#projects .slide').show();
    $('#projects .center').slides({
      play: 8000,
      generateNextPrev: true,
      generatePagination: true,
      hoverPause: true
    });
    return false;
  };
  return exports.home = function() {
    $('#testimonials .slide').show();
    $('#testimonials').slides({
      play: 18000,
      generateNextPrev: true,
      generatePagination: false,
      effect: "fade"
    });
    $('#recent-projects .slide').show();
    $('#recent-projects #slideshow').slides({
      play: 6000,
      generateNextPrev: true,
      generatePagination: false
    });
    return false;
  };
});
window.module("EstimateForm", function(exports) {
  exports.init = function() {
    this.populateSpecs();
    return false;
  };
  return exports.populateSpecs = function() {
    var quantity, service, size, stock, text;
    size = $('#size_params') ? $('#size_params').text() : '';
    stock = $('#stock_params') ? $('#stock_params').text() : '';
    quantity = $('#quantity_params') ? $('#quantity_params').text() : '';
    service = $('#service_params') ? "Services: " + $('#service_params').text() : '';
    text = $('#estimate_specs').text();
    $('#estimate_specs').val(text.replace('Size:', "Size: " + size).replace('Quantity:', "Quantity: " + quantity).replace('Stock:', "Stock: " + stock) + service);
    return false;
  };
});
window.module("DatePicker", function(exports) {
  return exports.init = function() {
    $.each($('.datepicker'), function() {
      var value;
      value = $(this).val();
      if ($(this).hasClass('future')) {
        return $(this).glDatePicker({
          startDate: new Date(value),
          allowOld: false,
          selectedDate: 0
        });
      } else {
        return $(this).glDatePicker();
      }
    });
    return false;
  };
});
window.module("DropdownMenus", function(exports) {
  exports.init = function() {
    this.estimate();
    this.browseProducts();
    return false;
  };
  exports.browseProducts = function() {
    $('.menu_redirect select').change(function() {
      return window.location = $(this).val();
    });
    return false;
  };
  return exports.estimate = function() {
    var product_menu;
    product_menu = $('#estimate_product_id');
    if (product_menu) {
      product_menu.change(function() {
        var id;
        id = $(this).val();
        console.log(id);
        return $.ajax({
          url: "" + (Constants.root()) + "products/" + id + "/specs.html",
          cache: false,
          success: function(html) {
            return $("#estimate_specs").val(html);
          }
        });
      });
    }
    return false;
  };
});
$(window).load(function() {
  DropdownMenus.init();
  EstimateForm.init();
  DatePicker.init();
  Slideshow.init();
  return false;
});
