$(document).ready(function(){
  	anchorHandler();
	deleteItem();
});

function anchorHandler () {
	var blink = function(element) {
		$(element).fadeOut('slow', function() {
			$(element).fadeIn('slow');
		});
	};
	
	$('a[href*=#]').click(function() {
    	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      		var $target = $(this.hash);
      		$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
      		if ($target.length) {
        		var targetOffset = $target.offset().top;
        		$('html,body').animate({scrollTop: targetOffset}, 1000, "linear", blink($target));
       			return false;
      		}
    	}
  	});
}

function deleteItem() {
	$('table td a.delete').click(function(event) {
		var itemName = $.trim($(this).parent().siblings(':first').text());
		var deleteItem = confirm('Do you want to delete "' + itemName + '"?');
		if (!deleteItem) {
			event.preventDefault();
		};
	});
}