function summaryEdit (f) {
	setStep (f);
	document.form.submit();
}

function setStatus (f){
var vCurStep = 1;
var iCurStep = document.form.STEP.value;
vCurStep = parseInt(iCurStep);


	if (f == "Calculate"){
		document.form.STEP.value = vCurStep ;
	} else if (f == "Next") {
		if (vCurStep >= 5) { vCurStep = 5;}
		else {vCurStep = vCurStep + 1;}
		document.form.STEP.value = vCurStep;
	} else if (f == "Previous") {
	
		if (vCurStep <= 1) { vCurStep = 1;}
		else { vCurStep = vCurStep - 1;}		
		document.form.STEP.value = vCurStep;
	} else if (f == "SubmitSummary") {
		document.form.STEP.value = 5;
	} else {
		document.form.STEP.value = 1;
	}		

}

function setStep (f){

	if (f == "Step_2"){
		document.form.STEP.value = 2 ;
	} else if (f == "Step_3") {
		document.form.STEP.value = 3;
	} else if (f == "Step_4") {
		document.form.STEP.value = 4;
	} else if (f == "Step_5") {
		document.form.STEP.value = 5;		
	} else {
		document.form.STEP.value = 1;
	}

}

function gotoSubstep(url_path) {
	chkReqFields ();

		document.form.action = url_path;
		setOnlyNumeric();
		document.form.submit();
		return false;
}

function chkReqFields () {
// var vFamily = document.form.FAMILY.value;
var vDevice = document.form.DEVICE.value;
var vPackage = document.form.PACKAGE.value;
var msg = "Please select below required field(s):\n";
var msg1 = "";

//	if (vFamily == 0) {	msg1 += " - Family\n"; }
	if (vDevice == 0) {	msg1 += " - Device\n"; }
	if (vPackage == 0) { msg1 += " - Package\n"; }

	if (msg1 != ""){
		msg = msg + msg1;
		alert(msg);
		document.form.STEP.value = 1;
		document.form.submit();
		return false;
	}
	return true;
}

function clearZero(element) { if (element.value == "0.00") element.value = ""; 
return true; }

function addZero(element) { if (element.value == "") element.value = "0.00"; 
return true; }

function roundn(n, x)
{
	x = (!x) ? 2 : places;
	return Math.round(n * Math.pow(10, x)) / Math.pow(10, x);
}


function setOnlyNumeric() {
var fLength = document.form.length;
var eType = "";
var eVal = "";
var reComma = /,/gi;

	for (var i = 0; i < fLength; i++) {
		eType = document.form[i].type;
		eVal = document.form[i].value;
		if ((eType == "text") || (eType == "hidden")){
			document.form[i].value = eVal.replace(reComma,"");
		}
	}

}

function nonNumeric(str)
{
	for (var i = 0; i < str.length; i++)
	{
		var c = str.charAt(i);
		if ((c < "0" || c > "9") && c != "-" && c != ".") { return true; }
	}
	return false;
}


function checkNum(element, minval, maxval)
{
	if (!minval) minval = 0;
	if (!maxval) maxval = 99999;
	var str = element.value + "";
	if (str == "") { element.value = "0.00"; return true; }
	if (parseFloat(str) < minval || parseFloat(str) > maxval || nonNumeric(str))
	{
		alert("\nThis field must be a number from " + minval + " to " + maxval);
		element.value = "";
		element.focus();
		return false;
	}
	return true;
}

function checkNumTA(element, tempGrade, maxval)
{
//	if (!minval) minval = 0; 

	tempGrade = document.form.TEMPGRADE1.value;

	if (!maxval) maxval = 99999;
	var str = element.value + "";
	if (str == "") { element.value = "0.00"; return true; }
	
	if (tempGrade == 1) {
		ta_minval = 0;
		ta_maxval = 85;
	} else {
		ta_minval = -40;
		ta_maxval = 100;	
	}
	
	if (parseFloat(str) < ta_minval || parseFloat(str) > ta_maxval || nonNumeric(str))
	{
		alert("\nThis field must be a number from " + ta_minval + " to " + ta_maxval);
		element.value = "";
		element.focus();
		return false;
	}
	return true;
}

	
function popUp(theURL) {
    var newWin = open(theURL,"popWin","width=400,height=260,top=10,left=10,scrollbars,resizable");
	newWin.focus();
}	

function help(topic)
{
	if (help_msg[topic])
	{
		var help_win = window.open("","","width=300,height=300");
		help_win.document.open();
		help_win.document.write(header + help_msg[topic] + closeButton + footer);
		help_win.document.close();
		if (!IE3) { help_win.focus(); }
	}
}


