function visOfDiv(id, ths, status) {
	obj = document.getElementById(id);
	
	if ( status == 1 ) {
		// Отображаем
		obj.style.display = 'block';
	} else {
		// Скрываем
		obj.style.display = 'none';
	}
}

//Функции для автокомплита
function findValue(li) {
		if( li == null ) return alert("No match!");

		// if coming from an AJAX call, let's use the CityId as the value
		if( !!li.extra ) var sValue = li.extra[0];

		// otherwise, let's just display the value in the text box
		else var sValue = li.selectValue;

		//alert("The value you selected was: " + sValue);
	}

	function selectItem(li) {
		findValue(li);
	}

	function formatItem(row) {
		return row[0] ;
	}

	function lookupAjax(){
		var oSuggest = $("#inp")[0].autocompleter;
		oSuggest.findValue();
		return false;
	}

	function ChangeSumm() {
		var isUncomplete = true;
		var countprod=0;
		var price = $("input[name='price_kol']").val();
		var summ=0;
		var summtext;
		$("input.kolvo").each(function (index, domEle) {
		var value = $(this).val();
		var isUncompleteloc = false;
		var oRegExp = /^[0-9]*$/;
		isUncompleteloc=oRegExp.test(value) ? false : true;
		if(isUncompleteloc) isUncomplete = false;
		else if (value) countprod = countprod*1 + value*1;
		});
		if (isUncomplete) {
		$("input#DobToZak").removeAttr('disabled');
		}else{
		$("input#DobToZak").attr('disabled', 'disabled');
		}
		if(countprod*1<1){
			$("input#DobToZak").attr('disabled', 'disabled');
		}
		summ=countprod*price;
		if(summ>0){
			summtext='<br /> Сумма: '+ summ + ' руб.';
		}else{
			summtext='';
		}
		$("div.summ").html("Общее количество: " + countprod + summtext);
		}
	
$(document).ready(function() {
	$("input#DobToZak").attr('disabled', 'disabled');
	
	 $("input.kolvo").keyup(ChangeSumm); 
});



$(function() {
    $(".button").click(function() {
        var $button = $(this);
        var oldValue = $button.parent().find("input").val();
        if (oldValue =="") {
        	oldValue=0;
        }
    
        if ($button.text() == "+") {
    	  var newVal = parseFloat(oldValue) + 1;
    	  // AJAX save would go here
    	} else {
    	  // Don't allow decrementing below zero
    	  if (oldValue >= 1) {
    	      var newVal = parseFloat(oldValue) - 1;
    	      // AJAX save would go here
    	  }
    	}
    	$button.parent().find("input").val(newVal);
    	ChangeSumm();
    	
    });
    //$(".button").mouseup(ChangeSumm);
});

