var isNS6 = document.getElementById && !document.all;
var manufact_selection = 2
var sort_selection = 1
var sOT = ''

function changeManfSort(iRadioBut,iOther,iLast){
	var sFormSO = isNS6? document.getElementById("frmSortOrder"): frmSortOrder;
	for (var i = 0; i < sFormSO.manufact.length; i++)
		if (sFormSO.manufact[i].checked && (i == iLast))
			return false;			
	window.location="/supplies.asp?mnf="+iRadioBut+"&ord="+iOther;
}

function changeListSort(iRadioBut,iOther,iLast){
	var sFormSO = isNS6? document.getElementById("frmSortOrder"): frmSortOrder;
	for (var i = 0; i < sFormSO.orderBy.length; i++)
		if (sFormSO.orderBy[i].checked && (i == iLast))
			return false;
	window.location="/supplies.asp?mnf="+iOther+"&ord="+iRadioBut;
}

function EntCan(iEntCan,iCA,sSO){
	var sFormPO = isNS6? document.getElementById("frmPO"): frmPO;
	if (iEntCan)
		window.location="/place_order.asp?sCurrentAccount="+iCA+"&sPO="+sFormPO.po.value+"&iTab=3&sSO="+sSO;
	else
		window.location="/my_account.asp?sCurrentAccount="+iCA+"&iTab=3";
}

function EntLine(sCA,iFltr,iOS){
	var sFormPO = isNS6? document.getElementById("frmPO"): frmPO;
	var sFormListItems = isNS6? document.getElementById("frmSupplyList"): frmSupplyList;
	var sItemTable = isNS6? document.getElementById("dbCustOrdtable"): dbCustOrdtable;
	var sOrderSelection='';
	var iCount = 1;
	var sLineItemTextbox;
	sLineItemTextbox = new Array(6)
	if (sFormListItems.iRecCnt.value >1)		
		sLineItemTextbox[1] = sFormListItems.Li1.value;
	if (sFormListItems.iRecCnt.value >2)		
		sLineItemTextbox[2] = sFormListItems.Li2.value;
	if (sFormListItems.iRecCnt.value >3)		
		sLineItemTextbox[3] = sFormListItems.Li3.value;
	if (sFormListItems.iRecCnt.value >4)		
		sLineItemTextbox[4] = sFormListItems.Li4.value;
	if (sFormListItems.iRecCnt.value >5)		
		sLineItemTextbox[5] = sFormListItems.Li5.value;
	if (sFormListItems.iRecCnt.value >6)		
		sLineItemTextbox[6] = sFormListItems.Li6.value;
		
	for (iCount = 1;iCount < sFormListItems.iRecCnt.value;iCount++){
		if (sLineItemTextbox[iCount]>0){
			sOrderSelection = sOrderSelection+sLineItemTextbox[iCount]+'|_';
			sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[1].innerHTML+'|_';
			sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[2].innerHTML+'|_';
			sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[3].innerHTML+'|_';
			sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[4].innerHTML+'|_';
			sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[5].innerHTML+'|_';
			//sOrderSelection = sItemTable.rows[iCount].cells[6].innerHTML;
		}
	}
	if (sOrderSelection > ""){
		var sRequestStrings = '';
		if (sFormPO.po.value > "")
			sRequestStrings = sRequestStrings+'&sPO='+sFormPO.po.value;
		if (iFltr)
			sRequestStrings = sRequestStrings+'&iFltr='+iFltr;
		window.location = "supplyorder.asp?sCurrentAccount="+sCA+sRequestStrings+"&sOS="+sOrderSelection+"&iA=1";
	}
	//sFormPO.po.value = sOrderSelection;
}
	
function leaveOrdering(iTab,sCA){
	var sRequestStrings = '/my_account.asp?sCurrentAccount='+sCA+'&iTab='+iTab;
	window.location=(sRequestStrings);
}

