function check_error()
{
	setTimeout( "do_check_error()", 1000)	;	
}
function do_check_error()
{
	alert('hier');
}
function ajax_test()
{
	setTimeout( "myalert('test')", 1000)	;
}
function myalert( msg)
{
	alert(msg);
}

function switch_display( element_id )
{
    if ( $('#'+element_id).css('display')=='none' ){
        $('#'+element_id).css('display' , 'block');        
    }
    else{
        $('#'+element_id).css('display' , 'none');
    }
}

function toggledisplay (id)
	{
	if (document.getElementById) {
	var mydiv = document.getElementById(id);
	mydiv.style.display = (mydiv.style.display=='block'?'none':'block');
	}
	
}
function bevor_send_bewertung()
{
    if( $('#berertungs_form_rating').val()==0 )
    {
        alert('Geben Sie Ihre Bewertung indem Sie entsprechende Anzahl von Sternen anklicken');
        //$('#berertungs_form_text').focus();    
        return false;
    }
    else
    if ($('#berertungs_form_text').val()=='')
    {
        alert('Geben Sie bitte kommentar zu Ihrer Bewertung ein.');
        $('#berertungs_form_text').focus();
        return false;    
    }
    
    common_ajax('ajax_function/save_bewertung' , 'bewertungs_container' , 'bewertung_f' , true );
    
    
    return false;
 
}
function show_status_message( message , title )
{
    if (title == undefined) title = 'Message';
    if (!$('#status_message').length)
    {
        $('body').append($('<div id="status_message"  title="'+title+'" ></div>'));
    }
    $('#status_message').html(message);
    $('#status_message').dialog();
    
}

function common_ajax( source , ausgabe_element_id , form_id_or_data , json )
{
    $('#'+ausgabe_element_id).append('<img src="'+site_url+'images/ajax_loader.gif" class="ajax_loader" title="loading" />');
    if ( typeof( form_id_or_data ) == "object" ) { var post_data = form_id_or_data.join('&'); } else { var post_data = $('#'+form_id_or_data).serialize(); }
    ssuc = false;  
    jQuery.ajax({
    	url: site_url + source, 
    	data: post_data,
    	type: "POST",
    	timeout: 4000,
    	error: function(){ console.log("25:Fehler"); },
    	success: function(ausgabe){    	   
    	   $('.ajax_loader').remove();    
    	    if (json){ 
    	       responseJSON = jQuery.parseJSON(ausgabe);               
               if ( responseJSON.message ) { $( '#' + ausgabe_element_id ).html( responseJSON.message ); }
               if ( responseJSON.sys_message ) { show_status_message( responseJSON.sys_message ); }
               if ( responseJSON.redirect) { window.location.replace( responseJSON.redirect );   }
                
            }
            else
            {
                $( '#' + ausgabe_element_id ).html( ausgabe );
            }
            
            if ( json ) { return responseJSON; }
   		}
        
        
        
    });
    
    return false;
}

function edit_leistung_antwort( antwort_id )
{
    $('#edit_leistung_antwort_'+antwort_id).css('display' , 'none');
    html = '<form id="save_leistung_antwort_form_'+antwort_id+'" method="post" action="#" onsubmit="return save_leistung_antwort('+antwort_id+')" >'+
    '<textarea id="leistung_antwort_form_text_'+antwort_id+'" class="edit_lkd_antwort">'+$('#lkf_id_' + antwort_id).html()+
    '</textarea>'+
    '<br /><input type="submit" value="speichern" />';
    
    $('#lkf_id_' + antwort_id).html( html.replace( /<br\s*\/?>/mg , "") );
}

function save_leistung_antwort( antwort_id )
{
    //alert('save_leistung_antwort_form_'+antwort_id);
    common_ajax('ajax_function/save_antwort' , 'lkf_id_'+antwort_id , new Array('lkd_answer='+$('#leistung_antwort_form_text_'+antwort_id).val() , 'lkd_id='+antwort_id ) , true );
    $('#edit_leistung_antwort_'+antwort_id).css('display' , 'block');
    return false;
}
























