$(document).ready(function(){
	function getRelatedProducts(id) {
		var values = ''; 
		values = "id=" + id;
		values += "&type=" + $("#type").val();
		
		$.post("/en/order/ajaxGetRelatedProducts", values, function(data){
			var value = '';
			$("product", data).each(function(i) {
				var id = $("id", this).text();
				var ident = $("ident", this).text();
				var name = $("name", this).text();
				var type = $("type", this).text();
				var slots = $("slots", this).text();
				var slotsPresent = $("slotsPresent", this).text();
				var price = $("price", this).text();
				var pricePresent = $("pricePresent", this).text();
				var image = $("image", this).text();
				var location = $("location", this).text();
				var rental = $("rental", this).text();
				var language = $("#language").val();
				
				value += "<input type='hidden' name='" + id + "_url' id='" + id + "_url' value='" + ident + "' />";
				value += "<input type='hidden' name='" + id + "_name' id='" + id + "_name' value='" + name + "' />";
				value += "<input type='hidden' name='" + id + "_type' id='" + id + "_type' value='" + type + "' />";
				value += "<input type='hidden' name='" + id + "_slots' id='" + id + "_slots' value='" + slots + "' />";
				value += "<input type='hidden' name='" + id + "_rental' id='" + id + "_rental' value='" + rental + "' />";
				value += "<input type='hidden' name='" + id + "_location' id='" + id + "_location' value='" + location + "' />";
				
				value += "<div style='text-align: center;' class='light'><a href='/" + language + "/products/" + ident + "' class='light'>";
				value += "<br /><br />";
				value += "<img src='/images/products/" + ident + ".png' border='0' /><br />";
				value += "<b>" + name + "</b><br />";
				value += slotsPresent + " " + type + " / " + pricePresent;
				value += "</a></div>";
			});
			
			$("#relatedProducts_container").html(value);
			
			$("#relatedProducts_container input").bind("click", function() {
				var product = $("#" + $(this).attr('name') + "_url").val();
				var location = $("#" + $(this).attr('name') + "_location").val();
				var type = $("#" + $(this).attr('name') + "_type").val();
				var slots = $("#" + $(this).attr('name') + "_slots").val();
				var rental = $("#" + $(this).attr('name') + "_rental").val();
				
				addProductToCart(product, location, type, slots, rental);
			});
		});
	}
	
	$("#type").change(function() {
		if($(this).val() == "public") {
			$("#privateprices").hide();
			$("#publicprices").show();
		}
		else {
			$("#privateprices").show();
			$("#publicprices").hide();
		}
	});
	
	//getRelatedProducts($("#product").val());
	
});
