package modules.chat.blocks.help
{
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import utils.*;
	
	/**
	* Help contents block class
	*/
	dynamic public class BxContent extends BxTopic
	{
		private var
			sContents:String;
		/**
		* @private
		*/
		function BxContent(aData:Object)
		{
			super(aData);
			sContents = BxXml.replaceXmlCharacters(BxXml.getChildByProperty(aData, "contents")["_value"]);
			maximized = false;
			this.txtContents.mouseWheelEnabled = false;
			this.txtContents.addEventListener(TextEvent.LINK, onContentClick);
		}
		/**
		* @private
		*/
		override protected function onAddToStage(event:Event):void
		{
			tfSource = root.mcStyle.HelpTopic;
			caption = sCaption;
			contents = sContents;
		}
		/**
		* Help contents ID
		*/
		public function get id():String {return sId;}
		/**
		* Maximize/minimize contents
		*/
		public function set maximized(bMode:Boolean):void
		{
			this.txtContents.scaleY = bMode ? 1 : 0;
			this.txtContents.visible = bMode;
		}

		private function onContentClick(event:TextEvent):void
		{
			gotoTopic(event.text);
		}
		/**
		* Contents caption
		*/
		override public function set caption(sCaption:String):void
		{
			super.caption = "<U>" + sCaption + "</U>";
		}
		
		private function set contents(sContents:String):void
		{
			this.txtContents.htmlText = BxStyle.getHtmlText(sContents, root.mcStyle.HelpContents);
		}
		/**
		* Contents block width
		*/
		override public function set width(iWidth:Number):void
		{
			this.txtContents.autoSize = TextFieldAutoSize.LEFT;
			this.txtContents.width = iWidth;
		}
		/**
		* Contents block height
		*/
		override public function get height():Number
		{
			return this.txtContents.visible ? super.height : this.btn.height;
		}
	}
}