/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////LEGAL DISCLAIMER/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////You can not replace or modify any line  of this file. If you are using SGAG you are accepting this. If you do it you can have some legal problems. ////////////////////////
//////SGAG is (c) copyrighted by dmu.com - 2207/2007                                                                                                                        /////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//
// Sgag.js
//
 
var iPosition, sTemp, gsBrowserName;

//
// validateBrowserOS()
//
function validateBrowserOS()
{
       
        var sDetect = navigator.userAgent.toLowerCase();
	var sOS, sBrowser, sVersion;

	if ( checkIt( sDetect, 'konqueror' ))
	{
		sBrowser = 'Konqueror';
		sOS = 'Linux';
	}
	else if ( checkIt( sDetect, 'safari' ))
		sBrowser = 'Safari';
	else if ( checkIt( sDetect, 'omniweb' ))
		sBrowser = 'OmniWeb';
	else if ( checkIt( sDetect, 'opera' ))
		sBrowser = 'Opera';
	else if ( checkIt( sDetect, 'webtv' ))
		sBrowser = 'WebTV';
	else if ( checkIt( sDetect, 'icab' ))
		sBrowser = 'iCab';
	else if ( checkIt( sDetect, 'msie' ))
		sBrowser = 'Internet Explorer';
	else if ( !checkIt( sDetect, 'compatible' ))
	{
		sBrowser = 'Netscape Navigator';
		sVersion = sDetect.charAt( 8 );
	}
	else
		sBrowser = 'An unknown browser';

	if ( !sVersion )
		sVersion = sDetect.charAt( iPosition + sTemp.length );

	if ( !sOS )
	{
		if ( checkIt( sDetect, 'linux' ))
			sOS = 'Linux';
		else if ( checkIt( sDetect, 'x11' ))
			sOS = 'Unix';
		else if ( checkIt( sDetect, 'mac' ))
			sOS = 'Mac';
		else if ( checkIt(  sDetect,'win' ))
			sOS = 'Windows';
		else 
			sOS = 'an unknown operating system';
	}

	if ( (sBrowser != 'Internet Explorer' && sBrowser != 'Netscape Navigator' && sBrowser != 'Opera') || sOS != 'Windows' )
	{
		alert( 'This page uses the Blink 3D Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer  running on Windows. The page can not be displayed well as you are not using Internet Explorer on Windows.' );
		location = document.referer;
	}
	else if ( sBrowser == 'Internet Explorer' && sOS == 'Windows' && parseInt( sVersion ) < 6 )
	{
		alert( 'This page uses the Blink 3D Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer Version 5.0 or above. The page can not be displayed as you are using version '+sVersion+' of Internet Explorer.' );
		location = document.referer;
	}
	else if ( sBrowser == 'Netscape Navigator' && sOS == 'Windows' && parseInt( sVersion ) < 1 )
	{
		alert( 'This page uses the Blink 3D Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer Version 5.0 or above.  The page can not be displayed as you are using version '+sVersion+' of Firefox.' );
		location = document.referer;
	}
	else if ( sBrowser == 'Opera' && sOS == 'Windows' && parseInt( sVersion ) < 9 )
	{
		alert( 'This page uses the Blink 3D Plugin from Pelican Crossing (http://www.pelicancrossing.com) which requires Internet Explorer Version 5.0 or above.  The page can not be displayed as you are using version '+sVersion+' of Opera.' );
		location = document.referer;
	}
        else    
	{
		// alert( 'This page uses the Blink 3D Plugin version 141 and requires  Windows and Internet Explorer Version 5.0 or above. DO NOT WORK WITH OTHER BROWSERS! If you do not have the plugin, go to www.dmu.com for free download.' );
		 
	}
	gsBrowserName = sBrowser;
}


//
// checkIt()
//
function checkIt( sDetect, sParam )
{
	iPosition = sDetect.indexOf( sParam ) + 1;
	sTemp = sParam;
	return ( iPosition );
}


//
// createBlink3DControl()
//
function createBlink3DControl( )
{
var sWidth = "100%";
var sHeight = "80%";
var sEnvURL = "http://www.dmu.com/bl/worldgal.env"; 
var sPluginVersion = "1,1,2,141";
var sChatPaneVisible = "1";
var sChatPaneLocked = "0";
var sToolbarVisible = "1";
var sToolbarLocked = "0";
var sContextMenuVisible = "1";
var sSplitPercentage = "25";
var sUIVisible = "1"
var sRenderSystem = "0"
var sSceneManager = "0";
var sAntiAlias = "0";
var sRTT = "0";
var sNvPrefHUD = "0";
var sDownloadProgressBarStyle = "1";
var sLoadProgressBarStyle = "0";
var sForceDownload = "0";
var sResourceGroupName = "";
	if ( window.ActiveXObject )
	{
                 	
		 document.write( '<object ID="Blink3DCtl" classid="CLSID:65A0276F-A5C2-4BA2-82DA-BC4AF3250F9E"' );
                  
		 document.write( ' width = "'+sWidth+'"' );
		 document.write( ' height = "'+sHeight+'">' );
		 document.write( ' <PARAM name="FileName" value="'+sEnvURL+'">' );
		 document.write( ' <PARAM name="ChatPaneVisible" value="'+sChatPaneVisible+'">' );
		 document.write( ' <PARAM name="ChatPaneLocked" value="'+sChatPaneLocked+'">' );
		 document.write( ' <PARAM name="ToolbarVisible" value="'+sToolbarVisible+'">' );
		 document.write( ' <PARAM name="ToolbarLocked" value="'+sToolbarLocked+'">' );
		 document.write( ' <PARAM name="ContextMenuVisible" value="'+sContextMenuVisible+'">' );
		 document.write( ' <PARAM name="SplitPercentage" value="'+sSplitPercentage+'">' );
		 document.write( ' <PARAM name="UIVisible" value="'+sUIVisible+'">' );
		 document.write( ' <PARAM name="RenderSystem" value="'+sRenderSystem+'">' );
		 document.write( ' <PARAM name="SceneManager" value="'+sSceneManager+'">' );
		 document.write( ' <PARAM name="DownloadProgressBarStyle" value="'+sDownloadProgressBarStyle+'">' );
		 document.write( ' <PARAM name="LoadProgressBarStyle" value="'+sLoadProgressBarStyle+'">' );
		 document.write( ' <PARAM name="ForceDownload" value="'+sForceDownload+'">' );
		 document.write( ' <PARAM name="ResourceGroupName" value="'+sResourceGroupName+'">' );
		 document.write( ' <PARAM name="AntiAlias" value="'+sAntiAlias+'">' );
		 document.write( ' <PARAM name="RenderToTexture" value="'+sRTT+'">' );
		 document.write( ' <PARAM name="AllowNvPrefHUD" value="'+sNvPrefHUD+'">' );
		 document.write( '</object>' );
	}
	else
	{
		if ( gsBrowserName == 'Netscape Navigator' )		
{
                         
			 document.write( '<object ID="Blink3DCtl"' );
			 document.write( ' TYPE = "application/x-blink3d"' );
			  
			 document.write( ' width = "'+sWidth+'"' );
			 document.write( ' height = "'+sHeight+'">' );
			 document.write( ' <PARAM name="FileName" value="'+sEnvURL+'">' );
			 document.write( ' <PARAM name="ChatPaneVisible" value="'+sChatPaneVisible+'">' );
			 document.write( ' <PARAM name="ChatPaneLocked" value="'+sChatPaneLocked+'">' );
			 document.write( ' <PARAM name="ToolbarVisible" value="'+sToolbarVisible+'">' );
			 document.write( ' <PARAM name="ToolbarLocked" value="'+sToolbarLocked+'">' );
			 document.write( ' <PARAM name="ContextMenuVisible" value="'+sContextMenuVisible+'">' );
			 document.write( ' <PARAM name="SplitPercentage" value="'+sSplitPercentage+'">' );
			 document.write( ' <PARAM name="UIVisible" value="'+sUIVisible+'">' );
			 document.write( ' <PARAM name="RenderSystem" value="'+sRenderSystem+'">' );
			 document.write( ' <PARAM name="SceneManager" value="'+sSceneManager+'">' );
			 document.write( ' <PARAM name="DownloadProgressBarStyle" value="'+sDownloadProgressBarStyle+'">' );
			 document.write( ' <PARAM name="LoadProgressBarStyle" value="'+sLoadProgressBarStyle+'">' );
			 document.write( ' <PARAM name="ForceDownload" value="'+sForceDownload+'">' );
			 document.write( ' <PARAM name="ResourceGroupName" value="'+sResourceGroupName+'">' );
			 document.write( ' <PARAM name="AntiAlias" value="'+sAntiAlias+'">' );
			 document.write( ' <PARAM name="RenderToTexture" value="'+sRTT+'">' );
			 document.write( ' <PARAM name="AllowNvPrefHUD" value="'+sNvPrefHUD+'">' );
			 document.write( '</object>' );
		}
		else
		{
			document.write( '<embed name="Blink3DCtl"' );
			document.write( ' type="application/x-blink3d"' );
			
			document.write( ' width="'+sWidth+'"' );
			document.write( ' height="'+sHeight+'"' );
			document.write( ' FileName="'+sEnvURL+'"' );
			document.write( ' ChatPaneVisible="'+sChatPaneVisible+'"' );
			document.write( ' ChatPaneLocked="'+sChatPaneLocked+'"' );
			document.write( ' ToolbarVisible="'+sToolbarVisible+'"' );
			document.write( ' ToolbarLocked="'+sToolbarLocked+'"' );
			document.write( ' ContextMenuVisible="'+sContextMenuVisible+'"' );
			document.write( ' SplitPercentage="'+sSplitPercentage+'"' );
			document.write( ' UIVisible="'+sUIVisible+'"' );
			document.write( ' RenderSystem="'+sRenderSystem+'"' );
			document.write( ' SceneManager="'+sSceneManager+'"' );
			document.write( ' DownloadProgressBarStyle="'+sDownloadProgressBarStyle+'"' );
			document.write( ' LoadProgressBarStyle="'+sLoadProgressBarStyle+'"' );
			document.write( ' ForceDownload="'+sForceDownload+'"' );
			document.write( ' ResourceGroupName="'+sResourceGroupName+'"' );
			document.write( ' AntiAlias="'+sAntiAlias+'"' );
			document.write( ' RenderToTexture="'+sRTT+'"' );
			document.write( ' AllowNvPrefHUD="'+sNvPrefHUD+'">' );
			document.write( '</embed>' );
		}
	}
}

