// wait for the DOM to be loaded 
$(document).ready(function() { 
$('.error').hide();	

// form validation
$(function() {	   
		$("#submit").click(function() {
									 
		var areacode = $("input#areacode").val(); 
			areacode =  $.trim(areacode); 			
        		if (areacode == "") {   
					alert("Please enter an area code.");
					$("input#areacode").focus();					
      			return false;
	    	}
			
		var phone1 = $("input#phone1").val(); 
			phone1 =  $.trim(phone1); 			
        		if (phone1 == "") {   
					alert("Please enter your phone number.");
					$("input#phone1").focus();					
      			return false;
	    	}
			
		var phone2 = $("input#phone2").val(); 
			phone2 =  $.trim(phone2); 			
        		if (phone2 == "") {   
					alert("Please enter the last 4-digits of your phone number.");
					$("input#phone2").focus();					
      			return false;
	    	}
			
		// submit the form
		var areacode = $("input#areacode").val();
		var phone1 = $("input#phone1").val();
		var phone2 = $("input#phone2").val();
		
		var myphonenum = areacode+phone1+phone2;
		
		var dataString = '&to=1'+myphonenum;
		// alert("phone: "+myphonenum);

$.ajax({   
	type: "POST",
	url: "http://www.i2sms.net/services/httpsend/httpsend.php?username=crosbyvva&pword=suite200&message=Thank%20you%20for%20your%20interest%20in%20ClothingDonations.org.%20Simply%20reply%20to%20this%20message%20with%20ZIP%20ZIPCODE.%20Ex:%20ZIP%2020476",
	data: dataString,
	statusCode: {
    404: function() {
      alert('page not found');
    },
	200: function() {
      alert('success');
    }
  },
  complete: function() {
	  alert("all done");
	  	$('form#phone').hide();
	  	$('#redbox #boxcopy').html("<div id='boxcopy'></div>");   
		$('#redbox #boxcopy').html("<p>Thank you. You should receive a text message.</p>");
		$('#redbox #boxcopy').fadeIn('normal');
		
	  
  }
	/* success: function() {
		alert("success");
		$('#redbox #boxcopy').html("<div id='boxcopy'></div>");   
		$('#redbox #boxcopy').html("<p>Thank you. You should receive a text message.</p>");
		$('#redbox #boxcopy').fadeIn('normal');
		$('form#phone').hide();
	} */
});
return false;


		}); 
	});
	
}); // closes the very first tag


/* $('form#phone').submit(
	function(){
									 
	var areacode = $("input#areacode").val(); 
			areacode =  $.trim(areacode); 			
        		if (areacode == "") {   
					alert("Please enter an area code.");
					$("input#areacode").focus();					
      			return false;
	    	}
			
		var phone1 = $("input#phone1").val(); 
			phone1 =  $.trim(phone1); 			
        		if (phone1 == "") {   
					alert("Please enter your phone number.");
					$("input#phone1").focus();					
      			return false;
	    	}
			
		var phone2 = $("input#phone2").val(); 
			phone2 =  $.trim(phone2); 			
        		if (phone2 == "") {   
					alert("Please enter the last 4-digits of your phone number.");
					$("input#phone2").focus();					
      			return false;
	    	}
			
		// submit the form
		var areacode = $("input#areacode").val();
		var phone1 = $("input#phone1").val();
		var phone2 = $("input#phone2").val();
		
		var myphonenum = areacode+phone1+phone2;
		
		var dataString = 'to=1'+myphonenum;
		// alert("phone: "+myphonenum);

$.ajax({   
	type: "GET",   
  	//url: "http://www.clothingdonations.org/wp-content/themes/clothingdonationv1/app-textreminder/index.php",
	url: "http://www.i2sms.net/services/httpsend/httpsend.php?to=1"+myphonenum+"&username=crosbyvva&pword=suite200&message=Thank%20you%20for%20your%20interest%20in%20ClothingDonations.org.%20Simply%20reply%20to%20this%20message%20with%20ZIP%20ZIPCODE.%20Ex:%20ZIP%2020476",
	success: function() {
		alert("success");
		$('#redbox #boxcopy').html("<div id='boxcopy'></div>");   
		$('#redbox #boxcopy').html("<p>Thank you. You should receive a text message.</p>");
		$('#redbox #boxcopy').fadeIn('normal');
		$('form#phone').hide();
	}
});

return false;
});
*/
