/*

	Name:		HOWE vizualized showroom v3.
	Last edit:	TurnTool.JF 15-08-2006

*/
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function element(id)
{
	if(ie4)	// Explorer 4
		return document.all[id];
	else	// Explorer 5+ Netscape 6+ and Mozilla and Firefox
		return document.getElementById(id);
}

function initTurnTool()
{
	var tntInstalled = isTurnToolInstalled();
	if (tntInstalled==false)
	{
		element('InstallTag').innerHTML = '<center><input type=button value="Install TurnTool Viewer" onclick="installTurnTool();"></center>';
		checkRefresh();
	}
	else
	{
		if (!(ie4||ie5))
		{
			element('TurnTool').innerHTML = '<embed id="TNTCtrl" width="640" height="480" src="hhh.tnt" transparent="0" ctrl_color="#FFFFFF" pluginspage="http://www.turntool.com/download/" type="application/tntfile"></embed>';
		}
	}	
}

function writeTNT(filesrc)
{
	document.write("<object id='TNTCtrl' width='"+tntwidth+"' height='"+tntheigth+"' classid='CLSID:402ee96e-2ce8-482d-ada5-ceceea07e16d' codebase='http://www.turntool.com/ViewerInstall.exe#version=2,12,0,1' >");
	document.write("<param name='transparent' value='0'>");
	document.write("<param name='ctrl_color' value='#FFFFFF'>");
	document.write("<param name='tnt_back_color' value='#FFFFFF'>");
	document.write("<param name='tnt_width' value='"+tntwidth+"'>");
	document.write("<param name='tnt_height' value='"+tntheigth+"'>");
	document.write("<param name='src' value='"+filesrc+"'>");
	document.write("<embed id='TNTCtrlXP' width='"+tntwidth+"' height='"+tntheigth+"' src='"+filesrc+"' transparent='0' ctrl_color='#FFFFFF' tnt_back_color='#FFFFFF' pluginspage='http://www.turntool.com/download/' type='application/tntfile'></embed>");
	document.write("</object>");
}

function isTurnToolInstalled()
{
	var tntInstalled = false;
	if (ie4||ie5)
	{
		try
		{
			var xObj = new ActiveXObject("TNT.TNTCtrl");
			if (xObj)
			{
				tntInstalled = true;
			}
		}
		catch (e)
		{
		}
	}
	else
	{
		if(navigator.plugins.namedItem("TurnTool XPCOM Plugin"))
		{
			tntInstalled = true;
		}
	}
	return tntInstalled;
}

function installTurnTool() 
{
	if (ie4||ie5)
	{
		window.location.href = "http://www.turntool.com/ViewerInstall.exe";
	}
	else
	{
		var xpi = {'TurnTool Viewer Installation':'http://www.turntool.com/ViewerInstall.xpi'};
		InstallTrigger.install(xpi,installFinish);
	}
}

function installFinish(url, result)
{
	window.location.href = window.location;
}

var checkCounter = 0;
function checkRefresh()
{
	var tntInstalled = isTurnToolInstalled();
	if(tntInstalled==false)
	{
		checkCounter++;
		if (checkCounter>20)
		{
			checkCounter=0;
			installTurnTool();
		}
		setTimeout('checkRefresh()',500);
	}
	else
	{
		window.location.href = window.location;
	}
}

function doLoaded()
{
	makeMap();
	initFurnitureNames();
	initConfigNames();
}
var h = 600;
var w = 800;
function initScreen()
{
	h = window.screen.height;
	w = window.screen.width;
	if(h < 600)
	   {	h = 600;	}
	if(h > 600)
	   {	h = 750		}
	if(w < 800)
	   {	w = 800;	}
	if(w > 800)
	   {	w = 900;	}
	
	if(window.name != 'tnt')
	{
		w += 20;
		h += 150;
	}
	if (parseInt(navigator.appVersion)>3)
	{
	   	if (navigator.appName=="Netscape") {
	    top.outerWidth=w;
	    top.outerHeight=h;
		}
		else top.resizeTo(w,h);
 	}
}

var currentRoom = 1;

function toDec(roomA)
{
	var room;
	switch(roomA){
		case "A" : {
			room = 0;
			break;
		}
		case "B" : {
			room = 1;
			break;
		}
		case "C" : {
			room = 2;
			break;
		}
		case "D" : {
			room = 3;
			break;
		}
		case "E" : {
			room = 4;
			break;
		}
		case "F" : {
			room = 5;
			break;
		}
		case "G" : {
			room = 6;
			break;
		}
		default : {
			room = 7;
			break; 
		}
		
	};
	return room;		
}

