$(document).ready(function(){   
	
	init_product_finder();

});

function refresh_product_finder() {
	
	$("#productfindertype").change(function () {
		$("#productfindertype").unbind("change");
		init_product_finder();
	});

	$("#box1").click(function () {
		var value = $(this).attr("value");
		if (value == parseInt(value)) {
			$("#box1").unbind("click");
			$("#box2").load("/includes/inc.productfinder.php", {box:2, tag:value, type:$("#productfindertype").attr("value")}, function() {
				$("#box3").html("");																														
				refresh_product_finder();
			});
		}
	});
	
	$("#box2").click(function () {
		var value = $(this).attr("value");
		if (value == parseInt(value)) {
			$("#box2").unbind("click");		
			$("#box3").load("/includes/inc.productfinder.php", {box:3, tag:value, type:$("#productfindertype").attr("value")}, function() {
				refresh_product_finder();
			});
		}
	});
	
	$("#box3").click(function () {
		document.location = $(this).attr("value");
	});

}

function init_product_finder() {
	
	$("#box1").load("/includes/inc.productfinder.php", {box:1, type:$("#productfindertype").attr("value")}, function() {
		$("#box2").html("");																														
		$("#box3").html("");																														
		refresh_product_finder();
	});

}