$(document).ready(function() {
		
	// 	Subscribe field clear on focus
		$("#stayInTheLoopInput").focus(function () {
			
			if ($(this).val() == "Email")
			{
				$(this).val('');
			}
		});
		
	// 	Subscribe field insert Name on blur
		$("#stayInTheLoopInput").blur(function () {
			
			if ($(this).val() == "")
			{
				$(this).val('Email');
			}
		});
    
	// 	Run Mailing List Subscribe To List
		$('#stayInTheLoopForm').submit(function() {
		
			var subEmail = $("#stayInTheLoopInput").val();
			var subAction = $('#stayInTheLoopForm input:radio:checked').val();
			var errors = false;
			
			if(subEmail == 'Email')
			{
				errors = true;
				$.fn.colorbox({html:'<p style="font-size:12px; padding:15px 20px 5px 20px; color:#C00;">Please enter your email address!</p>'});
				
			}
			
			if(subEmail == '')
			{
				errors = true;
				$.fn.colorbox({html:'<p style="font-size:12px; padding:15px 20px 5px 20px; color:#C00;">Please enter your email address!</p>'});
				
			}
			
			if(errors == false)
			{
				$.post('mailinglist.php', { e: subEmail, a: subAction }, function(data) {
				  
				  $.fn.colorbox({html:'<p style="font-size:12px; padding:15px 20px 5px 20px;">'+data+'</p>'});
				  $("#stayInTheLoopInput").val('Email');
				  return false;
				  
				});
			}
			
			return false;					
		});
	
	
		/*$("#stayInTheLoopSubmit").click(function() {
			
			var subEmail = $("#stayInTheLoopInput").val();
			var subAction = $('[name=subscribe]').fieldValue();
			
			var msg = "subEmail";
			
			$.fn.colorbox({html:'<p>Hello</p>'});
			
			//$.fn.colorbox({html:'email: '+subEmail+' Action Value: '+subAction});
			
			//var subName = 'Subscriber';
			//var subEmail = $("#stayInTheLoopInput").val();
			//var key = '40939bda-c335-45da-bad7-ea5d57087004';
			//var ListName = 'ttl';
			//var URL = 'http://app.newsberry.com/api/subscriber.asmx/Add';
			
			/*$.ajax({ url: "http://app.newsberry.com/api/subscriber.asmx/Add", { licenseKey: key, listName: ListName, email: subEmail, name: subName }, success: function(){
				$(this).addClass("done");
			}});
			*/
			
			/*$.post("http://app.newsberry.com/api/subscriber.asmx/Add?", { emailTo: emailToVal, emailFrom: emailFromVal, subject: subjectVal, message: messageVal }, function(data){ alert(data); });*/
			
			/*$.ajax({
			  type: 'POST',
			  url: "http://app.newsberry.com/api/subscriber.asmx/Add?",
			  data: { licenseKey: key, listName: ListName, email: subEmail, name: subName },
			  success: function() { alert(data); },
			  dataType: XML
			}); 
			
			$.post('http://app.newsberry.com/api/subscriber.asmx/Add', function(data) {
			  $('#page').html(data);
			});	 
			
			return false;
		});
		*/

});


$(function() {
	
	
		
});