Ajax.PassivePeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function($super, container, url, options) {
$super(options);
this.onComplete = this.options.onComplete;

this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);

this.updater = { };
this.container = $(container);
this.url = url;

this.start();
},

start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},

stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},

updateComplete: function(response) {
 ajaxlineaf = response.responseText.search("ajaxs_");
 ajaxstickf = response.responseText.search("ajaxstick_");
 
 if (response.responseText.substring(ajaxlineaf,ajaxlineaf+16) == this.lastText) {
 this.decay = this.decay * this.options.decay;
} else 
 {
  Ajax.show =1;
this.decay = 1;
this.container.update(response.responseText);
ajaxline = response.responseText.search("ajaxs_");
this.lastText = response.responseText.substring(ajaxline,ajaxline+16);

}

 
if (response.responseText.substring(ajaxstickf,ajaxstickf+20) == this.lastTexts) {
this.decays = this.decays * this.options.decays;
} else 
 {
  Ajax.show =2;
var start = $('startstickajax').value;
if (start  < 2)
 {
 $('startstickajax').value=2;	
 }else
 {	
$('startstickajax').value=3;
 }
this.decays = 1;
this.container.update(response.responseText);
ajaxstick = response.responseText.search("ajaxstick_");
this.lastTexts = response.responseText.substring(ajaxstick,ajaxstick+20);
}

this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},

onTimerEvent: function() {
  
this.updater = new Ajax.Request(this.url, this.options);
  
}
});

function stopajaxlive(id,forumid)
  {
      $('hidajax_'+id).value = $('tlist_'+id).checked ? '1' : '0';
         if($('hidajax_'+id).value ==1)
     {
     getdata.opt = false;	
     }
     if($('hidajax_'+id).value ==0)
     {
     getdata.opt = true; 
	 getdata(forumid);	
     }
    
  }

 
function getdata(id)
 {
var url = 'ajaxdisplay.php?f='+id;
var target = "threadbits_forum_"+id;	
var t = document.createElement(target);
var setting3 = $F('ajaxsetting3');
var setting4 = $F('ajaxsetting4');
 var myAjax = new Ajax.PassivePeriodicalUpdater(target, url, {method: 'get',frequency : setting3,  decay : setting4,onSuccess:function() {
 	 	if (getdata.opt==false)
 	     {
 	    myAjax.stop();
 	     }
 	    
   	   }
});
}

  
function showfadecon()
 { 
var setting5 = $F('ajaxsetting5');
var setting6 = $F('ajaxsetting6');
var setting7 = $F('ajaxsetting7');
  if(Ajax.show ==1)	
   {
 
 		for(i=1;i<=7;i++)
 		{
 	$('fade'+i).setStyle({visibility: 'visible'});
new Effect.Opacity(
   'fade'+i, { 
       duration:   setting5, 
    fps:        setting6,  
    sync:       false, 
    from:       0.0, 
    to:         1.0, 
    delay:      setting7, 
    complete:   0

   }
);

}
  }
    if(Ajax.show ==2)	
   {
   	  if(!($F('startstickajax') ==2))	
   {
   	for(i=1;i<=7;i++)
 		{
 	$('stickfade'+i).setStyle({visibility: 'visible'});
new Effect.Opacity(
   'stickfade'+i, { 
       duration:   setting5, 
    fps:        setting6,  
    sync:       false, 
    from:       0.0, 
    to:         1.0, 
    delay:      setting7, 
    complete:   0
   }
);
  }

}
  }
 }