﻿function Process_Quote_Form_Real(what){

	box = what.Paper_ID;
	var Paper_ID = box.options[box.selectedIndex].value;
	
	var Horz_Trim_Size = what.Horz_Trim_Size.value;
	var Vert_Trim_Size = what.Vert_Trim_Size.value;

	box = what.CutType;
	var CutType = box.options[box.selectedIndex].value;

	box = what.FoldType;
	var FoldType = box.options[box.selectedIndex].value;

	box = what.PrintType;
	var PrintType = box.options[box.selectedIndex].value;

	box = what.DeliveryType;
	var DeliveryType = box.options[box.selectedIndex].value;
	
	box = what.PostalType;
	var PostalType = box.options[box.selectedIndex].value;	
	
	var Quantity = what.Quantity.value;
	var IncludeDiscount = true;
	
	calc_quote(Paper_ID,Horz_Trim_Size,Vert_Trim_Size,CutType,FoldType,PrintType,DeliveryType,PostalType,Quantity,IncludeDiscount)

}

function set_trim_dimensions(what) {

	box = what.TrimSize;
	var TrimSize = box.options[box.selectedIndex].value;

	if (TrimSize != "Custom") { // Not custom therefore disable custom fields and get size from drop down

		what.Horz_Trim_Size.disabled = true;
		what.Vert_Trim_Size.disabled = true;
	
		var arr = new Array(3);	
		arr = TrimSize.split("x");
		what.Horz_Trim_Size.value = arr[0];
		what.Vert_Trim_Size.value = arr[1];
	
	} else { // Allow the user to adjust the custom fields
	
		what.Horz_Trim_Size.disabled = false;
		what.Vert_Trim_Size.disabled = false;
	
	}
	
	Process_Quote_Form(what);
	
}

function check_trim_dimensions(what) {

	var Horz_Trim_Size = what.Horz_Trim_Size.value;
	var Vert_Trim_Size = what.Vert_Trim_Size.value;
	
	// Check limits and alert
	if (Horz_Trim_Size < 50 || Vert_Trim_Size < 50) {
		alert("Minimum trim size 50mm x 50mm");
	}
	
	if (Horz_Trim_Size > 440 || Vert_Trim_Size > 310) {
		alert("Maximum trim size 440mm x 310mm");
	}
	
	// Adjust the limits to min or maximum allowed
	if (Horz_Trim_Size < 50) { what.Horz_Trim_Size.value = 50; }
	if (Vert_Trim_Size < 50) { what.Vert_Trim_Size.value = 50; }
	
	if (Horz_Trim_Size > 440) { what.Horz_Trim_Size.value = 440; }
	if (Vert_Trim_Size > 310) { what.Vert_Trim_Size.value = 310; }

	// Process the form
	Process_Quote_Form(what);

}


/* EOF */