$(document).ready(function() {

	var search = $("input#search");		
	var default_value = search.val();

	search.focus(function(){
		if (search.val() == default_value) search.val("");
	});
	search.blur(function(){
		if (search.val() == "") search.val(default_value);
	});
	
	$(".landing-post").click(function(){
		dest = $(this).find('h3 a').attr('href');
		window.location = dest;
	});
	
	$("#donate, #donate-link").click(function() {
		var h  = $(this).attr('href');
		window.open(h,'popup','width=713,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');		
		return false;
	});

	$("a.anchorLink").anchorAnimate();
	
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}