jQuery( document ).ready( function(){
	
	
	jQuery("#top-email").autofill({
  	value: 'Email'
  });
  jQuery("#top-zip").autofill({
  	value: 'Zip'
  });
	jQuery(".email-text").autofill({
            value: 'Email Address'
     });
	jQuery(".zip-text").autofill({
            value: 'Zip Code'
     });
	jQuery(".fname-text").autofill({
            value: 'First Name'
     });
	jQuery(".lname-text").autofill({
            value: 'Last Name'
     });
	
	jQuery("#email-signup").validationEngine();
	
	jQuery("#top-signup").validationEngine({
		promptPosition: "bottomLeft",
		scroll: false,
    success :  function() { topSignupSubmit() },
    failure : function() {}
	});

	function topSignupSubmit(){
		
		// Group 2 is News to Receive, Group 1 is Signup Location
		var groups2 = "";
		jQuery("input:checked").each( function(){
			groups2 += jQuery(this).val() + ",";	 
		});

		var passvars = {
						action:		"mc_submit",
						zip:			jQuery('#top-zip').val(),
						email: 		jQuery('#top-email').val(),
						group1:		jQuery('#top-source').val(),
						group2:	groups2
						}
		jQuery.post( "/wp-admin/admin-ajax.php",
			passvars, 
			function(data){
				if(data.status){
					window.location = "/thanks/";
	
				} else{
					alert(data.msg);
				}
			},
			"json");

	}

	/*
	jQuery('.field')
		.focus(function(){
			if ( jQuery(this).attr('value') == jQuery(this).attr('title') ) {
				jQuery(this).attr({ 'value': '' })
			}
		})
		.blur(function(){
			if ( jQuery(this).attr('value') == '' ) {
				jQuery(this).attr({ 'value': jQuery(this).attr('title') })
			}
		})
	*/
	
	jQuery('.all').siblings().hide();
	jQuery('.tabs-nav a').click(function(e) {
		jQuery('.tabs-nav a').removeClass('active');
		jQuery(this).addClass('active');
		var index = jQuery('.tabs-nav a').index(this);
		jQuery('#tabs div.tab:visible').hide();
		jQuery('#tabs div.tab').eq(index).show();
		e.preventDefault();
	
	});
	
	
});