window.onload=function(){
	$('searchformbox').hide();
	$('searchbutton').observe('click', showForm);
	$('searchformbox').observe('mouseout', searchformMouseOutHandler);
	
	$('comment_author').observe('focus', commentAuthorFocus);
	$('comment_author').observe('blur', commentAuthorBlur);
	$('comment_email').observe('focus', commentEmailFocus);
	$('comment_email').observe('blur', commentEmailBlur);		
	$('comment_url').observe('focus', commentURLFocus);
	$('comment_url').observe('blur', commentURLBlur);
	$('comment_text').observe('focus', commentTextFocus);
	$('comment_text').observe('blur', commentTextBlur);		
}

/* SEARCHBOX: */

function showForm(event){
	$('searchbutton').hide();
	$('searchformbox').show();
	$('s').focus();
}
function  searchformMouseOutHandler(event){
	if (!bubbledFromChild(this, event)) {
		$('searchbutton').show();
		$('searchformbox').hide();
	}
}
function bubbledFromChild(element, event)  {
  var target = event.element();
  if (target === element) target = event.relatedTarget;
  return (target && target.descendantOf(element));
} 

/* COMMENTS: */


function commentAuthorFocus(event){
	if ($('comment_author').value == 'Name'){
		$('comment_author').value = '';
	}
}
function commentAuthorBlur(event){
	if ($('comment_author').value == ''){
		$('comment_author').value = 'Name';
	}	
}
function commentEmailFocus(event){
	if ($('comment_email').value == 'E-Mail (wird nicht angezeigt)'){
		$('comment_email').value = '';
	}
}
function commentEmailBlur(event){
	if ($('comment_email').value == ''){
		$('comment_email').value = 'E-Mail (wird nicht angezeigt)';
	}	
}
function commentURLFocus(event){
	if ($('comment_url').value == 'URL'){
		$('comment_url').value = '';
	}
}
function commentURLBlur(event){
	if ($('comment_url').value == ''){
		$('comment_url').value = 'URL';
	}	
}
function commentTextFocus(event){
	if ($('comment_text').value == 'Kommentar'){
		$('comment_text').value = '';
	}
}
function commentTextBlur(event){
	if ($('comment_text').value == ''){
		$('comment_text').value = 'Kommentar';
	}	
}