function switchDisplay(num) {
	for (x = 1; x < 7; x++) {
		if (x == num) {
			document.getElementById("table" + x).style.visibility = "visible";
			document.getElementById("table" + x).style.display = "block";
			document.getElementById("sb_" + x).style.backgroundColor = "gray";
			}
		else {
			document.getElementById("table" + x).style.visibility = "hidden";
			document.getElementById("table" + x).style.display = "none";
			document.getElementById("sb_" + x).style.backgroundColor = "black";
			}
		}
	for (d = 1; d < 7; d++) {
		for (i = 1; i < 7; i++) {
			if (document.getElementById("pos_" + d + "_" + i)) document.getElementById("pos_" + d + "_" + i).selectedIndex = 0;
			if (document.getElementById("sell" + i)) document.getElementById("sell" + i).selectedIndex = 0;
			}
		}
	document.getElementById("cashback").innerHTML = formatCurrency(0);
	if (document.getElementById("localover")) document.getElementById("localover").innerHTML = formatCurrency(0);
	}

function calcSC(i) {
	myComm = new Array(0,0,0,0,0,0,0)
	myStatus = document.getElementById("pos_1_" + i).selectedIndex;
	licSold = document.getElementById("sell" + i).selectedIndex;
	licNum = parseInt(document.getElementById("num" + i).value)
	if (isNaN(licNum)) licNum = 0;
	minStatus = 0;
	/*	0 = nothing
		1 = md
		2 = rmd	*/
	if (myStatus > 0 && licSold > 0) {
		//Local Sold
		totComm = 0;
		for (d = i; d > 0; d--) {
			if (document.getElementById("pos_" + d + "_" + i).selectedIndex == 1 && minStatus < 1) { myComm[d] = 100 - totComm; totComm += myComm[d]; minStatus = 2; }
			if (document.getElementById("pos_" + d + "_" + i).selectedIndex == 2 && minStatus < 2) { myComm[d] = 100 - totComm; if (totComm > 0) { totComm += myComm[d] } else { totComm = 100 }; minStatus = 2; }
			if (document.getElementById("pos_" + d + "_" + i).selectedIndex == 3 && minStatus < 3) { myComm[d] = 200 - totComm; if (totComm > 0) { totComm += myComm[d] } else { totComm = 200 }; minStatus = 3; }
			if (document.getElementById("pos_" + d + "_" + i).selectedIndex == 4 && minStatus < 4) { myComm[d] = 300 - totComm; if (totComm > 0) { totComm += myComm[d] } else { totComm = 300 }; minStatus = 4; }
			}
		//OVERRIDES
		//var curBonusAmount = 0;
		//if (document.getElementById("pos_1_" + i).selectedIndex == 4) {
		//	nmdCount = 1;
		//	if (i > 1) {
		//		for (d = 2; d <= i; d++) {
		//			if (document.getElementById("pos_" + d + "_" + i).selectedIndex == 4) nmdCount++;
		//			}
		//		}
		//	if (nmdCount < 4) {
		//		overrideNumber = 4 - nmdCount;
		//		if (overrideNumber == 1) curOverAmount = 10 * licNum;
		//		else curOverAmount = 20 * licNum;
		//		document.getElementById("localover").innerHTML = formatCurrency(curOverAmount)
		//		}
		//	else document.getElementById("localover").innerHTML = "$0.00";
		//	}
		//else if (document.getElementById("localover")) document.getElementById("localover").innerHTML = "$0.00";
		}
	if (myComm[1] > 0) document.getElementById("cashback").innerHTML = formatCurrency(myComm[1] * licNum)
	else document.getElementById("cashback").innerHTML = formatCurrency(0)
	}