function newRoom(roomA)
{
	roomA = roomA.substring(5,6);
	
	if(roomA.match = "zone")
		var room = toDec(roomA);
	else
		var room = roomA;
	if(room == currentRoom)
		return false;
		
	var html = '';
	if(room < 7)
	{
		checkMap(room);
		
		html += '<form>\n<table class="howeselect" width="100%"><tbody><tr width="100%">\n';
		for(var m = 0 ; m < configArray[room].length ; m++)
		{
			html += '<td align="center">\n';
			html += '<a href="#" class="';
			if(m==0)
				html += 'layoutactive';
			else
				html += 'layoutlink';
			html += '" id="'+m+'" onclick="selectLayout(this.id); return false;">';
			html += configArray[room][m] + '\n<img src="gp_pil_down.gif" border="0"></a>\n';
			html += '</td>\n';			
		}
		html += '</tr></tbody></table>\n</form>';
		
		currentRoom = room;
		currentLayout = 0;
		element('layoutDiv').innerHTML = html;
	}
	else
	{	// if I am somewhere with no HOWE products I need no options!
		element('chairType').innerHTML = '';
		element('chairFinishes').innerHTML = '';
		element('tableType').innerHTML = '';
		element('tableFinishes').innerHTML = '';	
	}
	
	if(room < 7)
		newLayout();
	currentRoom = room;
}

function checkMap(room) // change map if upstairs or change back to ground floor!
{
	var zPos = parseFloat(TNTDoCommand('SceneGraph.Objects("PhysSphere#A").GetPositionWorldZ()'));
	
	// change the map if upstairs!
	if(room == 2)
		element('mapImg').src = 'map1.jpg';
	else
		element('mapImg').src = 'map0.jpg';
}

function updateTNTview()
{
	var currentConf = 1;
	var roomNameCmd = new Array('A','B','C','D','E','F','G');
	var layoNameCmd = new Array('a','b','c','d');
	var tabSel = element('tableSelection');
	var charSel = element('chairSelection');
	// hide the correct stuff !
	for(var m = 0 ; m < roomNameCmd.length ; m++)
	{
			var cmd = 'SceneGraph.Objects("#' + roomNameCmd[m] + /*layoNameCmd[n] +*/ '*").SetVisible(false)';
			TNTDoCommand(cmd);
		for(var n = 0 ; n < layoNameCmd.length ; n++)
		{
		}
	}
	
	// view the correct stuff !
	var specialviewtable = '';
	var specialviewchair = '';
	if(element('chairType').innerHTML != '')
	{
		specialviewchair = (element('chairSelection').selectedIndex+1).toString();
	}
	if(element('tableType').innerHTML != '')
	{
		specialviewtable = (element('tableSelection').selectedIndex+1).toString();
		if(tabSel.options[tabSel.selectedIndex].value.toLowerCase().indexOf('tutor') > -1)
		{
			specialviewchair += specialviewchair;
		}
	}	
	var cmdTable = 'SceneGraph.Objects("#' + roomNameCmd[currentRoom] + layoNameCmd[currentLayout] + specialviewtable + '_*").SetVisible(true)';
	TNTDoCommand(cmdTable);
	var cmdChair = 'SceneGraph.Objects("#' + roomNameCmd[currentRoom] + layoNameCmd[currentLayout] + specialviewchair + 'c_*").SetVisible(true)';
	TNTDoCommand(cmdChair);
	viewSpecials();
}

function updateChairsInRoom()
{
	var roomNameCmd = new Array('A','B','C','D','E','F','G');
	var layoNameCmd = new Array('a','b','c','d');
	var tabSel = element('tableSelection');	
	var chaSel = element('chairSelection');
	var debug = '';
	for(var v = 0; v < tabSel.options.length; v++)
	{
		var cmd = 'SceneGraph.Objects("#' + roomNameCmd[currentRoom] + layoNameCmd[currentLayout] + /*(v+1) +*/ '*c_*").SetVisible(false)';
		TNTDoCommand(cmd);
		debug += cmd+'\n';
	}
	debugAlert('Hide: '+cmd);
	var cmd = 'SceneGraph.Objects("';
	var cmdStr = '#' + roomNameCmd[currentRoom] + layoNameCmd[currentLayout] + (chaSel.selectedIndex+1);
	var cmdStr3 = '';
	var cmdStr2 = '';
	/*if(chairTable)
		cmdStr2 += '_';
	else
	*/	cmdStr2 += 'c';
	if((currentRoom == 1) || (currentRoom == 5))
	{
			if(((currentLayout == 0)||(currentLayout == 1))&&tabSel[tabSel.selectedIndex].value.match('tutor') > -1)
			{
				cmdStr3 += (chaSel.selectedIndex+1);
			}
	}
	cmd += cmdStr+cmdStr3+cmdStr2+'_*").SetVisible(true)';
	debugAlert('chairUpdate: '+cmd);
	TNTDoCommand(cmd);
}

