/* WWWWHITTARD Tea Zone Scripts */	

/**********************************************************************************/

/* Blend Tea Zone Tea */

function blendMyTeaZoneTea() {

		var theTargetForm=document.getElementById("TEAZONEFORM");
		var theTargetRequestInput=document.getElementById("TEAZONEREQUEST");
		theTargetForm.submit();
}

/**********************************************************************************/

/* Delete Tea Zone Blend */

function deleteTeaZoneBlend(teaZoneBlendLineId) {

	if(window.confirm("Are you sure you want to delete this blend of tea?")) {

		var theTargetForm=document.getElementById("CATALOGUEITEMFORM_"+teaZoneBlendLineId);
		var theTargetInput=document.getElementById("CATALOGUEITEMMODE_"+teaZoneBlendLineId)

		theTargetInput.value="DELETE";
		theTargetForm.submit();
	}
}

/**********************************************************************************/

/* Edit Tea Zone Blend */

function editTeaZoneBlend(teaZoneBlendLineId) {

	var theTargetForm=document.getElementById("CATALOGUEITEMFORM_"+teaZoneBlendLineId);
	var theTargetInput=document.getElementById("CATALOGUEITEMMODE_"+teaZoneBlendLineId)

	theTargetInput.value="EDIT";
	theTargetForm.submit();

}

/**********************************************************************************/

/* Cancel Tea Zone Blend */

function cancelTeaZone() {
		this.location.href=teaZoneCancelUrl.value;
}

/**********************************************************************************/

/* Evaluate Tea Zone Blend Total */

function evaluateTeaZoneBlendTotal() {

	var theTargetForm=document.getElementById("TEAZONEFORM");
	var theTargetCell=document.getElementById("TEAZONEBLENDTOTAL");
	var theRunningBlendTotal=0;

	for(var i=0; i<theTargetForm.elements.length; i++) {

		var thisFormElement=theTargetForm.elements[i];
		var theFormElementElements=thisFormElement.id.split("_");

		if(theFormElementElements[0].toUpperCase()=="TEAZONEINGREDIENTQTY") {

			if(theFormElementElements[1] !=3) {
				if(!isNaN(thisFormElement.value)) {
					theRunningBlendTotal=theRunningBlendTotal+parseInt(thisFormElement.value);
				}
			}
		}
	}


	theTargetCell.innerHTML=theRunningBlendTotal+" %";
}

/**********************************************************************************/

