$(document).ready(function() {

	//open external links in new window
	$("a:not([href*='"+site_url+"'])").not("[href^=#]").attr({ target: "_blank" });


	$(".donate-amount").change(function() {
		var v = $(this).val();
		if (v == 'other') {
			$(this).next(".donate-other").show().children('input').focus();
		} else {
			$(this).next(".donate-other").hide();	
		}
	});
	
	$('.donate-other input').keydown(function(e){
		// prevent user from typing a comma
		if (e.keyCode == 188){
			e.preventDefault();
		}
	});

	$(".donationCheckoutForm").submit(function() {
		amount = this.donation_custom_amount.value;
		desc = this.desc.value;
		if(this.donation_custom_amount.value == 'other') {
			amount = parseFloat(this.custom_amount.value);
		}
		this.options_1.value = desc + ' - $'+amount+' + $' + amount;
	});

	
	$.fn.search = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
				$(this).addClass('lowercase');				
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
				$(this).removeClass('lowercase');
			}
		});
	};
	$("#s").search();

});