function viewSpecials() 	// hide/view extras in some rooms
{
	if(!(currentRoom == 1 && currentLayout == 1))
		TNTDoCommand('SceneGraph.Objects("#Bb_stack").SetVisible(false)');
	else if(currentRoom != 4)	
		TNTDoCommand('SceneGraph.Objects("#Ec_stack").SetVisible(false)');
	else if(currentRoom != 5)
		TNTDoCommand('SceneGraph.Objects("#Fc_stack").SetVisible(false)');
	else if(!(currentRoom == 6 && currentLayout == 0))
		TNTDoCommand('SceneGraph.Objects("#Ga_whiteboard").SetVisible(false)');
	
	
	if(currentRoom == 1 && currentLayout == 1)
		TNTDoCommand('SceneGraph.Objects("#Bb_*").SetVisible(true)');
	else if(currentRoom == 4)
		TNTDoCommand('SceneGraph.Objects("#Ec_*").SetVisible(true)');	
	else if(currentRoom == 5)
		TNTDoCommand('SceneGraph.Objects("#Fc_*").SetVisible(true)');
	else if(currentRoom == 6 && currentLayout == 0)
		TNTDoCommand('SceneGraph.Objects("#Ga_*").SetVisible(true)');
}

function newLayout() // new layout selected, so new products are to be shown
{
	debugAlert('newLayout()');
		
	makeTypeMenu('chair');
	makeTypeMenu('table');
	
	if(element('chairType').innerHTML != '')
		selectType(element('chairSelection'));
	if(element('tableType').innerHTML != '')
		selectType(element('tableSelection'));
}

function selectFinishes(what,indexId)
{
	debugAlert('selectFinishes('+what+', '+indexId+')');
	var srcName = finishes[indexId][2][0];
	mapName = finishes[indexId][2][what.selectedIndex+1];
	
	if(what)
		var desPath = finishes[indexId][2][what.selectedIndex+1] + '.bmp'; // (OLD CODE!) mapName.substring(0,mapName.length-1) + (what.selectedIndex+1) + '.bmp';
	else
		var desPath = mapName + '.bmp';	
	TNTDoCommand('SceneGraph.Bitmap("' + srcName + '").Load("' + desPath + '")');
	debugTNTalert('SceneGraph.Bitmap("' + srcName + '").Load("' + desPath + '")');
	TNTfocus();
}

function makeTypeMenu(what)
{
	var chairTable = 0;
	var selectWidth = 150;
	if(what == 'table')
		chairTable = 1;
	if(w > 800)
		selectWidth = 200;
	var html = '<SELECT NAME="' + what + 'Selection" id="' + what + 'Selection" onChange=selectType(this); font=-1 SIZE="1" style="width: ' + selectWidth + 'px">';
	for(var m = 0 ; m < layoutStuff[currentRoom][currentLayout][1][chairTable].length ; m++)
	{
		html += ' <OPTION class="one" id="' + what + 'TypeTable' + m + '" value="' + layoutStuff[currentRoom][currentLayout][1][chairTable][m] + '"';
		if(m==0)
			html += ' selected="selected"';
		html += '>' + layoutStuff[currentRoom][currentLayout][1][chairTable][m] + '</OPTION>'; 
	}
	html += '</SELECT>';
	element(what + 'Type').innerHTML = html;
	makeFinishesMenu(layoutStuff[currentRoom][currentLayout][1][chairTable][0]);
	if(m!=0)
		return true;
	else
		return false;
}

function makeFinishesMenu(headline /* what to print in option group*/ )
{
	
	var selectWidth = 150;
	if(w > 800)
		selectWidth = 200;
	var chairTableType = 0 ;
	
	if(headline)
	{
		if(headline.match('Genus'))
			chairTableType = 0;
		else if(headline.match('plas'))
			chairTableType = 3;
		else if(headline.match('uphol'))
			chairTableType = 2;
		else if(headline.match('40'))
			chairTableType = 1;
		else if(headline.match('Motio'))
			chairTableType = 4;
		else if(headline.match('Tempest bar'))
			chairTableType = 10;
		else if(headline.match('Tutor'))
			chairTableType = 11
		else
			chairTableType = 5;
			
		var typec = 'chair';
		if(chairTableType > 4)
			typec = 'table';
	
		var html = '<SELECT NAME="' + typec + 'FinishesSelection" id="' + typec + 'FinishesSelection" onchange=selectFinishes(this,' + chairTableType + '); font=-1 SIZE="1" style="width: ' + selectWidth + 'px">';
		html +=	'<optgroup label="' + headline + '">';
		for(var m = 0 ; m < finishes[chairTableType][1].length ; m++)
		{
				html += ' <OPTION class="three" id="' + typec + 'FinishesTable' + m + '" value="' + finishes[chairTableType][1][m] + '">' + finishes[chairTableType][1][m] + '</OPTION>'; 
		}
		html += '<optgroup></SELECT>';
		element(typec + 'Finishes').innerHTML = html;
		
		selectFinishes(element(typec + 'FinishesSelection'),chairTableType);
	}
	else	// no tables in config!!!
	{
		element('tableType').innerHTML = '';
		element('tableFinishes').innerHTML = ''; 
	}
}
function selectType(what)
{
	debugAlert('selectType('+what.id+')');
	makeFinishesMenu(what[what.selectedIndex].value);
	updateTNTview();
	TNTfocus();
}

