﻿// JavaScript Document
var loadingGraphic = '<img src="/assets/images/loading.gif">';

$(document).ready(function() {
	//QuickAdd Form//
	quickOrder.clearData();
	emailSubscribe.clearData();
	emailSubscribe.processForm();

});

quickOrder = {
	clearData: function() {
		$("#quickOrder input").focus(function() {
			$(this).attr('value','');
		});
		$("#quickOrder input").blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].defaultValue);
			}
		});		
	}
},

emailSubscribe = {
	clearData: function() {
		$("#subscribeForm input").focus(function() {
			$(this).attr('value','');
		});
		$("#subscribeForm input").blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this)[0].defaultValue);
			}
		});		
	},
	processForm: function() {
		$("#subscribeForm form").submit(function(){
			formLabelsAndValues=$("#subscribeForm form").serialize();
			$("#subscribeForm").html(loadingGraphic);
			$.post('/components/subscribe/process.cfm',formLabelsAndValues, function(response) {
				emailSubscribe.formResponse(response);
			});
			return false;
		});	
	},
	formResponse: function(response) {
		$("#subscribeForm").html(response);
		emailSubscribe.processForm();
	}
}




/*
function quickORd
			$("#f-log-email").focus(function() {
				$(this).attr('value','');
			});
			$("#f-log-email").blur(function() {
				if ($(this).val() == "") {
					$(this).val($(this)[0].defaultValue);
				}
			});

								<form method="post" id="quickOrder">
									<input type="text" name="sku" value="sku" style="width: 40px;"> <input type="text" name="quantity" value="1" style="width: 14px; text-align: center;">
									<button class="defaultBtn"><span>Add To Cart</span></button>
								</form>
*/
