$(document).ready(function() {
		function addChangeOther(field) {
			$("#" + field).change(function() {
				id = "#" + this.id;
				debug('id = ' + id + ', val = ' + $(this).val());
				if ($(this).val() == 'Other' || $(this).val() == '4 Colour Process')
					$("#" + field + "-custom").show();
				else {
					$("#" + field + "-custom").hide();
					$("#" + field + "-custom-value").val('');
				}
			});
		}

		addChangeOther('envelope_size');
		addChangeOther('envelope_sealType');
		addChangeOther('printing_desc');
		addChangeOther('envelope_style');
		addChangeOther('envelope_paperType');
		addChangeOther('envelope_paperWeight');


		$("div.quote-tab").click(function() {
			id = this.id;

			for (var i = 1; i <= 4; i++) {
				if (id == "quote-tab-" + i) {
					if ($("#quote-tab-" + i + "-content").css('display') == 'none') {
						$("#quote-tab-" + i).css('cursor', 'auto');
						$("#quote-tab-" + i + " img").toggle();
						$("#quote-tab-" + i + "-content").slideDown();
					}
				} else if ($("#quote-tab-" + i + "-content").css('display') == 'block') {
					$("#quote-tab-" + i).css('cursor', 'pointer');
					$("#quote-tab-" + i + " img").toggle();
					$("#quote-tab-" + i + "-content").slideUp();
				}
			}

		});


		$("#quote #reset").click(function() {
			$("#quote input, #quote textarea").not("input[type=submit]").not("input[type=reset]").val('');
			$("#quote select").val('').change();
		});

		$("#quote-form").Form({'submitButtonId':'form-submission'});
	});