var currentLayout = 0;
function selectLayout(id)
{
	debugAlert('selectLayout('+id+')');
	element(currentLayout).className = 'layoutlink';
	element(id).className = 'layoutactive';
	
	currentLayout = id;
	
	var chairbool = makeTypeMenu('chair');
	var tablebool = makeTypeMenu('table');
	if(chairbool==true)
		selectType(element('chairSelection'));
	if(tablebool==true)
		selectType(element('tableSelection'));
	TNTfocus();
}

var roomnames = new Array('Hall area','Confrence room','Canteen/Cafe on 1st floor','Library','Break out area','Traning room','Meeting room');

function makeTNT()
{
		
}

function makeMap()
{
	var html = 	'<IMG id="mapImg" SRC="map0.jpg" WIDTH=200 HEIGHT=182 BORDER=0 ALT="" USEMAP="#map0_Map">';
	html += 	'<MAP NAME="map0_Map">';
	html += 	'<AREA SHAPE="poly" ALT="Confrence room" titel="Confrence room" COORDS="25,16, 25,33, 37,46, 54,46, 67,33, 67,16, 54,4, 37,4" HREF="Confrence room" onclick="goMap(1); return false;">';
	html += 	'<AREA SHAPE="rect" ALT="Library" titel="Library" COORDS="93,79,122,124" HREF="Library" onclick="goMap(3); return false;">';
	html += 	'<AREA SHAPE="rect" ALT="Break out area" titel="Break out area" COORDS="127,80,163,129" HREF="Break out area" onclick="goMap(4); return false;">';
	html += 	'<AREA SHAPE="rect" ALT="Meeting room" titel="Meeting room" COORDS="165,123,196,166" HREF="Meeting room" onclick="goMap(6); return false;">';
	html += 	'<AREA SHAPE="rect" ALT="Traning room" titel="Traning room" COORDS="165,64,196,107" HREF="Traning room" onclick="goMap(5); return false;">';
	html += 	'<AREA SHAPE="rect" ALT="Hall area" titel="Hall area" COORDS="3,54,59,103" HREF="Hall area" onclick="goMap(0); return false;">';
	html += 	'</MAP>';
	
	element('mapDiv').innerHTML = html;
}

function goMap(where)
{
	changePysPos(where);
}

function changePysPos(where)
{
	var xPos = -128;
	var yPos = -395;
	var zPos = 35;
	var xRot = 90;
	var yRot = 90;
	var zRot = 0;
	switch(where){
		case 0 : {
			xPos = -107;
			yPos = -175;
			zRot = 110;
			break;
		}
		case 1 : {
			xPos = 55;
			yPos = 213;
			zRot = 90;
			break;
		}
		case 2 : {
			xPos = 223;
			yPos = 31;
			zPos = 189;
			zRot = 145;
			break;
		}
		case 3 : {
			xPos = 471;
			yPos = -199;
			zRot = 340;
			break;
		}
		case 4 : {
			xPos = 797;
			yPos = -90;
			zRot = 310;
			break;
		}
		case 5 : {
			xPos = 1123;
			yPos = -249;
			zRot = 45;
			break;
		}
		case 6 : {
			xPos = 1117;
			yPos = -457;
			zRot = 300;
			break;
		}
		case "Hall" : {
			xPos = -107;
			yPos = -175;
			zRot = 110;
			break;
		}
		case "Conference" : {
			xPos = 55;
			yPos = 213;
			zRot = 90;
			break;
		}
		case "Cafe/canteen" : {
			xPos = 223;
			yPos = 31;
			zPos = 189;
			zRot = 145;
			break;
		}
		case "Library" : {
			xPos = 471;
			yPos = -199;
			zRot = 340;
			break;
		}
		case "Breakout" : {
			xPos = 797;
			yPos = -90;
			zRot = 310;
			break;
		}
		case "Traning" : {
			xPos = 1123;
			yPos = -249;
			zRot = 45;
			break;
		}
		case "Meeting" : {
			xPos = 1117;
			yPos = -457;
			zRot = 300;
			break;
		}
		default : {
			return false;
			break; 
		}
		
	};
	debugAlert('SceneGraph.Objects("PhysSphere#A").SetPositionWorld(' + xPos + ',' + yPos + ',' + zPos + ')');
	TNTDoCommand('SceneGraph.Objects("PhysSphere#A").SetPositionWorld(' + xPos + ',' + yPos + ',' + zPos + ')');
	TNTDoCommand('SceneGraph.Objects("PhysSphere#A").SetRotationWorld(' + xRot + ',' + yRot + ',' + zRot + ')');
	TNTfocus();
}

function getWindowSize(direction) 
{ // returns the size of the browser window
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(direction=='x' || direction=='X')
  	return myWidth;
  else if(direction=='y' || direction=='Y')
  	return myHeight;
}

