$(function() {
	$("#tree").treeview({
		collapsed: true,
		animated: "medium",
		unique: true,
		control:"#sidetreecontrol",
		persist: "location"
	});
})

$(document).ready(function(){
	$("input.intvalue").keyup( function() {

	price_id = $(this).attr("id");
	price_value = $(".price_"+price_id).attr("value");
	product_count = $(this).attr("value");
	all_price = price_value*product_count;

	all_price = Math.round(all_price*Math.pow(10,2))/Math.pow(10,2);

	$("#price_count_"+price_id).attr("value",product_count);

	$("#all_price_"+price_id).html(all_price);
	
	summ = parseFloat(0);
	$(".product_summ").each(function () {
		summ = summ + parseFloat($(this).text());
	});
	
	summ = Math.round(summ*Math.pow(10,2))/Math.pow(10,2);
	$("#cart_total").html(summ);
	//alert(price_id);
	 // alert($(".price_"+price_id).attr("value"));
	});
	
	$("input.intvalue").keypress( function(evt) {
		var charCode = ( evt.which != null ) ? evt.which : event.keyCode
		return (charCode < 32 || (charCode >= 48 && charCode <= 57))
					
	});


	$('#inputDate').DatePicker({
		format:'Y-m-d',
		date: $('#inputDate').val(),
		current: $('#inputDate').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
		},
		onChange: function(formated, dates){
			$('#inputDate').val(formated);
			$('#inputDate').DatePickerHide();
		}
	});
	
	$('#inputDate2').DatePicker({
		format:'Y-m-d',
		date: $('#inputDate2').val(),
		current: $('#inputDate2').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#inputDate2').DatePickerSetDate($('#inputDate2').val(), true);
		},
		onChange: function(formated, dates){
			$('#inputDate2').val(formated);
			$('#inputDate2').DatePickerHide();
		}
	});
	
	$('#show_form').click(function () { 
      if ($('#search_form').css('display')=='none'){
    	  $('#search_form').css('display','block');
      }else{
    	  $('#search_form').css('display','none');
      } 
      return false;
    });

	$('.empty_search').click(function () { 
	      if ($('#search_form').css('display')=='none'){
	    	  $('#search_form').css('display','block');
	      }else{
	    	  $('#search_form').css('display','none');
	      } 
	      return false;
	    });
	
	
});

