Event.observe(window, 'load', function() {
	resize_cart();
});

Event.observe(window, 'resize', function() {
	resize_cart();
});

Ajax.busyCount = 0;
Ajax.Responders.register({
  onCreate: function() {
    $(document.body).addClassName('ajax-busy');
    Ajax.busyCount++;
  },
  onComplete: function() {
    Ajax.busyCount--;
    if (Ajax.busyCount == 0) {
      $(document.body).removeClassName('ajax-busy');
    }
  }
});

function resize_cart() {
	var cart = $('cart');
	if (cart) {
		var viewport = vp();
		$('cart_items').style.height = (viewport[1] - 390) + 'px';
		cart.style.display = 'block';
	}
}

function vp() {
	var x, y;
	
	if (self.innerHeight) {
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	
	return [x, y];
}