var configArray		= new Array();
function initConfigNames()
{
	configArray[0]	= new Array('Cafe 1','Cafe 2','Cafe/bar');
	configArray[1]	= new Array('Training','Conference','Meeting 1','Meeting 2');
	configArray[2]	= new Array('Dining','Eating','Cafe');
	configArray[3]	= new Array('Group work','Studying');
	configArray[4]	= new Array('Group work','Meeting','Training');
	configArray[5]	= new Array('Training 1','Training 2','Conference');
	configArray[6]	= new Array('Video Conference','Meeting 1','Meeting 2');
}

var layoutStuff 	= new Array();
var finishes;
function initFurnitureNames()
{
	
	// ========================HALL AREA START========================================
	layoutStuff[0]		= new Array();				// Hall area
	layoutStuff[0][0]	= new Array();				// Hall area layout 1
	layoutStuff[0][0][0]	= 'Cafe 1';				// Hall area layout 1 name
	layoutStuff[0][0][1]	= new Array();
	layoutStuff[0][0][1][0]	= new Array('Genus arm chair, 4-leg, standing','Genus arm chair, 4-leg, hanging','40/4 arm chair, upholstered');		// Hall area layout 1 Chairs
	layoutStuff[0][0][1][1]	= new Array('Tempest round');		// Hall area layout 1 table models
	
	layoutStuff[0][1]	= new Array();				// Hall area layout 2
	layoutStuff[0][1][0]	= 'Cafe 2';				// Hall area layout 2 name
	layoutStuff[0][1][1]	= new Array();
	layoutStuff[0][1][1][0]	= new Array('Genus arm chair, 4-leg, standing','Genus arm chair, 4-leg, hanging','40/4 arm chair, upholstered');		// Hall area layout 2 Chairs
	layoutStuff[0][1][1][1]	= new Array('Tempest square','Simpla square','Spectra square');		// Hall area layout 2 table models
	
	layoutStuff[0][2]	= new Array();				// Hall area layout 3
	layoutStuff[0][2][0]	= 'Cafe/bar';				// Hall area layout 3 name
	layoutStuff[0][2][1]	= new Array();
	layoutStuff[0][2][1][0]	= new Array('Genus barstool');		// Hall area layout 2 Chairs
	layoutStuff[0][2][1][1]	= new Array('Tempest bar, round');		// Hall area layout 2 table models
	// ========================HALL AREA END==========================================
	
	// ========================CONFERENCE START=======================================
	layoutStuff[1]		= new Array();				// Confrence room
	layoutStuff[1][0]	= new Array();				
	layoutStuff[1][0][0]	= 'Training';				
	layoutStuff[1][0][1]	= new Array();
	layoutStuff[1][0][1][0]	= new Array('40/4 chair','Genus sledge chair','40/4 plastic','Motio Meeting');		
	layoutStuff[1][0][1][1]	= new Array('Simpla, rect. & V-shape','Tempest, rect. & V-shape','Plico, rect. & V-shape','Spectra, rect. & V-shape','Moveo Meeting rect. & V','Tutor');		
	
	layoutStuff[1][1]	= new Array();				
	layoutStuff[1][1][0]	= 'Conference';				
	layoutStuff[1][1][1]	= new Array();
	layoutStuff[1][1][1][0]	= new Array('40/4 chair w. write pad','Genus sledge chair','40/4 chair','Motio Visitor');		
	layoutStuff[1][1][1][1]	= new Array();
	
	layoutStuff[1][2]	= new Array();				
	layoutStuff[1][2][0]	= 'Meeting 1';				
	layoutStuff[1][2][1]	= new Array();
	layoutStuff[1][2][1][0]	= new Array('40/4 chair','Genus sledge chair','40/4 plastic');		
	layoutStuff[1][2][1][1]	= new Array('Spectra, rect. & V-shape','Simpla, rect. & V-shape','Tempest, rect. & V-shape','Plico, rect. & V-shape');		
	
	layoutStuff[1][3]	= new Array();				
	layoutStuff[1][3][0]	= 'Meeting 2';				
	layoutStuff[1][3][1]	= new Array();
	layoutStuff[1][3][1][0]	= new Array('Motio Conference');		
	layoutStuff[1][3][1][1]	= new Array('Moveo Conference rect. & boat');		
	// ========================CONFERENCE END=========================================
	
	// ========================CANTEEN/CAFE START=====================================
	layoutStuff[2]		= new Array();
	layoutStuff[2][0]	= new Array();
	layoutStuff[2][0][0]	= 'Dining';
	layoutStuff[2][0][1]	= new Array();
	layoutStuff[2][0][1][0]	= new Array('40/4 plastic chair','Genus chair, 4-leg');
	layoutStuff[2][0][1][1]	= new Array('Plico, rect.','Simpla, rect.','Tempest, rect.','Spectra, rect.');
	
	layoutStuff[2][1]	= new Array();
	layoutStuff[2][1][0]	= 'Eating';
	layoutStuff[2][1][1]	= new Array();
	layoutStuff[2][1][1][0]	= new Array('40/4 plastic chair','Genus chair, 4-leg');	
	layoutStuff[2][1][1][1]	= new Array('Plico, rect.','Simpla, rect.','Tempest, rect.','Spectra, rect.');
	
	layoutStuff[2][2]	= new Array();
	layoutStuff[2][2][0]	= 'Cafe';
	layoutStuff[2][2][1]	= new Array();
	layoutStuff[2][2][1][0]	= new Array('Genus chair, 4-leg','40/4 plastic chair');
	layoutStuff[2][2][1][1]	= new Array('Tempest, squares & rounds','Simpla, square','Spectra, square');
	// ========================CANTEEN/CAFE END======================================
	
	// ========================LIBRARY START=========================================
	layoutStuff[3]		= new Array();
	layoutStuff[3][0]	= new Array();
	layoutStuff[3][0][0]	= 'Group work';
	layoutStuff[3][0][1]	= new Array();
	layoutStuff[3][0][1][0]	= new Array('40/4 chair','Genus chair, 4-leg');
	layoutStuff[3][0][1][1]	= new Array('Tempest, half round & rect.','Simpla, half round % rect.','Plico, half round & rect.','Spectra, half round & rect.');
	
	layoutStuff[3][1]	= new Array();
	layoutStuff[3][1][0]	= 'Studying';
	layoutStuff[3][1][1]	= new Array();
	layoutStuff[3][1][1][0]	= new Array('40/4 chair','Genus chair, 4-leg');	
	layoutStuff[3][1][1][1]	= new Array('Tempest, half round & rect.','Simpla, half round % rect.','Plico, half round & rect.','Spectra, half round & rect.');
	// ========================LIBRARY END===========================================
	
	// ========================BREAK OUT AREA START==================================
	layoutStuff[4]		= new Array();
	layoutStuff[4][0]	= new Array();
	layoutStuff[4][0][0]	= 'Group work';
	layoutStuff[4][0][1]	= new Array();
	layoutStuff[4][0][1][0]	= new Array('40/4 chair','Genus chair, 4-leg');
	layoutStuff[4][0][1][1]	= new Array('Simpla, trapezoid', 'Tempest, trapezoid','Spectra, trapezoid');
	
	layoutStuff[4][1]	= new Array();
	layoutStuff[4][1][0]	= 'Meeting';
	layoutStuff[4][1][1]	= new Array();
	layoutStuff[4][1][1][0]	= new Array('40/4 chair','Genus chair, 4-leg');
	layoutStuff[4][1][1][1]	= new Array('Simpla, trapezoid', 'Tempest, trapezoid','Spectra, trapezoid');
	
	layoutStuff[4][2]	= new Array();
	layoutStuff[4][2][0]	= 'Training';
	layoutStuff[4][2][1]	= new Array();
	layoutStuff[4][2][1][0]	= new Array('40/4 chair','Genus chair, 4-leg');
	layoutStuff[4][2][1][1]	= new Array();
	// ========================BREAK OUT AREA END====================================
	
	// ========================TRAINING ROOM START====================================
	layoutStuff[5]		= new Array();
	layoutStuff[5][0]	= new Array();
	layoutStuff[5][0][0]	= 'Training 1';
	layoutStuff[5][0][1]	= new Array();
	layoutStuff[5][0][1][0]	= new Array('40/4 chair, upholstered','Genus arm chair, sledge','Motio Conference');
	layoutStuff[5][0][1][1]	= new Array('Tempest, rect.','Simpla, rect.','Plico, rect.','Spectra, rect.','Moveo Training');
	
	layoutStuff[5][1]	= new Array();
	layoutStuff[5][1][0]	= 'Training 2';
	layoutStuff[5][1][1]	= new Array();
	layoutStuff[5][1][1][0]	= new Array('40/4 chair, upholstered','Genus arm chair, sledge','Motio Conference','40/4 plastic');
	layoutStuff[5][1][1][1]	= new Array('Tempest, rect.','Simpla, rect.','Plico, rect.','Spectra, rect.','Moveo Training','Tutor');
	
	layoutStuff[5][2]	= new Array();
	layoutStuff[5][2][0]	= 'Conference';
	layoutStuff[5][2][1]	= new Array();
	layoutStuff[5][2][1][0]	= new Array('40/4 chair, upholstered','Genus arm chair, sledge','Motio Visitor');
	layoutStuff[5][2][1][1]	= new Array();
	// ========================TRAINING ROOM  END======================================
	
	// ========================MEETING ROOM START====================================
	layoutStuff[6]		= new Array();
	layoutStuff[6][0]	= new Array();
	layoutStuff[6][0][0]	= 'Video conference';
	layoutStuff[6][0][1]	= new Array();
	layoutStuff[6][0][1][0]	= new Array('Genus arm chair, 4-leg','40/4 arm chair, upholstered','Motio Meeting');
	layoutStuff[6][0][1][1]	= new Array('Plico, rect. & V-shape','Simpla, rect. & V-shape','Tempest, rect. & V-shape','Spectra, rect. & V-shape','Moveo Meeting, rect & V');
	
	layoutStuff[6][1]	= new Array();
	layoutStuff[6][1][0]	= 'Meeting 1';
	layoutStuff[6][1][1]	= new Array();
	layoutStuff[6][1][1][0]	= new Array('Genus arm chair, 4-leg','40/4 arm chair, upholstered','Motio Meeting');
	layoutStuff[6][1][1][1]	= new Array('Plico, rect. & V-shape','Simpla, rect. & V-shape','Tempest, rect. & V-shape','Spectra, rect. & V-shape','Moveo Meeting, rect. & V');
	
	layoutStuff[6][2]	= new Array();
	layoutStuff[6][2][0]	= 'Meeting 2';
	layoutStuff[6][2][1]	= new Array();
	layoutStuff[6][2][1][0]	= new Array('Motio Conference');
	layoutStuff[6][2][1][1]	= new Array('Moveo Conference');
	
	// ========================MEETING ROOM  END======================================
	
	// 0 - 4 chairs 5 - 8 tables!
	finishes = new Array();
	finishes[0]	= new Array();
	finishes[0][0]  = 'Genus chair';
	finishes[0][1]	= new Array(
		'Blackbird, P200',
		'Coconut, P300',
		'Ayers Rock red, P110',
		'Bluestone, P140',
		'HOWE grey, P100',
		'Birch veneer, V13'
	);
	// Mapping to finishes	    1st: max source / default, rest folowes above list!
	finishes[0][2]	= new Array('mat_g_01','mat_g_01','mat_g_02','mat_g_03','mat_g_04','mat_g_05','mat_g_06');	
		
	finishes[1]	= new Array();
	finishes[1][0]  = '40/4 chair';
	finishes[1][1]	= new Array(
		'Beech veneer, V2',
		'Cherry veneer, V5',
		'Walnut veneer, V15',
		'White maple veneer, LW16'
	);
	finishes[1][2]	= new Array('mat_41_01','mat_41_01','mat_41_02','mat_41_03','mat_41_04');
	
	finishes[2]	= new Array();
	finishes[2][0]  = '40/4 chair, upholstered';
	finishes[2][1]	= new Array(
		'Black leather, Elmosoft 99999',
		'Cream Trevira, Pro 201',
		'Light grey wool, Tonus 135',
		'Green-blue wool, Tonus 627'
	);
	finishes[2][2]	= new Array('mat_42_01','mat_42_01','mat_42_02','mat_42_03','mat_42_04');
	
	finishes[3]	= new Array();
	finishes[3][0]  = '40/4 plastic chair';
	finishes[3][1]	= new Array(
		'Ayers Rock red, PA110',
		'Black, PA200',
		'Marble, PA120',
		'Coconut, PA300'
	);
	finishes[3][2]	= new Array('mat_43_01','mat_43_01','mat_43_02','mat_43_03','mat_43_04');
	
	finishes[4]	= new Array();
	finishes[4][0]  = 'Motio';
	finishes[4][1]	= new Array(
		'Black leather, Elmosoft 99999',
		'Cream Trevira, Pro201',
		'Light blue Trevira, Pro 711',
		'Grey Messenger, 031',
		'Red Messenger, 025'
	);
	finishes[4][2]	= new Array('mat_m_01','mat_m_01','mat_m_02','mat_m_03','mat_m_04','mat_m_05');
	
	// now the tables!
	finishes[5]	= new Array();
	finishes[5][0]  = 'Simpla table';
	finishes[5][1]	= new Array(
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'Black ash veneer, LW17',
		'HOWE Grey laminate, L100',
		'White laminate, L300'
	);
	finishes[5][2]	= new Array('mat_t_01','mat_t_01','mat_t_02','mat_t_03','mat_t_04','mat_t_05');
	
	finishes[6]	= new Array();
	finishes[6][0]  = 'Tempest table';
	finishes[6][1]	= new Array(
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'Black ash veneer, LW17',
		'HOWE Grey laminate, L100',
		'White laminate, L300'
	);
	finishes[6][2]	= new Array('mat_t_01','mat_t_01','mat_t_02','mat_t_03','mat_t_04','mat_t_05');
		
	finishes[7]	= new Array();
	finishes[7][0]  = 'Plico table';
	finishes[7][1]	= new Array(
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'Black ash veneer, LW17',
		'HOWE Grey laminate, L100',
		'White laminate, L300'
	);
	finishes[7][2]	= new Array('mat_t_01','mat_t_01','mat_t_02','mat_t_03','mat_t_04','mat_t_05');
	
	finishes[8]	= new Array();
	finishes[8][0]  = 'Spectra table';
	finishes[8][1]	= new Array(
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'Black ash veneer, LW17',
		'HOWE Grey laminate, L100',
		'White laminate, L300'
	);
	finishes[8][2]	= new Array('mat_t_01','mat_t_01','mat_t_02','mat_t_03','mat_t_04','mat_t_05');
			
	finishes[9]	= new Array();
	finishes[9][0]  = 'Moveo table';
	finishes[9][1]	= new Array(
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'Black ash veneer, LW17',
		'HOWE Grey laminate, L100',
		'White laminate, L300'
	);
	finishes[9][2]	= new Array('mat_t_01','mat_t_01','mat_t_02','mat_t_03','mat_t_04','mat_t_05');
	
	finishes[10]	= new Array();
	finishes[10][0]  = 'Tempest table';
	finishes[10][1]	= new Array(
		'White laminate, L300',
		'Maple veneer, V1',
		'Walnut veneer, V15',
		'HOWE Grey laminate, L100'
	);
	finishes[10][2]	= new Array('mat_t_05','mat_t_05','mat_t_01','mat_t_02','mat_t_04');
	
	finishes[11]	= new Array();
	finishes[11][0]  = 'Tutor';
	finishes[11][1]	= new Array(
		'White laminate, L300',
		'Red laminate, L110',
		'Black laminate, L200'
	);
	finishes[11][2]	= new Array('mat_tt_01', 'mat_tt_01', 'mat_tt_02','mat_tt_03');
	
	

	
}
 
