var SECTION_CODE = "SECTION_CODE";
var ITEM_ID = "ITEM_ID";
var jump = "jump";
$(document).ready(function(){
	
	_item_id = $("#"+ITEM_ID);
	if (_item_id.children().length < 2)
	{
		$("#"+jump).attr("disabled", 1);
		_item_id.attr("disabled", 1);
	}
	else
	{
		$("#"+jump).removeAttr("disabled");
		_item_id.removeAttr("disabled");
	}	
		
	
	$("#"+SECTION_CODE).removeAttr("disabled").change(function(){
		_this = $(this);
		_item_id = $("#"+ITEM_ID);
		if (_this.val())
		{
			_item_id.load(items_loader, {
				  'IBLOCK_ID':IBLOCK_ID
				, 'SECTION_CODE':_this.val()
				, 'SORT_BY3': SORT_BY3
				, 'SORT_ORDER3': SORT_ORDER3
				, 'SORT_BY4': SORT_BY4
				, 'SORT_ORDER4': SORT_ORDER4
			},
			function (responseText, textStatus, XMLHttpRequest) {
				if (_item_id.children().length == 0)
				{
					$("#"+jump).attr("disabled", 1);
					_item_id.attr("disabled", 1);
					$("#"+jump).attr("disabled", 1);
				}
				else
				{
					$("#"+jump).removeAttr("disabled");
					_item_id.removeAttr("disabled");
					$("#"+jump).removeAttr("disabled");
				}
			}
			);
		}
		else
		{
			$("option[value!='']", _item_id).remove();
			_item_id.attr("disabled", 1);
			$("#"+jump).attr("disabled", 1);
		};
				
	});
	
	
});