$(function() {

	var posn = 0;
	var features = $('#top_features ul').children().size();
	
	function draw_buttons( delta ) {
		posn += delta;
		if (posn <= 0) {
			$( "#top_features .back" ).hide();
		} else {
			$( "#top_features .back" ).show();
		}
		if (posn >= features-2) {
			$( "#top_features .next" ).hide();
		} else {
			$( "#top_features .next" ).show();
		}
	}

	$( "#top_features .next" ).click( function() {
		$("#feature_slider").animate({ 
			marginLeft: "-=294px"
			}, 500, "swing", function() { draw_buttons( 1 ); } );
		return false;
	});

	$( "#top_features .back" ).click( function() {
		$("#feature_slider").animate({ 
			marginLeft: "+=294px"
			}, 500, "swing", function() { draw_buttons( -1 ); } );
		return false;
	});

	draw_buttons( 0 );

});


$(function() {

	$(".comment-body").each(function() {
		// q = $('<div class="comment-quote">quote</div>')''
		// $( this ).parent().append( q );
		var fn = function() { 
			var val = $(this).prev().prev().text();
			val = jQuery.trim( val );
			val = "<blockquote>"+val+"</blockquote>\n\n";
			$( "#comment-box" ).val( val );
			$( "#comment-box" ).focus();
		};
		var div = $('<div class="comment-quote">zitieren</div>')
		   .appendTo( $(this).parent() )
		   .bind('click',fn);
	});

});

$(function() {
	
	$("input.input-email").each(function() {
		var input = jQuery(this);
		var title = input.attr('title');
		if (title) { 
			// on blur, set value to title attr if text is blank
			input.val(title).addClass("blur");
			input.focus(
				function() {
					input.val("").removeClass("blur");
				}
			)
		}	
	})

	$("input.input-search").each(function() {
		var input = jQuery(this);
		var title = input.attr('title');
		if (title) { 
			// on blur, set value to title attr if text is blank
			input.val(title).addClass("blur");
			input.focus(
				function() {
					input.val("").removeClass("blur");
				}
			)
		}	
	})
	
});

