isopened = 0;
StartDoorFrame=0;
StopDoorFrame=50;
var INITIAL = 0;
var STATE1 = 1;
var roof_state = INITIAL;

function OnReady(){
		element('TNTCtrl').transparent = 0;
		
		var webOk = false;
		new Ajax.Request('http://www.visimmo3d.com/testWeb.php',{asynchronous:false,onSuccess:function(r){webOk = true;}});
		if (webOk)
			TNTDoCommand('SceneGraph.Bitmap("tv_screen").Load("http://www.visimmo3d.com/advert/alliance/ex_honfleur/logo_honfleur.jpg")');
}

function OnClick(obj){
	obj = obj.toLowerCase();
	
	if(obj == "arrow"){
		Walk('Camera01', 'PhysSphere_Camera01');
	}	
	
	if( (obj == "toilets_door01")){
		isopened = !isopened;
		OpenCloseDoor(obj,isopened)
	}
		
}

function callWindow(title, width, height)
{
  window.open("",title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + width + ",height=" + height);
}


///////ROOF///////
function setRoofOn(){
	element("toit").checked = false;
	TNTDoCommand('Objects("roof_*").SetVisible(true)');
	
	roof_state = INITIAL;	
	//setState("ext", ext_wall_state);
}

function toggleRoof(){
	if(roof_state == STATE1)
		setRoofOn();
	else
		setRoofOff();
}

function setRoofOff(){
	element("toit").checked = true;
	TNTDoCommand('Objects("roof_*").SetVisible(false)');
	roof_state = STATE1;
}

var cur_roof_color = 'tuiles';

function switchRoof(roof_color)
{
	if (element("toit").checked == false)
	{
		switch (roof_color)
		{
			case 'tuiles':
				TNTDoCommand('Objects("roof_roof_tuiles").SetVisible(true)');
				TNTDoCommand('Objects("roof_roof_ardoise").SetVisible(false)');
			break;
			case 'ardoise':
			TNTDoCommand('Objects("roof_roof_ardoise").SetVisible(true)');
			TNTDoCommand('Objects("roof_roof_tuiles").SetVisible(false)');
			
			break;
		}
		cur_roof_color= "roof_color";
	}
}

function OpenCloseDoor(doorname,isopened)
{
	TNTDoCommand('Objects('+ doorname + ').StopAnimation()');
	TNTDoCommand('Objects('+ doorname + ').SetEnable(true)');
	
	var CurFrame = TNTDoCommand('Objects('+ doorname +').GetFrame()');
	if (!isopened)
		TNTDoCommand('Objects('+ doorname + ').PlayAnimation(' + CurFrame +',' + StartDoorFrame + ',false)');
	else
		TNTDoCommand('Objects('+ doorname + ').PlayAnimation(' + CurFrame +',' + StopDoorFrame + ',false)');
}


function HideGroup(groupname)
{
	TNTDoCommand('ObjectTree("' + groupname + '").SetVisible(false)');
}

function ShowGroup(groupname)
{
	TNTDoCommand('ObjectTree("' + groupname + '").SetVisible(true)');
}


