/*
  mach hier mal noch nen kommentar drumrum
*/    
	if( typeof FSC != 'object')
	{
	  FSC = new Object();
	}

  FSC.BubbleFeedback = {
  	timeout_time: Array(),
  	timeout_function: Array(),
  	timeout_events:  Array(),
  	drag_z: 10
  };
  FSC.BubbleFeedback.init = function (id, path, auto_close)
  {
  	if(typeof id != 'string')
  	{
  		id = $(id).attr("id");
  	}
  	
  	var position = $("#"+id).offset();
  	var height = $("#"+id).height();

  	if(height==0)
  	{
  		height = 20; // link-height
  	}
  	
    if(id.indexOf('_bubble') > 0)
    {
      id = id.substr(0, id.indexOf('_bubble'))
    }
    var id_div = id + '_bubble';

    if($( "#" + id_div ).length > 0)
    {
    	$( "#" + id_div ).remove();
      window.clearTimeout(FSC.BubbleFeedback.timeout_events[id]);
      FSC.BubbleFeedback.timeout_time[id] = null;
      return false;
    }
    var div = document.createElement( 'div' );
    div.id = id_div;
    div.style.zIndex = ++FSC.BubbleFeedback.drag_z;
    div.className = 'contentbubble';
    $(div).html('<img src="http://img.wallstreet-online.de/loading.gif" alt=""  /> Bitte warten ...');
    
    $('body').append( div );
    $( div ).css("top", (position.top + height) + "px");
    $( div ).css("left", position.left + "px");
    
		if(auto_close > 0)
		{
			FSC.BubbleFeedback.timeout_function[id] = "if($('"+id_div+"')){$( '"+id_div+"' ).remove()}";
			FSC.BubbleFeedback.timeout_time[id] = auto_close;
		}
		
		$.post(path, 
			function(transport)
			{
			  if((FSC.BubbleFeedback.timeout_time[id] > 0) && FSC.BubbleFeedback.timeout_function[id] && FSC.BubbleFeedback.timeout_time[id])
			  {
			    FSC.BubbleFeedback.timeout_events[id] = window.setTimeout(FSC.BubbleFeedback.timeout_function[id], FSC.BubbleFeedback.timeout_time[id]);
			  }
			  $(div).html(transport).Draggable( {handle:'.handle'} )
			  .click(function(){$(div).css("zIndex",++FSC.BubbleFeedback.drag_z)})
			  ;
			}
		);
  }

  FSC.BubbleFeedback.close = function( id )
  {
		FSC.BubbleFeedback.init($(id).parents('div.contentbubble').eq(0).attr("id"))
  }
  
  FSC.BubbleFeedback.post = function( id )
  {
  	if(id.tagName=='INPUT')
  	{
  		id.blur();
  		$(id).css('background', 'url(http://img.wallstreet-online.de/loading.gif) no-repeat');
  		$(id).attr('value', '   Bitte warten');
  	}
  	var form = id.form;
  	var target = $(form).parents('div.contentbubble').eq(0);

  	$.post(
  		form.action, $(form).formSerialize(), function(transport)
			{
			  target.html(transport);
			}
		);
  }
    
