jQuery(document).ready(function($) { try {
	
	var compareUrl = $('#compare_form').attr("action");
	
	var size = function () {
	  r = $(".compare-box input:checked").size(); 
		return r;
	}


$('#compare_form .compare-box input').click(function () {
		if (size() > max) { alert(err); return false; } else {
		  //$(this).parent('label').toggleClass("added");
		  $(this).parent().parent("div.compare-box").toggleClass("added");
		}
		if ($(this).is(":checked")) {
			$(this).next('span').bind('click', productList).text(activeTxt);
			
		} else {
			$(this).next('span').unbind('click', productList).text(passiveTxt)
		}
	});

} catch (err) {
	//if(window.console) { window.console.log(err) }
	//return false;
}

	function productList() {
		if (size() > 0) {
			prods = function () {
				var d = "";
				$("#compare_form .compare-box input:checked").each(function(index) {
					d = d + $(this).val();
					if ((index + 1) != size()) {
						d = d + ",";
					}
				});
				return d;
			}
			// the extra commas make it easier to remove product IDs reliably - RBJ
			document.location = compareUrl + prods()
		};
		return false;
	}

});
