function do_calculation1(tField) 
{
	if( tField=="hb1value" )
	{
		housevalue = $('hb1value').value;
		first2 = $('hb1first2').value;
		first1 = $('hb1first1').value;
		
		if( (first2 == 0)&&(first1!=0) ) $('hb1first2').value = first1 * housevalue / 100;
			
		if( first2!=0 )  $('hb1first1').value = first2 * 100 / housevalue;

		tempInterest = $('hb1first1').value;

		first2 = $('hb1first2').value;	
		$('hb1credit').value = housevalue - first2;
	}

	if (tField=="hb1first1")
	{
		interest = $('hb1first1').value;
		housevalue = $('hb1value').value;
		
		$('hb1first2').value = interest * housevalue / 100;
		$('hb1credit').value = housevalue - $('hb1first2').value;
	}

	if (tField=="hb1first2")
	{
		first2 = $('hb1first2').value;
		housevalue = $('hb1value').value;
		
		tempInterest = first2 * 100 / housevalue;
		
		$('hb1first1').value = first2 * 100 / housevalue ;
		$('hb1credit').value = housevalue - document.getElementById('hb1first2').value;
	}

	if (tField=="hb1credit")
	{
		credit = $('hb1credit').value;
		housevalue = $('hb1value').value;
		
		$('hb1first2').value = housevalue - credit;
		$('hb1first1').value = $('hb1first2').value * 100 / housevalue ;
		
		tempInterest = $('hb1first1').value;
		/*if (tempInterest < defInterest)
		{
			$('hb1first1').value = defInterest;
			$('hb1first2').value = defInterest * housevalue / 100;
			$('hb1credit').value = housevalue - $('hb1first2').value;
		}*/
	}

	pricipal = $('hb1credit').value / $('hb1years').value / 12;
	interest = $('hb1credit').value * $('hb1interest').value / 100 / 12 ;

//	var kas= $('hb1credit').value;
//	var pross = $('hb1interest').value/1200;
//	var menesi = $('hb1years').value*12;
//	var k = 1+pross;
//
//	if( kas && pross && menesi ) 
//	{
//		pw = Math.pow(k,menesi);
//		kopa = kas*(pross*pw)/(pw-1);
//
//		$('hb1total').value = kopa ;
//	}


	$('hb1value').   value = Math.round( $('hb1value').value );
	$('hb1first1').  value = Math.round( $('hb1first1').value*10 )/10;
	$('hb1first2').  value = Math.round( $('hb1first2').value );
	$('hb1credit').  value = Math.round( $('hb1credit').value );
	$('hb1interest').value = Math.round( $('hb1interest').value*1000 )/1000;
	$('hb1years').   value = Math.round( $('hb1years').value );
//	$('hb1total').   value = Math.round( $('hb1total').value );
	$('hb1total').value=Math.round( pricipal+interest );
}

function do_calculation2( tField ) 
{
	years = $('hb1years').value;
	interest = $('hb1interest').value;
	payment = $('hb1total').value;
	
	$('hb1credit').value =  payment / ( (1/(12*years)) + (interest/1200) );

	$('hb1value').value = ($('hb1credit').value * 1) + ($('hb1first2').value * 1) ;
	$('hb1first1').value = $('hb1first2').value * 100 / $('hb1value').value ;
	
	$('hb1value').   value = Math.round( $('hb1value').value );
	$('hb1first1').  value = Math.round( $('hb1first1').value*10 )/10;
	$('hb1first2').  value = Math.round( $('hb1first2').value );
	$('hb1credit').  value = Math.round( $('hb1credit').value );
	$('hb1interest').value = Math.round( $('hb1interest').value*1000 )/1000;
	$('hb1years').   value = Math.round( $('hb1years').value );
	$('hb1total').   value = Math.round( $('hb1total').value );
}

function setCurrency( currency )
{
	$('currency').set(  'html',currency );
	$('currency1').set( 'html',currency );
	$('currency2').set( 'html',currency );
}

function setPrice( price, currency, curname, years )
{
	$('mycalc').style.display="block";
	
	$('hb1years').value=years;
	$('hb1value').value=price;
	$('curr_base').options[currency].selected=true;
	
	setCurrency( curname );
	
	do_calculation1('hb1value');
}


