/**
 * Updates the Per-Page select when per page var is available
 * @desc Builds the add to cart buttons
 * @author Doug Hill doug@zagg.com
 * @since 05.21.2010
 */
var PerPage = Class.create({
	initialize: function(json){
		this.perpage = json.per_page;
		this.form = json.form;
		this.updateDrop();
		this.observeDiv();
	},
	updateDrop: function(){
		$$('#'+this.form+' option').each(function(opt){
			if(opt.value == this.perpage){
				opt.selected = true;
			}
		}.bind(this));
	},
	observeDiv: function(){
		$$('#'+this.form+' select').each(function(sel){
			sel.observe('change', function(){
				this.form.submit();
			});
		});
	}
});
