		function isValidEmail(email) {
			var reEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/
			return reEmail.test(email);
		}

		function callBack(text)
	    {	
			/* Used for all HTTP Ajax requests */
    	}
    	
		// Pop up the new Email Signup box
	    function popUpEmail(btnClick)
    	{
     		var emailAddr = $('#inputEmail').val();
	    	
    		if (btnClick=='noThanks'){
    			$.cookie("lenoxEmail","noThanks",{path:'/',expires:3650});
    			$("#closeLB").click();
    			cmCreatePageElementTag('NO THANKS - DONT ASK AGAIN','EMAIL SIGNUP LIGHTBOX');
    			return;
    		}

    		if (btnClick=='subscriber'){
    			$.cookie("lenoxEmail","subscriber",{path:'/',expires:3650});
    			$("#closeLB").click();
    			cmCreatePageElementTag('ALREADY EMAIL SUBSCRIBER','EMAIL SIGNUP LIGHTBOX');
    			return;
    		}

    		if (btnClick=='notNow'){
    			$.cookie("lenoxEmail","notNow",{path:'/',expires:2});
    			$("#closeLB").click();
    			cmCreatePageElementTag('NOT NOW - ASK ME LATER','EMAIL SIGNUP LIGHTBOX');
    			return;
    		}

    		if (btnClick=='go'){
    			// no action taken
    		}

    		if (!isValidEmail(emailAddr)) {
    			// Use this syntax when replaceing the html div in a static form name (prodId is NOT in the form id name).
				//$('#error').html('<span class="errorText">Please enter a valid email address</span>');
	    		$("[id=error]").each(function(i,e){
	    			$(e).html('<span class="errorText">You&#146;ve entered an invalid email address. Try again.</span>');
	    		});

	    	} else {
				// Call emailInterface.cfc to add the email to the customer table
				$.ajax({
					type: 'POST',
					url: '/model/remote/emailInterface.cfc?method=addEmail',
					data: ({emailAddr: emailAddr}),
					dataType: 'json',
					async: false,
					cache: false,
					success: function(result) {
			    		if (result.success) {
			    			//console.log('post success');
								// Re-display the email form with the Thank You message. (Displays the confirm email form)
					    		//$("p").css({"display":"none"});

					    		$("[id=email_entry]").each(function(i,e){
					    			$(e).css("display","none");
					    		});
			
					    		//$("#email_confirm").attr("style","display:block");
					    		$("[id=email_confirm]").each(function(i,e){
					    			$(e).css("display","block");
					    		});
    							$.cookie("lenoxEmail","Go",{path:'/',expires:3650});
    							cmCreatePageElementTag('FORM SUBMITTED:GO','EMAIL SIGNUP LIGHTBOX');
    							cmCreateRegistrationTag(emailAddr,emailAddr);
								$("#closeLB").click();
															
			    		} else {
				    			//alert("This New Email "+emailAddr+" was NOT ADDED");
				   				// Item not added to cart
								//$('#error').html('<span class="errorText">The Email you Entered was NOT added.  Please re-enter the email.</span>');
				    			//$('#email_entry').attr('style','display:blocked');
					    		$("[id=error]").each(function(i,e){
					    			$(e).html('<span class="errorText">You&#146;ve entered an invalid email address. Try again.</span>');
					    		});
					    		$("[id=email_entry]").each(function(i,e){
					    			$(e).css("display","blocked");
					    		});
					    		$("[id=email_confirm]").each(function(i,e){
					    			$(e).css("display","none");
					    		});

						}
					}
				});
	    		
 		   	}
		}	