////sendScript()
function sendScript( sValue ) {
    getBlinkObject( "Blink3DCtl" ).PluginCommand( sValue ); 
} 

////getBlinkObject()
function getBlinkObject() {    
if ( window.document["Blink3DCtl"] )    {       
 return window.document["Blink3DCtl"];    
}    
else if ( navigator.appName.indexOf( "Microsoft Internet" ) == -1 )    {
  if ( document.embeds && document.embeds["Blink3DCtl"] )          
       return document.embeds["Blink3DCtl"];    }    
  else // if ( navigator.appName.indexOf( "Microsoft Internet" ) != -1 )    
{
       return document.getElementById("Blink3DCtl");    
 } 
}
////////////////
////getSaveCookie2()//for transform
 
 function getSaveCookie2(){ 
  try{
  if(getCookie("avtrans") != null){  
   var commavt = "loadTokenAvTrans('"+getCookie("avtrans") + "');";  
   sendScript( commavt );   
  } 
  else{  
  // var commavt2 = "Chat.print('NEVER SAVED')";  
  // sendScript( commavt2 );   
   }
  }
 catch(e){
  var commavt3 = "Chat.print('WOW!')";  
  sendScript( commavt3 );   ;   
 }
 }

//// setSaveCookie2()

function setSaveCookie2(){ 
try{
 setCookie ("avtrans",  document.fm1.txx.value);
}
catch(e){
 var commavt4 = "Chat.print('WOW!')";  
  sendScript( commavt4 );   ;   
}
} 
/////////////////
////////////////
////getSaveCookie()
 
function getSaveCookie(){ 
 try{
 if(getCookie("avpos") != null){  
  var commav = "loadTokenAvPos('"+getCookie("avpos") + "');";  
  sendScript( commav );   
 } 
 else{  
  var commav2 = "Chat.print('You don't have a permanent  avatar.')";  
  sendScript( commav2 );   
  }
 }
catch(e){
 var commav3 = "Chat.print('You don't have a permanent  avatar.')";  
  sendScript( commav3 );   ;   
}
}

//// setSaveCookie()

function setSaveCookie(){ 
try{
 setCookie ("avpos",  document.fm1.txx.value);
}
catch(e){
 var commav4 = "Chat.print('You don't have a permanent  avatar.')";  
  sendScript( commav4 );   ;   
}
} 
/////////////////

///onresize()
 
 
window.onresize=function(){
 
 
 if (window.location.reload)
   window.location.reload( true );
 else if (window.location.replace)
   window.location.replace(unescape(location.href))
  else
 window.location.href=unescape(location.href)
}
 
 


////onload()

