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 (form_id_or_data)
    if ( typeof( form_id_or_data ) == "object" ) { var post_data = form_id_or_data.join('&'); } else { var post_data = $('#'+form_id_or_data).serialize(); }
      
    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.focus) { $('#'+responseJSON.focus).focus();   }
               if ( responseJSON.pulsate) { $('#'+responseJSON.pulsate).effect( "pulsate", {times:3}, 500 );  }                  
               if ( responseJSON.redirect) { window.location.replace( responseJSON.redirect );   }
            }
            else
            $( '#' + ausgabe_element_id ).html( ausgabe );
            
            
            
            if (json) { return responseJSON; }
            else
            { 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(); 
}
/** AJAX UPLOAD functions ***/
function ajaxFileUpload()
{
    /*
    $("#news_f_submit")
	.ajaxStart(function(){
		$(this).hide();
	})
	.ajaxComplete(function(){
		$(this).show();
	});
    */
    //starting setting some animation when the ajax starts and completes
	$("#upload_progress")
	.ajaxStart(function(){
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});
	
	/*
		prepareing ajax file upload
		url: the url of script file handling the uploaded files
                    fileElementId: the file type of input element id and it will be the index of  $_FILES Array()
		dataType: it support json, xml
		secureuri:use secure protocol
		success: call back function when the ajax complete
		error: callback function when the ajax failed
		
            */
	$.ajaxFileUpload
	(
		{
			url: site_url+'ajax_popup/doajaxfileupload', 
			secureuri:false,
			fileElementId:'fileToUpload',
			dataType: 'json',
			success: function (data, status)
			{
			    // alert('hier success');
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert( data.error );
                        $('#fileToUpload').val('');
					}else
					{
						//alert(data.msg);
                        bilder();
                        /*
                        $('#news_f_image').val(data.uploaded_file_name);
                        $('#image_ajax_upload_f').css('display' , 'none');
                        $('#uploadedFileView').html('<img src="'+data.uploaded_file_link+'" />');
                        */
					}
				}
		  },
			error: function (data, status, e)
			{
			     print_r(data);
			     if(data.error != '')
					{
					       //	alert( data.error );
					}else
				alert( e );
			}
		}
	);
	
	return false;

}  
