var secondsAfterPageOpen = 10;

function spin_up() {
	$("#m_wrapper").animate( {
		'bottom': '0px',
		'opacity': '1'
	},500, 'swing' );		
}
$(document).ready(function(){


	$("#m_name").data('label', $("#m_name").attr('value'));
	$("#m_email").data('label', $("#m_email").attr('value'));
	$("#m_name, #m_email").each( function() {
		$(this).data('dirty', 'no');
		$(this).data('background-color', $(this).css('background-color'));
		$(this).attr('value', $(this).data('label'));
	});
	
	$("#m_wrapper").css("opacity","0");

	if (typeof document.body.style.maxHeight === "undefined") { //if IE 6 
		$("#m_wrapper").css('display','none');
	} else {
		setTimeout ( spin_up, secondsAfterPageOpen * 1000 );		
	}
	
	$("#m_slider_close").click( function() {
		$("#m_wrapper").animate( {
			'bottom': '-100px',
			'opacity': '0'
		},500,'', function() {
			$("#m_wrapper").hide();
		} );
		return false;
	});
	$("#m_submit").click( function() {
		
		i = $('#m_aweber').contents().find('body');
		i.find('#a_name').attr('value', $("#m_name").attr('value') );
		i.find('#a_email').attr('value', $("#m_email").attr('value') );
		i.find('#a_affil').attr('value', 'pickles' );
		i.find("#a_submit").trigger('click');

		$("#m_content").hide();
		$("#m_success_submit").show();
		return;
	
		var errors = 'no';
		$("#m_name, #m_email").each( function() {	
			if( $(this).data('dirty') == 'no' ) {
				$(this).css('background-color', 'pink');
				errors = 'yes';
			}
		});
		if ($("#m_email").attr('value').search(/^(\w+@\w+\.\w{2,4})$/) == -1){ 	
			errors = 'yes';
			$("#m_email").css('background-color', 'pink');
		}
		if(errors == 'no') {
			
		
		}

	});
	$("#m_name, #m_email").focus( function() {
		$(this).css('background-color', $(this).data('background-color'));
		if($(this).data('dirty') == 'no') {
			$(this).attr('value', '');
		}
	});
	$("#m_name, #m_email").blur( function() {
		if($(this).attr('value') == '') {
			$(this).attr('value', $(this).data('label'));
		} else {
			$(this).data('dirty', 'yes');
		}
	});
});


	