function formatNumberK(num, precision) {
denominator = Math.pow(10, precision)
number = Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
str_number = new String(number);
if (precision>0) {
	if (str_number.indexOf(".")<0) {
		str_number += ".";
		for (i=0;i<precision;i++) {
			str_number += "0";
		}
	} else {
		// --- decimal point is found, need to pad trailing zero's
		number_after_decimal = str_number.length - (str_number.indexOf(".") + 1);
		if (number_after_decimal < precision) {
			for (i=number_after_decimal;i<precision;i++) {
				str_number += "0";
			}
		}
	}
}
return (str_number);
}	


function formatPercentage(num, precision) {
denominator = Math.pow(10, precision)
percent = Math.round(num * 100 * denominator)/denominator;
str_percentage = new String(percent);
if (precision>0) {
	if (str_percentage.indexOf(".")<0) {
		str_percentage += ".";
		for (i=0;i<precision;i++) {
			str_percentage += "0";
		}
	} else {
		// --- decimal point is found, need to pad trailing zero's
		number_after_decimal = str_percentage.length - (str_percentage.indexOf(".") + 1);
		if (number_after_decimal < precision) {
			for (i=number_after_decimal;i<precision;i++) {
				str_percentage += "0";
			}
		}
	}
}
return (str_percentage + "%");
}


function formatNumber(num) {
num = Math.round(num);
dstr = new String(num);
fstr = "";
for (i=dstr.length;i>=0;i=i-3) {
	if (i-3>0) {
		fstr = "," + dstr.substring(i-3,i) + fstr;
	} else {
		fstr = dstr.substring(0,i) + fstr;
		break;
	}
}
return fstr;
}


function roundn(n, x)
{	// places
//x = (!x) ? 2 : x;
return Math.round(n * Math.pow(10, x)) / Math.pow(10, x);
}
	
var arrDevice = new Array("", "EP20K200C", "EP20K400C", "EP20K600C", "EP20K1000C", "EP20K30E", "EP20K60E", "EP20K100E", "EP20K160E", "EP20K200E", "EP20K300E", "EP20K400E", "EP20K600E", "EP20K1000E", "EP20K1500E");	
var arrPackage = new Array("", "144 FineLine BGA", "144 TQFP", "208 PQFP", "240 PQFP", "324 FineLine BGA", "356 BGA", "484 FineLine BGA", "652 BGA", "672 FineLine BGA", "1020 FineLine BGA");	
var arrThermPack = new Array("", "B356", "B652", "F1020", "F144", "F324", "F484", "F672", "Q208", "Q240", "T144");	
	
	
	
function setIOStandard(val, e)
{	// f.iostd_TRIO1
	// document.form.iostd_TRIO1
	// onchange="setIOStandard(this.value, document.form.<%= TRIO_col2_Iname %>)"
	var vf = val;
	
	e.options.length = 0;
	e.options[0] = new Option("", "0", true, true);
		
		if (vf == 1){ 				
			e.options[1] = new Option("3.3_LVTTL/LVCMOS","1");
			e.options[2] = new Option("2.5_LVTTL/LVCMOS","2");
		} else if (vf == 2) { 
			e.options[1] = new Option("SSTL-3_I","3");
			e.options[2] = new Option("SSTL-3_II","4");
			e.options[3] = new Option("SSTL-2_I","5");
			e.options[4] = new Option("SSTL-2_II","6");
		} else if (vf == 3) { 
			e.options[1] = new Option("CTT","7");
			e.options[2] = new Option("GTL","8");
			e.options[3] = new Option("GTL+","9");
			e.options[4] = new Option("HSTL_I","10");
			e.options[5] = new Option("HSTL_II","11");
			e.options[6] = new Option("SSTL-3_I","12");
			e.options[7] = new Option("SSTL-3_II","13");
			e.options[8] = new Option("SSTL-2_I","14");
			e.options[9] = new Option("SSTL-2_II","15");
		 } else {
		 /*
			e.options[1] = new Option("3.3_LVTTL/LVCMOS","1");
			e.options[2] = new Option("2.5_LVTTL/LVCMOS","2");
			e.options[3] = new Option("SSTL-3_I","3");
			e.options[4] = new Option("SSTL-3_II","4");
			e.options[5] = new Option("SSTL-2_I","5");
			e.options[6] = new Option("SSTL-2_II","6");
			e.options[7] = new Option("CTT","7");
			e.options[8] = new Option("GTL","8");
			e.options[9] = new Option("GTL+","9");
			e.options[10] = new Option("HSTL_I","10");
			e.options[11] = new Option("HSTL_II","11");
			e.options[12] = new Option("SSTL-3_I","12");
			e.options[13] = new Option("SSTL-3_II","13");
			e.options[14] = new Option("SSTL-2_I","14");
			e.options[15] = new Option("SSTL-2_II","15");
		 */
		 
		}		
}

