function nextpage(fromsubsection, tosubsection) {
    document.userdata.fromsubsection.value = fromsubsection;
    document.userdata.tosubsection.value = tosubsection;
	document.userdata.action= "inputdata.asp"
	document.userdata.submit();
}

function popup(PopEvent,popWidth,popHeight) {
	var popName = "Tips";
	var popLeft;
	var popTop;
	popLeft = 1/2 * (window.screen.availwidth - popWidth) + 20;
	popTop = 1/2 * (window.screen.availheight - popHeight) + 20;
	var desktop=window.open(PopEvent, popName,'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=' + popWidth + ',height=' + popHeight + ',resizable=no,left=' + popLeft + ',top=' + popTop);
	desktop.focus();
}

function calculate() { 
  	var i, j, s, v, total;
	var tot = new Array(12);
  	for (i = 0; i < 4; i++) {
		total = 0;
		for (j = 0; j<12; j++) {	
			v = Math.floor(document.userdata.month[4*j + i].value);
			if (i == 0) {
			  tot[j] = v;
			} else { 
              tot[j] = tot[j] + v; }
			
			total = total + v;						 		 
		}
		s = "year[" + (i + 1) + ",1]";
		document.all(s).innerHTML = "R" + total;
	}
	total = 0
	for (j = 0; j<12; j++) {
		total = total + tot[j];
		s = "month[5," + (j + 1) + "]";
		document.all(s).innerHTML = "R" + tot[j];	
	}
	document.all("year[5,1]").innerHTML = "R" + total;	

  	for (i = 0; i < 4; i++) {
		total = 0;
		for (j = 0; j<2; j++) {	
			v = Math.floor(document.userdata.year[4*j + i].value);
			if (i == 0) {
			  tot[j] = v;
			} else { 
              tot[j] = tot[j] + v; }			
			total = total + v;						 		 
		}
		s = "year[" + (i + 1) + ",4]";
		document.all(s).innerHTML = "R" + total;
	}
	total = 0
	for (j = 0; j<2; j++) {
		total = total + tot[j];
		s = "year[5," + (j + 2) + "]";
		document.all(s).innerHTML = "R" + tot[j];	
	}
	document.all("year[5,4]").innerHTML = "R" + total;	
  }  