function StopUpdatePosition()
{
 if (updatePositionID!=0)
 { clearInterval(updatePositionID);
  updatePositionID = 0;
 }
}
 
function StartUpdatePosition()
{
 StopUpdatePosition();
 updatePositionID = setInterval("UpdatePosition()", 250);
}
 
function UpdatePosition()
{
 var wX = -parseFloat(TNTDoCommand('SceneGraph.Objects("PhysSphere#A").GetPositionWorldX()'));
 var wY = -parseFloat(TNTDoCommand('SceneGraph.Objects("PhysSphere#A").GetPositionWorldY()'));
 element("youareherediv").style.posLeft = parseInt(topLeftSX + (wX - topLeftWX) * factorX);
 element("youareherediv").style.posTop = parseInt(topLeftSY + (wY - topLeftWY) * factorY);
}
// ==============UPDATE POS END===============

function centerWindow()
{
  if (window.screen)
  {
	var screenWidth = screen.availWidth;
	var screenHeight = screen.availHeight;
	var windowWidth = 900;
	var windowHeight = 760;
	
	if(window.name != 'tnt')
	{
		windowWidth += 20;
		windowHeight += 150;
	}
	top.resizeTo(windowWidth,windowHeight);
	top.moveTo(screenWidth/2 - windowWidth/2, screenHeight/2 - windowHeight/2);
  }
}

