$(document).ready(function () {
	$.localScroll();
	
	//make rel=external open in new tab
	$('a[rel*=external]').click(function(){ this.target = "_blank"; }); // make rel="external" links open new tab/window


	$("input.clean").each(function(){
		$(this).val($(this).attr('title'));
		$(this).bind('focus', function(){
			if ($(this).val() == $(this).attr('title')){
				$(this).val('');
				$(this).removeClass('clean');
			}
		});
		$(this).bind('blur', function(){		
			if ($(this).val() == ''){
				$(this).val($(this).attr('title'));
				$(this).addClass('clean');				
			}	
		});
	});		
	
	$(".donation-amount li").live('click', function(){
		$(this).find('input').attr('checked', true).change();

	})	
	
	$(".donation-amount li input").change(function(){
		$(".donation-amount li").removeClass("selected");
		$(this).parent("li").addClass("selected");
		$("#donate-amount").val($(this).val());
	});
	
	$("input.own-value").live("keyup", function(){
		var ownVal = $(this).val();
		$(this).parents("li").find(".radio").attr("value", ownVal);
	});
	
	
	if( location.hash.slice(1) == "choose" ){
		$(".set-your-own").show();
		$(".set-your-own").click()
	};
	
	

    $(".recent-tweets-placeholder").tweet({
       	query: "killspill",

        avatar_size: 16,
        count: 4,
        loading_text: "loading tweets..."
    });	
    
	twttr.anywhere(function (T) {
		
		    T("#tbox-main").tweetBox({
		      height: 60,
		      width: 390,
		      label: "Help us spread the word!",
		      defaultContent: "Help animal cleanup and rescue in the gulf. Donate at http://killspill.org and they will match your donation."
		    });
		
		  });
		  
	twttr.anywhere(function (T) {
		
		    T("#tbox-thanks").tweetBox({
		      height: 60,
		      width: 390,
		      label: "Help us spread the word!",
		      defaultContent: "I just donated to protect animals in the Gulf of Mexico, and I hope you will too! - http://killspill.org"
		    });
		
		  });		  
					

});

	
