<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by alex (mmlab) -->
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<include src="resimage.xml" />

	<composition   _name="CChemicalCloud">
		<script>
			this.autoHideComments=true;
			this.maxWidth = 190;
			this.currentSize = 14;
			this.leftBorder = 7;
			this.rightBorder = 7;
			this.topBorder = 7;
			this.bottomBorder = 7;
			this.scomments = new Array();
			this.sccomments = new Array();
			this.currentComment=null;
			this.pxml = null;	// вспомогательная переменная
			this.soundEvent = "";
		</script>
		 <composition   _name="cloud" _class="CResizablePaper" _depth="-1">
			<image _name="lt" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(0,0,7,7);</script>
			</image>
			<image _name="ct" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(7,0,43,7);</script>
			</image>
			<image _name="rt" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(50,0,7,7);</script>
			</image>
			<image _name="lc" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(0,7,7,7);</script>
			</image>
			<image _name="cc" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(7,7,43,7);</script>
			</image>
			<image _name="rc" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(50,7,7,7);</script>
			</image>
			<image _name="lb" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(0,14,7,7);</script>
			</image>
			<image _name="cb" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(7,14,43,7);</script>
			</image>
			<image _name="rb" src="eval(ENVRPATH+'cloud.png')">
				<script>this.crop(50,14,7,7);</script>
			</image>
		</composition>
		<image _name="inote" src="eval(ENVRPATH+'cloud.png')" _x="103" _y="342" _depth="-2" >
				<script>this.crop(11,21,21,20);</script>
		</image>

	<xml _name="sxml" src=":\scomments.xml" />
	<xml _name="scxml" src="rmsnd:comments.xml" />
	<script src="comments.mjs"/>
	<styles _name="stlCloud" fontSize="14"  fontFamily="Microsoft Sans Serif"  textAlign="left" color="#000000"/>
	<text _name="tcomment" style="parent.stlCloud" _x="7" _y="7" _depth="-2" />

	<script><![CDATA[
		function Initialize()
		{
			this.loadXML(this.sxml);
			this.loadXML(this.scxml);
		}

		function reloadCloudXML(path)
		{
			this.sxml.src = path;
			this.scomments.length=0;
			this.loadXML(this.sxml);
		}

		function loadXML(xml)
		{
			//trace(xml.src);
			this.pxml = xml;
			var Level1=xml.XMLDocument.firstChild.childNodes;
			var len=Level1.length;
			for(var ii=0; ii<len; ii++)
			{
				item=Level1.item(ii);
				if( item.nodeName == null)	continue;
				else	if( item.nodeName == "comments")
					loadComments(item);
			}
		}

		function loadComments(node)
		{
			var children=node.childNodes;
			if(children==undefined||children==null)	return;
			var len=children.length;
			for(var ii=0; ii<len; ii++)
			{
				child=children.item(ii);
				if( child.nodeName == "entry")
					loadComment(child);
			}
		}

		function loadComment(node)
		{
			var children=node.childNodes;
			var len=children.length;
			for(var ii=0; ii<len; ii++)
			{
				child=children.item(ii);
				if( child.nodeName == null)
				{
					var comment = new CCommentItem();
					comment.id = node.getAttribute('id');
					comment.text = child.nodeValue;
					if( this.pxml == this.sxml)
						this.scomments[this.scomments.length] = comment;
					else	if( this.pxml == this.scxml)
						this.sccomments[this.sccomments.length] = comment;
				}
			}
		}

		function splay(id, ev)
		{
			trace("## chemcloud.splay["+id+"]");
			showComment(this.scomments, id, ev);
		}

		function scplay(id, ev)
		{
			trace("## chemcloud.scplay["+id+"]");
			showComment(this.sccomments, id, ev);
		}

		function showComment(array, id, ev)
		{
			if( ev==undefined || ev==null)
				ev = true;
			if( array==undefined || id==undefined || array==null || id==null)
			{
				showTextComment("");
				return;
			}
			this.currentComment=null;
			if( !isNaN(parseInt(id)))	// is numeric
			{
				for(var ii=0;ii<array.length;ii++)
				{
					if( array[ii].id==id)
					{
						this.currentComment = array[ii];
						break;
					}
				}
			}
			else
			{
				showTextComment("");
				return;
			}
			if(this.currentComment==null)
				showTextComment("");
			else
			{
				this.soundEvent = ev;
				showTextComment(this.currentComment.text);
			}
		}

		function showTextComment(txt)
		{
			trace("## chemcloud.showTextComment["+txt+"]");
			var vs = this._visible;
			this._visible = false;
			this.tcomment._width = this.maxWidth;
			var	tvalue = "<p align=\"left\"><font size=\"" + this.currentSize + "\">" + txt + "</font></p>";
			this.tcomment.height=-1;
			this.tcomment.value = tvalue;
			this.cloud.resize(
				this.leftBorder+this.rightBorder + this.tcomment.getMediaSize().width,
				this.topBorder+this.bottomBorder + this.tcomment.getMediaSize().height);
			this.cloud._x = 76;
			this.cloud._y = inote._y - this.cloud._height + 1;
			this.tcomment._x = this.cloud._x + this.leftBorder;
			this.tcomment._y = this.cloud._y + this.topBorder;
			this._visible = vs;
			if( txt != "")
				seqComment.rewindAndPlay();
			else
				this._visible = false;
		}
	]]></script>
		<sequencer _name="seqComment">
			<script>
				if( !this.autoHideComments)	false;
			</script>
			<script>
				this.show();
				if( this.soundEvent != "")	this.soundEvent;
				else true;
			</script>
			<script>
				this.hide();
			</script>
		</sequencer>
	</composition>
</rmml>
