// Custom script

var initAnimation = false;
var initColours = false;
var initCurves = false;

var doAnimation = true;
var doColours = false;
var doCurves = false;

var timer;

infoArray = new Array();
infoArray[1] = "<span class='large'>01</span> <p>Tensar<i>tech</i> - TW3 (Keystone) Wall Systems are ideal where existing levels need to be raised with very little or no additional land-take - such as the addition of an extra carriageway on to this road.</p>";
infoArray[2] = "<span class='large'>02</span> <p>To demonstrate the construction sequence we will take a closer look at a short section of the road length. A level base is prepared.</p>";
infoArray[3] = "<span class='large'>03</span><p>No foundation is required, only a shallow concrete levelling strip below the wall face.</p>";
infoArray[4] = "<span class='large'>04</span><p>The Tensar<i>tech</i> - TW3 (Keystone) facing blocks are delived on pallets. A mortar bed is placed to receive the first course of base unit blocks.</p>";
infoArray[5] = "<span class='large'>05</span><p>The blocks are laid accurately to line and level.</p>";
infoArray[6] = "<span class='large'>06</span><p>The rest of the base blocks are laid to line and level.</p>";
infoArray[7] = "<span class='large'>07</span><p>Alignment must be checked in both directions using a spirit level.</p>";
infoArray[8] = "<span class='large'>08</span><p>The first layer of selected fill material  is then placed and compacted in accordance with the specification. The heavy roller is kept away from tha wall face.</p>";
infoArray[9] = "<span class='large'>09</span><p>A perforated drainage pipe is installed at the base and surrounded by a gravel drainage layer. Fill within 2m of the facing units is compaced with a small roller of vibrating plate.</p>";
infoArray[10] = "<span class='large'>10</span><p>the GRP dowels supplied are located into the base block. These provide a shear connection for the next row of blocks.</p>";
infoArray[11] = "<span class='large'>11</span><p>Tensar geogrid reinforcement is cut and positioned. Tensar's unique blue connectors are inserted to anchor the geogrid between the facing blocks. Before laying subsequent courses of facing blocks, always remove debris from the surface of the blocks with a suitable brush.</p>"
infoArray[12] = "<span class='large'>12</span><p>Tensioning the geogrid before placing the next fill layer ensures no slack is left in the connection at the face.</p>";
infoArray[13] = "<span class='large'>13</span><p>Fill is placed and compaced in layers up to the next layer of geogrid.</p>";
infoArray[14] = "<span class='large'>14</span><p>When working at height a suitable guard rail must be installed.</p>";
infoArray[15] = "<span class='large'>15</span><p>Monitoring of vertical and horizontal alignment of the face continues throughout construction.</p>";
infoArray[16] = "<span class='large'>16</span><p>Construction of the wall continues, placing fill, geogrids and facing blocks, progressively to the top.</p>";
infoArray[17] = "<span class='large'>17</span><p>A specialist concrete adhesive is applied to the penultimate course of facing blocks.</p>";
infoArray[18] = "<span class='large'>18</span><p>The top course of blocks is glued to the course below.</p>";
infoArray[19] = "<span class='large'>19</span><p>Where a parapet is detailed, a layer of compressible foam is placed to ensure no vertical load it transferred to the wall face.</p>";
infoArray[20] = "<span class='large'>20</span><p>A precast or cast-insitu concrete parapet is placed and backfilled.</p>";
infoArray[21] = "<span class='large'>21</span><p>The parapet and road construction is completed.</p>";
infoArray[22] = "<span class='large'>22</span><p>A crash barrier or protective railing is installed.</p>";
infoArray[23] = "<span class='large'>23</span><p>The new dual carriageway opened to traffic.</p>";

function viewSingle() {
	doAnimation = false;
	doColours = false;
	doCurves = false;
	clearTimeout(timer);
	element('TNTCtrl').src = "tnt/animate.tnt";
	swapping = true;	
	Restart();
	setInfo(1);	
}

// Sets information bar
function setInfo(num) {
	element('info').innerHTML = infoArray[num];
}