//delete this function	
function supplyFilterList(iFilter,sCA){
	var sFormPO = isNS6? document.getElementById("frmSupplyList"): frmSupplyList;
	var sFormPO = isNS6? document.getElementById("frmPO"): frmPO;
	var sRequestStrings = '/supplyorder.asp?sCurrentAccount='+sCA+'&iTab=3&iFltr='+iFilter;
	if (sFormPO.po.value > "")
		sRequestStrings = sRequestStrings+'&sPO='+sFormPO.po.value;
	window.location=(sRequestStrings);
}
	
function ChangeSupplyFilter(iFilter,sCA){
	var sRequestStrings = '/supplyorder.asp?sCurrentAccount='+sCA+'&PS=3';
	window.location=(sRequestStrings);
}
	
function DeleteLineItem(sCA,sLi){
	var sRequestStrings = '/supplyorder.asp?sCurrentAccount='+sCA+'&PS=7&sDel='+sLi;
	window.location=(sRequestStrings);
}

function UpdateItemQty(sCA,iRecCnt){		
	var isNS6 = document.getElementById && !document.all;
	var sFormListItems = isNS6? document.getElementById("frmSupplyList"): frmSupplyList;
	var sItemTable = isNS6? document.getElementById("dbCustOrdtable"): dbCustOrdtable;
	var sLineItemTextbox;
	sLineItemTextbox = new Array(6)
	if (iRecCnt >0)		
		sLineItemTextbox[1] = sFormListItems.Li1.value;
	if (iRecCnt >1)		
		sLineItemTextbox[2] = sFormListItems.Li2.value;
	if (iRecCnt >2)		
		sLineItemTextbox[3] = sFormListItems.Li3.value;
	if (iRecCnt >3)		
		sLineItemTextbox[4] = sFormListItems.Li4.value;
	if (iRecCnt >4)		
		sLineItemTextbox[5] = sFormListItems.Li5.value;
	if (iRecCnt >5)		
		sLineItemTextbox[6] = sFormListItems.Li6.value;
	var sOrderSelection='|_';
	var iCount = 1;
	for (iCount = 1;iCount < iRecCnt+1;iCount++){
		if (sLineItemTextbox[iCount]>""){
			if (1>0){
				//sOrderSelection = sOrderSelection+'|_';
				sOrderSelection = sOrderSelection+sItemTable.rows[iCount].cells[1].innerHTML+'|_';
				sOrderSelection = sOrderSelection+sLineItemTextbox[iCount]+'|_';
			}
		}
	}
	window.location = "supplyorder.asp?sCurrentAccount="+sCA+"&sOS="+sOrderSelection+"&iA=1&Ps=6";
}

function newitem(iItem,iPos,iStatus){		
	var isNS6 = document.getElementById && !document.all;
	var sBox = isNS6? document.getElementById("supplyOrderItem"): supplyOrderItem;
	var sForm = isNS6? document.getElementById("orderForm"): orderForm;
	var sSupplylistTable = isNS6? document.getElementById("priceHeader"): priceHeader;
	var sItemTable = isNS6? document.getElementById("addItem"): addItem;
	if (iStatus){
		item_selection = iItem;
		sForm.qty.value = "";
		sItemTable.rows[0].cells[1].innerHTML = sSupplylistTable.rows[iPos].cells[0].innerHTML;
		sItemTable.rows[1].cells[1].innerHTML = sSupplylistTable.rows[iPos].cells[1].innerHTML;
		sItemTable.rows[2].cells[1].innerHTML = sSupplylistTable.rows[iPos].cells[2].innerHTML;
		sItemTable.rows[3].cells[1].innerHTML = sSupplylistTable.rows[iPos].cells[3].innerHTML;
		sItemTable.rows[4].cells[1].innerHTML = sSupplylistTable.rows[iPos].cells[4].innerHTML;
		sBox.style.visibility = "visible";
		eval(sBox).style.zIndex = 3
		sForm.qty.focus();
	}
	else{
		window.alert ("Online ordering not currently available.");
	}
}
