function trbg_on(kolor) {
kolor.style.backgroundColor='#ffc300';
}

function trbg_off(kolor) {
kolor.style.backgroundColor='#ffcc33';
}

function tr_on(kolor,barwa) {
kolor.style.backgroundColor=barwa;
}

function tr_off(kolor,barwa) {
kolor.style.backgroundColor=barwa;
}

function wyborTypu(wybor) {
//	document.kn.id02.value=wybor;
	para = document.kn.id02.options[document.kn.id02.selectedIndex].value;
/*	document.kn.id02.options.value=wybor;
	document.kn.submit(); */
	para = document.kn.id02.options[document.kn.id02.selectedIndex].value;
	window.open('index.php?id01=szukaj&id02='+para,'_self'); 
}
function wyslijFormularz() {
		document.kn.submit();
		return true;
		}
function okno(nier,nrof) {
	noweokno=window.open("show.php?id01=pic&id02="+nier+"&id03="+nrof,nrof,"toolbar=no, location=0, directories=0, status=0, menubar=0, resizable=yes, scrollbars=yes,width=700,height=500");
	} /* koniec okno(nier,nrof) */

function ofbez() {
	noweokno1=window.open("show.php?id01=ofbez","OfertaBezposrednia","toolbar=no, location=0, directories=0, status=0, menubar=0, resizable=yes, scrollbars=yes,width=320,height=240");
	} /* koniec okno(nier,nrof) */

function formularz() {
	formatka=window.open("formularze.php","Formularz","toolbar=no, location=0, directories=0, status=0, menubar=0, resizable=yes, scrollbars=yes,width=700,height=500");
	}
var Napis="Witamy na stronach KILJAN Nieruchomo�ci!!!                                                       ";
function NapisPrz() {
        Napis=Napis.substring(1,Napis.length)+Napis.charAt(0);
        status=Napis;
        setTimeout("NapisPrz()",60);
} /* koniec NapisPrz */

function licz()
{

	forma = document.forms['ca'];
	
	if(forma.elements['typ'].value=='dzialki' || forma.elements['typ'].value=='obiekty')
	{
		document.forms.ca.wl1[0].disabled = true;
	}
	
	
	cenaW = sprC(forma.elements['cena'].value,forma.elements['cena'].value.length);
	forma.elements['cena'].value=cenaW;
	wl11 = document.forms.ca.wl1[0].checked;
	wl21 = document.forms.ca.wl2[0].checked;
	
	if(!document.forms.ca.wl1[0].checked && !document.forms.ca.wl1[1].checked && document.getElementById('typ').value=='mieszkania')
	{
		alert('Wybierz typ wlasnosci');
		return;
	}


	wl31 = document.forms.ca.wl3.checked;
	notar = zaoK(opNot(cenaW));
	
	forma.elements['pod1'].value=cenaW*0.02;
	
	if (wl11 != 1) //nieruchomosc
	{
		if(forma.elements['typ'].value=='obiekty')
			notars = notar;
		else if(forma.elements['typ'].value=='dzialki')
			notars = notar;	
		else
			notars = zaoK(notar/2);
		
		oplS = zaoK(opSad(cenaW));
		opWP = 450;
		forma.elements['pod2'].value=zaoK(notars);
		forma.elements['pod5'].value=zaoK(oplS);
		forma.elements['pod6'].value=zaoK(opWP);
	} 
	else 
	{ //spoldzielcze
		notars = zaoK(notar/2);
		opWP = 0;
		if ( wl31 == 1 ) //ksiega wieczysta
		{
			oplS = zaoK(opSad(cenaW));
			
	
			opWP = 200;
			opWP = 450; //was 100		
		} 
		else  // bez ksiegi wieczystej
		{
			if(forma.elements['typ'].value=='mieszkania')
			{
				opWP = 250; //was 100
				oplS = 0;			
			}
			else
			{	
				//oplS = opWP;
				oplS = 200;
		//		oplS = zaoK(opSad(cenaW));
				opWP = 450; //was 100
			}
	
		}
		forma.elements['pod2'].value=zaoK(notars);
		forma.elements['pod5'].value=zaoK(oplS);
		forma.elements['pod6'].value=zaoK(opWP);
	}
	forma.elements['pod3'].value=zaoK(notars*0.23);
	if (wl21 == 1) {
		cp=0;
		cpV=cp;
		forma.elements['pod4'].value=zaoK(cp);
		forma.elements['pod4a'].value=zaoK(cpV);
		} else {
		cp=zaoK(lb(cenaW)*0.03);
		if ( cp < 1000) cp=1000;
		cpV=cp*0.23;
		forma.elements['pod4'].value=zaoK(cp);
		forma.elements['pod4a'].value=zaoK(cpV);
		}
	sumaOp = zaoK((cenaW*0.02)+(notars*1.23)+cp+cpV+opWP+oplS);
	forma.elements['pod7'].value=sumaOp;
	forma.elements['pod8'].value=zaoK(lb(cenaW)+sumaOp);
} /* koniec licz */

function zaoK(liczba)
{
	return Math.round(liczba);
} /* zaoK(liczba) */

function sprC(liczba,dlugosc) {
var zwrot;
zwrot = '';
	for (i=0;i < dlugosc; i++) {
		if (liczba.charAt(i) < '0' || liczba.charAt(i) > '9' ) {
			return zwrot;
			} else {
			zwrot = zwrot+liczba.charAt(i);
			}
		}
	return zwrot;
	} /* sprC(liczba) */
function lb(liczba) {
	if(isNaN(liczba)) 
		return '';
		else if ( liczba == 0) 
		return 0;
		else
		return parseInt(liczba);
	} /* lb(liczba) */
	
function opNot(liczba) 
{
	if (liczba <= 0 )
		return 0;
	else if (liczba <= 3000)
		return 100;
	else if (liczba <= 10000)
		return (100+ (liczba-3000)*0.03);
	else if (liczba <= 30000)
		return (310+ (liczba-10000)*0.02);
	else if (liczba <= 60000)
		return (710+ (liczba-30000)*0.01);
	else if (liczba <= 1000000)
		return (1010+ (liczba-60000)*0.004);
	else 
		return (4770+(liczba-1000000)*0.002);
	}  /* opNot(liczba) */
	
function opSad(liczba) 
{
	return 200;
} /* opSad(liczba) */

