function liczraty(cena, procent)
{
	wwidth=250;
	wheight=250;
	pleft=Math.round((screen.width-wwidth)/2);
	ptop=Math.round((screen.height-wheight)/2);

	var Win = window.open("","displayWindow","width="+wwidth+",height="+wheight+",resizable=0,scrollbars=yes,menubar=no,left="+pleft+",top="+ptop );

	Win.document.open();
	Win.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
	Win.document.writeln('<html><head><title></title>');
	Win.document.writeln('<meta http-equiv="Content-Language" content="pl">');
	Win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
	Win.document.writeln('<script type="text/javascript">'
	+
'function checkdata(myform, cena)  '+
'{ '+
'  	if(myform.cenaproduktu) '+
'	{ '+
'		if (myform.cenaproduktu.value == "") '+
'		{ '+
'			myform.cenaproduktu.value=cena; '+
'		} '+
'		else '+
'		{ '+
'			if (valid_int(myform.cenaproduktu.value)){} '+
'			else '+
'	  			myform.cenaproduktu.value=cena; '+
'	  	} '+
'  	} '+
'	if(myform.iloscrat) '+
'	{ '+
'		if (myform.iloscrat.value == "") '+
'		{ '+
'	  		myform.iloscrat.value=12; '+
'	  	} '+
'  	} '+
'  	if(myform.wplatawlasna) '+
'	{ '+
'		if (myform.wplatawlasna.value == "") '+
'		{ '+
'			myform.wplatawlasna.value=0; '+
'		} '+
'		else '+
'		{ '+
'			if (valid_int(myform.wplatawlasna.value)){} '+
'			else '+
'	  			myform.wplatawlasna.value=0; '+
'	  	} '+
'  	} '+
'} '+
'function MM_findObj2(n, d) { '+
'  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { '+
'    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} '+
'  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; '+
'  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); '+
'  if(!x && d.getElementById) x=d.getElementById(n); return x; '+
'} '+
'function valid_int(phone){ '+
'	var good_char; '+
'	var good_chars = "qwertyuiopasdfghjklzxcvbnm!~#$%^&*_|=?:,<}{[]@.>QWERTYUIOPLKJHGFDSAZXCVBNM"; '+
'	for (i=0; i<good_chars.length; i++) { '+
'	  good_char=good_chars.charAt(i); '+
'		if (phone.indexOf(good_char) != -1) { '+
'	         return false; '+
'	      } '+
'	} '+
'	return true; '+
'} '+
'function wyliczrate(cena, procent) '+
'{ '+
'  myform = MM_findObj2(\'form\'); '+
'	checkdata(myform, cena); '+
'	var result = 0; '+
'	var wplata_wlasna = parseInt(myform.wplatawlasna.value); '+
'	var cena_produktu = parseInt(myform.cenaproduktu.value); '+
'	var ilosc_rat = parseInt(myform.iloscrat.value); '+
'	if ( (wplata_wlasna < cena_produktu) && (wplata_wlasna >= 0) && (ilosc_rat > 0) ) '+
'	{ '+
'		result = ( (cena_produktu - wplata_wlasna) / ilosc_rat ) * ( 1 + procent / 100 ); '+
'		result = Math.round( result * 100 ) / 100; '+
'	} '+
'	myform.result.value = result; '+
'} '+
	'</script></head><body>');
	Win.document.writeln('<h3 style="color:#3159b0">Kalkulator rat</h3><p style="font:11px Tahoma;color:#5E7387">Aby wyliczyć kwotę rat proszę wypełnic następujace pola</p><form action="#" method="get" id="form"><table width="190"><tr><td style="font:11px Tahoma;color:#5E7387">cena produktu:</td><td><input type="text" style="background-image:url(/images/buttons/bkInput2.gif);width:60px;border:1px solid #ccc" name="cenaproduktu" value="'+cena+'" /></td></tr><tr><td style="font:11px Tahoma;color:#5E7387">ilość rat:</td><td><input style="background-image:url(/i/bkInput2.gif);width:60px;border:1px solid #ccc" type="text" name="iloscrat" value="" /></td></tr><tr><td style="font:11px Tahoma;color:#5E7387">wpłata własna:</td><td><input type="text" name="wplatawlasna" style="background-image:url(/images/buttons/bkInput2.gif);width:60px;border:1px solid #ccc" value="" /></td></tr><tr><td style="font:11px Tahoma;color:#5E7387">rata:</td><td><input type="text" style="background-image:url(/images/buttons/bkInput2.gif);width:60px;border:1px solid #ccc" name="result" value="" disabled="disabled" /></td></tr><tr><td colspan="2" align="right" style="padding-right:24px"><input style="padding: 0;margin: 0;width: 71px;height: 20px;border: 0;cursor:pointer;background:transparent url(../images/buttons/wyliczrate.gif) 0 0 no-repeat;" type="button" value="" onclick="javascript:wyliczrate(' + cena + ',' + procent + ');" /></td></tr><table></form>');
	Win.document.writeln('</body></html>');

	Win.document.close();
	Win.focus();
}