function showQty(num, switchColor){
	//try {


	if(document.multiOrderForm['vwitem' + num].checked){
	document.getElementById('itemQty' + num).style.display = 'block';
	document.getElementById('itemRow' + num).style.backgroundColor = '#EEF6FF';
	}else{
	document.getElementById('itemQty' + num).style.display = 'none';
	document.getElementById('itemRow' + num).style.backgroundColor = switchColor;
	}
	//} catch(e) {
	//	alert(document.multiOrderForm['vwitem' + num]);
	//	alert(document.forms['multiOrderForm'].elements['vwitem' + num]);
	//	alert(document.forms['multiOrderForm'].elements['vwitem' + num].checked);
	//}
	
	
	calculateSubtotal();
}

function changeCellColor(checkbox,cell,switchFromColor,switchToColor){
	if(document.multiOrderForm[checkbox].checked){
	document.getElementById(cell).style.backgroundColor = switchToColor;
	}else{
	document.getElementById(cell).style.backgroundColor = switchFromColor;
	}
	calculateSubtotal();
}

function calculateSubtotal(){
 var subTotal = 0;
 var formLen = document.multiOrderForm.elements.length;
 
 for(i=0; i<formLen; i++){
 	if(document.multiOrderForm.elements[i].type=="checkbox" && document.multiOrderForm.elements[i].checked){
 		var itemName = document.multiOrderForm.elements[i].name;
		var itemPrice = document.multiOrderForm.elements[itemName + '-price'].value - 0;
		var formatItemName = itemName.replace(/vwitem/,"");
		var itemQty = document.multiOrderForm.elements['vwquantity' + formatItemName].value;
		subTotal += itemPrice * itemQty;
 	}
 }
 document.getElementById("multiOrderSubtotal").innerHTML = '<span class="product2">Total: ' + formatCurrency(subTotal) + '</span>';
 document.getElementById("multiOrderSubtotal2").innerHTML = '<span class="product2">Total: ' + formatCurrency(subTotal) + '</span>';
}


function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function remoteAddToWishlist(eWishForm,itemId) {
PopUpOpenYahooStoreMIML('http://www.ewish.com/merchants/atr.cfm','EwishLogon',itemId);
document.getElementById(eWishForm).submit();
return false;
}

