// PowerPC Calculator Processing Script
// Written by Dustin M. Waibel (x4750)
// Loosely based on original utility scripted written by Val Laolagi
// v1.0 (02/10/03): wrote functions.
// v1.1 (03/26/03): changed typeVirtexIIProDevice function to all if statements for
//                  better legibility.
// v2.0 (06/24/03): added the ability to clear drop-down boxes to InitForm; added the
//                  functionality to mulitply the drop-downs against the next occurring 
//                  radio button.

function InitForm() {
	document.myform.total.value=0;
	temptotal=0;
	document.myform.typeVirtexIIPro.value = ' ';
	for (xx=0; xx < document.myform.elements.length; xx++) {
	        if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio') {
		        document.myform.elements[xx].checked = false;
			}
			if (document.myform.elements[xx].type == 'select-one')  {
				document.myform.elements[xx].selectedIndex = 0;
			}
	}
}

function addit() {
	var i = 0;
	var temptotal = 0;
	var tempdrop = 1;
	var tempval = 0;
	for (i = 0; i < document.myform.length; i++) {
		if (document.myform.elements[i].type == 'select-one')  {
			tempdrop = eval(document.myform.elements[i].options[document.myform.elements[i].selectedIndex].value);
			continue;
		}
		if (document.myform.elements[i].checked) {
			tempval = tempdrop * eval(document.myform.elements[i].value);
			temptotal = temptotal + tempval;
		}
		tempdrop = 1;
	}
	return (temptotal);
}
 
function typeVirtexIIProDevice() {
	if (document.myform.total.value < 3169) {
		document.myform.typeVirtexIIPro.value = 'XC2VP2';
	}
	if (document.myform.total.value > 3168 && document.myform.total.value < 6769) {
		document.myform.typeVirtexIIPro.value = 'XC2VP4';
	}
	if (document.myform.total.value > 6768 && document.myform.total.value < 11089) {
		document.myform.typeVirtexIIPro.value = 'XC2VP7';
	}
	if (document.myform.total.value > 11088 && document.myform.total.value < 20881) {
		document.myform.typeVirtexIIPro.value = 'XC2VP20';
	}
	if (document.myform.total.value > 20880 && document.myform.total.value < 30817) {
		document.myform.typeVirtexIIPro.value = 'XC2VP30';
	}
	if (document.myform.total.value > 30816 && document.myform.total.value < 43633) {
		document.myform.typeVirtexIIPro.value = 'XC2VP40';
	}
	if (document.myform.total.value > 43632 && document.myform.total.value < 53137) {
		document.myform.typeVirtexIIPro.value = 'XC2VP50';
	}
	if (document.myform.total.value > 53136 && document.myform.total.value < 74485) {
		document.myform.typeVirtexIIPro.value = 'XC2VP70';
	}
	if (document.myform.total.value > 74484 && document.myform.total.value < 99217) {
		document.myform.typeVirtexIIPro.value = 'XC2VP100';
	}
	if (document.myform.total.value > 99216 && document.myform.total.value < 125137) {
		document.myform.typeVirtexIIPro.value = 'XC2VP125';
	}
	if (document.myform.total.value > 125136) {
		document.myform.typeVirtexIIPro.value = 'Does Not Fit in Virtex Series';
	}
}
