function showhideboxes(){
	// Apply the date picker jQuery UI element to the wedding date:
	$('#email_signup input[name=User Defined]').datepicker({ dateFormat: 'm/d/yy' });

	// Make the default text in the email popup and form show and hide nicely:
	$('#email_signup input[name=Email Address]').focus(function(){
		if( $('#email_signup input[name=Email Address]').val() == 'Email Address' ){
			$('#email_signup input[name=Email Address]').val('');
		}
	});

	$('#email_signup input[name=Email Address]').blur(function(){
		if( $('#email_signup input[name=Email Address]').val() == '' ){
			$('#email_signup input[name=Email Address]').val('Email Address');
		}
	});

	// Make the default text in the name popup and form show and hide nicely:
	$('#email_signup input[name=Full Name]').focus(function(){
		if( $('#email_signup input[name=Full Name]').val() == 'Full Name' ){
			$('#email_signup input[name=Full Name]').val('');
		}
	});

	$('#email_signup input[name=Full Name]').blur(function(){
		if( $('#email_signup input[name=Full Name]').val() == '' ){
			$('#email_signup input[name=Full Name]').val('Full Name');
		}
	});

	// Make the default text in the date popup and form show and hide nicely:
	$('#email_signup input[name=User Defined]').focus(function(){
		if( $('#email_signup input[name=User Defined]').val() == 'User Defined' ){
			$('#email_signup input[name=User Defined]').val('');
		}
	});

	$('#email_signup input[name=User Defined]').blur(function(){
		if( $('#email_signup input[name=User Defined]').val() == '' ){
			$('#email_signup input[name=User Defined]').val('User Defined');
		}
	});

	// POPUP:
	// Make the default text in the email popup and form show and hide nicely:
	$('#sm_content input[name=Email Address]').focus(function(){
		if( $('#sm_content input[name=Email Address]').val() == 'Email Address' ){
			$('#sm_content input[name=Email Address]').val('');
		}
	});

	$('#sm_content input[name=Email Address]').blur(function(){
		if( $('#sm_content input[name=Email Address]').val() == '' ){
			$('#sm_content input[name=Email Address]').val('Email Address');
		}
	});

	// Make the default text in the name popup and form show and hide nicely:
	$('#sm_content input[name=Full Name]').focus(function(){
		if( $('#sm_content input[name=Full Name]').val() == 'Full Name' ){
			$('#sm_content input[name=Full Name]').val('');
		}
	});

	$('#sm_content input[name=Full Name]').blur(function(){
		if( $('#sm_content input[name=Full Name]').val() == '' ){
			console.log('Full name was blank!');
			$('#sm_content input[name=Full Name]').val('Full Name');
		}
	});

	// Make the default text in the date popup and form show and hide nicely:
	$('#sm_content input[name=User Defined]').focus(function(){
		if( $('#sm_content input[name=User Defined]').val() == 'User Defined' ){
			$('#sm_content input[name=User Defined]').val('');
		}
	});

	$('#sm_content input[name=User Defined]').blur(function(){
		if( $('#sm_content input[name=User Defined]').val() == '' ){
			$('#sm_content input[name=User Defined]').val('User Defined');
		}
	});
}

$(document).ready(function(){
	// FORM:
	showhideboxes();

	if($.cookie('maybelater') != 'yes'){
		// Set up the cookies and interstitial:
		if( undefined == $.cookie('views') ){
			// Set the cookie:
			$.cookie('views', '0', { expires: 3, path: '/', domain: 'marilynskeepsakes.com' });
		} else{
			if(parseInt($.cookie('views')) < 16){
				// Increment the cookie:
				$.cookie('views', (parseInt($.cookie('views')) + 1), { expires: 3, path: '/', domain: 'marilynskeepsakes.com' });
			}
			
			if(parseInt($.cookie('views')) >= 16 && $.cookie('action') != 'nothanks'){
				$.cookie('views', 0, { expires: 3, path: '/', domain: 'marilynskeepsakes.com' });
			}

			// Determine if we should show the interstitial:
			if(parseInt($.cookie('views')) === 2){
				$('a.on_load_modal').smart_modal({
					show:function(){
						showhideboxes();
						$('.email_signup input[name=User Defined]').datepicker({ dateFormat: 'm/d/yy' });
						$('#ui-datepicker-div').css('z-index', '1002');
						// Higher z-index, width
						// Undo in hide
					},
					hide:function(){
					}
				});
				$('a.on_load_modal').smart_modal_show();

				$('a.close_interstitial').click(function(){
					$('a.on_load_modal').smart_modal_hide();
					return false;
				});

				$('a.maybelater').click(function(){
					$('a.on_load_modal').smart_modal_hide();
					$.cookie('maybelater', 'yes', { expires: 14, path: '/', domain: 'marilynskeepsakes.com' });
					return false;
				});

				$.cookie('interstitial-count', parseInt($.cookie('interstitial-count')) + 1);
			}
		}
	}
});
