function switch_display(id){
  
  $('#'+id).css('display' , ($('#'+id).css('display')=='block' )?'none':'block' ); 
  /*
  if (document.getElementById) {
    var mydiv = document.getElementById(id);
    mydiv.style.display = (mydiv.style.display=='block'?'none':'block');
  }
  */
  }
function check_form ( )
{
	$error = '';
	
	if ( !$('#thread_new_betreff').val() ) 
	{ 
		$error = $error + 'Das Feld Betreff muss nicht lehr sein!\n';
		$('#thread_new_betreff').css('border' ,'1px solid red');
	}
	
	if ( !$('#thread_new_text').val() ) 
	{ 
		$error = $error + 'Das Feld text muss nicht lehr sein!\n';
		$('#thread_new_text').css('border' ,'1px solid red');
	}
	
	if ( !$('#sicherheitscode').val() ) 
	{ 
		$error = $error + 'Das Feld Sicherheitscode muss nicht lehr sein!\n';
		$('#sicherheitscode').css('border' ,'1px solid red');
	}
	
	if ($error!='')
	{
		alert ($error);
		return false;
	}
	else return true;
}


function check_kommentar_form ( )
{
	$error = '';
	/*
	if ( !$('kommentar_new_betreff').present() ) 
	{ 
		$error = $error + 'Das Feld Betreff muss nicht lehr sein!\n';
		$('kommentar_new_betreff').style.border = '1px solid red';
	}*/
	if ( !$('#kommentar_new_text').val() ) 
	{ 
		$error = $error + 'Das Feld text muss nicht lehr sein!\n';
		$('#kommentar_new_text').css('border' ,'1px solid red');
	}	
	if ( !$('#sicherheitscode').val() ) 
	{ 
		$error = $error + 'Das Feld Sicherheitscode muss nicht lehr sein!\n';
		$('#sicherheitscode').css('border' ,'1px solid red');
	}
	if ($error!='')
	{
		alert ($error);
		return false;
	}
	else return true;
}
function thread_new()
{
	if (!check_form()) return;
    /*	
	$('thread_new_form').request({
  onComplete: function( transport )
  { if (transport.responseText == '0') alert('Captcha False!!!'); else 
  	if (transport.responseText == '1')
    {
  		window.location.replace(site_url+'forum/page/1'); 
	}else alert ('Fehler!!!');
  }
});
*/

    form_data = document.getElementById('thread_new_form');
	form_data.onsubmit = new Function('return false');
	var inputs = [];
	$(':input', form_data).each(function(){ inputs.push(this.name + '=' + encodeURIComponent(this.value)); })
	jQuery.ajax({		
		data: inputs.join('&'),
		url: form_data.action,
		type: "POST",
		timeout: 10000,
		error: function(){ console.log("25:Fehler1"); },
		success: function(ret){ 
			//$('#divAnfrage').html(ret); 
			if ( ret == 0 ) 
			{ 
				$('#new_thread_submit_button').css('display','inline');
				$('#new_thread_ajax_action').css('display','none');
				alert ('Sicherheitscode Falsch!!!');
				
			}else
			if ( ret == 1 ) { window.location.replace(site_url+controller.forum+'/page/1'); 
		
			}else alert (ret);
			  
	
			}
			});	
		return false;
	
}
function kommentar_new( t_id )
{
	if (!check_kommentar_form()) return;	


my_form = document.getElementById('kommentar_new_form');
	var inputs = [];
	$(':input', my_form).each(function(){ inputs.push(this.name + '=' + encodeURIComponent(this.value)); })
	jQuery.ajax({
		data: inputs.join('&'),
		url: my_form.action,
		type: "POST",
		timeout: 10000,
		error: function(){ console.log("25:Fehler"); },
		success: function(ret){ 
			//$('#divAnfrage').html(ret); 
			if ( ret == 0 ) {
					//$('#new_kommentar_submit_button').css('display','inline');
					//$('#new_kommentar_ajax_action').css('display','none');
					alert ('Sicherheitscode Falsch!!!');					
			}
			if ( ret == 1 ) { window.location.replace(site_url+controller.forum+'/thread/'+t_id );   }
			}			 				
	});	
	return false;
	
}
function antwort_auf( p_id )
{
	$('#p_id').val(p_id);
	if ( $('#new_kommentar_div').css('display') == 'none' || $('#new_kommentar_div').css('display') == '' ) $('#new_kommentar_div').css('display' , 'block');
	window.location.replace(this_script+'#new_kommentar_link' ); 
}

