$(document).ready(function(){
	
	$('.s_list').tablesorter();
	$('.s2').change(function(){$("form[filter]").submit();});
	$('#predm').change(function(){
	var datar = $.ajax({
	 url: "?ajax=get_sprav",
	 data: "id="+$("#predm").val(),
	 dataType: "html",
	 async: false
	}).responseText;
	$('#predm_sub').empty();
	$('#predm_sub').append(datar);
});

$('#change_price').click(function(){
	$("input#change_price").attr("disabled", true);
	var id = '';
	$(".cp").each(function(){
		if ($(this).attr("checked"))
			id += $(this).attr("id")+',';
	});
	var price = $.ajax({
	 type: "POST",
	 url: "?ajax=change_price",
	 data: "id="+id+"&delta="+$("#delti").val()+"&perc="+$("#peri").val(),
	 dataType: "html",
	 async: false
	}).responseText;
	if (price != "1") {$("input#change_price").attr("style", "border: 1px solid red");alert(price);}
	else {$("input#change_price").removeAttr("style");}
	
	$("input#change_price").attr("disabled", false);
});
$(".set_all").toggle(
	function(){
		$("input").each(function(){
			$(this).attr("checked",true);
		});},
	function(){
	$("input").each(function(){
		$(this).attr("checked", false);
		});
	});
$("#delti").attr("readonly", "readonly");

$(".sel").change(function(){
	$("#delti").attr("readonly", true);
	$("#peri").attr("readonly", true);
	$("#delti").val("");
	$("#peri").val("");
	$("#"+$(this).attr("id")+"i").attr("readonly", false);
	$("#"+$(this).attr("id")+"i").focus();
});	

$("a.bk").click(function(){history.go(-2);});
$("a.chp").click(function(){$("#admin").toggle();});

$("input.searchWork").keyup(function(){
	//alert("a#w"+$(this).val());
	$("a#w"+$(this).val()).focus().addClass("use");
	$(this).focus();
});
	
	
});

	function check_srok() {
		
		obj1 = document.getElementById('crok');
		obj = document.getElementById('srk');
		if (obj1.value == "other")
		obj.style.display = "block";
		else
		obj.style.display = "none";
	}
function show(id) {
	
	obj = document.getElementById(id);


	if (obj.style.display == "none")
	
	{
		obj.style.display="block";
	}
	else
	obj.style.display="none";
}