function playStage(theStage) {
	element('TNTCtrl').src = "tnt/animate.tnt";
	swapping = true;	
	doAnimation = true;
	doColours = false;
	doCurves = false;
	clearTimeout(timer);
	switch(theStage) {
		case 1:
			from = '0';
			to = '300';	
			setInfo(1);
		break
		case 2:
			from = '300';
			to = '350';			
			setInfo(2);			
		break
		case 3:
			from = '350';
			to = '489';			
			setInfo(3);			
		break
		case 4:
			from = '490';
			to = '540';			
			setInfo(4);				
		break		
		case 5:
			from = '540';
			to = '640';			
			setInfo(5);				
		break
		case 6:
			from = '640';
			to = '805';			
			setInfo(6);				
		break
		case 7:
			from = '805';
			to = '965';			
			setInfo(7);				
		break
		case 8:
			from = '965';
			to = '1200';			
			setInfo(8);				
		break
		case 9:
			from = '1200';
			to = '1600';			
			setInfo(9);				
		break
		case 10:
			from = '1600';
			to = '1725';			
			setInfo(10);				
		break
		case 11:
			from = '1725';
			to = '2405';			
			setInfo(11);				
		break
		case 12:
			from = '2405';
			to = '2900';			
			setInfo(12);				
		break
		case 13:
			from = '2900';
			to = '3205';			
			setInfo(13);				
		break
		case 14:
			from = '3205';
			to = '3320';			
			setInfo(14);				
		break		
		case 15:
			from = '3320';
			to = '3405';			
			setInfo(15);				
		break
		case 16:
			from = '3405';
			to = '5390';			
			setInfo(16);				
		break
		case 17:
			from = '5390';
			to = '5515';			
			setInfo(17);				
		break
		case 18:
			from = '5515';
			to = '5665';			
			setInfo(18);				
		break
		case 19:
			from = '5665';
			to = '5815';			
			setInfo(19);				
		break
		case 20:
			from = '5815';
			to = '5915';			
			setInfo(20);				
		break
		case 21:
			from = '5915';
			to = '5965';			
			setInfo(21);				
		break	
		case 22:
			from = '5965';
			to = '6115';			
			setInfo(22);				
		break
		case 23:
			from = '6115';
			to = '6240';			
			setInfo(23);				
		break		
	}
	TNTDoCommand('Objects("*").PlayAnimation('+from+','+to+',false,20)');
}

var swapping = false;
function playAll() {
	doAnimation = true;
	doColours = false;
	doCurves = false;
	clearTimeout(timer);
	resetSlider();
	element('TNTCtrl').src = "tnt/animate.tnt";
	swapping = true;
	setStatus('1');
	TNTDoCommand('Objects("*").PlayAnimation(0,6240,false,20)');
	getFrame();
}

// recursive function to get current frame number
function getFrame() {
	clearTimeout(timer);
	frmcnt = TNTDoCommand('Objects("*").GetFrame()');
	reportStage(frmcnt);
	timer = setTimeout("getFrame()",1000);	
}

