if(!window.Microsoft)window.Microsoft={};if(!window.Microsoft.Photosynth)window.Microsoft.Photosynth={};if(!window.Microsoft.Photosynth.Math)window.Microsoft.Photosynth.Math={};Microsoft.Photosynth.Config={minimumSilverlightVersion:"4.0.50401.0",maxImageDimension:512,xapSource:"http://photosynth.net/silverlight/photosynth.xap",psWebService:"http://photosynth.net/",silverlightInstallUrl:"http://www.microsoft.com/silverlight/resources/install.aspx",clickToViewImageUrl:"http://photosynth.net/inc/images/view_embed_btn.png",backgroundTexture:"http://photosynth.net/api/slbackground_black.png",useLeftPadding:false,analyticsWebServiceBase:"http://maps.slapi0.virtualearth.net/explore/CosmosAnalyticsService.svc",promptForInstall:true,backgroundColor:"000000"};Microsoft.Photosynth.Strings={ClickToView:"Click to view the synth",PleaseRefresh:"You may need to reload this page when the<br>Silverlight installation is finished.",PleaseRestart:"You may need to restart the browser when the<br>Silverlight installation is finished."};Microsoft.Photosynth.viewers=[];Microsoft.Photosynth._nextId=0;Microsoft.Photosynth.NavigationType={Immediate:0,Direct:1,DefaultPath:2};Microsoft.Photosynth.DisplayMode={TwoD:1,ThreeD:2};Microsoft.Photosynth.PointCloudMode={ImagesOnly:1,ImagesAndPointCloud:2,PointCloudOnly:3};Microsoft.Photosynth.viewerLoadCollectionCompletedCallback=function(b){var a=Microsoft.Photosynth._getViewerInstance(b.id);if(a==null)return;a._onLoadCollectionCompleted(b)};Microsoft.Photosynth.installSilverlight=function(){top.location=Microsoft.Photosynth.Config.silverlightInstallUrl};Microsoft.Photosynth._getNextId=function(){Microsoft.Photosynth._nextId++;return Microsoft.Photosynth._nextId};Microsoft.Photosynth._getViewerInstance=function(b){for(var a in Microsoft.Photosynth.viewers)if(Microsoft.Photosynth.viewers[a].id==b)return Microsoft.Photosynth.viewers[a];return null};Microsoft.Photosynth.registerViewer=function(a){a.id="photosynth_viewer_"+Microsoft.Photosynth._getNextId();Microsoft.Photosynth.viewers.push(a)};Microsoft.Photosynth.delayLoadClicked=function(b){var a=Microsoft.Photosynth._getViewerInstance(b);if(a==null)return;a.onDelayLoadClicked()};Microsoft.Photosynth.installClicked=function(){for(var a in Microsoft.Photosynth.viewers)Microsoft.Photosynth.viewers[a].onInstallClicked()};Microsoft.Photosynth.resizeImageToParent=function(n,o,p,j){var d=document.getElementById(o),m=document.getElementById(p),k=5,e=d.width,b=d.height,c=m.offsetWidth-k*2,f=m.offsetHeight-k*2,a=1;if(e>c)a=c/e;if(b*a>f)a=f/b;var i=e>b?e*a:b*a;if(i>j)a=a*(j/i);d.width=d.width*a;d.style.visibility="visible";var h=document.getElementById(n+"_messageDisplay"),q=document.location.href;if(h!=null){var g="0",l="0";if(a>0)g=b*a-80;if(b<120)g=f*a-80;h.style.paddingTop=g+"px";if(Microsoft.Photosynth.Config.useLeftPadding==true){if(c/2-c>0)l=c/2-c;h.style.paddingLeft=l+"px"}}};Microsoft.Photosynth.Viewer=function(b){var a=this;this._init=function(){a.id="";Microsoft.Photosynth.registerViewer(a);a._viewerInstance=null;a.viewport3D=null;if(typeof b=="string")a._owner=document.getElementById(b);else a._owner=b;a.loadCollectionCompleted=null;a.displayModeChanged=null;a.pointCloudModeChanged=null;a.moveToImageCompleted=null;a.beforeToggleFullScreen=null};this._onLoadCollectionCompleted=function(b){a._viewerInstance=b;a._viewerInstance.content.api.registerViewer(a);a.viewport3D=a._viewerInstance.content.api.viewport3D;a._viewerInstance.content.api.displayModeChanged=a._onDisplayModeChanged;a._viewerInstance.content.api.pointCloudModeChanged=a._onPointCloudModeChanged;a._viewerInstance.content.api.moveToImageCompleted=a._onMoveToImageCompleted;a._viewerInstance.content.api.beforeToggleFullScreen=a._onBeforeToggleFullScreen;a.loadCollectionCompleted!=null&&a.loadCollectionCompleted(a)};this._onDisplayModeChanged=function(b){a.displayModeChanged!=null&&a.displayModeChanged(b)};this._onPointCloudModeChanged=function(b){a.pointCloudModeChanged!=null&&a.pointCloudModeChanged(b)};this._onMoveToImageCompleted=function(b){a.moveToImageCompleted!=null&&a.moveToImageCompleted(b)};this._onBeforeToggleFullScreen=function(b,c){a.beforeToggleFullScreen!=null&&a.beforeToggleFullScreen(b,c)};this.getPoseState=function(){if(a._viewerInstance==null)return "";return a._viewerInstance.content.api.getPoseState()};this.setFromPoseState=function(b){if(a._viewerInstance==null)return;a._viewerInstance.content.api.setFromPoseState(b)};this.getPointCloudMode=function(){if(a._viewerInstance==null)return;return a._viewerInstance.content.api.pointCloudMode};this.setPointCloudMode=function(b){if(a._viewerInstance==null)return;a._viewerInstance.content.api.pointCloudMode=b};this.setSlideshowInterval=function(b){if(a._viewerInstance==null)return;a._viewerInstance.content.api.setSlideshowInterval(b)};this.isSlideshowRunning=function(){if(a._viewerInstance==null)return;return a._viewerInstance.content.api.isSlideshowRunning()};this.toggleSlideshow=function(b){if(a._viewerInstance==null)return;a._viewerInstance.content.api.toggleSlideshow(b)};this.getCurrentDisplayMode=function(){if(a._viewerInstance==null)return -1;return a._viewerInstance.content.api.currentDisplayMode};this.getSelectedImageId=function(){if(a._viewerInstance==null)return -1;return a._viewerInstance.content.api.selectedImageId};this.moveToImage=function(b,c){if(a._viewerInstance==null)return;a._viewerInstance.content.api.moveToImage(b,c)};this.loadCollectionAsync=function(c){if(a._loadParameters!=null)throw"Load can only be called once on a viewer instance";a._loadParameters=c;var b;if(c.delayLoad&&Silverlight.isInstalled(Microsoft.Photosynth.Config.minimumSilverlightVersion))b=a.onCreateDelayLoadHtml();else b=a._createViewerHtml();this.setContainerHtml(b)};this.setContainerHtml=function(b){a._owner.innerHTML=b};this.onInstallClicked=function(){var b=null;if(Silverlight.isBrowserRestartRequired)b=document.getElementById(a.id+"_restartMessageDisplay");else b=document.getElementById(a.id+"_refreshMessageDisplay");if(b!=null){b.style.display="block";var d=document.getElementById(a.id+"_installMessageDisplay");if(d!=null)d.style.display="none";var c=document.getElementById(a.id+"_installLink");if(c!=null){c.onclick="";c.style.cursor="cross"}}Silverlight.getSilverlight(Microsoft.Photosynth.Config.minimumSilverlightVersion)};this.onDelayLoadClicked=function(){var b=a._createViewerHtml();a._owner.innerHTML=b};this.onCreateInstallHtml=function(){if(Microsoft.Photosynth.Config.promptForInstall){var c=a._getHtmlTemplate(),b='<div style="width:410px" id="'+a.id+'_installMessageDisplay"><img id="'+this.id+'imgClick" alt="'+Microsoft.Photosynth.Strings.ClickToView+'" title="'+Microsoft.Photosynth.Strings.ClickToView+'" src="'+Microsoft.Photosynth.Config.clickToViewImageUrl+'" />                             <p style="color:#ffffff;font-size:10px;cursor:default;background-image:url('+Microsoft.Photosynth.Config.backgroundTexture+'); padding:4px;margin:20px;margin-top: 10px;border-style:none;">                                 You\'ll be installing <span style="cursor:pointer;text-decoration:underline;" onclick="Microsoft.Photosynth.installSilverlight(); if (event.stopPropagation) {event.stopPropagation();} else {event.cancelBubble = true;};"><b>Microsoft Silverlight</b></span>. It\'s small and fast.                             </p></div>                             <div style="width:410px; display:none;" id="'+a.id+'_restartMessageDisplay"><p style="color:#ffffff;font-size:16px;cursor:default;background-image:url('+Microsoft.Photosynth.Config.backgroundTexture+');padding:4px;margin:20px;border-style:none;">'+Microsoft.Photosynth.Strings.PleaseRestart+'</p></div>                             <div style="width:410px; display:none;" id="'+a.id+'_refreshMessageDisplay"><p style="color:#ffffff;font-size:16px;cursor:default;background-image:url('+Microsoft.Photosynth.Config.backgroundTexture+');padding:4px;margin:20px;border-style:none;">'+Microsoft.Photosynth.Strings.PleaseRefresh+"</p></div>";return c.replace("##OVERLAY_CONTENT##",b).replace("##ONCLICK##","onclick=\"Microsoft.Photosynth.installClicked('"+a.id+"');\"")}else return '<div id="'+a.id+'_mainDiv" style="min-height:100%;position:relative;width:100%;height:100%;overflow:hidden;margin:0;padding:0;background-color:#'+a._loadParameters.backgroundColor+';" >                     <div style="z-index:0;min-height:100%;position:absolute;width:100%;height:100%;margin:0;padding:0;border:0;background-color:#'+a._loadParameters.backgroundColor+';">                         <table width="100%" style="height:100%;margin:0;padding:0;border:0;">                             <tr>                                 <td width="100%" height="100%" style="margin:0;padding:0;border:0;" align="center">                                     <img onload="Microsoft.Photosynth.resizeImageToParent(\''+a.id+"', '"+a.id+"_holdingImage', '"+a.id+"_mainDiv', "+Microsoft.Photosynth.Config.maxImageDimension+');" style="visibility:hidden;" id="'+a.id+'_holdingImage" src="'+a._loadParameters.holdingImageUrl+'" />                                 </td>                             </tr>                         </table>                     </div>'};this.onCreateClickToViewHtml=function(b){var c='<div style="width:410px"><img id="'+this.id+'imgClick" alt="'+Microsoft.Photosynth.Strings.ClickToView+'" title="'+Microsoft.Photosynth.Strings.ClickToView+'" src="'+Microsoft.Photosynth.Config.clickToViewImageUrl+'" /></div>';return a._getHtmlTemplate().replace("##OVERLAY_CONTENT##",c).replace("##ONCLICK##","onclick=\"window.top.location.href='/view/"+b+"'\"")};this.onCreateDelayLoadHtml=function(){var c=a._getHtmlTemplate(),b='<div style="width:410px"><img id="'+a.id+'imgClick" alt="'+Microsoft.Photosynth.Strings.ClickToView+'" title="'+Microsoft.Photosynth.Strings.ClickToView+'" src="'+Microsoft.Photosynth.Config.clickToViewImageUrl+'" /></div>';return c.replace("##OVERLAY_CONTENT##",b).replace("##ONCLICK##"," onclick=\"Microsoft.Photosynth.delayLoadClicked('"+a.id+"');\"")};this._getHtmlTemplate=function(){return '<div id="'+a.id+'_mainDiv" style="cursor:pointer;font-family:Verdana,Arial,Helvetica;z-index:0;min-height:100%;position:relative;width:100%;height:100%;overflow:hidden;margin:0;padding:0;" ##ONCLICK## >                     <div style="z-index:0;min-height:100%;position:absolute;width:100%;height:100%;margin:0;padding:0;border:0;">                         <table width="100%" style="height:100%;margin:0;padding:0;border:0;">                             <tr>                                 <td width="100%" height="100%" style="margin:0;padding:0;border:0;" align="center">                                     <img onload="Microsoft.Photosynth.resizeImageToParent(\''+a.id+"', '"+a.id+"_holdingImage', '"+a.id+"_mainDiv', "+Microsoft.Photosynth.Config.maxImageDimension+');" style="visibility:hidden;" id="'+a.id+'_holdingImage" alt="'+Microsoft.Photosynth.Strings.ClickToView+'" title="'+Microsoft.Photosynth.Strings.ClickToView+'" src="'+a._loadParameters.holdingImageUrl+'" />                                 </td>                             </tr>                         </table>                     </div>                     <div style="z-index:1;min-height:100%;position:absolute;width:100%;height:100%;margin:0;padding:0;border:0;background-color:Transparent;">                         <table border="0" style="height:100%;margin-left:auto;margin-right:auto;padding:0;border:0" align="center">                             <tr>                                 <td height="100%" style="margin:0;padding:0 auto; border:0;" align="center">                                     <div id="'+a.id+'_messageDisplay">                                         ##OVERLAY_CONTENT##                                     </div>                                 </td>                             </tr>                         </table>                     </div>                 </div>'};this._isIos=function(){var a=navigator.userAgent.toLowerCase();return a.indexOf("iphone")>=0||a.indexOf("ipad")>=0||a.indexOf("ipod")>=0};this._createViewerHtml=function(){var f=null,b=[];this._loadParameters.autoPlay!=null&&b.push("autoPlay="+(this._loadParameters.autoPlay?"true":"false"));var d="false";if(this._loadParameters.suppressFirstUsePanel!=null)d=this._loadParameters.suppressFirstUsePanel?"true":"false";b.push("suppressFirstUsePanel="+d);var c="true";if(this._loadParameters.incrementViewCountOnLoad!=null)c=this._loadParameters.incrementViewCountOnLoad?"true":"false";b.push("incrementViewCountOnLoad="+c);Microsoft.Photosynth.Config.psWebService!=null&&Microsoft.Photosynth.Config.psWebService!=""&&b.push("psWebService="+Microsoft.Photosynth.Config.psWebService);Microsoft.Photosynth.Config.analyticsWebServiceBase!=null&&Microsoft.Photosynth.Config.analyticsWebServiceBase!=""&&b.push("analyticsWebServiceBase="+Microsoft.Photosynth.Config.analyticsWebServiceBase);this._loadParameters.jsonUri!=null&&this._loadParameters.jsonUri!=""&&b.push("jsonUri="+this._loadParameters.jsonUri);this._loadParameters.collectionId!=null&&this._loadParameters.collectionId!=""&&b.push("cid="+this._loadParameters.collectionId);var e=this._isIos()?this.onCreateClickToViewHtml(this._loadParameters.collectionId):Silverlight.createObject(Microsoft.Photosynth.Config.xapSource,f,a.id,{version:Microsoft.Photosynth.Config.minimumSilverlightVersion,alt:a.onCreateInstallHtml(),width:"100%",height:"100%",background:"#000000",enableHtmlAccess:"true",autoUpgrade:"true",allowHtmlPopupWindow:"true"},{},b.join(","),a);return e};a._init()};Microsoft.Photosynth.Viewer.LoadParameters=function(d,c,e,f,b,a,g){this.collectionId=d;this.holdingImageUrl=c;this.delayLoad=e;this.autoPlay=f;this.suppressFirstUsePanel=b;this.incrementViewCountOnLoad=a;this.jsonUri=g};Microsoft.Photosynth.Math.Quaternion=function(b,c,d,a){this._init=function(a,c,d,b){if(a){this.x=a;this.y=c;this.z=d;this.w=b}else{this.x=0;this.y=0;this.z=0;this.w=1}};this._init(b,c,d,a)};Microsoft.Photosynth.Math.Vector3D=function(a,b,c){this._init=function(a,b,c){if(a){this.x=a;this.y=b;this.z=c}else{this.x=0;this.y=0;this.z=0}};this._init(a,b,c)};
