<?xml version="1.0" encoding="UTF-8"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<include src="chembase.xml"/>
	<include src="window.xml"/>		
	<include src="scroller.xml"/>
	<include src="scrollHTML.xml"/>
	<!-- Можно выделть в отдельный файл -->
	<text name="centerTitle" width="600"  depth="-1">
		<script>
			function setValue (aText)
			{
				this.value=aText;
				this.x = (800 - this.getMediaSize().width)/2;
			}			
		</script>
	</text>
	<composition name="CBackWindow" class="CBaseWindow" userEvents="onReload" depth="-1">
		<image name="btBack" src="eval(ENVRPATH+'window\\btBack.png')"  x="4" y="4"  depth="-1" visible="false">
			<script event="onPress">
				parent.back();
			</script>
		</image>
		<script event="onReload"><![CDATA[
			var h=0;
			var w=0;
			if (this.nowFrame==this.mainFrame)
				{
					h=this.nowFrame.nowHeight;
					w=this.nowFrame.nowWidth;
				}
			else
				{
					h=this.nowFrame.height;
					w=this.nowFrame.width;
				}					
			if (this.butsNavig.visible)
				{
					this.resize(this.nowFrame.width+2,this.nowFrame.height+38);
					this.butsNavig.x = this.imFrame.x+this.imFrame.width  - 80;
					this.butsNavig.y = this.imFrame.y+this.imFrame.height  - 38;
				}
			else
				this.resize(w+2,h+2);	
			this.imgBGround.y = this.imFrame.y+2;
			this.imgBGround.x = this.imFrame.x+2;
			this.imgBGround.width = this.imFrame.width-4;
			this.imgBGround.height = this.imFrame.height-4;
			this.x = (Player.window.clientWidth - w) / 2;
			this.y = (Player.window.clientHeight - h) /2;
			this.nowFrame.visible = true;
			if (this.nowFrame.backFrame != null && this.nowFrame.backFrame != undefined)
			{
				this.btBack.visible = true;
				this.txtTitle._x = 25;
				this.txtTitle._y = 3;
			}
			else
			{
				this.btBack.visible = false;
				this.txtTitle._x = 10;
				this.txtTitle._y = 3;
			}
		]]></script>
		<script event="evClosed">
			this.nowFrame.visible = false;
			this.nowFrame = this.mainFrame;
			fireEvent("onReload");
		</script>			
		<script>
			this.nowFrame = null;
			function back()
			{
				this.nowFrame.src = "about:blank";
				this.nowFrame.visible = false;
				this.nowFrame.backFrame.visible = true;
				this.nowFrame = this.nowFrame.backFrame;
				this.butsNavig.visible = false;
				fireEvent("onReload");
			}
		</script>
	</composition>	
	<!-- Можно было выделть в отдельный файл -->
	<scene _name="CMainMenuScene" _class="CChemBaseScene" _final="false">
		<composition name="objInClassMenu">
			<text name="txTitle" class="centerTitle" width="600" depth="-1"/>
			<text name="subTitle1"  class="centerTitle" width="600" depth="-1"/>
			<text name="subTitle2"  class="centerTitle" width="600" depth="-1"/>
		</composition>
		<composition name="objInLabsMenu">
			<image name="listFon" depth="-1"/>
			<composition name="btnChemists"  class="ui_CTextButton" depth="-1">
				<script>
					this.captionSpacingV = 50;
					this.captionSpacingH = 5;
					this.init( 3,["stNormalItem", "stNormalItem", "stNormalItem"], false);
				</script>
				<script event="onRelease">
					scene.CHTMLWindow.showList("Химики");
				</script>
			</composition>
			<composition name="btnTables"  class="ui_CTextButton" depth="-1">
				<script>
					this.captionSpacingV = 50;
					this.captionSpacingH = -1;
					this.init( 3,["stNormalItem", "stNormalItem", "stNormalItem"], false);					
				</script>
				<script event="onRelease">
					scene.CHTMLWindow.showList("Таблицы");
				</script>
			</composition>
			<composition name="btnTasks"  class="ui_CTextButton" depth="-1">
				<script>
					this.captionSpacingV = 47;
					this.captionSpacingH = 2;
					this.init( 3,["stNormalItem", "stNormalItem", "stNormalItem"], false);
				</script>
				<script event="onRelease">
					var toLink = Player.module.identifier;
					var pos = toLink.lastIndexOf(".");
					toLink = toLink.substring(0,pos+1)+"tasks";
					Player.module.gotoLink(toLink);
				</script>
			</composition>
			<composition name="btnInternet"  class="ui_CTextButton" depth="-1">
				<script>
					this.captionSpacingV = 52;
					this.captionSpacingH = 10;
					this.init( 3,["stNormalItem", "stNormalItem", "stNormalItem"], false);
				</script>
				<script event="onRelease">
					scene.CHTMLWindow.showList("Ссылки");
				</script>
			</composition>
			<text name="txTitle" class="centerTitle" width="600" depth="-1"/>
			<text name="subTitle"  class="centerTitle" width="600" depth="-1"/>
			<text name="classTitle" class="centerTitle" width="600" depth="-1"/>
			<text name="labsTitle" class="centerTitle" width="600"  depth="-1"/>
		</composition>

		<composition name="cMainMenu" class="ui_CNumberMenu" depth="-1">
			<composition name="itemTemplate">
				<image name="imLoaded"   visible="false"/>
			</composition>
			<script>
				function onItemSelected()
				{
					Player.module.gotoLink(Event.object.data);
				}
			</script>
			<sequencer name="seq_Load" loop="true" playing="true">
				<script><![CDATA[
					if (this.visible)
					{
						if (items != null)
							for (var j=0; j<items.length;j++)
							{
								items[j].imLoaded.visible=!Player.module.linkExists(items[j].data);
							}
					}
					2000;
				]]></script>
			</sequencer>						
		</composition>
		<composition name="cMainClassMenu" class="ui_CButtonMenu" depth="-1">
			<composition name="itemTemplate">
				<image name="imFon"/>
			</composition>
			<script><![CDATA[
				this.itemStateCount = 3;
				function onItemSelected()
				{
					this.visible=false;
					for (var i = 0;  i < scene.cMainMenu.usedItems;  i++)
					{
						scene.cMainMenu.items[i].visible=false;
					}					
				    scene.cMainMenu.usedItems=0;
					scene.objInClassMenu.visible=false;					
					scene.objInLabsMenu.classTitle.setValue(Event.object.txCaption.value );
					scene.objInLabsMenu.labsTitle.setValue("Лабораторные работы:");
					scene.objInLabsMenu.visible=true;
					for (var i = 0;  i < Event.object.data.length;  i++)
					{
						scene.cMainMenu.addItem(Event.object.data[ i].title,Event.object.data[i].id,(i+1)+".");
 					}					
					scene.cMainMenu.visible=true;
				}
				]]>				
			</script>
		</composition>
		<composition name="CHTMLWindow" class="CBackWindow" visible="false" depth="-100">
			<image name="imgBGround"/>
			<composition name="butsNavig" x="200" depth="-10" y="600" class="CNextPrevNavig">
				<script event="onGoPrev">					
					this.parent.htmlList.goPrev();
				</script>
				<script event="onGoNext">
					this.parent.htmlList.goNext();
				</script>
			</composition>
			<script>
				imgBGround.src=CHEMISTPATH+"fon.png";
				this.nowFrame = this.htmlList;
				this.mainFrame = this.htmlList;
				function showList(aTitle)
				{				
				this.nowFrame.src = "about:blank";
				this.nowFrame.visible = false;
				this.nowFrame = this.mainFrame;
				this.setTitle(aTitle);
					if (aTitle=="Таблицы")
						this.htmlList.loadHTML(TABLEPATH+'indext.html',350,400,false);
					else
					if (aTitle=="Ссылки")
						this.htmlList.loadHTML(LINKSPATH+'links.html',400,700);
					else
						this.htmlList.loadHTML(CHEMISTPATH+'chemists.html',400,350);
					this.show();
				this.butsNavig.visible = false;
				fireEvent("onReload");
				}
			</script>
			<script event="onReload">
				this.modal = true;
			</script>
			<script event="evClosed">
				this.modal = false;
			</script>
			<composition name="htmlList"  class="CScrollHTML"  x="1" y="23" depth="-1">
				<activex name="scrollHTML">
					<script>
						function onShowTable(h, w, elem)
						{						
							parent.onShowTable(h, w, elem);
						}
						function onShowChemist(numInArray)
						{					
							if (this.arrLinks==null)
									this.parent.arrLinks = this.call("getAllLinks","").split("||");
							parent.onShowChemist(numInArray);
						}
					</script>
				</activex>
				<script>
					this.arrLinks = null;
					this.nowLink=0;
				</script>			
				<script>
					function goPrev()
					{
						if (this.nowLink==0) 
								this.nowLink=this.arrLinks.length-1;
						else
							this.nowLink--;
						this.onShowChemist(this.nowLink);
					}
					function goNext()
					{
						if (this.nowLink==(this.arrLinks.length-1)) 
							this.nowLink=0;
						else
							this.nowLink++;
						this.onShowChemist(this.nowLink);
					}				
					function onShowTable(h, w, elem)
					{						
						parent.htmlItem.src = TABLEPATH+elem;
						parent.htmlItem.height = h;
						parent.htmlItem.width = w;
						this.visible = false;
						parent.nowFrame = parent.htmlItem;
						parent.htmlItem.backFrame = this;
						this.parent.butsNavig.visible = false;
						fireEvent("parent.onReload");
					}
					function onShowChemist(numInArray)
					{					
						this.nowLink=numInArray;
						parent.htmlItem.src = CHEMISTPATH+this.arrLinks[this.nowLink];
						parent.htmlItem.height = 400;
						parent.htmlItem.width = 700;
						this.visible = false;
						parent.nowFrame = parent.htmlItem;
						parent.htmlItem.backFrame = this;
						this.parent.butsNavig.visible = true;
						fireEvent("parent.onReload");
					}
				</script>
			</composition>
			<activex name="htmlItem" visible="false" x="1" y="23" depth="10">
			</activex>
		</composition>
		<script><![CDATA[
		    function init( aTitle1,aTitle2, aThem)
			{
				var aTitle=aTitle1+" "+aTitle2;
				scene.objInLabsMenu.visible=false;
				this.objInClassMenu.txTitle.setValue("Компьютерный практикум по химии");
				this.objInClassMenu.subTitle1.setValue(aTitle1);
				this.objInClassMenu.subTitle2.setValue(aTitle2);
				scene.objInLabsMenu.txTitle.setValue("Компьютерный практикум по химии");
				scene.objInLabsMenu.subTitle.setValue(aTitle);
				scene.objInClassMenu.visible=true;
				Player.globals.themas = new Array();
				for (var i = 0;  i < aThem.length;  i+=2)
				{				  
					var thema = new Object();
					thema.title = aThem[ i];					
					var labs = aThem[ i+1];					
					thema.labs = new Array();
					for (var j = 0;  j < labs.length;  j+=2)
						{
						 	var laba = new Object();
							laba.id = labs[j];
							laba.title = labs[j+1];
							thema.labs.push(laba); 
						};
					thema.alias = '';
					Player.globals.themas.push( thema);
				};
				for (var i = 0;  i < Player.globals.themas.length;  i++)
				{
					cMainClassMenu.addItem( Player.globals.themas[ i].title,Player.globals.themas[i].labs);
				}
				Player.UI.location.setPlayerTitleMode( Player.UI.location.TM_MODULE);
			}
		    function reStart( aTitle, aThem)
			{
				scene.objInLabsMenu.visible=false;
				scene.objInClassMenu.visible=true;
				scene.cMainClassMenu.visible=true;
				scene.cMainMenu.visible=false;
			}
		]]></script>
	</scene>
</rmml>
