// JavaScript Document

function watchForm(f)
{
    if(!f) return;

    for(var i = 0; i < f.elements.length; i++)
    {
         var el = f.elements[i];
         if(el.type == 'text') el.onkeyup = el.onblur = gesamt_summe;
    }
}
function gesamt_summe()
{
    var f = this.form;
    var index = 0;
    var gg = 0;
    while( f.anzahl[index] )
    {
        var anzahl = f.anzahl[index].value || 0;
        var preis = f.preis[index].value || 0;
        gg += f.summe[index].value = anzahl * preis;
        index++;
    }


	var cr = document.getElementById('caprow');
    if (gg>300) {
    	if(cr.style.display=='none') cr.style.display = 'table-row';
    	f.cap.value = gg;
    	f.gg_summe.value = 300;
    }
	else {
		if(cr.style.display!='none') cr.style.display = 'none';
		f.gg_summe.value = gg;
	}
}
window.onload = function()
{
watchForm( document.forms['rechne'] );
};



