// Подбор по параметрам
$(document).ready(function(){
// Ползунки
	$('#trackbar').trackbar({
		onMove : function() {
		$("#door_price_from").text(this.leftValue);
		$("#door_price_to").text(this.rightValue);
		},
		//dual : false, // two intervals
		width : 500, // px
		leftLimit : parseInt($("#door_price_from").text()), // unit of value
		leftValue : 6000, // unit of value
		rightLimit : parseInt($("#door_price_to").text()), // unit of value
		rightValue : 18000, // unit of value
		//showSmallTicks : true,
		showBigTicks : true,
		roundUp : 500,
		//bigTicks : 1,
		hehe : ":-)"
	});
	
// Выбор типа дверей
	$("#door_type").click(function(){
		var curr_type = $("#" + $(this).attr("name"));
		var next_type = "";
		if(curr_type.is(":last-child"))
			 next_type = $("#types_list li:first-child");
		else
			 next_type = curr_type.next();
		$(this).attr("name", next_type.attr("id"));
		$(this).text(next_type.text());
	});
	
// Отправка параметров побора дверей
	$("#suit").click(function(){
		//var path = "http://dverko.ru/podbor/";
		/*path += "?price_from=" + $("#door_price_from").text();
		path += "&price_to=" + $("#door_price_to").text();
		path += "&type=" + $("#door_type").attr("name");*/
		
		if($("#selection").length) $("#selection").remove();
		
		$("body").append("\n<form id='selection' action='http://dverko.ru/suit/' method='POST' class='hidden'></form>\n");
		$("#selection").append("<input type='hidden' name='price_from' value='" + $("#door_price_from").text() + "'>\n");
		$("#selection").append("<input type='hidden' name='price_to' value='" + $("#door_price_to").text() + "'>\n");
		$("#selection").append("<input type='hidden' name='type' value='" + $("#door_type").attr("name") + "'>");
		$("#selection").submit();
		return false;
		//window.location.href = path;
	});
});
