

// This method does the following on mouse click:
// 1) If the check box's checked status is true, then:
//    a) Highlight the background color of the item's row.
//    b) Add the price of this item to the Product Total.
// 2) if the check box's checked status is false, then:
//    a) Clear the highlight of the background color of the item's row.
//    b) Subtract the price of this item from the Product Total.
//
function productSelection(curObj, rowID, price){

	debug("The checkbox's status is = " + curObj.checked);
	if(curObj.checked){
		selectRow(rowID, "green");
		total(price); //Add to the total
	}
	else{
		selectRow(rowID, "");
		total(-price); //Subtract from the total
	}

}

function selectRow(row, color){
	document.getElementById(row).style.backgroundColor = color;
}

function total(price){
	grandTotal = document.getElementById("total");
	grandTotal.value = parseFloat(grandTotal.value) + parseFloat(price);
	grandTotal.value = new Number(grandTotal.value).toFixed(2); // We only want 2 digits after the decimal point.
}

// This function will handle how the Product Description will behave when user mouse over the product's image.
// The effect is either to show or hide the description.
//
function showDescription(divID, vis){
	debug("showDescription - divID=" + divID + " and vis=" + vis);
	
	document.getElementById(divID).style.visibility = vis;
}

function submitForm(){
	alert("Thank you for your order. Please come again soon.");
	return false;
}


// This is a helper method to display messages to the console for us.
//
function debug(msg){
	console.log("DEBUG: " + msg);
}



