var CBRant = {
	submitTimer:null,undoTimer:null,undoing:false,
	ShowUpdate:function(){$('rantDisplay').hide();$('rantClear').hide();$('rantEdit').show();if($('rant') != null ){$('rant').focus(); $('rant').select();};},
	CancelRant:function(){if( CBRant.submitTimer != null ){clearTimeout(CBRant.submitTimer);}$('rantDisplay').show();$('rantClear').show();$('rantEdit').hide();$('rant').value = unescape($F('rant_org'));},
	SaveMyRant:function(){if( CBRant.submitTimer != null ){	clearTimeout(CBRant.submitTimer);}CBRant.SaveRant();},
	ClearRant:function(){$('rantDisplay').update('');$('rant').value = '';CBRant.SaveRant();},
	EditorFocus:function(){if( CBRant.submitTimer != null ){	clearTimeout(CBRant.submitTimer);}$('rant').select();},
	EditorBlur:function(){CBRant.submitTimer = setTimeout("CBRant.SaveMyRant()",400);},
	HideUndo:function(txt){$('rant_org').value = escape($F('rant'));$('rantUndo').hide();this.undoing = false;},
	UndoRant:function(){this.undoing = true;clearTimeout(CBRant.undoTimer);$('rant').value = unescape($F('rant_org'));$('rantUndo').hide();CBRant.SaveRant();},
	EditorKeyPress:function(event){if(!event){event=window.event;}if(event.keyCode){keyPressed=event.keyCode;}else if(event.which){keyPressed=event.which;}if(keyPressed==9){CBRant.SaveRant();return false;}if(keyPressed==13){CBRant.SaveRant();return false;}if(keyPressed==27){CBRant.CancelRant();return false;}return true;},
	SaveRant:function()
	{
		if( CBRant.submitTimer != null ){	clearTimeout(CBRant.submitTimer);	}
		new Ajax.Request('rant.php',{method:'post',parameters:{rtext:$F('rant')},
			onSuccess:function(transport){
				var j = transport.responseText.evalJSON(true);
				if(j.rant){	$('rant').value = j.rant; $('rantDisplay').update(j.rant);}
				$('rantEdit').hide();$('rantDisplay').show();$('rantClear').show();
				if( CBRant.undoing == false)
				{	new Effect.Appear('rantUndo');CBRant.undoTimer = setTimeout("CBRant.HideUndo()",45000);	}
				CBRant.undoing = false;
			},
			onFailure: function(){ alert('Unable to update Expression/Rant'); }
		});
	}
}
Event.observe(window,'load',function(){var rd = $('rantDiv');if( rd != null){rd.observe('mouseover',function(event){rd.removeClassName('rantDivNormal').addClassName('rantDivHover');});rd.observe('mouseout', function(event){rd.removeClassName('rantDivHover').addClassName('rantDivNormal');});}});