function TNTDoCommand(string)
{
	var control = element("TNTCtrl");
	if(control && control.ready)
		return control.TNTDoCommand(string);
	return "";
}

function OnReady()
{
	debugAlert('OnReady');
	newRoom('AAAAAAAA');
	
	StartUpdatePosition();
	if(ie4||ie5)
		window.status = "TurnTool Ready";
	TNTfocus(); 	
}
function TNTfocus()
{
	if(ie4||ie5)
		element("TNTCtrl").focus();
}

function OnClick( obj )
{
}

function OnMouseEnter( obj )
{
}

function OnMouseExit( obj )
{
}

function OnZoneEnter( zone, physics )
{
	debugAlert('OnZoneEnter('+zone+')');
	newRoom(zone);
}

function OnZoneExit( zone, physics )
{
}


var shotNum = 0;
var sessionID = new String('HOWE_');
function RenderImg(size)
{
	if(!size)
		size = 0;
	var rendername = 'TURNTOOL_';
	if(shotNum<10)
		rendername = rendername + '0';
	var cmd = '"' + rendername  + '_' + sessionID + shotNum + '.bmp",' + size;
	TNTDoCommand('Renderer.SaveImage(' + cmd + ')');
	shotNum++;
}

function HelpTNT()
{	
	//to modify the link to the help file, edit the 'functions/help.html' below!
	window.open('help.html','howehelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=816,height=600,left=20,top=20');
}

function CloseTNT()
{
	window.close();
}


var debugCMD = '';
function debug(cmd)
{
	debugCMD = cmd + '<BR>' + debugCMD;
	element('debug').innerHTML = debugCMD;
}

function debugAlert(cmd)
{
	//alert(cmd);	
}
function debugTNTalert(cmd)
{
	/*if(ie4||ie5)
		window.status = cmd;	*/
}

function openNewWindow(who)
{
	var m = 'width='+ screen.availWidth + ',height=' + screen.availHeight + ',status=no,toolbar=no,menubar=no,location=no,scrollbars=no';
	var win = window.open(who,'tnt',m);
	return false;
}