function setPackage(Dval, f)
{	
	var vf = Dval;
	
	f.PACKAGE.options.length = 0;
//	f.PACKAGE.options[0] = new Option("", "0", true, true);
	if (vf == 1) { 
		f.PACKAGE.options[0] = new Option("672 FineLine BGA", "1");	
	} else if (vf == 2) { 
		f.PACKAGE.options[0] = new Option("780 FineLine BGA", "2");			
	} else if (vf == 3) { 
		f.PACKAGE.options[0] = new Option("780 FineLine BGA", "2");			
	} else if (vf == 4) {  
		f.PACKAGE.options[0] = new Option("1020 FineLine BGA", "3");
	} else if (vf == 5) {  
		f.PACKAGE.options[0] = new Option("1020 FineLine BGA", "3");
	} else { 	
		f.PACKAGE.options[0] = new Option("672 FineLine BGA", "1");	
		f.PACKAGE.options[1] = new Option("780 FineLine BGA", "2");			
		f.PACKAGE.options[2] = new Option("1020 FineLine BGA", "3");
	}
		
}

function setPackagexx(Dval, f)
{	
	var vf = Dval;
	
	f.PACKAGE.options.length = 0;
//	f.PACKAGE.options[0] = new Option("", "0", true, true);
	if (vf == 3) { 
		f.PACKAGE.options[0] = new Option("672 FineLine BGA", "3");	
	} else if (vf == 4) { 
		f.PACKAGE.options[0] = new Option("780 FineLine BGA", "4");			
	} else if (vf == 5) { 
		f.PACKAGE.options[0] = new Option("780 FineLine BGA", "4");			
	} else if (vf == 6) {  
		f.PACKAGE.options[0] = new Option("1020 FineLine BGA", "6");
	} else if (vf == 7) {  
		f.PACKAGE.options[0] = new Option("1020 FineLine BGA", "6");
	} else { 	
		f.PACKAGE.options[0] = new Option("672 FineLine BGA", "3");	
		f.PACKAGE.options[1] = new Option("780 FineLine BGA", "4");			
		f.PACKAGE.options[2] = new Option("1020 FineLine BGA", "6");
	}
		
}

function setPackagexxxx(Dval, f)
{	
	var vf = Dval;
	
	f.PACKAGE.options.length = 0;
	f.PACKAGE.options[0] = new Option("", "0", true, true);
	if (vf == 1) { 
		f.PACKAGE.options[1] = new Option("484 FineLine BGA", "1");
		f.PACKAGE.options[2] = new Option("672 FineLine BGA", "2");	
		f.PACKAGE.options[3] = new Option("672 BGA", "3");			
		f.PACKAGE.options[4] = new Option("780 FineLine BGA", "4");	
	} else if (vf == 2) {
		f.PACKAGE.options[1] = new Option("484 FineLine BGA", "1");
		f.PACKAGE.options[2] = new Option("672 FineLine BGA", "2");	
		f.PACKAGE.options[3] = new Option("672 BGA", "3");			
		f.PACKAGE.options[4] = new Option("780 FineLine BGA", "4");	
	} else if (vf == 3) { 
		f.PACKAGE.options[1] = new Option("672 FineLine BGA", "2");	
		f.PACKAGE.options[2] = new Option("672 BGA", "3");			
		f.PACKAGE.options[3] = new Option("780 FineLine BGA", "4");			
		f.PACKAGE.options[4] = new Option("1020 FineLine BGA", "6");			
	} else if (vf == 4) { 
		f.PACKAGE.options[1] = new Option("780 FineLine BGA", "4");			
		f.PACKAGE.options[2] = new Option("956 FineLine BGA", "5");			
		f.PACKAGE.options[3] = new Option("1020 FineLine BGA", "6");
	} else if (vf == 5) { 
		f.PACKAGE.options[1] = new Option("956 FineLine BGA", "5");			
		f.PACKAGE.options[2] = new Option("1020 FineLine BGA", "6");
		f.PACKAGE.options[3] = new Option("1508 FineLine BGA", "7");			
	} else if (vf == 6) {  
		f.PACKAGE.options[1] = new Option("956 FineLine BGA", "5");			
		f.PACKAGE.options[2] = new Option("1020 FineLine BGA", "6");
		f.PACKAGE.options[3] = new Option("1508 FineLine BGA", "7");			
	} else if (vf == 7) {  
		f.PACKAGE.options[1] = new Option("956 FineLine BGA", "5");			
		f.PACKAGE.options[2] = new Option("1508 FineLine BGA", "7");			
	} else { 	
		f.PACKAGE.options[1] = new Option("484 FineLine BGA", "1");
		f.PACKAGE.options[2] = new Option("672 FineLine BGA", "2");	
		f.PACKAGE.options[3] = new Option("672 BGA", "3");			
		f.PACKAGE.options[4] = new Option("780 FineLine BGA", "4");			
		f.PACKAGE.options[5] = new Option("956 FineLine BGA", "5");			
		f.PACKAGE.options[6] = new Option("1020 FineLine BGA", "6");
		f.PACKAGE.options[7] = new Option("1508 FineLine BGA", "7");	
	}
		
}
	
	
