var Store = {
	
	init: function() {
		$('a.swatch').click(function(){		$('li.selected').removeClass('selected');
									 		$(this).parent().addClass('selected');
									 		Store.ChangeProduct($(this).attr('id').getNum());
											$('#sku-form').val($(this).attr('rel'));
											return false;
										});
	},
	
	
	ChangeProduct: function(id) {
		$.getJSON(root_path+"/product_ajax.cfm?id="+id, function(json){
			$('span#product-name').html(json.NAME);
			$('#main-image').attr('src', json.MAIN_IMAGE);
			
			
			if (json.REFILL_IMAGE != undefined) {
				$('#refill-image').show();
				$('#refill-image').attr('src', json.REFILL_IMAGE);
			} else {
				$('#refill-image').hide();
			}
			
			$('p#description').html(json.DESCRIPTION);
		});
	}
	
	
	
};


String.prototype.getNum = function() {
	return this.split('-')[1];
}



$(document).ready(function() {
	Store.init();
	


	$('.project-month').css("height", ($('.homepage-menu').height()-26) + "px");


	$("a.zoom").fancybox({	'overlayShow'			: false,
						 	'zoomOpacity'			: true,
							'overlayShow'			: false,
							'zoomSpeedIn'			: 300,
							'zoomSpeedOut'			: 200,
							'padding'				: 0

						 
						   });
	
});
