//***************** STATISTICS DATABASE COMMUNICATION	function WriteStats(objectstring,actionstring,flag)	{		//get current browser url		htmlurl=location.href;				//set planner and plannerobject to unknown		planner="unknown";		plannerobject="unknown";		objectaction="unknown";				//get pub parameter from url		if(htmlurl.indexOf('pbs=')>0)		{			plannerstart=htmlurl.indexOf('pbs=')+4;			plannerend=htmlurl.indexOf('&',plannerstart);			if(plannerend==-1)			{				planner=htmlurl.substr(plannerstart);			}			else			{				planner=htmlurl.substr(plannerstart,plannerend-plannerstart);			}						if(planner=="")			{				planner=htmlurl.substr(plannerstart);			}		}		else		{			if(htmlurl.indexOf('skn=')>0)			{				plannerstart=htmlurl.indexOf('skn=')+4;				plannerend=htmlurl.indexOf('&',plannerstart);				planner="unknown:"+htmlurl.substr(plannerstart,plannerend-plannerstart);				if(planner=="")				{					planner=htmlurl.substr(plannerstart);				}			}		}				//if flag is 0 then input string is LoadModel() string & extract model name		if(flag==0)		{			firstcomma=objectstring.indexOf(',');			secondcomma=objectstring.indexOf(',',firstcomma+1);			objectstart=objectstring.indexOf("'",secondcomma)+1;			objectend=objectstring.indexOf("'",objectstart);			plannerobject=objectstring.substr(objectstart,objectend-objectstart);			objectaction=actionstring;		}				//if flag is 1 then log a custom event		if(flag==1)		{			plannerobject=objectstring;			objectaction=actionstring;		}				//create XMLHTTP request object (the IE way)		try		{														httpreq=new ActiveXObject("Microsoft.XMLHTTP");		}		catch(err)		{			httpreq=new ActiveXObject("Msxml2.XMLHTTP");		}				//use XMLHTTP request to unobtrusively perform a HTTP GET on database php script		//added a reset date to work-around IE caching bug with XMLHTTP request object		httpreq.open("GET", 'http://www.navigram.com/WriteStats/WriteStats.php?planner='+planner+'&object='+plannerobject+'&objaction='+objectaction, false);		ResetDate=new Date(0)		httpreq.setRequestHeader("If-Modified-Since",ResetDate);		httpreq.send("");				httpreq=null;	}//***************** GENERAL FUNCTIONS   function GetElement(name)						// returns a reference to an element contained in the document   {    if (document.getElementById) { this.obj = document.getElementById(name) }    else if (document.all) { this.obj = document.all[name] }                  // for IE4.0    return this.obj;   }   //***************** GENERAL COMMANDS   var mode3d = 0;				// global variable for toggling the 3d mode   var CommWin;   function CommWindow(theHref,theWidth,theHeight,theScroll,theTool,theMenu)		// opens a popup window to communicate with   {    CommWin=window.open(theHref,'_blank','resizable=yes,toolbar="'+theTool+'" scrollbars="'+theScroll+'" menubar="'+theMenu+'" width='+theWidth+',height='+theHeight);   }   function PopUpWindow(theHref,theWidth,theHeight,theScroll,theTool,theMenu)		// opens a popup window   {    window.open(theHref,'_blank','resizable=yes,toolbar="'+theTool+'" scrollbars="'+theScroll+'" menubar="'+theMenu+'" width='+theWidth+',height='+theHeight);   }   function RunFoldMenu(active)   {    var isin = 0        if (active.id == "foldmenuhead") {isin = 1}    else while (active.parentElement)    {     if (active.id == "foldmenuhead" || active.id == "foldmenulist")     {      if (active.id == "foldmenuhead") {isin = 1} else {isin = 0}      break     }     active = active.parentElement    }    if (isin)    {     var foldercontent = active.all.tags("UL")[0]     if (foldercontent.style.display == "none")     {      foldercontent.style.display = ""      active.style.listStyleImage = "url(../../skn/"+parent.params['skn']+"/nav-foldopen.png)";      }     else     {      foldercontent.style.display = "none"      active.style.listStyleImage = "url(../../skn/"+parent.params['skn']+"/nav-foldclose.png)";     }    }   }   function AddJavascript(jsname)   {    var th = document.getElementsByTagName('head')[0];    var s = document.createElement('script');    s.setAttribute('type','text/javascript');    s.setAttribute('src',jsname);    th.appendChild(s);   }//***************** MAIN COMMUNICATION FUNCTIONS   function PDScript(theScript) 					// sends 4dscript to the plug-in   {     focus();    parent.PageDive.runscript(theScript)        }   function NavScript(theScript) 					// sends 4dscript to the plug-in and returns value   {    parent.PageDive.Script=theScript;    return parent.PageDive.Script;   }   function PDMessage(forAtom,theMessage) 				// sends a 4dscript message to an atom in the model, examples: PDMessage('anatom','[text]'), PDMessage('anatom',6)   {     parent.PageDive.Runscript('sendmessagedirect(atombyname([' + forAtom + '],model),' + theMessage + ')')    }   function HPDMessage(forAtom,theMessage) 				// determines over which component the mouse hovers and sends a 4dscript message to an atom in the model   {     PageDive.Runscript('hitexec([do(gcode(396,0),gcode(399,1),sendmessagedirect(atombyname([' + forAtom + '],model),' + theMessage + '),gcode(399,0))])')    }   function PDUpdateMessage(forAtom,theMessage)				// updates values in the control page after sending a 4dscript message to an atom in the model   {    PDMessage(forAtom,theMessage);    UpdateComponentParameters();   }//***************** DRAG AND DROP      var DropMode=0;var DropCode='';   function ShowDragCursor()						// sets dragging behaviour   {    PageDive.Runscript('gcode(396,1)');    window.event.returnValue = false;    window.event.dataTransfer.dropEffect = 'copy';   }   function Drop()							// sets drop behaviour   {									// REMOVE?":curname = curname.substring(0,curname.lastIndexOf('.'));    if (DropMode==1)							// IE7: use dropmode 1 for new catalogs for IE7 with long strings    {     var info=DropCode;     DropMode=0;    } else    {     var info = window.event.dataTransfer.getData('Text');           	// retrieve the dropped data as text     info = info.substring(35,info.lastIndexOf(')')+1);              	// starting with string after "javascript:" and ending with ")"    };        if ( info.substring(0,9) == 'PDMessage' ) { info = 'H' + info } 	// if dragged function is a PDMessage make it HPDMessage    eval(info);                                                     	// execute the resulting function		WriteStats(info,"Drop",0);   }//***************** CONTROLPAGE AND LIBRARY PAGE FUNCTIONS   var lastControlPage = '';						// global variable to store the last active page in the iframeControl element   function loadcontrolpage(aPage)   {    lastControlPage = '';    parent.GetElement('iframeControl').src = aPage;   }   function showcontrolpage(a,b)					// version 2005, shows the object's control page in the iframeControl element; this function is called from the model, a=controlpagename, b=controldirectory, c=atomid, d=componentinfo   {    AtomName = a;    var lastcontrolpagepos;    if ( a != lastControlPage ) { lastcontrolpagepos = 0 }    if ( b.lastIndexOf('/') == -1 ) { parent.GetElement('iframeControl').src = '../../ro/objects/' + a + '/' + a + '.html' }       else {parent.GetElement('iframeControl').src = '../../ro/objects/' + b + a + '.html' }    lastControlPage = a;    top.focus();   }   var previousPage = 'noneexistingobject'; // strange name for first time start purposes   function DisplayControlPage(a) // is called from dragged object after loading; a = object page   {    if ( ( appIsOnline == 1 ) && ( previousPage != a ) ) // if the property page is online & is different from the last    {     var pos = a.lastIndexOf('/');     var obj = a.substr(pos+1); // store the name of the object for statistics     if ( typeof parent.CallTracker == 'function' ) parent.CallTracker(obj); // test for legacy pages that don't use statistics    }    parent.GetElement('iframeControl').src = a;    top.focus();    previousPage = a;   }   function emptycontrolpage()						// clears the page in the iframeControl element when an object is deleted; this function is called from the model   {    lastControlPage = '';    parent.GetElement('iframeControl').src = '';   }   function ScrollToLastPosition() 					// scrolls the control page to the last know scroll position   {    window.scrollTo(0,parent.lastcontrolpagepos)    }   function SelectCatalog(pageName) 					// 2006: shows the selected catalog in the library area   {     top.GetElement('iframeLibrary').src = pageName        WriteStats(pageName.substr(pageName.lastIndexOf('/')+1).replace('.html', ''),'SelectCatalog',1);    }   function selectcatalog(pageName) 					// 2005: shows the selected catalog in the library area   {     pageName = pageName.replace('../../../', '../../');	    SelectCatalog(pageName);    }   function LoadModel(theDomain,theCatalog,theModel,thePage,theThumbnail,theFlags,theReplace,theInit,theURL)   {    var theRoot=GetThePath(true,theURL,false);    if (theInit=='') {theInit='0'};    HPDMessage('CATALOGOBJECTLOADER','parstring(1,['+objIsOnline+'],['+theRoot+'],['+theDomain+'],['+theCatalog+'],['+theModel+'],['+thePage+'],['+theThumbnail+'],['+theFlags+'],['+theReplace+'],'+theInit+')');   }//***************** INITIALIZATION AND DEINITIALIZING FUNCTIONS   var NavigramIsLoaded=false;   var appIsOnline=0;   var objIsOnline=0;   var PageLoadCount=0;   var PageNeedCount=0;   function GetParams(defaultFolder)					// returns the parameters in the url   {    GetNavFilePath(true);    var idx = document.location.href.indexOf('?');    var params = new Array();    params['language']=navigator.browserLanguage.substring(0,2);    params['ini']=defaultFolder;    params['int']=defaultFolder;    params['mnu']=defaultFolder;    params['mod']=defaultFolder;    params['sel']=defaultFolder;    params['skn']=defaultFolder;    params['hlp']=defaultFolder;    params['sys']=defaultFolder;    params['mnuobj']='menuobject';    params['selonline']='selector';    params['title']='Navigram Planner';    params['tracker']=defaultFolder;    if (idx != -1)    {     var pairs = document.location.href.substring(idx+1, document.location.href.length).split('&');     for (var i=0; i<pairs.length; i++)     {      var nameVal = pairs[i].split('=');      params[nameVal[0]] = nameVal[1];     }    }    document.title=params['title'];    return params;   }   function GetThePath(topLevel,curPath,isApp)   {    if (document.location.protocol == 'file:')				// if off-line    {     if (isApp) {appIsOnline=0} else {objIsOnline=0};     curPath = curPath.substring(8, curPath.lastIndexOf('applications/'))+'applications/';     if (!topLevel) {curPath=curPath+'mod/'+params['mod']+'/';}		// path without protocol     curPath = curPath.replace(/\//g, '\\');				// replace forward slashes by back slashes     curPath = curPath.replace('%20', ' ');				// replace %20 by spaces    }    else																// if     {     if (isApp) {appIsOnline=1} else {objIsOnline=1};     curPath = curPath.substring(0, curPath.lastIndexOf('applications/'))+'applications/';          // protocol and path     if (!topLevel) {curPath=curPath+'mod/'+params['mod']+'/';}		// path without protocol    }    return curPath;   }   function GetNavFilePath(topLevel) 					// returns the path of the model, if topLevel is true, returns the navigram directory, otherwise mod subdirectory   {    var thePath = document.location.href;    return GetThePath(topLevel,thePath,true);   }   var PageLoadCount=0;   var PageLastCount=0;   function InitLanguages(lang)   {       var a;    a=params['language'];    if (lang!='AA') {params['language']=lang};    ReadyToTranslate=1;        //    if (a!=params['language']) {top.ChangeLanguage(params['language']);};    if (a!=params['language'])      {       for ( var i=0; i<top.document.frames.length; i++ )       {        if (top.document.frames(i).src!='')        {         top.document.frames(i).LoadVocabulary('en');         top.document.frames(i).TranslateThisPage();               }       }    };        //    top.GetElement('iframeNavStart').style.display='none';//    top.GetElement('divNavigram').style.display='block';   }   function Finalize()   {     if (appIsOnline==1)     {      PDScript("settimerevent([do(execstring(label([xmeasure],main)),gcode(394,0))])");     }      else          {      NavScript('do(gcode(394,0),execstring(label([xmeasure],main)))');      top.GetElement('iframeNavStart').style.display='none';      top.GetElement('divNavigram').style.display='block';                  var curlng=NavScript('label([xlanguage],main,2)');      InitLanguages(curlng);      //      PDScript("settimerevent([do(gcode(394,0),execstring(label([xmeasure],main)),javascript(concat([InitLanguages('],label([xlanguage],main,2),[')])))])");     };   }   function LoadPlugin()     {    top.focus();//     divNavigram.innerHTML = '<object id="PageDive" ondragenter="ShowDragCursor()" ondragover="ShowDragCursor()" ondrop="Drop()" style="WIDTH:100%; HEIGHT:100%" classid="CLSID:A92E0798-BFA4-4FEE-BB48-8E2C69B2B0C5" codebase="http://www.navigram.com/engine/v812/PageDive5.cab#version=8,1,2,0">'+     divNavigram.innerHTML = '<object id="PageDive" ondragenter="ShowDragCursor()" ondragover="ShowDragCursor()" ondrop="Drop()" style="WIDTH:100%; HEIGHT:100%" classid="CLSID:6E718D87-6909-4FCE-92D4-EDCB2F725727" codebase="http://www.navigram.com/engine/v911/Navigram.cab#version=9,1,1,0">'+     '<param name="ParamURL" value="' + GetNavFilePath(false) + params['model'] + '.3di">'+     '<param name="BGColor" value="16777215">'+     '<param name="Renderers" value="">'+     '<param name="NoRenderURL" value="' +GetNavFilePath(true) + 'sys/'+params['sys']+'/navigram-no3d.html">'+     '</object>';   }   function AfterPagesLoaded2()   {   }   function AfterPagesLoaded()   {    PageLoadCount=PageLoadCount+1;    if ( ((PageLoadCount==6) && (appIsOnline==1)) || ((PageLoadCount==4) && (!(appIsOnline==1))))    {     PageLoadCount=6;     LoadPlugin();    };    if (!(appIsOnline==1))    {         if (PageLoadCount==8)     {      LoadCatalogSelector();     }          if (PageLoadCount==10)     {      setTimeout('top.Finalize();',100);     }    } else    {     if (PageLoadCount==7)     {      top.GetElement('iframeNavStart').style.display='none';      top.GetElement('divNavigram').style.display='block';      setTimeout('top.Finalize();',100);     }    }   }   function LoadPageInFrame(a,b)   {    PageNeedCount=PageNeedCount+1;    GetElement(b).src =a;       }   function LoadNavigram()						// creates the plug-in object, loads a model   {    PageLoadCount=0;    PageNeedCount=0;    ReadyToTranslate=0;    LoadPageInFrame('../../sys/'+params['sys']+'/navigram-load.html','iframeNavStart');    LoadPageInFrame('../../mnu/'+params['mnu']+'/menunavigate2d.html','iframeMenuNavigate');        LoadPageInFrame('../../mnu/'+params['mnu']+'/'+params['mnuobj']+'.html','iframeMenuObject');    LoadPageInFrame('../../mnu/'+params['mnu']+'/menumain.html','iframeMenuMain');    if (appIsOnline==1) {LoadCatalogSelector()}		WriteStats('Navigram plug-in','Launch',1);     }   function SetPDServerPath()						// sets the server and the path after loading the model   {    var thePath = GetNavFilePath(true);    PageDive.Runscript('do(approotdir(['+thePath+']),approotdironline('+appIsOnline+'),settextatt(11,concat(approotdir,[cat/navrp/ro/]),atombyname([Controller],model)),settextatt(12,[/],atombyname([Controller],model)),t:=approotdir,if(not(approotdironline),do(settextatt(11,concat(t,[cat\\navrp\\ro\\]),atombyname([Controller],model)),settextatt(12,[\\],atombyname([Controller],model)))))');   }   function OnTerminatePD(theCode) 					// quits, if theCode=1,asks to save the model when you close the window, theCode=2: save always, theCode=3: no save   {     if (theCode==1) {PDScript('terminator([do(if(confirm(['+tr('Would_you_like_to_save_the_current_project')+']),do(gstring(2):=[Overwrite file],gstring(3):=[Name],kernelfnc([prepare pack model v800]))),kernelfnc([save main settings and quit]))])')}    //    if (theCode==1) {PDScript('terminator([do(if(confirm(['+tr('Would_you_like_to_save_the_current_project')+']),do(curdir:=pdir([pack]),curdir:=pdir([pack/temp1]),curdir:=pdir([pack/temp2]),curdir:=pdir([pack/temp3]),setlabel([packfilename],characterstring(extractprename(do(t:=getfilesave(concat(pdir([pack]),chr(92),label([packfilename],main),[.3di]),[*.3di]),if(fileexists(concat(extractprename(t),[.3di])),if(confirm(['+tr('Overwrite_file')+']),t,t:=[]),t)))),main),if(not(comparetext([],label([packfilename],main))),do(setlabel([packfilenameexists],1,main),setlabel([pack_sub],0,main),kernelfnc([pack model dialog]),run)))),kernelfnc([save main settings and quit]))])')}    //    if (theCode==2) {PDScript('terminator([do(if(1,do(curdir:=pdir([pack]),curdir:=pdir([pack/temp1]),curdir:=pdir([pack/temp2]),curdir:=pdir([pack/temp3]),setlabel([packfilename],characterstring(extractprename(do(t:=getfilesave(concat(pdir([pack]),chr(92),label([packfilename],main),[.3di]),[*.3di]),if(fileexists(concat(extractprename(t),[.3di])),if(confirm(['+tr('Overwrite_file')+']),t,t:=[]),t)))),main),if(not(comparetext([],label([packfilename],main))),do(setlabel([packfilenameexists],1,main),setlabel([pack_sub],0,main),kernelfnc([pack model dialog]),run)))),kernelfnc([save main settings and quit]))])')}    //    if (theCode==3) {PDScript('terminator([kernelfnc([save main settings and quit])])')}   }      function LoadCatalogSelectorAuto()   {    var a='../../sel/'+params['sel']+'/';    top.GetElement('iframeSelector').src=a+'selectorauto.html';   }   function LoadCatalogSelector()   {    var a='../../sel/'+params['sel']+'/';    if (appIsOnline)     {     top.GetElement('iframeSelector').src=a+params['selonline']+'.html';    } else    {          top.NavScript('do(gstring(1):=concat(approotdir,[sel\\'+params['sel']+'\\]),execfilesection(pdir([navigram_pro.fnc]),[Update Catalog Selector V9]),about)');         LoadCatalogSelectorAuto();//     top.PDScript('settimerevent([do(gstring(1):=concat(approotdir,[sel\\'+params['sel']+'\\]),execfilesection(pdir([navigram_pro.fnc]),[Update Catalog Selector]))])');    }   }   function PageDiveInitOk()						// function is called from model, when the model is succesfully loaded it maximizes the 3dview and sets several system settings   {    NavigramIsLoaded=true;    top.iframeMenuMain.UpdateParams();    SetPDServerPath();    OnTerminatePD(1);//    if (!(appIsOnline==1)) {LoadCatalogSelector();};    if (params['submodel']==1)     {     LoadModel('navrp','navbasic-rooms','n0086_room','n0086.html','nav-rooms.png','','BUILDINGCONTAINER','',this.location.href);    } else    {     LoadModel(params['sub1'],params['sub2'],params['sub3'],params['sub4'],params['sub5'],'','BUILDINGCONTAINER','',this.location.href);    }   }   function NewModel()   {    top.location.reload()   }//***************** END