$(document).ready(function(){

	$('#donate-form').css('display','none');

	$('#donate-form button.cancel').click(function () {
		$('#donate-form').slideUp("fast");
	});

	$('#donate-form button.agree').click(function () {
		if ($('#donate-form input.terms').attr('checked'))
		{
			window.location.href = "http://apaulodesign.com/widgets/Data-Vu.zip";
		}
		else
		{
			alert("In order to download this widget, you need to click the check box indicating you agree to the terms and conditions.")
		}
	});

	$('.download').click(function() {
		$('#donate-form').slideDown("fast");
	});

	
	$('#list-submit').click(function() {
		$('#list-submit').attr("disabled","disabled");
		$.get("/widgets/list.php", { email: $('#user-email').attr("value") }, function() {
			//$('#list-submit').attr("disabled","");
			//$('#user-email').attr("value",":)");
			$('#mailing-list').hide("normal");
		});
	});
});


String.prototype.trim = function () {
	return this.replace(/^\s+|\s+$/g, '');	// faster for short strings that probably don't contain leading/trailing white space
	//return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');	// fastest performance, especially for long strings
}

//unverified
String.prototype.isEmail = function () {
	var rx = new RegExp("\\w+([-+.\Õ]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	var matches = rx.exec(this);

	return (matches != null && this == matches[0]);
}