
function calcClass(){
	
	this.calcExp = function(){
		
		count1 = $j('#count1').val();
		price1 = $j('#price1').val();
		count2 = $j('#count2').val();
		price2 = $j('#price2').val();
		
		$j.ajax({
		    url: '/calculator/calcexp',
		    type: 'post',
		    data: 'count1=' +count1 + '&price1=' + price1 + '&count2=' + count2 + '&price2=' + price2,
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#sum1').val(data.sum1);
				$j('#sum2').val(data.sum2);
				$j('#sumAll1').val(data.sumAll);
				setTimeout(function(){
		    		calcAll();
		    	}, 500)
		    }
		});
		
	}
	
	this.calcRep = function(){
		
		repOilSum = $j('#repOilSum').val();
		repFiltrSum = $j('#repFiltrSum').val();
		repFiltrGazSum = $j('#repFiltrGazSum').val();
		repBrake1Sum = $j('#repBrake1Sum').val();
		repBrake2Sum = $j('#repBrake2Sum').val();
		repTires = $j('#repTires').val();
		repOther1Sum = $j('#repOther1Sum').val();
		repOther2Sum = $j('#repOther2Sum').val();
		repOther3Sum = $j('#repOther3Sum').val();
		
		$j.ajax({
		    url: '/calculator/calcrep',
		    type: 'post',
		    data: 'repOilSum=' +repOilSum + '&repFiltrSum=' + repFiltrSum + '&repFiltrGazSum=' + repFiltrGazSum + '&repBrake1Sum=' + repBrake1Sum + '&repBrake2Sum=' + repBrake2Sum + '&repTires=' + repTires+ '&repOther1Sum=' + repOther1Sum+ '&repOther2Sum=' + repOther2Sum + '&repOther3Sum=' + repOther3Sum,
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#sumAll2').val(data.sumAll);
		    	setTimeout(function(){
		    		calcAll();
		    	}, 500)
		    }
		});
		
	}
	
	this.calcRepair = function(){
		
		repEngineSum1 = $j('#repEngineSum1').val();
		repEngineSum2 = $j('#repEngineSum2').val();
		repDriveSum1 = $j('#repDriveSum1').val();
		repDriveSum2 = $j('#repDriveSum2').val();
		repDriveGazSum1 = $j('#repDriveGazSum1').val();
		repDriveGazSum2 = $j('#repDriveGazSum2').val();
		repBodySum1 = $j('#repBodySum1').val();
		repBodySum2 = $j('#repBodySum2').val();
		repOtherSum1 = $j('#repOtherSum1').val();
		repOtherSum2 = $j('#repOtherSum2').val();
		
		$j.ajax({
		    url: '/calculator/calcrepair',
		    type: 'post',
		    data: 'repEngineSum1=' +repEngineSum1 + '&repEngineSum2=' + repEngineSum2 +
		    		'&repDriveSum1=' + repDriveSum1 + '&repDriveSum2=' + repDriveSum2 + 
		    		'&repDriveGazSum1=' + repDriveGazSum1 + '&repDriveGazSum2=' + repDriveGazSum2+ 
		    		'&repBodySum1=' + repBodySum1+ '&repBodySum2=' + repBodySum2 + 
		    		'&repOtherSum1=' + repOtherSum1 + '&repOtherSum2=' + repOtherSum2,
		    		
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#sumAll3').val(data.sumAll);
		    	setTimeout(function(){
		    		calcAll();
		    	}, 500)
		    }
		});
		
	}
	
	this.calcConst = function(){
		
		constInsSum = $j('#constInsSum').val();
		constTechSum = $j('#constTechSum').val();
		constOtherSum = $j('#constOtherSum').val();
		
		
		$j.ajax({
		    url: '/calculator/calcconst',
		    type: 'post',
		    data: 'constInsSum=' +constInsSum + '&constTechSum=' + constTechSum + '&constOtherSum=' + constOtherSum,
		    		
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#sumAll4').val(data.sumAll);
		    	setTimeout(function(){
		    		calcAll();
		    	}, 500)
		    }
		});
		
	}
	
	this.calcOther = function(){
		
		otherCost1 = $j('#otherCost1').val();
		otherCost2 = $j('#otherCost2').val();
		otherCost3 = $j('#otherCost3').val();
		
		
		$j.ajax({
		    url: '/calculator/calcother',
		    type: 'post',
		    data: 'otherCost1=' +otherCost1 + '&otherCost2=' + otherCost2 + '&otherCost3=' + otherCost3,
		    		
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#sumAll5').val(data.sumAll);
		    	setTimeout(function(){
		    		calcAll();
		    	}, 500)
		    }
		});
		
	}
	
	function calcAll(){
		
		sumAll1 = $j('#sumAll1').val();
		sumAll2 = $j('#sumAll2').val();
		sumAll3 = $j('#sumAll3').val();
		sumAll4 = $j('#sumAll4').val();
		sumAll5 = $j('#sumAll5').val();
		
		
		$j.ajax({
		    url: '/calculator/calallcost',
		    type: 'post',
		    data: 'sumAll1=' +sumAll1 + '&sumAll2=' + sumAll2 + '&sumAll3=' + sumAll3 + '&sumAll4=' + sumAll4 + '&sumAll5=' + sumAll5,
		    		
		    dataType: 'json',
		    timeout: 1000,
		    error: function(){
		        //alert('somethig went wrong !!');
		    },
		    success: function(data){
		    	$j('#allCost').html(data.sumAll);
		    }
		});
		
	}
	
	this.hideAndShow = function(idDes){
		if(document.getElementById(idDes).style.display == "none"){
			$j("#"+idDes).show("normal")
		}else{
			$j("#"+idDes).hide("slow")
		}
	}
	
}

calc = new calcClass;