// called by getFrame() to display the current stage number
function reportStage(theFrame) {
	// 1
	if(theFrame >= 1 && theFrame < 300) {
		setStatus('1');
		currentStage = 1;
	}
	// 2
	if(theFrame >= 300 && theFrame < 350) {
		setStatus('2');	
		currentStage = 2;
	}
	// 3
	if(theFrame >= 350 && theFrame < 489) {
		setStatus('3');
		currentStage = 3;
	}
	// 4
	if(theFrame >= 490 && theFrame < 540) {
		setStatus('4');	
		currentStage = 4;
	}
	// 5
	if(theFrame >= 540 && theFrame < 640) {
		setStatus('5');	
		currentStage = 5;
	}
	// 6
	if(theFrame >= 640 && theFrame < 805) {
		setStatus('6');	
		currentStage = 6;
	}
	// 7
	if(theFrame >= 805 && theFrame < 965) {
		setStatus('7');	
		currentStage = 7;
	}
	// 8
	if(theFrame >= 965 && theFrame < 1200) {
		setStatus('8');	
		currentStage = 8;		
	}
	// 9
	if(theFrame >= 1200 && theFrame < 1600) {
		setStatus('9');	
		currentStage = 9;		
	}
	// 10
	if(theFrame >= 1600 && theFrame < 1725) {
		setStatus('10');
		currentStage = 10;		
	}	
	// 11
	if(theFrame >= 1725 && theFrame < 2405) {
		setStatus('11');
		currentStage = 11;		
	}	
	// 12
	if(theFrame >= 2405 && theFrame < 2900) {
		setStatus('12');
		currentStage = 12;		
	}	
	// 13
	if(theFrame >= 2900 && theFrame < 3205) {
		setStatus('13');
		currentStage = 13;		
	}	
	// 14
	if(theFrame >= 3205 && theFrame < 3320) {
		setStatus('14');
		currentStage = 14;		
	}
	// 15
	if(theFrame >= 3320 && theFrame < 3405) {
		setStatus('15');
		currentStage = 15;		
	}	
	// 16
	if(theFrame >= 3405 && theFrame < 5390) {
		setStatus('16');
		currentStage = 16;		
	}	
	// 17
	if(theFrame >= 5390 && theFrame < 5515) {
		setStatus('17');
		currentStage = 17;		
	}	
	// 18
	if(theFrame >= 5515 && theFrame < 5665) {
		setStatus('18');
		currentStage = 18;		
	}	
	// 19
	if(theFrame >= 5665 && theFrame < 5815) {
		setStatus('19');
		currentStage = 19;		
	}	
	// 20
	if(theFrame >= 5815 && theFrame < 5915) {
		setStatus('20');
		currentStage = 20;		
	}	
	// 21
	if(theFrame >= 5915 && theFrame < 5965) {
		setStatus('21');
		currentStage = 21;		
	}	
	// 22
	if(theFrame >= 5965 && theFrame < 6115) {
		setStatus('22');
		currentStage = 22;		
	}	
	// 23
	if(theFrame >= 6115 && theFrame < 6240) {
		setStatus('23');
		currentStage = 23;		
	}		
}

// sets status message
function setStatus(message) {
	setInfo(message);	
}

var colourMode = false;
function colours() {
	clearTimeout(timer);
	element('colorTable').style.display = 'block';
	element('curveTable').style.display = 'none';
	resetSlider();	
	doColours = true;
	element('TNTCtrl').src = "tnt/colour.tnt";

}

function curved() {
	clearTimeout(timer);
	// Hide colors tab
	element('colorTable').style.display = 'none';
	element('curveTable').style.display = 'block';
	resetSlider();
	doCurves = true;
	element('TNTCtrl').src = "tnt/curved.tnt";	
	TNTDoCommand('Objects(“*”).SetFrame(100)');

}

function viewCurve(theCurve) {
	clearTimeout(timer);
	doCurves = true;
	setInfo(1);
	element('TNTCtrl').src = "tnt/curved.tnt";
	resetSlider();	
	switch(theCurve) {
		case 1:
			TNTDoCommand('Objects("*").PlayAnimation(100,100,false,20)');	
		break
		case 2:
			TNTDoCommand('Objects("*").PlayAnimation(100,0,false,20)');
		break
		case 3:
			TNTDoCommand('Objects("*").PlayAnimation(100,200,false,20)');
		break				
	}
}

function setColour(theColour) {
	clearTimeout(timer);
	doAnimation = false;
	doColours = true;
	doCurves = false;
	element('TNTCtrl').src = "tnt/colour.tnt";
	switch(theColour) {
		case 1:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/ivory.jpg")');
		break
		case 2:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/pewter.jpg")');
		break
		case 3:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/yorkstone.jpg")');
		break	
		case 4:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/hamstone.jpg")');
		break	
		case 5:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/sandstone.jpg")');
		break	
		case 6:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/chrome.jpg")');
		break
		case 7:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/flint.jpg")');
		break
		case 8:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/bathstone.jpg")');
		break
		case 9:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/terracotta.jpg")');
		break
		case 10:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/peat.jpg")');
		break
		case 11:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/straw.jpg")');
		break
		case 12:
			TNTDoCommand('SceneGraph.Bitmap("stones2").Load("tnt/russet.jpg")');
		break																									
	}

}
