
	/********* ALF ***055********/
	
	var json_url = 'json/';
	
		///////////// json UPDATE
	
		function alf_update( dbal, data, button, onSuccess ) {
		
			alf_json( json_url + 'action/alf_update/dbal/' + dbal, data, button, onSuccess );
				
		}
		
		/////////// json check_entry
			
		function alf_check_entry( button, dbal ) {
		
			alf_json_form( json_url + 'check_entry/', dbal + '_form', button.id, function( json ) {
					$( dbal + '_form' ).submit();
				} );
		
		}
	
		///////////// json FORM
	
		function alf_json_form( url, form, button, onSuccess ) {
		
			alf_json( url, $( form ).serialize( true ), button, onSuccess );
				
		}
		
		///////////// Clear json
		
		function alf_json( url, parameters, button, onSuccess ) {
		
			var trans = '';
			
			if( button != null )  {
				button.disabled = true;
				parameters[ 'button' ] = button.id;
			}
				
			new Ajax.Request( url, {
					method: 'post',
					parameters: parameters,
					requestHeaders: { Accept: 'application/json' },
					onSuccess: function( transport ) {
						var json = transport.responseText.evalJSON( true );
						
						if( json[ 'signal' ] == 'ERROR' ) {
							
							if( json[ 'link' ] && $( json[ 'link' ] ) ) {
								//$( json[ 'link' ] ).style.color = '#CC0000';
								new Effect.Highlight( $(json[ 'link' ]), { startcolor: '#CC0000', endcolor: '#ffffff' });
								//window.scrollTo( 0, $( json[ 'link' ] ).offsetTop + 150 );
								
							} else {
							
								alf_msg( json[ 'msg' ] );
							
							}
							
							button.disabled = false;
							
						} else if( json[ 'signal' ] == 'OK' ) {
							
							if( onSuccess != null ) {
								onSuccess( json );	
							}
								
						} else if( json[ 'signal' ] == 'LOGIN FAIL' ) {
						
							alf_msg( 'Bitte loggen Sie sich neu ein. Die SESSION ist abgelaufen.' );
							if( login_url != undefined ) {
								location = login_url;
							}
						
						} else {
							
							alf_msg( 'Interner Fehler: JSON liefert keine verwertbare Antwort' );
							
						}
						
						if( button != null && button != undefined ) 
							button.disabled = false;
								
					}
				} );
				
		}
		
		//////// Roundabout
		
		function padding(laenge) {
		result = '';
		for (i = 0; i < laenge; i++)
		result = result + '___';
		return result;
		}
		
		function print_r(das_array, ebene) {
		var result = '';
		for (var wert in das_array)
		if (typeof das_array[wert] == "object")
		result = result + ' ' + padding(ebene) + wert + "\n" + print_r(das_array[wert], ebene + 1);
		else
		result = result + ' ' + padding(ebene) + wert + ' = ' + das_array[wert] + "\n";
		
		return result;
		}
		
		/////// MSG BOX
		
		function alf_msg( msg ) {
			/*$( 'alf_msg' ).innerHTML = msg;
			$( 'alf_blackbox' ).style.display = '';
			$( 'alf_msg_box' ).style.display = '';*/
			alert(msg);
		}
		
		function alf_msg_hide() {
			$( 'alf_blackbox' ).style.display = 'none';
			$( 'alf_msg_box' ).style.display = 'none';
		}
		
		//////////////////////////
		
		
		
		/**

**/
		function alf_mailto( email, text ) {
			
			plain_email = alf_decode_email( email );
			plain_text = alf_decode_email( text );
			
			document.write( '<a href="mailto:' + plain_email + '">' + plain_text + '</a>' );
			
		}
		
		function alf_email( email ) {
			
			plain_email = alf_decode_email( email );
			
			document.write( plain_email );
			
		}

 		function alf_decode_email( email ) {
			
			email = email.replace( /\§\%\§/g, '@' );
			email = email.replace( /\%\§\%/g, '.' );
			
			return email;
			
		}
		
		
		/*
		other
		*/
		
		function nl2br(str) {
			
			if(typeof(str)=="string")
				return str.replace(/(\r\n)|(\n\r)|\r|\n/g,"<br />");
		   else return str;
		
		   return r;
	  }
		