window.onload=function(){

validateBrowserOS(); 
 
sendScript("Chat.print('SGAG 1.0 - (C) www.dmu.com - 2007/2008');"); 


var initialScript=
//////////////////////////////////INITIAL SCRIPT INLINE

//'if(EXTERNAL_IP_ADDRESS=="xmpp.pelicancrossing.com" && "no"==DEFAULTGALLERY){'+
      'oText = GUISystem.createStaticText( "Server" );'+
 
     // 'oText.backgroundEnabled = false;'+
    // 'oText.horizFormatting = oText.HORZ_FORMAT_WORD_WRAP_LEFT_ALIGNED;'+
    //   'oText.vertFormatting = oText.VERT_FORMAT_CENTERED;'+
    // 'oText.active = true;'+
   //  'oText.alwaysOnTop = true;'+
  //  'oText.absolutePositionX=0;'+
   //  'oText.absolutePositionY=0;'+
   //  'oText.normalTextColor = Color( 0, 1, 0, 1 );'+  
  //   'oText.readOnly=true;'+ 
  //   'oText.absoluteWidth = 100;'+  
  //   'oText.absoluteHeight = 100;'+ 
 //   'oText.text = "YOU ARE USING THE CHAT SERVER FROM www.pelicancrossing.com THAT IS AVAILABLE ONLY FOR TESTS, DEMOS OR COURSES.        TO AVOID THIS MESSAGE YOU NEED TO HAVE YOUR FREE  CHAT SERVER RUNNING!   YOU CAN LEARN HOW TO INSTALL THE CHAT SERVER AT YOUR COMPUTER GOING TO  www.dmu.com";'+
 
   //  'GUISystem.addChildWindow( oText);'+ 
//'};'+








'var name;'+ 

'if("yes"==GRID){'+
'bl0aEntity = Scene.createEntity( "bl0a","base10000x25x10000.mesh" );'+
'bl0aNode = Scene.createSceneNode( "bl0aNode" );'+
'bl0aNode.attachObject( bl0aEntity );'+
'bl0aNode.translate(Vector( 0,0,0),bl0aNode.TRANSFORM_WORLD );'+
'bl0aNode.rotate( Rotation( "Y", 0 ), bl0aNode.TRANSFORM_LOCAL );'+
'bl0aNode.scale = Vector( 9980/10000 ,  1, 9980/10000 );'+
'bl0aEntity.setMaterialName( "Grid10000x10000" );'+
'bl0aEntity.fixed = false;'+
'bl0aEntity.kinematic = true;'+
'bl0aEntity.collisionGeometryType=bl0aEntity.COLLISION_GEOM_BOX;'+
'bl0aEntity.createPhysicalModel();'+    
'};'+


 
//Default Browsers
'if("yes"==DEFAULTGALLERY){'+
//
'if("yes"==HASPANEL1){'+
 
'bl3aafdjEntity = Scene.createEntity( "bl3aafdj","browser150x150x0.mesh" );'+
'bl3aafdjNode = Scene.createSceneNode( "bl3aafdjNode" );'+
'bl3aafdjNode.attachObject( bl3aafdjEntity );'+
'bl3aafdjNode.translate(Vector(-175,175,-1160),bl3aafdjNode.TRANSFORM_WORLD );'+
'bl3aafdjNode.rotate( Rotation( "Y", 3.14), bl3aafdjNode.TRANSFORM_LOCAL );'+ 
'bl3aafdjNode.rotate( Rotation( "Z", 3.14), bl3aafdjNode.TRANSFORM_LOCAL );'+  
'if(PANEL1IMAGE=="default") PANEL1IMAGE="http://myopinionafdj.blogspot.com/2007/09/oscar-peterson.html";'+ 
'bl3aafdjMaterial = Scene.createHTMLMaterial( "bl3aafdjMaterial",PANEL1IMAGE, 512, 512) ;'+  
'bl3aafdjMaterial.staticImage = false;'+
'bl3aafdjEntity.setMaterialName( "bl3aafdjMaterial" );'+
 'bl3aafdjMaterial.staticImage = false;'+
'bl3aafdjtextpresented=0;'+

'bl3aafdjMouseListener1 = new Object();'+
'bl3aafdjMouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
   'Mouse.cursor = Mouse.CURSOR_APP_HAND;'+  
   'if(bl3aafdjtextpresented==0){'+
'if(PANEL1TEXT=="default") PANEL1TEXT="You can go to the blog having the  complete post, clicking the little red cube over the panel. Returning from the IE you will came here!";'+ 
  
 'Chat.print(PANEL1TEXT);'+ 
'if(PANEL1LINK=="default") PANEL1LINK="http://myopinionafdj.blogspot.com/2007/09/oscar-peterson.html";'+       
 'name="bl1001";'+
  'link(-175,260,-1160,0,\'Red\',PANEL1LINK,\' \');'+
      'bl3aafdjtextpresented=1;'+ 
   '};'+ 
'};'+
'Mouse.addListener(bl3aafdjMouseListener1,bl3aafdjEntity,true );'+
'bl3aafdjMouseListener2 = new Object();'+
'bl3aafdjMouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_ARROW;'+  
 '};'+
'Mouse.addListener(bl3aafdjMouseListener2,bl3aafdjEntity,true );'+

 
 
'};'+ 


//
'if("yes"==HASPANEL2){'+
 
'bl3bafdjEntity = Scene.createEntity( "bl3bafdj","browser150x150x0.mesh" );'+
'bl3bafdjNode = Scene.createSceneNode( "bl3bafdjNode" );'+
'bl3bafdjNode.attachObject( bl3bafdjEntity );'+
'bl3bafdjNode.translate(Vector(0,175,-1225),bl3bafdjNode.TRANSFORM_WORLD );'+
'bl3bafdjNode.rotate( Rotation( "Y",  3.925), bl3bafdjNode.TRANSFORM_LOCAL );'+ 
'bl3bafdjNode.rotate( Rotation( "Z", 3.14), bl3bafdjNode.TRANSFORM_LOCAL );'+ 
'if(PANEL2IMAGE=="default") PANEL2IMAGE="http://farm2.static.flickr.com/1329/1323041790_1bc2cc7653.jpg";'+  
'bl3bafdjMaterial = Scene.createHTMLMaterial( "bl3bafdjMaterial",PANEL2IMAGE, 100, 100);'+
'bl3bafdjMaterial.staticImage = false;'+
'bl3bafdjEntity.setMaterialName( "bl3bafdjMaterial" );'+
 
'bl3bafdjtextpresented=0;'+
'bl3bafdjpagepresented=0;'+
'bl3bafdjMouseListener1 = new Object();'+
'bl3bafdjMouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_APP_HAND;'+  
   'if(bl3bafdjtextpresented==0){'+
 'if(PANEL2TEXT=="default") PANEL2TEXT="You can see better this photo  at Flickr, clicking the litle yellow cube over the panel. Returning from the IE you will came here!";'+ 
 
    'Chat.print(PANEL2TEXT);'+ 
 'if(PANEL2LINK=="default") PANEL2LINK="http://www.flickr.com/photos/adamascj/1323041790/";'+       
 'name="bl1002";'+
  'link(0,260,-1225,0.785,\'Yellow\',PANEL2LINK,\' \');'+
  
 'bl3bafdjtextpresented=1;'+ 
  '};'+ 
'};'+
'Mouse.addListener(bl3bafdjMouseListener1,bl3bafdjEntity,true );'+
'bl3bafdjMouseListener2 = new Object();'+
'bl3bafdjMouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_ARROW;'+  
  'bl3bafdjtitlepresented=0;'+
  'bl3bafdjpagepresented=0;'+
  
'};'+
'Mouse.addListener(bl3bafdjMouseListener2,bl3bafdjEntity,true );'+
 
'};'+ 
//
'if("yes"==HASPANEL3){'+
 
'bl3cafdjEntity = Scene.createEntity( "bl3cafdj","browser150x150x0.mesh" );'+
'bl3cafdjNode = Scene.createSceneNode( "bl3afdjcNode" );'+
'bl3cafdjNode.attachObject( bl3cafdjEntity );'+
'bl3cafdjNode.translate(Vector(-175,175,-1850),bl3cafdjNode.TRANSFORM_WORLD );'+
'bl3cafdjNode.rotate( Rotation( "Y", 0), bl3cafdjNode.TRANSFORM_LOCAL );'+ 
'bl3cafdjNode.rotate( Rotation( "Z", 3.14), bl3cafdjNode.TRANSFORM_LOCAL );'+ 
'if(PANEL3IMAGE=="default") PANEL3IMAGE="http://octenderly.blogspot.com/";'+  
'bl3cafdjMaterial = Scene.createHTMLMaterial( "bl3cafdjMaterial",PANEL3IMAGE, 512, 512) ;'+ 
'bl3cafdjMaterial.staticImage = false;'+
'bl3cafdjEntity.setMaterialName( "bl3cafdjMaterial" );'+
 
'bl3cafdjtextpresented=0;'+
 
'bl3cafdjMouseListener1 = new Object();'+
'bl3cafdjMouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
   'Mouse.cursor = Mouse.CURSOR_APP_HAND;'+  
   'if(bl3cafdjtextpresented==0){'+
'if(PANEL3TEXT=="default") PANEL3TEXT="You can read   about the author of this music clicking the little green cube over the panel.Returning from the IE you will came here! ";'+ 
   
     'Chat.print(PANEL3TEXT);'+ 
'if(PANEL3LINK=="default") PANEL3LINK="http://myopinionafdj.blogspot.com/2007/09/oscar-peterson.html";'+       
 'name="bl1003";'+
  'link(-175,260,-1850,0,\'Green\',PANEL3LINK,\' \');'+
     'bl3cafdjtextpresented=1;'+ 
   '};'+ 
'};'+
'Mouse.addListener(bl3cafdjMouseListener1,bl3cafdjEntity,true );'+
'bl3cafdjMouseListener2 = new Object();'+
'bl3cafdjMouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_ARROW;'+  
  'bl3cafdjtitlepresented=0;'+
  'bl3cafdjpagepresented=0;'+
   
'};'+
'Mouse.addListener(bl3cafdjMouseListener2,bl3cafdjEntity,true );'+
 
'};'+

//
'if("yes"==HASPANEL4){'+
 
'bl3dafdjEntity = Scene.createEntity( "bl3dafdj","browser150x150x0.mesh" );'+
'bl3dafdjNode = Scene.createSceneNode( "bl3dafdjNode" );'+
'bl3dafdjNode.attachObject( bl3dafdjEntity );'+
'bl3dafdjNode.translate(Vector(-600,175,-1400),bl3dafdjNode.TRANSFORM_WORLD );'+
'bl3dafdjNode.rotate( Rotation( "Y",  1.57), bl3dafdjNode.TRANSFORM_LOCAL );'+ 
'bl3dafdjNode.rotate( Rotation( "Z", 3.14), bl3dafdjNode.TRANSFORM_LOCAL );'+ 
'if(PANEL4IMAGE=="default") PANEL4IMAGE="http://farm2.static.flickr.com/1199/1365872924_340453fd09_m.jpg";'+  
'bl3dafdjMaterial = Scene.createHTMLMaterial( "bl3dafdjMaterial",PANEL4IMAGE, 100, 100);'+
'bl3dafdjMaterial.staticImage = false;'+
'bl3dafdjEntity.setMaterialName( "bl3dafdjMaterial" );'+
 
'bl3dafdjtextpresented=0;'+
'bl3dafdjpagepresented=0;'+
'bl3dafdjMouseListener1 = new Object();'+
'bl3dafdjMouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_APP_HAND;'+  
   'if(bl3dafdjtextpresented==0){'+
 'if(PANEL4TEXT=="default") PANEL4TEXT="You can see better this photo  at Flickr, clicking the litle yellow cube over the panel. Returning from the IE you will came here!";'+ 
 
    'Chat.print(PANEL4TEXT);'+ 
 'if(PANEL4LINK=="default") PANEL4LINK="http://www.flickr.com/photos/adamascj/1365872924/";'+       
 'name="bl1004";'+
  'link(-600,260,-1400,0,\'Yellow\',PANEL4LINK,\' \');'+
  
 'bl3dafdjtextpresented=1;'+ 
  '};'+ 
'};'+
'Mouse.addListener(bl3dafdjMouseListener1,bl3dafdjEntity,true );'+
'bl3dafdjMouseListener2 = new Object();'+
'bl3dafdjMouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_ARROW;'+  
  'bl3dafdjtitlepresented=0;'+
  'bl3dafdjpagepresented=0;'+
  
'};'+
'Mouse.addListener(bl3dafdjMouseListener2,bl3dafdjEntity,true );'+
 
'};'+ 

//Default gallery

//Infoman
'if(INFOMANMSG=="default") INFOMANMSG="Welcome to the Default Galery of SGAG. We are now presenting Oscar Peterson. This theme will be changed soon. Enjoy and return many times. Thanks.";'+ 
'name="bl10044";'+
'infoman(-350,5,-1760,0.785,INFOMANMSG);'+

//
'bl0bEntity = Scene.createEntity( "bl0b","base10000x25x10000.mesh" );'+
'bl0bNode = Scene.createSceneNode( "bl0bNode" );'+
'bl0bNode.attachObject( bl0bEntity );'+
'bl0bNode.translate(Vector(-250,300,-1550),bl0bNode.TRANSFORM_WORLD );'+
'bl0bNode.rotate( Rotation( "Y", 0 ), bl0bNode.TRANSFORM_LOCAL );'+
'bl0bNode.scale = Vector( 900/10000 ,  25/25,  900/10000);'+
'bl0bEntity.setMaterialName( "Orange" );'+
'bl0bEntity.fixed = false;'+
'bl0bEntity.kinematic = true;'+
'bl0bEntity.collisionGeometryType=bl0bEntity.COLLISION_GEOM_BOX;'+
'bl0bEntity.createPhysicalModel();'+   
//
'bl0cEntity = Scene.createEntity( "bl0c","base10000x25x10000.mesh" );'+
'bl0cNode = Scene.createSceneNode( "bl0cNode" );'+
'bl0cNode.attachObject( bl0cEntity );'+
'bl0cNode.scale = Vector( 200/10000 ,  25/25, 1000/10000);'+
'bl0cNode.translate(Vector(-390,-10,-600),bl0cNode.TRANSFORM_WORLD );'+
'bl0cNode.rotate( Rotation( "Y", 0 ), bl0cNode.TRANSFORM_LOCAL );'+
'bl0cEntity.setMaterialName( "Green" );'+
'bl0cEntity.fixed = false;'+
'bl0cEntity.kinematic = true;'+
'bl0cEntity.collisionGeometryType=bl0cEntity.COLLISION_GEOM_BOX;'+
'bl0cEntity.createPhysicalModel();'+  
//
'bl0dEntity = Scene.createEntity( "bl0d","base10000x25x10000.mesh" );'+
'bl0dNode = Scene.createSceneNode( "bl0dNode" );'+
'bl0dNode.attachObject( bl0dEntity );'+
'bl0dNode.translate(Vector(-250,0,-1450),bl0dNode.TRANSFORM_WORLD );'+
 'bl0dNode.rotate( Rotation( "Y", 0 ), bl0dNode.TRANSFORM_LOCAL );'+
'bl0dNode.scale = Vector( 900/10000 ,  25/25,  900/10000);'+
'bl0dEntity.setMaterialName( "Green" );'+
'bl0dEntity.fixed = false;'+
'bl0dEntity.kinematic = true;'+
'bl0dEntity.collisionGeometryType=bl0dEntity.COLLISION_GEOM_BOX;'+
'bl0dEntity.createPhysicalModel();'+    
  
//Walls
//
'bl1aEntity = Scene.createEntity( "bl1a","walldoor600x300x50.mesh" );'+
'bl1aNode = Scene.createSceneNode( "bl1aNode" );'+
'bl1aNode.attachObject( bl1aEntity );'+
'bl1aNode.translate(Vector(-650,0,-1100),bl1aNode.TRANSFORM_WORLD );'+
'bl1aNode.rotate( Rotation( "Y", 0 ), bl1aNode.TRANSFORM_LOCAL );'+
'bl1aEntity.setMaterialName( "Chocolate" );'+
'bl1aEntity.fixed = false;'+
'bl1aEntity.kinematic = true;'+
'bl1aEntity.collisionGeometryType=bl1aEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl1aEntity.createPhysicalModel();'+
//
'bl5aEntity = Scene.createEntity( "bl5a","scalable50x300x50.mesh" );'+
'bl5aNode = Scene.createSceneNode( "bl5aNode" );'+
'bl5aNode.attachObject( bl5aEntity );'+
'bl5aNode.scale = Vector( 290/50 , 300/300, 50/50 );'+
'bl5aNode.translate(Vector(-50,0,-1100),bl5aNode.TRANSFORM_WORLD );'+
'bl5aNode.rotate( Rotation( "Y", 0.785 ), bl5aNode.TRANSFORM_LOCAL );'+
'bl5aEntity.setMaterialName( "Transparent" );'+
'bl5aEntity.fixed = false;'+
'bl5aEntity.kinematic = true;'+
'bl5aEntity.collisionGeometryType=bl5aEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl5aEntity.createPhysicalModel();'+  
//
'bl5bEntity = Scene.createEntity( "bl5b","scalable50x300x50.mesh" );'+
'bl5bNode = Scene.createSceneNode( "bl5bNode" );'+
'bl5bNode.attachObject( bl5bEntity );'+
'bl5bNode.scale = Vector( 50/50 , 300/300, 650/50 );'+
'bl5bNode.translate(Vector(100,0,-1300),bl5bNode.TRANSFORM_WORLD );'+
'bl5bNode.rotate( Rotation( "Y", 0 ), bl5bNode.TRANSFORM_LOCAL );'+
'bl5bEntity.setMaterialName( "Transparent" );'+
'bl5bEntity.fixed = false;'+
'bl5bEntity.kinematic = true;'+
'bl5bEntity.collisionGeometryType=bl5bEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl5bEntity.createPhysicalModel();'+  
//
'bl5cEntity = Scene.createEntity( "bl5c","scalable50x300x50.mesh" );'+
'bl5cNode = Scene.createSceneNode( "bl5cNode" );'+
'bl5cNode.attachObject( bl5cEntity );'+
'bl5cNode.scale = Vector( 800/50 , 300/300, 50/50 );'+
'bl5cNode.translate(Vector(-650,0,-1900),bl5cNode.TRANSFORM_WORLD );'+
'bl5cNode.rotate( Rotation( "Y", 0 ), bl5cNode.TRANSFORM_LOCAL );'+
'bl5cEntity.setMaterialName("Chocolate" );'+
'bl5cEntity.fixed = false;'+
'bl5cEntity.kinematic = true;'+
'bl5cEntity.collisionGeometryType=bl5cEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl5cEntity.createPhysicalModel();'+  
//
'bl5dEntity = Scene.createEntity( "bl5d","scalable50x300x50.mesh" );'+
'bl5dNode = Scene.createSceneNode( "bl5dNode" );'+
'bl5dNode.attachObject( bl5dEntity );'+
'bl5dNode.scale = Vector( 50/50 , 300/300, 850/50 );'+
'bl5dNode.translate(Vector(-650,0,-1100),bl5dNode.TRANSFORM_WORLD );'+
'bl5dNode.rotate( Rotation( "Y", 0 ), bl5dNode.TRANSFORM_LOCAL );'+
'bl5dEntity.setMaterialName("Chocolate" );'+
'bl5dEntity.fixed = false;'+
'bl5dEntity.kinematic = true;'+
'bl5dEntity.collisionGeometryType=bl5dEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl5dEntity.createPhysicalModel();'+ 

//Column&Doors 
//
'bl4aEntity = Scene.createEntity( "bl4a","column50x200x50.mesh" );'+
'bl4aNode = Scene.createSceneNode( "bl4aNode" );'+
'bl4aNode.attachObject( bl4aEntity );'+
'bl4aNode.translate(Vector(100,0,-1100),bl4aNode.TRANSFORM_WORLD );'+
'if(LOGOIMAGE=="default") LOGOIMAGE="http://farm2.static.flickr.com/1149/1322938842_93586eff96.jpg";'+ 

'bl4aMaterial =Scene.createHTMLMaterial( "bl4aMaterial",LOGOIMAGE, 512 , 512);'+
'bl4aMaterial.staticImage = true;'+
'bl4aEntity.setMaterialName( "bl4aMaterial" );'+
'bl4aEntity.fixed = false;'+
'bl4aEntity.kinematic = true;'+
'bl4aEntity.collisionGeometryType=bl4aEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl4aEntity.createPhysicalModel();'+ 
'bl4aLoop = new Object();'+ 
'bl4aLoop.timestep = function(appLag, dt){'+  
'bl4aNode.rotate( Rotation( "Y", 0.005), bl4aNode.TRANSFORM_LOCAL );'+
'};'+
'Application.addTimestep(bl4aLoop );'+ 
//Door
'bl2aEntity = Scene.createEntity( "bl2a","scalable50x300x50.mesh" );'+
'bl2aNode = Scene.createSceneNode( "bl2aNode" );'+
'bl2aNode.attachObject( bl2aEntity );'+
'bl2aNode.scale = Vector( 200/50 , 250/300, 30/50 );'+
'bl2aNode.translate(Vector(-500,0,-1060),bl2aNode.TRANSFORM_WORLD );'+
'bl2aNode.rotate( Rotation( "Y",  0 ), bl2aNode.TRANSFORM_LOCAL );'+
'bl2aEntity.setMaterialName( "Yellow" );'+
'bl2aInitialPos=bl2aNode.position;'+
'bl2aEntity.fixed = false;'+
'bl2aEntity.kinematic = true;'+
'bl2aEntity.collisionGeometryType=bl2aEntity.COLLISION_GEOM_TRI_SOUP;'+
'bl2aEntity.createPhysicalModel();'+ 
'bl2aMouseListener1 = new Object();'+
'bl2aMouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_APP_HAND;'+  
  
'};'+
'Mouse.addListener(bl2aMouseListener1,bl2aEntity,true );'+
'bl2aMouseListener2 = new Object();'+
'bl2aMouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
  'Mouse.cursor = Mouse.CURSOR_ARROW;'+  
 '};'+
'Mouse.addListener(bl2aMouseListener2,bl2aEntity,true );'+

'bl2aMouseListener3 = new Object();'+
'bl2aopen=0;'+
'bl2aMouseListener3.onClick = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){'+
   'if(oObject==bl2aEntity){'+  
    'if(bl2aopen==0){'+
      'bl2aopen=1;'+
     'bl2aNode.translate(Vector(+200,0 , 0 ), bl2aNode.TRANSFORM_LOCAL);'+
     'bl2aEntity.movePosition(bl2aNode.position);'+
      
   '}'+
   'else{'+
    //'bl2aopen=0;'+
     
   // 'bl2aEntity.movePosition(bl2aInitialPos);'+
     
   '};'+
  '};'+
'};'+
'Mouse.addListener( bl2aMouseListener3 ,bl2aEntity,true);'+

//Final for Default Gallery
'};'+

//////////////////////////BLOCKS

'try{'+
'if(BLOCK1 !=null){  eval( BLOCK1 );name="BLOCK1"  ;}; '+
'if(BLOCK2 !=null){  eval( BLOCK2 );name="BLOCK2"  ;}; '+
'if(BLOCK3 !=null){  eval( BLOCK3 );name="BLOCK3"  ;}; '+
'if(BLOCK4 !=null){  eval( BLOCK4 );name="BLOCK4"  ;}; '+
'if(BLOCK5 !=null){  eval( BLOCK5 );name="BLOCK5"  ;}; '+
'if(BLOCK6 !=null){  eval( BLOCK6 );name="BLOCK6"  ;}; '+
'if(BLOCK7 !=null){  eval( BLOCK7 );name="BLOCK7"  ;}; '+
'if(BLOCK8 !=null){  eval( BLOCK8 );name="BLOCK8"  ;}; '+
'if(BLOCK9 !=null){  eval( BLOCK9 );name="BLOCK9"  ;}; '+
'if(BLOCK10 !=null){  eval( BLOCK10 );name="BLOCK10"  ;}; '+
'if(BLOCK11 !=null){  eval( BLOCK11 );name="BLOCK11"  ;}; '+
'if(BLOCK12 !=null){  eval( BLOCK12 );name="BLOCK12"  ;}; '+
'if(BLOCK13 !=null){  eval( BLOCK13 );name="BLOCK13"  ;}; '+
'if(BLOCK14 !=null){  eval( BLOCK14 );name="BLOCK14"  ;}; '+
'if(BLOCK15 !=null){  eval( BLOCK15 );name="BLOCK15"  ;}; '+
'if(BLOCK16 !=null){  eval( BLOCK16 );name="BLOCK16"  ;}; '+
'if(BLOCK17 !=null){  eval( BLOCK17 );name="BLOCK17"  ;}; '+
'if(BLOCK18 !=null){  eval( BLOCK18 );name="BLOCK18"  ;}; '+
'if(BLOCK19 !=null){  eval( BLOCK19 );name="BLOCK19"  ;}; '+
 'if(BLOCK20 !=null){  eval( BLOCK20 );name="BLOCK20"  ;}; '+
'if(BLOCK21 !=null){  eval( BLOCK21 );name="BLOCK21"  ;}; '+
'if(BLOCK22 !=null){  eval( BLOCK22 );name="BLOCK22"  ;}; '+
'if(BLOCK23 !=null){  eval( BLOCK23 );name="BLOCK23"  ;}; '+
'if(BLOCK24 !=null){  eval( BLOCK24 );name="BLOCK24"  ;}; '+
'if(BLOCK25 !=null){  eval( BLOCK25 );name="BLOCK25"  ;}; '+
'if(BLOCK26 !=null){  eval( BLOCK26 );name="BLOCK26"  ;}; '+
'if(BLOCK27 !=null){  eval( BLOCK27 );name="BLOCK27"  ;}; '+
'if(BLOCK28 !=null){  eval( BLOCK28 );name="BLOCK28"  ;}; '+
'if(BLOCK29 !=null){  eval( BLOCK29 );name="BLOCK29"  ;}; '+
'if(BLOCK30 !=null){  eval( BLOCK30 );name="BLOCK30"  ;}; '+
'if(BLOCK31 !=null){  eval( BLOCK31 );name="BLOCK31"  ;}; '+
'if(BLOCK32 !=null){  eval( BLOCK32 );name="BLOCK32"  ;}; '+
'if(BLOCK33 !=null){  eval( BLOCK33 );name="BLOCK33"  ;}; '+
'if(BLOCK34 !=null){  eval( BLOCK34 );name="BLOCK34"  ;}; '+
'if(BLOCK35 !=null){  eval( BLOCK35 );name="BLOCK35"  ;}; '+
'if(BLOCK36 !=null){  eval( BLOCK36 );name="BLOCK36"  ;}; '+
'if(BLOCK37 !=null){  eval( BLOCK37 );name="BLOCK37"  ;}; '+
'if(BLOCK38 !=null){  eval( BLOCK38 );name="BLOCK38"  ;}; '+
'if(BLOCK39 !=null){  eval( BLOCK39 );name="BLOCK39"  ;}; '+
 'if(BLOCK40 !=null){  eval( BLOCK40 );name="BLOCK40"  ;}; '+
'if(BLOCK41 !=null){  eval( BLOCK41 );name="BLOCK41"  ;}; '+
'if(BLOCK42 !=null){  eval( BLOCK42 );name="BLOCK42"  ;}; '+
'if(BLOCK43 !=null){  eval( BLOCK43 );name="BLOCK43"  ;}; '+
'if(BLOCK44 !=null){  eval( BLOCK44 );name="BLOCK44"  ;}; '+
'if(BLOCK45 !=null){  eval( BLOCK45 );name="BLOCK45"  ;}; '+
'if(BLOCK46 !=null){  eval( BLOCK46 );name="BLOCK46"  ;}; '+
'if(BLOCK47 !=null){  eval( BLOCK47 );name="BLOCK47"  ;}; '+
'if(BLOCK48 !=null){  eval( BLOCK48 );name="BLOCK48"  ;}; '+
'if(BLOCK49 !=null){  eval( BLOCK49 );name="BLOCK49"  ;}; '+
 'if(BLOCK50 !=null){  eval( BLOCK50 );name="BLOCK50"  ;}; '+
'if(BLOCK51 !=null){  eval( BLOCK51 );name="BLOCK51"  ;}; '+
'if(BLOCK52 !=null){  eval( BLOCK52 );name="BLOCK52"  ;}; '+
'if(BLOCK53 !=null){  eval( BLOCK53 );name="BLOCK53"  ;}; '+
'if(BLOCK54 !=null){  eval( BLOCK54 );name="BLOCK54"  ;}; '+
'if(BLOCK55 !=null){  eval( BLOCK55 );name="BLOCK55"  ;}; '+
'if(BLOCK56 !=null){  eval( BLOCK56 );name="BLOCK56"  ;}; '+
'if(BLOCK57 !=null){  eval( BLOCK57 );name="BLOCK57"  ;}; '+
'if(BLOCK58 !=null){  eval( BLOCK58 );name="BLOCK58"  ;}; '+
'if(BLOCK59 !=null){  eval( BLOCK59 );name="BLOCK59"  ;}; '+
'if(BLOCK60 !=null){  eval( BLOCK60 );name="BLOCK60"  ;}; '+
'if(BLOCK61 !=null){  eval( BLOCK61 );name="BLOCK61"  ;}; '+
'if(BLOCK62 !=null){  eval( BLOCK62 );name="BLOCK62"  ;}; '+
'if(BLOCK63 !=null){  eval( BLOCK63 );name="BLOCK63"  ;}; '+
'if(BLOCK64 !=null){  eval( BLOCK64 );name="BLOCK64"  ;}; '+
'if(BLOCK65 !=null){  eval( BLOCK65 );name="BLOCK65"  ;}; '+
'if(BLOCK66 !=null){  eval( BLOCK66 );name="BLOCK66"  ;}; '+
'if(BLOCK67 !=null){  eval( BLOCK67 );name="BLOCK67"  ;}; '+
'if(BLOCK68 !=null){  eval( BLOCK68 );name="BLOCK68"  ;}; '+
'if(BLOCK69 !=null){  eval( BLOCK69 );name="BLOCK69"  ;}; '+
 'if(BLOCK70 !=null){  eval( BLOCK70 );name="BLOCK70"  ;}; '+
'if(BLOCK71 !=null){  eval( BLOCK71 );name="BLOCK71"  ;}; '+
'if(BLOCK72 !=null){  eval( BLOCK72 );name="BLOCK72"  ;}; '+
'if(BLOCK73 !=null){  eval( BLOCK73 );name="BLOCK73"  ;}; '+
'if(BLOCK74 !=null){  eval( BLOCK74 );name="BLOCK74"  ;}; '+
'if(BLOCK75 !=null){  eval( BLOCK75 );name="BLOCK75"  ;}; '+
'if(BLOCK76 !=null){  eval( BLOCK76 );name="BLOCK76"  ;}; '+
'if(BLOCK77 !=null){  eval( BLOCK77 );name="BLOCK77"  ;}; '+
'if(BLOCK78 !=null){  eval( BLOCK78 );name="BLOCK78"  ;}; '+
'if(BLOCK79 !=null){  eval( BLOCK79 );name="BLOCK79"  ;}; '+
'if(BLOCK80 !=null){  eval( BLOCK80 );name="BLOCK80"  ;}; '+
'if(BLOCK81 !=null){  eval( BLOCK81 );name="BLOCK81"  ;}; '+
'if(BLOCK82 !=null){  eval( BLOCK82 );name="BLOCK82"  ;}; '+
'if(BLOCK83 !=null){  eval( BLOCK83 );name="BLOCK83"  ;}; '+
'if(BLOCK84 !=null){  eval( BLOCK84 );name="BLOCK84"  ;}; '+
'if(BLOCK85 !=null){  eval( BLOCK85 );name="BLOCK85"  ;}; '+
'if(BLOCK86 !=null){  eval( BLOCK86 );name="BLOCK86"  ;}; '+
'if(BLOCK87 !=null){  eval( BLOCK87 );name="BLOCK87"  ;}; '+
'if(BLOCK88 !=null){  eval( BLOCK88 );name="BLOCK88"  ;}; '+
'if(BLOCK89 !=null){  eval( BLOCK89 );name="BLOCK89"  ;}; '+
 'if(BLOCK90 !=null){  eval( BLOCK90 );name="BLOCK90"  ;}; '+
'if(BLOCK91 !=null){  eval( BLOCK91 );name="BLOCK91"  ;}; '+
'if(BLOCK92 !=null){  eval( BLOCK92 );name="BLOCK92"  ;}; '+
'if(BLOCK93 !=null){  eval( BLOCK93 );name="BLOCK93"  ;}; '+
'if(BLOCK94 !=null){  eval( BLOCK94 );name="BLOCK94"  ;}; '+
'if(BLOCK95 !=null){  eval( BLOCK95 );name="BLOCK95"  ;}; '+
'if(BLOCK96 !=null){  eval( BLOCK96 );name="BLOCK96"  ;}; '+
'if(BLOCK97 !=null){  eval( BLOCK97 );name="BLOCK97"  ;}; '+
'if(BLOCK98 !=null){  eval( BLOCK98 );name="BLOCK98"  ;}; '+
'if(BLOCK99 !=null){  eval( BLOCK99 );name="BLOCK99"  ;}; '+
 'if(BLOCK100 !=null){  eval( BLOCK100 );name="BLOCK100"  ;}; '+

'}'+
'catch(e){'+
 
'};'+
//For tests only
'function receiving(x,y){'+ 
  'Chat.print(x + y.toString());'+
'};'+

//wall 
'function wall(width,height,depth,posx,posy,posz,roty,COLOR){'+
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'scalable50x300x50.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
 'eval(name + "Node.scale = Vector(" + width + "/50 ," + height + "/300," + depth + "/50 );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
 'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+
 'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_TRI_SOUP;");'+
 'eval(name + "Entity.createPhysicalModel();");'+   
'};'+

//browser
 'function  browser(posx,posy,posz,roty,TYPE,TEXTUREADD,CHATTEXT){'+

   
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'browser150x150x0.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
  
 
  'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
  'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Node.rotate( Rotation( \'Z\'," + 3.14 + ")," + name + "Node.TRANSFORM_LOCAL );");'+
  'var dim=512; if(TYPE=="flickr")dim=512;'+
//changed from 100 to 512 for flickr
  'eval(name + "Material = Scene.createHTMLMaterial( \'" + name + "Material\',\'" +TEXTUREADD+"\'," + dim + "," + dim +") ;");'+  


  'var sI=true; if(TYPE=="mp3" || TYPE=="youtube")sI=false;'+
 'eval(name + "Material.staticImage =" + sI + ";");'+
  'eval(name + "Entity.setMaterialName(\'" + name + "Material\');");'+
'eval(name + "titlepresented=0;");'+
'eval (name + "MouseListener1 = new Object();");'+
 'eval(name + "MouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_APP_HAND; if("+ name + "titlepresented==0){ Chat.print(\'" + CHATTEXT + "\' );" + name + "titlepresented=1;};};");'+ 
 'eval("Mouse.addListener(" + name + "MouseListener1," + name + "Entity,true );");'+

 'eval(name + "MouseListener2 = new Object();");'+ 
'eval(name + "MouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_ARROW;" +name + "titlepresented=0;};");'+ 
'eval("Mouse.addListener(" + name +"MouseListener2," + name + "Entity,true );");'+
 
'};'+

//////////
//external
'function  external(ENVXADDRESS,RESOURCEGROUP,ENTITYNAME,posx,posy,posz,roty){'+
'eval(name + "one=0;");'+
'eval (name + "OnDownload = new Object();");'+ 
'eval(name + "OnDownload.onDownload  = function(y){if(y==\'" + RESOURCEGROUP + "\' && " + name + "one==0){try{" + name + "Entity = Scene.getEntity(\'" + ENTITYNAME + "\');" + name + "Entity.parentSceneNode.position=Vector(" + posx + "," + posy + "," + posz + ");" + name + "Entity.parentSceneNode.orientation =  Rotation( \'Y\'," + roty + ");" + name + "one = 1;Application.removeListener(" + name + "OnDownload);}catch(e){Application.removeListener(" + name + "OnDownload);};};};Application.addListener(" + name + "OnDownload);Application.downloadEnvx(\'" + ENVXADDRESS + "\',\'" + RESOURCEGROUP + "\',true);");'+ 

'};'+ 
 
        
            
 

 
//////////

//walldoor
'function walldoor(posx,posy,posz,roty,COLOR){'+
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'walldoor600x300x50.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
 'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+
 'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_TRI_SOUP;");'+
 'eval(name + "Entity.createPhysicalModel();");'+   
'};'+ 
 
//tetrabase
'function tetrabase(width,depth,posx,posy,posz,roty,rotx,COLOR){'+
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'base10000x25x10000.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
 'eval(name + "Node.scale = Vector(" + width + "/10000 ,25/25," + depth + "/10000 );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
 'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Node.rotate( Rotation( \'X\'," + rotx + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+
 'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_BOX;");'+
 'eval(name + "Entity.createPhysicalModel();");'+   
'};'+ 


//hexabase
'function hexabase(width,depth,posx,posy,posz,roty,COLOR){'+
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'hexagon1000x20x1000.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
 'eval(name + "Node.scale = Vector(" + width + "/1000 ,20/20," + depth + "/1000 );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
 'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+
 'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_BOX;");'+
 'eval(name + "Entity.createPhysicalModel();");'+   
'};'+ 

//column
'function column(width,height,depth,posx,posy,posz,rotx,roty,rotz,velocity,TEXTUREADD){'+
'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'column50x200x50.mesh\' );");'+
'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
'eval(name + "Node.attachObject( "+ name + "Entity );");'+
'var dim=512; '+
 'eval(name + "Material = Scene.createHTMLMaterial( \'" + name + "Material\',\'" +TEXTUREADD+"\'," + dim + "," + dim +") ;");'+  
 'var sI=true;'+
 'eval(name + "Material.staticImage =" + sI + ";");'+
 'eval(name + "Entity.setMaterialName(\'" + name + "Material\');");'+
'eval(name + "Node.scale = Vector(" + width + "/50 ," + height + "/200," + depth + "/50 );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "+20," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
'eval(name + "Node.rotate( Rotation( \'Y\'," + 3.14 + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Node.rotate( Rotation( \'X\'," + rotx + ")," + name + "Node.TRANSFORM_LOCAL );");'+
'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Node.rotate( Rotation( \'Z\'," + rotz + ")," + name + "Node.TRANSFORM_LOCAL );");'+
 
 'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_TRI_SOUP;");'+
 'eval(name + "Entity.createPhysicalModel();");'+  
 'eval (name + "Loop = new Object();");'+
 'eval(name + "Loop.timestep = function(appLag, dt){" + name + "Node.rotate( Rotation( \'Y\'," + velocity + ")," + name + "Node.TRANSFORM_LOCAL ); };");'+ 
 'eval("Application.addTimestep(" + name + "Loop);");'+
 
'};'+  

//door
'function door(posx,posy,posz,roty,COLOR){'+
'eval(name + "open=0;");'+ 

'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'scalable50x300x50.mesh\' );");'+
'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
'eval(name + "Node.attachObject( "+ name + "Entity );");'+
'eval(name + "Node.scale = Vector(200/50 , 250/300, 30/50 );");'+
'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+ 
'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+ 
'eval(name + "InitialPos=" + name + "Node.position;");'+
'eval(name + "Entity.fixed = false;");'+
 'eval(name + "Entity.kinematic = true;");'+
 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_TRI_SOUP;");'+
 'eval(name + "Entity.createPhysicalModel();");'+  
'eval (name + "MouseListener1 = new Object();");'+
 'eval(name + "MouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_APP_HAND;   };");'+ 
 'eval("Mouse.addListener(" + name + "MouseListener1," + name + "Entity,true );");'+
'eval(name + "MouseListener2 = new Object();");'+ 
'eval(name + "MouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_ARROW; };");'+ 
'eval("Mouse.addListener(" + name +"MouseListener2," + name + "Entity,true );");'+ 
'eval(name + "MouseListener3 = new Object();");'+ 
'eval(name + "MouseListener3.onClick = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){if(oObject=="+ name + "Entity){ if(" + name + "Node.position !=" + name + "InitialPos &&" + name + "open==0){" + name + "Node.translate(Vector(+200,0 , 0 )," + name + "Node.TRANSFORM_LOCAL);" + name + "Entity.movePosition(" + name + "Node.position);" + name +"open=1;    } ;};};");'+  
'eval("Mouse.addListener(" + name +"MouseListener3," + name + "Entity,true );");'+  
'};'+  
 
//link 
'function poping(add){'+ 
//_blank is not working. So we are using _top
 'comsend = "window.open (\'" + add + "\', \'_top\', \'width=800 ,height=600 ,status=yes,toolbar=yes,scrollbars=yes,menubar=yes,location=yes,resizable=yes,top=0,left=0 \');" ;'+
 'Application.sendJS(comsend);'+  
'};'+

  'function transf(){'+ 
 
 

 'commavttt ="document.fm1.txx.value=\'" + Actor.position.x + ":"+ Actor.position.y + ":" +   Actor.position.z + ":" + Actor.avatarYaw + "\';setSaveCookie2();";'+
 
   'Application.sendJS(commavttt);'+ 
 '};'+

'function link(posx,posy,posz,roty,COLOR,POPPAGE,CHATTEXT){'+
'eval(name + "open=0;");'+ 

'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'column50x200x50.mesh\' );");'+
'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
'eval(name + "Node.attachObject( "+ name + "Entity );");'+
'eval(name + "Node.scale = Vector(10/50 , 10/200, 10/50 );");'+
'eval(name + "Node.translate(Vector(" + posx + "," + posy + "," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+ 
'eval(name + "Entity.setMaterialName(\'" + COLOR + "\');");'+ 
'eval(name + "titlepresented=0;");'+ 
 
'eval (name + "MouseListener1 = new Object();");'+
 'eval(name + "MouseListener1.onOver = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_APP_HAND; if("+ name + "titlepresented==0){ Chat.print(\'" + CHATTEXT + "\' );" + name + "titlepresented=1; };  };");'+ 
 'eval("Mouse.addListener(" + name + "MouseListener1," + name + "Entity,true );");'+
'eval(name + "MouseListener2 = new Object();");'+ 
'eval(name + "MouseListener2.onOut = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){ Mouse.cursor = Mouse.CURSOR_ARROW;" +name + "titlepresented=0; };");'+ 
'eval("Mouse.addListener(" + name +"MouseListener2," + name + "Entity,true );");'+ 
'eval(name + "MouseListener3 = new Object();");'+ 
//'acpos ="\'" + Actor.position.x + "\':\'" + Actor.position.y +"\':\'" +   Actor.position.z + "\'";'+
//'Chat.print(acpos);'+
 'eval(name + "MouseListener3.onClick = function( iMouseX, iMouseY, iMouseZ, oObject,iSubMesh ){if(oObject=="+ name + "Entity){ if( " + name + "open==0){poping(\'" + POPPAGE  + "\' ) ; transf();" + name +"open=1;    } ;};};");'+  

 
'eval("Mouse.addListener(" + name +"MouseListener3," + name + "Entity,true );");'+  

 
'};'+  



 
//infoman
 
'function infoman(posx,posy,posz,roty,CHATTEXT){'+
 'eval(name + "Entity = Scene.createEntity(\'" + name + "\',\'infoman100x150x70.mesh\' );");'+
 'eval(name + "Node = Scene.createSceneNode( \'" + name + "Node\' );");'+
 'eval(name + "Node.attachObject( "+ name + "Entity );");'+
 'eval(name + "Node.translate(Vector(" + posx + "," + posy + "+5," + posz + ")," + name + "Node.TRANSFORM_WORLD );");'+
'eval(name + "Node.rotate( Rotation( \'Y\',3.14)," + name + "Node.TRANSFORM_LOCAL );");'+
 'eval(name + "Node.rotate( Rotation( \'Y\'," + roty + ")," + name + "Node.TRANSFORM_LOCAL );");'+
// 'eval(name + "Entity.fixed = false;");'+
 //'eval(name + "Entity.kinematic = true;");'+
// 'eval(name + "Entity.collisionGeometryType=" + name + "Entity.COLLISION_GEOM_TRI_SOUP;");'+
 
 //'eval(name + "Entity.createPhysicalModel();");'+  
 'eval(name + "isFar=true;");'+ 
  'eval (name + "Loop = new Object();");'+
  'eval(name + "Loop.timestep = function(appLag, dt){if(Actor.dist(Vector(" + posx + "," + posy + "+5," + posz + "))< 300 &&" + name + "isFar){Chat.print(\'" + CHATTEXT + "\' );" + name + "Node.orientation = Actor.orientation;" + name + "Node.rotate( Rotation( \'Y\',3.14)," + name + "Node.TRANSFORM_LOCAL );" + name + "isFar=false;};};");'+ 
  'eval("Application.addTimestep(" + name + "Loop);");'+
'eval (name + "Loop2 = new Object();");'+
  'eval(name + "Loop2.timestep = function(appLag, dt){if(Actor.dist(Vector(" + posx + "," + posy + "+5," + posz + "))> 600 &&" + name + "isFar==false){" + name + "isFar=true;};};");'+ 
  'eval("Application.addTimestep(" + name + "Loop2);");'+

//'eval("PhysicsSystem.setCollisionNotify( Actor," + name + "Entity, PhysicsSystem.NOTIFY_ON_START_TOUCH );");'+
//'eval(name + "CollisionHandler = new Object();");'+
 //'eval(name + "CollisionHandler.onCollision = function( oCollisionObject1, oCollisionObject2 ) { Chat.print(\'" + CHATTEXT + "\' );};");'+ 
//'eval("PhysicsSystem.addListener(" + name + "CollisionHandler );");'+ 
 
'};'+ 
   
 

////////////////////////////////////////////////
 
'';
sendScript(initialScript); 
} 

////setCookie ()
 
function setCookie (name, value){
var dataexp = new Date ();
//valid for 365 days - you can change this validation
dataexp.setTime (dataexp.getTime() + (24 * 60 * 60 * 1000 * 365));
document.cookie = name + "=" + escape (value) + "; expires=" + dataexp.toGMTString() +  "; path=/";
}

////getCookie ()
function getCookie (name){ 
 var dcookie = document.cookie;  
  var cname = name + "="; 
 var clen = dcookie.length; 
 var cbegin = 0; 
while (cbegin < clen){  
 var vbegin = cbegin + cname.length;  
 if (dcookie.substring(cbegin, vbegin) == cname){
   var vend = dcookie.indexOf (";", vbegin);
   if (vend == -1) vend = clen;   
    return unescape(dcookie.substring(vbegin, vend));
  }  
 cbegin = dcookie.indexOf(" ", cbegin) + 1;  
 if (cbegin == 0) break; 
} 
return null;
}
//END