function forma(txt){
	txt=txt.toString();
	m=0;
	x="";
	for(i=txt.length-1;i>=0;i--){
		x=txt.substring(i,i+1)+x;
		if(m==2)
			x=" "+x;
		m++;
		if(m==3) m=0;
	}
	return x;
}

function calc_price()
{
   	otdelka = calc.elements['otdelka'].value;
   	square = calc.elements['square'].value;
        materin = "none";
           
   	if (otdelka == 1) {
   		sqprice=square*6500;
                materin = "";
   	}
	if (otdelka == 2) {
   		sqprice=square*10000;
                materin = "";
   	}
	if (otdelka == 3) {
   		sqprice=square*3000;
                materin = "";
   	}
	if (otdelka == 4) {
   		sqprice=square*6500;
                materin = "none";
   	}
      	
	sqprice=Number(sqprice);
	document.all.price.innerText=forma(sqprice);
        document.all.materin.style.display = materin;
};

function dispHandle(obj) 
{
if (obj.style.display == "none") {
	calc_price();
	obj.style.display = "";
	}
else
	obj.style.display = "none";
}		
