<?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="lists.xml"/>
	<include src="labReport.xml"/>
	<include src="window.xml"/>	

	<text name="centerTitle" width="600"  depth="-1">
		<script>
			function setValue (aText)
			{
				this.value=aText;
				this.x = (800 - this.getMediaSize().width)/2;
			}			
		</script>
	</text>
	
	<scene _name="CLabMenuScene" _class="CChemBaseScene" _final="false" userEvents="onLabReportPress">
		<image name="imBackground"/>
		<audio _name="testAudio"/>		
		
		<composition name="objInExpMenu">
			<image name="listFon" depth="0"/>
			<text name="txTitle" class="centerTitle" width="600" depth="-1"/>
			<text name="supTitle"  class="centerTitle" width="600" depth="-1"/>
			<text name="expTitle" width="600"  depth="-1"/>
			<composition name="btnCollect"  class="ui_CTextButton" depth="-1">
				<script>
					this.captionSpacingV = 50;
					this.captionSpacingH = -10;
					this.init( 3,["stNormalItem", "stNormalItem", "stNormalItem"], false);
				</script>
				<script event="onRelease">
					scene.CTestsWindow.showLinks("Справочные материалы");
				</script>				
			</composition>	
		</composition>
		
		<!-- WIN -->
		<composition name="CTestsWindow" class="CBaseWindow" visible="false" depth="-10">
			<image name="imgBGround"/>
			<script>
				this.wLinks=465;
			</script>
			<script>
				this.testSafety="";
				this.tests="";
				this.testPath="";
				this.whatIsTest=0;
				var pos1 = this.hsA01.hitArea.lastIndexOf(",")+1;
				var pos2 = this.hsA01.hitArea.lastIndexOf("]");
				this.heightArea = this.hsA01.hitArea.substring(pos1,pos2); 
			</script>
			<script event="evClosed">
				this.htmlTests.visible=false;
				this.htmlTests.src="about:blank";
				scene.testAudio.stop();
				this.menuOfLink.visible=false;
				this.modal=false;
			</script>			
			<script>
				function showTest(aTitle,testPath)
				{
					this.modal=true;
					this.cMenuLink.visible=false;
					this.setTitle(aTitle);
					this.testPath=testPath;
					Player.module.extract(testPath+"\\images\\","\\test\\images\\");
					Player.module.extract("rmsc:\\tests\\","\\test\\");
					Player.module.extract("rmcomscr:\\js\\tests.js","\\test\\");
					src=Player.module.extract(testPath+"test.html","\\test\\");
					this.htmlTests.src=src;
					this.resize(this.htmlTests.width+2,this.htmlTests.height+2);
					this.x = (Player.window.clientWidth - this.htmlTests.width) / 2 ;
					this.y = (Player.window.clientHeight - this.htmlTests.height -this.heightArea - 85) /2 +53;
					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.visible=true;
					this.htmlTests.visible=true;
				}
				function showLinks(aTitle)
				{
					this.modal=true;
					this.htmlTests.visible = false;
					this.setTitle(aTitle);
					var h = Math.max(300, (this.cMenuLink.height + 10));
					this.resize(this.wLinks + 2,h + 2);
					this.x = (Player.window.clientWidth - this.wLinks) / 2 ;
					this.y = (Player.window.clientHeight -h -heightArea - 85) /2 +53;
					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.cMenuLink.visible = true;
					this.visible = true;
				}
			</script>
			<activex name="htmlTests" width="780" height="485" x="1" y="23" depth="20" visible="false">
				<script>
				function DocumentComplete()
				{
					this.call('execScript', ' document.body.style.overflowX="hidden"; document.body.style.overflowY="hidden";');
				}	
				</script>
				<script>
					this.arrLinks = new Array();
				</script>
				<script>
					function SayQuestion(aSound)
					{
						if (aSound!="")
						{
							scene.testAudio.stop();
							scene.testAudio.src=this.parent.testPath+aSound;
							scene.testAudio.play();
						}
					}
					function TestDone(aRightAns,aQuestionNumber, aResultTab)
					{	
						var result=aRightAns+' правильных ответов из '+aQuestionNumber+' вопросов';						
						
						if (scene.CTestsWindow.whatIsTest==1) {this.parent.parent.labReportWin.setTestResults(aResultTab);}
						else if (scene.CTestsWindow.whatIsTest==2) {this.parent.parent.labReportWin.setTest2Results(result);}
						else (this.parent.parent.labReportWin.setTest2Results(''));
						trace(aResultTab);
						trace(aQuestionNumber);
						trace(aRightAns);
					}
					function SetLinks(aLinks)
					{
						this.arrLinks=aLInks;
					}
				</script>
			</activex>
			<composition name="cMenuLink" class="ui_CButtonMenu" visible="false">
			<composition name="itemTemplate">
				<image name="imLoaded"  visible="false"/>
			</composition>
				<script>
				  this.materials = null;
				</script> 
				<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++)
							{
								var strLink=items[j].data.substr(0, items[j].data.lastIndexOf(":"));
								items[j].imLoaded.visible=!Player.module.linkExists(strLink);
							}
						}
					}
					2000;
				]]></script>
			</sequencer>				
			</composition>
		</composition> 
		<!-- text -->
		<composition name="cTestTB"  class="ui_CTextButton" depth="-1">
			<script><![CDATA[
				this.captionAlignV = this.CA_MIDDLE;
				this.captionAlignH = this.CA_RIGHT_HAND;
				this.captionSpacingH = 2;
				this.txCaption.value="Тест по технике безопасности";
				this.init( 3,["stNormalItem", "stOveredItem", "stPressedItem"], false);
				this.x = this.x - this.width; 
				
				]]>
			</script>
			<script event="onRelease">
				scene.CTestsWindow.whatIsTest=2;
				scene.CTestsWindow.showTest("Тест по технике безопасности",scene.CTestsWindow.testSafety);
			</script>				
		</composition>	

		<composition name="cTestI"  class="ui_CTextButton" depth="-1">
			<script><![CDATA[
				this.captionAlignV = this.CA_MIDDLE;
				this.captionAlignH = this.CA_RIGHT_HAND;
				this.captionSpacingH = 2;
				this.txCaption.value="Итоговый тест";
				this.init( 3,["stNormalItem", "stOveredItem", "stPressedItem"], false);
				this.x = this.x - this.width; 
				trace('-----cTestI--');
				]]>
			</script>
			<script event="onRelease">
				trace('on release cTestTB--------');
				scene.CTestsWindow.whatIsTest=1;
				scene.CTestsWindow.showTest("Итоговый тест",scene.CTestsWindow.tests);
			</script>				
		</composition>	
        <!-- mainMenu-->	
		<composition name="cMenu" class="ui_CNumberButtonMenu" depth="-1">
			<composition name="itemTemplate">
				<image name="imLoaded"  visible="false"/>
			</composition>
			<script><![CDATA[
				this.itemStateCount = 3;
				function onItemSelected()
					{
						Player.module.gotoLink( Event.object.data);
					}
				]]>				
			</script>			
			<sequencer name="seq_Loaded" loop="true" playing="true">
				<script><![CDATA[
					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>
		<script><![CDATA[
			this.experiments = null;
			this.labReportWin = null;
			this.labReportHtml = null;
			Player.globals.labModule = Player.module.identifier;
			function init( aTitle, aExps, aMaterials,aTests,aTestSafety)
			{
				Player.globals.experiments = new Array();
				for (var i = 0;  i < aExps.length;  i++)
				{				  
					var exp = new Object();
					exp.id = aExps[ i++];
					exp.title = aExps[ i];
					exp.alias = '';
					Player.globals.experiments.push( exp);
				};
 				var linkM =CTestsWindow.cMenuLink;
 				  linkM.materials = new Array();
  				for (var i = 0;  i < aMaterials.length;  i++)
 				{				  
 					var exp = new Object();
 					exp.id = aMaterials[ i++];
 					exp.title = aMaterials[ i];
 					exp.alias = '';
 					linkM.materials.push( exp);
 				} 
 				for (var i = 0;  i < Player.globals.experiments.length;  i++)
					cMenu.addItem( Player.globals.experiments[ i].title, Player.globals.experiments[ i].id,(i+1)+".");
  				if (linkM.materials.length!=0)
					for (var i = 0;  i < linkM.materials.length;  i++)
						linkM.addItem( linkM.materials[ i].title, linkM.materials[ i].id); 
				else
					scene.objInExpMenu.btnCollect.visible=false					
				CTestsWindow.testSafety=aTestSafety;
				CTestsWindow.tests=aTests;
				if (!resourceExists(aTestSafety+"test.html"))
					cTestTB.visible=false;
				if (!resourceExists(aTests+"test.html"))
					cTestI.visible=false;
					
				this.objInExpMenu.txTitle.setValue(aTitle);
				this.objInExpMenu.supTitle.setValue("Лабораторная работа");
				this.objInExpMenu.expTitle.value = "Опыты:";					
				Player.globals.xmlReportText = null;
				this.labReportWin = new Composition();
				this.labReportWin._class = "CLabReportWin";
				this.labReportWin._name = 'labReportWindow';
				this.labReportWin.parent = scene;
				this.labReportWin.loadReport();
				
				Player.UI.location.setPlayerTitleMode( Player.UI.location.TM_MODULE);
				
				Player.UI.tools.addButton( 'Лабораторный журнал', this, 'onLabReportPress', getFullPath( 'rmgr:tools/bt_labreport.png'), 3);
			}		
			function showReport()
			{	
				this.labReportWin.showReport();
			}
		]]></script>
		<script event="onLabReportPress">
			this.showReport();
		</script>
	</scene>
</rmml>
