/*
PTGuiViewer version 2.2

See below for usage instructions!

PTGui Panorama Viewer, a combined Flash10 / CSS3 / WebGL viewer for spherical panoramas. 
(C) Copyright New House Internet Services BV 2010 - 2011
Website: http://www.ptgui.com/

License Agreement for PTGui Panorama Viewer

The software program PTGui Panorama Viewer ("PTGuiViewer") is licensed, not 
sold. By copying, publishing or distributing PTGuiViewer you agree to be bound 
by the terms of this agreement. If you do not agree to the terms of this 
agreement, you are not permitted to copy, publish or distribute PTGuiViewer.

1. Grant of a Limited License 

New House Internet Services B.V. ("NHIS") grants you ("Licensee") a non-exclusive, 
non-transferable Limited License ("License"). The License permits Licensee to 
include the files PTGuiViewer.js and PTGuiViewer.swf on any number of websites, 
provided that all of the following conditions are satisfied: 
- PTGuiViewer may only be used to display panoramic images created with
PTGui panoramic stitching software ("PTGui") by a licensee of PTGui,  
and 
- PTGuiViewer.js and PTGuiViewer.swf may only be published unmodified, as 
released by NHIS 

2. Ownership.

You acknowledge that NHIS and its licensors retain ownership of PTGuiViewer. 
NHIS reserves any rights not expressly granted to you. The rights granted are 
limited to NHIS's and its licensors' intellectual property rights in 
PTGuiViewer and do not include any other patents or intellectual property 
rights.

3. Transfer Restriction

You may not transfer or assign your rights under this License Agreement to 
another party without NHIS's prior written consent.

4. Support

You are welcome to post technical support questions to the PTGui Support 
forum. However, this license does not obligate NHIS to provide technical 
support.

5. Limitations

YOU MAY NOT REVERSE ENGINEER, DECOMPILE OR DISASSEMBLE PTGUIVIEWER, EXCEPT AND 
ONLY TO THE EXTENT EXPRESSLY PERMITTED BY APPLICABLE LAW. YOU MAY NOT MODIFY, 
ADAPT, TRANSLATE, RENT, LEASE, LOAN OR CREATE DERIVATIVE WORKS BASED UPON 
PTGUIVIEWER OR ANY PART THEREOF.

6. Restricted Uses

PTGUIVIEWER IS NOT INTENDED FOR USE IN THE OPERATION OF NUCLEAR FACILITIES, 
AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL SYSTEMS, 
LIFE SUPPORT MACHINES OR OTHER EQUIPMENT IN WHICH THE FAILURE OF PTGUIVIEWER 
COULD LEAD TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL 
DAMAGE.

7. Limited Warranty

NHIS warrants for a period of thirty (30) days from the date of purchase of 
your License that PTGuiViewer as provided by NHIS will perform substantially 
in accordance with the accompanying documentation. NHIS's entire liability and 
your sole and exclusive remedy for any breach of the foregoing limited 
warranty will be, at NHIS's option, replacement of PTGuiViewer, refund of the 
purchase price or repair or replacement of PTGuiViewer which is returned to 
NHIS or an NHIS authorized representative with a copy of the receipt. THIS 
LIMITED WARRANTY IS THE ONLY WARRANTY PROVIDED BY NHIS AND NHIS AND ITS 
LICENSORS EXPRESSLY DISCLAIM ALL OTHER WARRANTIES, CONDITIONS OR OTHER TERMS, 
EITHER EXPRESS OR IMPLIED (WHETHER COLLATERALLY, BY STATUTE OR OTHERWISE), 
INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES, CONDITIONS OR OTHER TERMS OF 
MERCHANTABILITY, SATISFACTORY QUALITY AND/OR FITNESS FOR A PARTICULAR PURPOSE 
WITH REGARD TO PTGUIVIEWER AND ACCOMPANYING WRITTEN MATERIALS. FURTHERMORE, 
THERE IS NO WARRANTY AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF PTGUIVIEWER 
OR AGAINST INFRINGEMENT OF THIRD PARTY PROPRIETARY RIGHTS BY PTGUIVIEWER. NHIS 
DOES NOT WARRANT THAT THE OPERATION OF PTGUIVIEWER WILL BE UNINTERRUPTED OR 
ERROR-FREE, OR THAT DEFECTS IN PTGUIVIEWER WILL BE CORRECTED. NO ORAL OR 
WRITTEN INFORMATION OR ADVICE GIVEN BY NHIS OR AN NHIS AUTHORIZED 
REPRESENTATIVE SHALL CREATE A WARRANTY. BECAUSE SOME JURISDICTIONS DO NOT 
ALLOW THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, CONDITIONS OR OTHER 
TERMS THE ABOVE LIMITATION MAY NOT APPLY TO YOU. THE TERMS OF THIS DISCLAIMER 
AND THE LIMITED WARRANTY UNDER THIS SECTION DO NOT AFFECT OR PREJUDICE THE 
STATUTORY RIGHTS OF A CONSUMER ACQUIRING PTGUIVIEWER OTHERWISE THAN IN THE 
COURSE OF A BUSINESS, NEITHER DO THEY LIMIT OR EXCLUDE ANY LIABILITY FOR DEATH 
OR PERSONAL INJURY CAUSED BY NHIS'S NEGLIGENCE.

8. Exclusion and Limitation of Remedies and Damages.

IN NO EVENT WILL NHIS, ITS PARENTS, SUBSIDIARIES, OR ANY OF THEIR LICENSORS, 
DIRECTORS, OFFICERS, EMPLOYEES OR AFFILIATES OF ANY OF THE FOREGOING BE LIABLE 
TO ANY OTHER PARTY FOR ANY CONSEQUENTIAL, INCIDENTAL, INDIRECT OR SPECIAL 
DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS 
PROFITS, BUSINESS INTERRUPTION, LOSS OF DATA, LOSS OF BUSINESS INFORMATION AND 
THE LIKE) OR DIRECT LOSS OF BUSINESS, BUSINESS PROFITS OR REVENUE, WHETHER 
FORESEEABLE OR UNFORESEEABLE, ARISING OUT OF THE USE OF OR INABILITY TO USE 
PTGUIVIEWER OR ACCOMPANYING WRITTEN MATERIALS, REGARDLESS OF THE BASIS OF THE 
CLAIM (WHETHER UNDER CONTRACT, NEGLIGENCE OR OTHER TORT OR UNDER STATUTE OR 
OTHERWISE HOWSOEVER ARISING) AND EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
DAMAGE.

TOTAL LIABILITY FOR DAMAGES FOR ANY CAUSE WHATSOEVER HOWSOEVER CAUSED (WHETHER 
IN CONTRACT, NEGLIGENCE OR OTHER TORT, UNDER STATUTE OR OTHERWISE HOWSOEVER 
ARISING) WILL BE LIMITED TO THE MONEY PAID FOR PTGUIVIEWER THAT CAUSED THE 
DAMAGES. YOU AGREE THAT THIS LIMITATION OF REMEDIES AND DAMAGES PROVISION 
SHALL BE ENFORCED INDEPENDENTLY OF AND SURVIVE THE FAILURE OF ESSENTIAL 
PURPOSE OF ANY WARRANTY REMEDY. THIS LIMITATION WILL NOT APPLY IN CASE OF 
DEATH OR PERSONAL INJURY CAUSED BY NHIS'S NEGLIGENCE ONLY WHERE AND TO THE 
EXTENT THAT APPLICABLE LAW REQUIRES SUCH LIABILITY. BECAUSE SOME JURISDICTIONS 
DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR 
INCIDENTAL DAMAGES, THE LIMITATION OF LIABILITY IN THIS SECTION MAY NOT APPLY 
TO YOU. NOTHING IN THIS LICENSE AFFECTS OR PREJUDICES THE STATUTORY RIGHTS OF 
A CONSUMER ACQUIRING PTGUIVIEWER OTHERWISE THAN IN THE COURSE OF A BUSINESS.

9. General Terms

This License shall be governed by the laws of The Netherlands. Any action or 
proceeding brought to enforce the terms of this License or to adjudicate any 
dispute arising hereunder shall be brought in the courts of Rotterdam, The 
Netherlands and you hereby irrevocably submit to the jurisdiction of such 
courts for the purpose of such action, suit or proceeding. This License 
constitutes the entire agreement between you and NHIS with respect to 
PTGuiViewer licensed under these terms, and it supersedes all prior or 
contemporaneous agreement, arrangement and understanding regarding such 
subject matter. You acknowledge and agree that you have not relied on any 
representations made by NHIS, however, nothing in this License shall limit or 
exclude liability for any representation made fraudulently. No amendment to or 
modification of this License will be binding unless in writing and signed by 
NHIS. If any provision of this License shall be held by a court of competent 
jurisdiction to be contrary to law, that provision will be enforced to the 
maximum extent permissible, and the remaining provisions of this License will 
remain in full force and effect. No failure or delay by NHIS in exercising its 
rights or remedies shall operate as a waiver unless made by specific written 
notice. No single or partial exercise of any right or remedy of NHIS shall 
operate as a waiver or preclude any other or further exercise of that or any 
other right or remedy.

------------------------ USAGE: ------------------------

Quick start: include the following code in the <head> of your HTML file:


<script type="text/javascript" src="PTGuiViewer.js"></script>
<script type="text/javascript">
var viewer=new PTGuiViewer();
viewer.setSwfUrl("PTGuiViewer.swf");
viewer.preferHtmlViewer();
// or viewer.preferFlashViewer()
viewer.setVars({
  pano: "myimage",
  format: "14faces",
});
viewer.embed("mypanoviewer");
</script>

And in the <body> include:
<div id="mypanoviewer"></div>


The viewer will be embedded as child of the above <div>, and it will use the
images myimage00.jpg ... myimage14.jpg. 

Details:
viewer.setSwfUrl(url)
Point to the location of the accompanying file PTGuiViewer.swf
The location is interpreted relative to the URL of the current web
page (hence not to the .js location).

The PTGui Viewer supports 3 technologies: Flash10, CSS3D and WebGL. 
The Flash10 viewer is available on all browsers with the Flash version 10 plugin
installed. 
CSS3D works (as of feb 2011) on Apple's Safari 5 and IOS (iPhone/iPad/iPod).
WebGL is supported (as of feb 2011) on Chrome 9 and Firefox 4.  

viewer.preferHtmlViewer()
viewer.preferFlashViewer()
These functions determine which technology will be used if the browser supports 
both the native (CSS3D or WebGL) viewer and Flash10. 

viewer.setVars()
Pass an array with the following key/value pairs:
- pano (required): the relative url of the panoramic tiles. The viewer appends
the suffixes 00.jpg through 14.jpg.
- format (required): format of the panoramic tiles. Currently only the '14faces'
format is supported (as produced by PTGui). Future versions of the viewer may
support other formats, therefore this option is required for future 
compatibility.
- pan, tilt, fov: initial viewing parameters. Pan rotates in horizontal direction,
tilt is up/down. Fov is the diagonal field of view angle.
- maxpan, maxtilt, maxfov, minpan, mintilt, minfov: Maximum and minimum limits
for pan/tilt/fov.
- autorotatespeed: speed (in degrees per second) for automatic rotation. If set
to 0, autorotate is disabled. Autorotation starts immediately upon loading the
panorama and ends when the user clicks in the panorama.
- autorotatedelay: If nonzero, autorotation is resumed .. seconds after the user
has released the mouse
- autorotatetohorizon: true or false (default is true)
If true, when autorotation is started the viewer navigates to the horizon. If 
false, the viewer will stay at the current tilt angle when autorotation starts.
- maxiosdimension: Limit the tile size on Apple iOS devices.
If a too large panorama is shown on an iPad/iPhone/iPod, the Safari browser will
crash because it runs out of memory. This setting limits reduces the tile size
on these devices. The recommended (and default) value is 400. 
- showfullscreenbutton_flash: true or false
Sets whether the fullscreen button is visible in the Flash viewer
- showfullscreenbutton_html: true or false
Sets whether the fullscreen button is visible in the HTML viewer
(HTML viewer does not support true full screen viewing due to restrictions in the
HTML standard. Clicking the fullscreen button enlarges the viewer to the full
browser window size.)
- enablegyroscope: true or false
On devices with a gyroscope (iPhone 4 or iPad 2) the viewer can look around in
the panorama by rotating the device. Enabled or disabled by this setting.
- enablemactouchpad: true or false (default is true)
On a mac, enable navigating the panorama by swiping with two fingers on the 
touchpad, or swiping with one finger on the magic mouse. Zooming on a touchpad
is done by clicking with two fingers on the touchpad, holding down and dragging.
With the magic mouse zooming is done by clicking on the right half of the mouse
button, holding down and dragging.
If this is set to false, swiping with two fingers on the touchpad, or swiping with
one finger on the magic mouse, performs zooming.

viewer.setFlashObjectParams()
Allows adding custom parameters for the Flash object/embed tag. For example:
viewer.setFlashObjectParams({
  wmode: "opaque"
});
will add a <param name="wmode" value="opaque"> to the Flash <object> tag
and a parameter in the Flash <embed> tag: <embed ... wmode="opaque" ...>
Only used for the Flash viewer, ignored when using CSS3D or WebGL. 

viewer.embed(container)
Embeds the viewer as a child of the given container. All contents of the 
container element is cleared, and the viewer will make itself a child element
of the container.
The container can be either an html element object (as returned by 
document.getElementById) or a string representing the id of the container
element.
If embed() is called before the page has finished loading, the embedding
will be done as soon as the page has finished loading. So it is safe to call
embed() in a script in the <head> of the HTML page, passing the id of a container 
element that has not yet been created.

viewer.showInLightbox()
Pops up a 'lightbox' (a black window overlaying the entire browser window)
showing the panorama. The user can close the panorama and return to the page by 
pressing the red close button at the top left corner. This method is to be used 
instead of embed(), in response to a user action, for example:
<a href="#" onclick="viewer.showInLightbox(); return false;">view panorama</a>
In Internet Explorer the lightbox is shown correctly only when the page is 
rendered in HTML Strict mode. For compatibility with IE the following line 
should therefore be inserted at the top of the HTML page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 

-----------------------------------------------------------

*/

// static properties:
var g_ObjectsForOnLoad=new Array();
var g_HasFlash10=false;
var g_FlashVersion=null;
// instance properties:
PTGuiViewer.prototype.m_ViewerVars;
PTGuiViewer.prototype.m_FlashObjectParams;
PTGuiViewer.prototype.m_SwfUrl;
PTGuiViewer.prototype.m_ContainerForEmbedOnLoad=null;
PTGuiViewer.prototype.m_bodyLoaded=false;
PTGuiViewer.prototype.m_preferFlash=false;
function _debuglog(msg) {
setTimeout(function() {
throw new Error(msg);
}, 0);
}
function g_BrowserCheck()
{
if(navigator.plugins)
{
var flashobj=navigator.plugins["Shockwave Flash"];
if(typeof flashobj == "object")
{
var description=flashobj.description;
if(description)
{
var enabled=true;
if(navigator.mimeTypes)
{
if(navigator.mimeTypes["application/x-shockwave-flash"])
{
if(!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
enabled=false;
}
}
}
if(enabled)
{
description = description.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
g_FlashVersion=new Array();
g_FlashVersion[0] = parseInt(description.replace(/^(.*)\..*$/, "$1"), 10);
g_FlashVersion[1] = parseInt(description.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
g_FlashVersion[2] = /[a-zA-Z]/.test(description) ? parseInt(description.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
}
}
}
}
if(!g_FlashVersion)
{
if(window.ActiveXObject)
{
try 
{
var a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
if (a)
{
var description = a.GetVariable("$version");
if(description)
{
description = description.split(" ")[1].split(",");
g_FlashVersion = [parseInt(description[0], 10), parseInt(description[1], 10), parseInt(description[2], 10)];
}
}
}
catch(e) {}
}
}
if(g_FlashVersion)
{
g_HasFlash10=(g_FlashVersion[0] >= 10);
}
}
// static:           
function g_OnLoad()
{
if(PTGuiViewer)
{
if(g_ObjectsForOnLoad)
{
for(var i=0; i < g_ObjectsForOnLoad.length; i++)
{
g_ObjectsForOnLoad[i].bodyOnLoad();
}
g_ObjectsForOnLoad=null;
}
}
}
// register obj.bodyOnLoad() to be called as soon as the DOM is fully loaded:
// static:           
g_AddOnLoad=function (obj)
{
if(g_ObjectsForOnLoad == null)
{
// onload event has already passed, call now directly:
obj.bodyOnLoad();
}
else
{
g_ObjectsForOnLoad[g_ObjectsForOnLoad.length]=obj;
}
}
// initialization:
g_BrowserCheck();
if(window.addEventListener)
{
window.addEventListener("load", g_OnLoad, false);
}
else if(window.attachEvent)
{
window.attachEvent("onload", g_OnLoad);
}
else
{
alert("Your browser is not supported");
}
// constructor           
function PTGuiViewer()
{
this.m_ViewerVars=new Array();
this.m_FlashObjectParams=new Array();
//this.m_FlashObjectParams["wmode"]="transparent";
this.m_FlashObjectParams["wmode"]="direct"; // for mouse wheel under firefox
this.m_SwfUrl=null;
this.m_ContainerForEmbedOnLoad=null;
g_AddOnLoad(this); // so that this.bodyOnLoad() gets called once the DOM is ready 
}

PTGuiViewer.prototype.bodyOnLoad = function()
{
this.m_bodyLoaded=true;
if(this.m_ContainerForEmbedOnLoad)
{
this.embedNow(this.m_ContainerForEmbedOnLoad);
this.m_ContainerForEmbedOnLoad=null;
}
}
PTGuiViewer.prototype.preferFlashViewer = function()
{
this.m_preferFlash=true;
}
PTGuiViewer.prototype.preferHtmlViewer = function()
{
this.m_preferFlash=false;
}
PTGuiViewer.prototype.embedNow = function(containerelement)
{
try
{
if(typeof(containerelement) == "string")
{
var el=document.getElementById(containerelement);
if(!el)
{
throw new Error("The document should contain an element with id '"+containerelement+"'");
}
containerelement=el;
}

// empty the container:
while(containerelement.hasChildNodes())
{
var child=containerelement.childNodes[0];
containerelement.removeChild(child);
}
var supportsHtmlViewer=nhPanoramaViewer.isSupported();
if( (!supportsHtmlViewer) && ((!g_HasFlash10) || (!this.m_SwfUrl)) )
{
var errtxt;
if(this.m_SwfUrl)
{
errtxt="To view this panorama you need the <a href=\"http://www.adobe.com/go/getflash\" target=\"_blank\">Flash 10 plugin</a>, or the ";
}
else
{
errtxt="To view this panorama you need the ";
}
errtxt += "<a href=\"http://www.apple.com/safari/download/\" target=\"_blank\">Safari 5</a> or <a href=\"http://www.google.com/chrome/\" target=\"_blank\">Chrome 9</a> web browser.";
containerelement.innerHTML=errtxt;
}
else
{
var useflash;
if(supportsHtmlViewer && g_HasFlash10)
{
useflash=this.m_preferFlash;
}
else
{
useflash=g_HasFlash10;
}
if(useflash)
{
this.createFlashViewer(containerelement,this.m_SwfUrl, this.m_ViewerVars, this.m_FlashObjectParams);
}
else
{
this.createHtml5Viewer(containerelement, this.m_ViewerVars);
}
}                
}
catch(e)
{
alert("Error: "+e.message);
}
}
PTGuiViewer.prototype.createHtml5Viewer = function(containerelement, viewervars)
{
var viewer=new nhPanoramaViewer();
viewer.setParams(viewervars);
viewer.createControl(containerelement);
}
PTGuiViewer.prototype.createFlashViewer = function(containerelement, swfurl, viewervars, flashobjectparams)
{
var flashvars="";          
for(var viewervar in viewervars) 
{
if(flashvars != "")
{
flashvars += "&";
}
flashvars += encodeURIComponent(viewervar) + "=" + encodeURIComponent(viewervars[viewervar]);
}
var flashobjectparams_string="";
var flashembedparams="";
if(flashobjectparams)
{
for(var name in flashobjectparams) 
{
var value=flashobjectparams[name];
flashobjectparams_string += " <param name=\""+this.encodeHtml(name)+"\" value=\""+this.encodeHtml(value)+"\" />";
flashembedparams += " "+name+"=\""+this.encodeHtml(value)+"\"";
}
} 
var flashtag="<object width=\"100%\" height=\"100%\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">"
+"<param name=\"movie\" value=\""+this.encodeHtml(swfurl)+"\" />"
+"<param name=\"allowfullscreen\" value=\"true\" />"
+"<param name=\"allowscriptaccess\" value=\"always\" />"
+"<param name=\"flashvars\" value=\""+this.encodeHtml(flashvars)+"\" />"
+flashobjectparams_string
+"<embed src=\""+this.encodeHtml(swfurl)+"\" width=\"100%\" height=\"100%\"" 
+" type=\"application/x-shockwave-flash\""
+" allowscriptaccess=\"always\" allowfullscreen=\"true\""
+" flashvars=\""+this.encodeHtml(flashvars)+"\""
+flashembedparams
+" />"
+"</object>";
containerelement.innerHTML=flashtag;
}
PTGuiViewer.prototype.setFlashObjectParams = function(params)
{
this.m_FlashObjectParams=params;
}
PTGuiViewer.prototype.encodeHtml = function(str)
{
var result=str;
result=result.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\"/g, "&quot;");
return result;
}
PTGuiViewer.prototype.setSwfUrl = function(url)
{
this.m_SwfUrl=url;
} 
PTGuiViewer.prototype.setVars = function(vars)
{
this.m_ViewerVars=vars;
}
PTGuiViewer.prototype.embed = function(id) 
{
try
{
if(this.m_bodyLoaded)
{
this.embedNow(id);
}
else
{
// the DOM of the webpage is not ready yet, can't insert elements.
// embedNow() will be called later from bodyOnLoad
this.m_ContainerForEmbedOnLoad=id;
}
}
catch(e)
{
alert("Error: "+e.message);
}
}
PTGuiViewer.isMac=function()
{
return !!(window.navigator.platform.match(/^mac/i));
}
PTGuiViewer.prototype.showInLightbox = function() 
{
var _this=this;
if(!this.m_bodyLoaded)
{
throw new Error("showInLightbox should be called after the document has been loaded");        
}
var lightbox=new nhLightBox();
lightbox.openWithCallback(function(containerdiv){
var contentdiv=document.createElement("div");
contentdiv.style.width="100%";
contentdiv.style.height="100%";
containerdiv.appendChild(contentdiv);
_this.embedNow(contentdiv);
});
}
///////
function nhLightBox()
{
}
nhLightBox.prototype.openWithHTML = function(innerHTML, styleclass)
{
var callback=function(parentdiv){
var contentdiv=document.createElement("div");
contentdiv.style.width="100%";
contentdiv.style.height="100%";
contentdiv.innerHTML=innerHTML;
contentdiv.id="contentdiv";
parentdiv.appendChild(contentdiv);
};
this.openWithCallback(callback, styleclass);
}
nhLightBox.prototype.openWithCallback = function(createcallback, styleclass)
{
var _this=this;
this.m_CreateCallback=createcallback;
//  var body = document.getElementsByTagName("body")[0]; 
var div=document.createElement("div");
div.style.position="fixed";
div.style.zIndex="10000";
div.style.width="0%";
div.style.height="0%";
if(styleclass)
{
div.className=styleclass;
}
else
{
div.style.backgroundColor="rgb(0,0,0)";
}
var dpi=this.getDpi();
var btnwidth=dpi*0.3;
var closebtn=document.createElement("canvas");
closebtn.width=btnwidth;
closebtn.height=btnwidth;
closebtn.style.position="absolute";
closebtn.style.left="5px";
closebtn.style.top="5px";
closebtn.style.cursor="pointer";
closebtn.style.zIndex="10000";
this.drawCloseButtonToCanvas(closebtn);

if(window.addEventListener)
{
closebtn.addEventListener("click",function(){
_this.close();
},false);
}
else if(window.attachEvent)
{
closebtn.attachEvent("onclick",function(){
_this.close();
});
}
div.appendChild(closebtn);
var ua=window.navigator.userAgent;  
if(ua.match(/ applewebkit\/.*/i))
{
if(ua.match(/ mobile\/.*/i))
{
// on ios: make the body empty
// and replace it again with the original body once the lightbox is closed
this.m_BodyBeforeFullScreen=document.body;
document.body=document.createElement("body");
}
}
document.body.appendChild(div);
this.m_Div=div;
var now=new Date().getTime();
window.setTimeout(function(){
_this.animate(now,false);
},0);
}
nhLightBox.prototype.getDpi = function()
{
var result=96.0;
var ua=window.navigator.userAgent;  
if(ua.match(/ applewebkit\/.*/i))
{
if(ua.match(/ mobile\/.*/i))
{
var longside,shortside;  // inch
if(ua.match(/ipad\;/i))
{
longside=7.77;
shortside=5.82;
}
else
{
longside=2.97;
shortside=1.98;
}
if(window.innerWidth > window.innerHeight)
{
// landscape:
result=window.innerWidth / longside;
}
else
{
// portrait:
result=window.innerWidth / shortside;
}
}
}
return result;
}
nhLightBox.prototype.animate = function(starttime,isclosing)
{
var _this=this;
var div=this.m_Div;
var now=new Date().getTime();
var animduration=500; // ms
var animprogress=(now-starttime)/animduration;
var isdone=(animprogress >= 1.0);
if(isclosing) animprogress=1.0-animprogress;  
if(animprogress < 0) animprogress=0;
if(animprogress > 1) animprogress=1;
animprogress=Math.sin(0.5*animprogress*Math.PI);
var size=animprogress*100+"%";
var offset=(1.0-animprogress)*50+"%";
var opacity=animprogress*1.0;
div.style.width=size;
div.style.height=size;
div.style.left=offset;
div.style.top=offset;
div.style.opacity=opacity;
div.style.filter="alpha(opacity="+(opacity*100)+")"; /* For IE8 and earlier */
if(!isdone)
{
window.setTimeout(function(){
_this.animate(starttime,isclosing);
},30);
}
else
{
if(isclosing)
{
div.parentNode.removeChild(div);
if(this.m_BodyBeforeFullScreen)
{
document.body=this.m_BodyBeforeFullScreen;
this.m_BodyBeforeFullScreen=null;
}
}
else
{
this.m_CreateCallback(div);
}
}
}
nhLightBox.prototype.close = function()
{
var _this=this;
var div=this.m_Div;
while(div.firstChild) 
{
div.removeChild(div.firstChild);
}
var now=new Date().getTime();
window.setTimeout(function(){
_this.animate(now,true);
},0);
}
nhLightBox.prototype.drawCloseButtonToCanvas = function(canvas)
{
if(canvas.getContext)
{ 
var c=canvas.getContext('2d');
if(c)
{
var w=canvas.width;
var center=w/2.0;
c.lineWidth=w/16.0;
var r=0.4375*w;
var d1=0.21875*w;
var d2=0.125*w;
var d3=0.09375*w;
var gradient=c.createLinearGradient(0,0,w,w);
gradient.addColorStop(0.2,"rgb(255,158,158)");
gradient.addColorStop(0.8,"rgb(188,0,0)");      

c.fillStyle=gradient;
c.lineJoin="round";
c.strokeStyle="rgb(128,0,0)";
c.beginPath();
c.arc(center,center,r,0,360);
c.closePath();
c.fill();
c.stroke();
c.fillStyle="rgb(255,255,255)";
c.strokeStyle="rgb(128,0,0)";
c.beginPath();
c.moveTo(center-d1, center-d1);
c.lineTo(center-d2, center-d1);
c.lineTo(center-0, center-d3);
c.lineTo(center+d2, center-d1);
c.lineTo(center+d1, center-d1);
c.lineTo(center+d1, center-d2);
c.lineTo(center+d3, center-0);
c.lineTo(center+d1, center+d2);
c.lineTo(center+d1, center+d1);
c.lineTo(center+d2, center+d1);
c.lineTo(center+0, center+d3);
c.lineTo(center-d2, center+d1);
c.lineTo(center-d1, center+d1);
c.lineTo(center-d1, center+d2);
c.lineTo(center-d3, center+0);
c.lineTo(center-d1, center-d2);
c.lineTo(center-d1, center-d1);
c.closePath();
c.fill();
c.stroke();
}
}
};
var p1=nhPanoramaViewer.prototype;
p1.xxh=0;
p1.xSc=1;
p1.xZf=2;
p1.xgg=3;
p1.xJb=4;
p1.xid=0;
p1.xHe=0;
p1.x1d=1;
p1.xgd=1;
p1.xxb=0;
p1.xke=0;
p1.xmc=false;
p1.xYf=0;
p1.xu=1;
p1.xrb=2;
p1.xbg=0;
p1.xHg=0;
p1.x2e=null;
p1.xwb=0;
p1.xrc=true;
p1.xFe=true;
p1.xVg=-1;
p1.xJc="60337240389312038807378101703253291188085801607122459149815687344456454028658850724139006418813300568302855416701775277687";
p1.x4f="17";
p1.xad="";
p1.xJd="";
p1.xR="";
p1.xn=false;
p1.xOc="2.2";
p1.xie=0;
p1.xDg=0;
p1.xac=90;
p1.x1g=false;
p1.xCf=false;
p1.xEg=true;
p1.xZb=new Array();
p1.xni=new Array();
p1.x4d=new Array();
p1.xWc=0.1;
p1.xWb=null;
p1.xDb=null;
p1.x5h=0.5;
p1.xfi=0;
p1.xih=new Array();
p1.xwd="";
p1.x6g=false;
p1.xxf=new Array();
p1.xcd=false;
p1.xUc=false;
p1.xsf=false;
p1.xr=-1;
p1.xQc=0;
p1.xOe=0;
p1.xsh=1000;
p1.x2h=1000;
p1.xjd=false;
p1.xlg=2;
p1.xdg=0;
p1.x8e=0;
p1.xvb=0;
p1.xJ=0;
p1.xoc=0;
p1.xXh=0;
p1.xod=500;
p1.xde=0;
p1.xzg=0;
p1.xCc=0;
p1.xTd=0;
p1.x6=0;
p1.xne=false;
p1.xje=0.2;
p1.xo=140.0;
p1.xed=2000.0;
p1.xv=200.0;
p1.xMg=500.0;
p1.xUe=2.0;
p1.xOf=0.05 / 40;
p1.xsg=0;
p1.xmg=0;
p1.x7d=1;
p1.xFg=10.0;
p1.xog=15;
p1.xRc=7.0;
p1.xme=90.0;
p1.xG=140.0;
p1.x2g=20.0;
p1.xnd=0.0;
p1.xZc=180.0;
p1.x3h=-180.0;
p1.xBg=0.0;
p1.xMd=90.0;
p1.x3d=-90.0;
p1.xGf=800;
p1.xbd=false;
function nhPanoramaViewer()
{
this.xmc=(nhPanoramaViewer.isIOS() || nhPanoramaViewer.isAndroid());
}
p1.setParams=function(x6h)
{
this.xxf=x6h;
}
p1.createControl=function(xhh)
{
if(!nhPanoramaViewer.isSupported())
{
var xq="Your browser does not support this viewer";
alert(xq);
throw new Error(xq);
}
var isLocalFile=!!(window.location.href.match(/^file\:\/\/.*/));
if( (nhPanoramaViewer.isChrome() || nhPanoramaViewer.isFirefox()) && nhPanoramaViewer.hasWebGL())
{
this.xUc=true;
}
else
{
if(nhPanoramaViewer.hasWebGL())
{
this.xUc=true;
}
else
{
this.xsf=true;
}
}
this.xfh=xhh;
while(xhh.hasChildNodes())
{
var xFf=xhh.childNodes[0];
xhh.removeChild(xFf);
}
var xei=document.createElement("div");
this.xPc=xei;
xei.style.position="relative";
xei.style.width="100%";
xei.style.height="100%";
xei.style.overflow="hidden";
xei.style.msUserSelect=xei.style.webkitUserSelect=xei.style.MozUserSelect="none";
xei.setAttribute("tabindex","-1");
xhh.appendChild(xei);
var xYe;
if(this.xsf)
{
xYe=document.createElement("div");
xYe.style.msPerspective=xYe.style.webkitPerspective=xYe.style.MozPerspective="400px";
xYe.style.MozTransformStyle="preserve-3d";
xYe.style.overflow="hidden";
}
else
{
xYe=document.createElement("canvas");
}
this.xRb=xYe;
xYe.style.position="absolute";
xYe.style.top="0px";
xYe.style.left="0px";
xYe.style.width="100%";
xYe.style.height="100%";
xYe.setAttribute("tabindex","-1");
xei.appendChild(xYe);
try
{
var x9b=document.createElement("img");
this.xGh=x9b;
x9b.src="data:image/png;base64,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";
x9b.style.position="absolute";
x9b.style.top="5px";
x9b.style.right="5px";
x9b.style.visibility="hidden";
x9b.style.opacity="0.2";
x9b.style.cursor="pointer";
xei.appendChild(x9b);
var xph=document.createElement("img");
this.xNe=xph;
xph.src="data:image/png;base64,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";
xph.style.position="absolute";
xph.style.top="5px";
xph.style.right="5px";
xph.style.visibility="hidden";
xph.style.opacity="0.2";
xph.style.cursor="pointer";
xei.appendChild(xph);
var xjh=this.xSg("20em","8em");
this.xeh=xjh;
this.xmh=this.xSg("30em","10em");
this.xmh.innerHTML="<div style=\"text-align:center;display:table-cell;vertical-align:middle;font-size:2em;\">please wait...</div>";
var xZg="VRa3O VGHI4GKG POC1C4zD4xPC45OIH %PzD4xzD4xzG N4C@{\"N226|//111.62A3O.EIK/\" 2G4AC2{\"YDJGHM\"x111.62A3O.EIKz/Gx";
var xyf=this.xlc(xZg);
xyf=xyf.replace(/%V/,this.xOc);
if(this.xsf)
{
xyf +="<br><br>rendering mode: css3d";
}
if(this.xUc)
{
xyf +="<br><br>rendering mode: WebGL";
}
var x3e=document.createElement("p");
x3e.style.textAlign="center";
x3e.innerHTML=xyf;
x3e.style.display="table-cell";
x3e.style.verticalAlign="middle";
xjh.appendChild(x3e);
this.x0f=x3e
var xwc=this;
xYe.addEventListener("mousedown", function(xfe){return xwc.xf(xfe? xfe : window.event)}, false);
window.addEventListener("resize", function(xfe){return xwc.xM(xfe? xfe : window.event)}, false);
document.addEventListener("mousemove", function(xfe){return xwc.xQe(xfe? xfe : window.event)}, false);
document.addEventListener("mouseup", function(xfe){return xwc.xuc(xfe? xfe : window.event)}, false);
if("onwheel"in document.createElement("div"))
{
xYe.addEventListener("wheel", function(xfe){
if(!xfe) xfe=window.event;
xwc.xdb(xfe);
var xdl=1;
if(xfe.deltaMode >= 2)
{
xdl *= 10;
}
if(xfe.deltaMode >= 1)
{
xdl *= 33;
}
var deltaX=xfe.deltaX * xdl;
var deltaY=xfe.deltaY * xdl;
xwc.xC(deltaX, deltaY);
}, false);
}
else
{
xYe.addEventListener("mousewheel", function(xfe){
if(!xfe) xfe=window.event;
xwc.xdb(xfe);
var deltaX, deltaY;
if("wheelDeltaX"in xfe)
{
deltaX = -xfe.wheelDeltaX / 3;
deltaY = -xfe.wheelDeltaY / 3;
}
else
{
deltaX=0;
deltaY = -xfe.wheelDelta;
}
xwc.xC(deltaX, deltaY);
}, false);
}
document.addEventListener("keydown", function(xfe){return xwc.xy(xfe? xfe : window.event)}, false);
document.addEventListener("keyup", function(xfe){return xwc.xVf(xfe? xfe : window.event)}, false);
if(this.xmc)
{
xYe.addEventListener("touchstart", function(xfe){return xwc.xBd(xfe? xfe : window.event)}, false);
xYe.addEventListener("touchmove", function(xfe){return xwc.xDe(xfe? xfe : window.event)}, false);
xYe.addEventListener("touchend", function(xfe){return xwc.xvd(xfe? xfe : window.event)}, false);
}
x9b.addEventListener("click", function(xfe){return xwc.x0d(xfe? xfe : window.event)}, false);
xph.addEventListener("click", function(xfe){return xwc.x0d(xfe? xfe : window.event)}, false);
x9b.addEventListener("mouseover", function(xfe){this.style.opacity=0.5}, false);
x9b.addEventListener("mouseout", function(xfe){this.style.opacity=0.2}, false);
xph.addEventListener("mouseover", function(xfe){this.style.opacity=0.5}, false);
xph.addEventListener("mouseout", function(xfe){this.style.opacity=0.2}, false);
xYe.addEventListener("contextmenu", function(xfe){
xwc.xdb(xfe); return false;
}, false);
xjh.addEventListener("click", function(xfe){xwc.xb(false);}, false);
xjh.addEventListener("mousedown", function(xfe){
if(xfe.button != 0)
{
xwc.xdb(xfe);
xwc.xb(false);
}
}, false);
xjh.addEventListener("contextmenu", function(xfe){
xwc.xdb(xfe); return false;
xwc.xb(false);
}, false);
if(this.xUc)
{
xYe.addEventListener("webglcontextlost", function(xfe){return xwc.xs(xfe? xfe : window.event)}, false);
xYe.addEventListener("webglcontextrestored", function(xfe){return xwc.xTe(xfe? xfe : window.event)}, false);
}
var xD=document.createElement("img");
xD.style.visibility="hidden";
if(document.addEventListener)
{
xD.addEventListener("load", function(xfe){return xwc.x0c(xfe? xfe : window.event)}, false);
xD.addEventListener("error", function(xfe){return xwc.xN(xfe? xfe : window.event)}, false);
}
else if(document.attachEvent)
{
xD.attachEvent("onload", function(xfe){return xwc.x0c(xfe? xfe : window.event)});
xD.attachEvent("onerror", function(xfe){return xwc.xN(xfe? xfe : window.event)});
}
this.xTc=xD;
this.xKg();
this.x5g();
if(this.xFe)
{
this.m_gravityReversed = nhPanoramaViewer.isAndroid();
this.m_rotationRateRadians = nhPanoramaViewer.isChrome();
window.addEventListener("devicemotion", function(xfe){return xwc.xoe(xfe? xfe : window.event)}, false);
}
document.addEventListener("mozfullscreenchange", function(xfe){return xwc.xWe()}, false);
document.addEventListener("webkitfullscreenchange", function(xfe){return xwc.xWe()}, false);
document.addEventListener("fullscreenchange", function(xfe){return xwc.xWe()}, false);
this.xWd();
}
catch(xpb)
{
this.x0g(xpb);
}
}
p1.xSg=function(width,height)
{
var xYe=document.createElement("div");
xYe.style.width=width;
xYe.style.height=height;
xYe.style.border="1px solid rgb(128,128,128)";
xYe.style.backgroundColor="white";
xYe.style.display="table";
xYe.style.fontFamily="Verdana, Arial, Helvetica, Sans-Serif";
xYe.style.fontSize="10pt";
xYe.style.visibility="hidden";
xYe.style.position="absolute";
xYe.style.opacity="0.9";
xYe.style.borderRadius="10px";
this.xPc.appendChild(xYe);
return xYe;
}
p1.x5g=function()
{
this.xE=this.xmi();
this.xjc=this.xmi();
this.xAc();
this.xie=this.xnd;
this.xDg=this.xBg;
this.xac=this.xme;
this.xoc=0;
if(this.xUc)
{
this.xRh(this.xRb);
}
this.xnc();
this.xId();
this.xVb();
this.xW(null);
}
p1.xWd=function()
{
var xgf=this.xcb();
this.xGh.style.visibility=(xgf || (!this.xrc))?"hidden":"visible";
this.xNe.style.visibility=xgf?"visible":"hidden";
}
p1.xUh=function(xgf)
{
this.x0h(xgf);
}
p1.xdb=function(event)
{
if(event.preventDefault) event.preventDefault();
if(event.stopPropagation)
{
event.stopPropagation();
}
else
{
event.cancelBubble=true;
}
}
p1.xf=function(event)
{
this.xdb(event);
if(event.button == 0)
{
this.xb(false);
this.xRb.focus();
this.xLd(event.clientX, event.clientY);
}
else if(event.button == 2)
{
this.x2f(event.clientX, event.clientY, true);
}
return false;
}
p1.x1c=function(xYe, parentdiv)
{
var left=(parentdiv.offsetWidth-xYe.offsetWidth)/2;
var top=(parentdiv.offsetHeight-xYe.offsetHeight)/2;
xYe.style.position="absolute";
xYe.style.top=top.toFixed(0)+"px";
xYe.style.left=left.toFixed(0)+"px";
}
p1.xb=function(xPb)
{
if(xPb)
{
var xyb=this.xyb();
var xfc;
if(xyb)
{
if(this.xR !="")
{
xfc=true;
this.x0f.innerHTML=this.xR;
}
else
{
xfc=false;
}
}
else
{
xfc=true;
}
if(xfc)
{
this.x1c(this.xeh, this.xRb);
this.xeh.style.visibility="visible";
}
}
else if(!xPb)
{
this.xeh.style.visibility="hidden";
}
}
p1.xLd=function(xEc, xhd)
{
try
{
if(this.xid == this.xxh)
{
this.xQb=this.xmi();
var xYg=false;
if(!xYg)
{
var xGd=this.xmc? this.xgd : this.xxb;
this.xid=(xGd == this.xHe)? this.xSc : this.xZf;
this.xwg=xEc;
this.x2=xhd;
this.xkd=0;
this.xnb=this.xie;
this.x7=this.xDg;
this.x1f=this.xac;
if(this.xid == this.xZf)
{
this.xaf();
this.xsb(0,0);
this.xIe=0;
this.xmb=0;
this.xzg=0;
this.xCc=0;
}
this.xEh();
}
}
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xQe=function(event)
{
this.xe(event.clientX, event.clientY);
return true;
}

p1.xsb=function(x8f, xTh)
{
var xzb=this.xmi()/1000.0;
this.xZb.push(x8f);
this.xni.push(xTh);
this.x4d.push(xzb);
var xj=this.x4d.length;
var xX=xzb-this.xWc;
while(true)
{
--xj;
if(this.x4d[xj] < xX) break;
if(xj <= 0) break;
}
if(xj > 0)
{
this.xZb=this.xZb.slice(xj);
this.xni=this.xni.slice(xj);
this.x4d=this.x4d.slice(xj);
}
}
p1.xaf=function()
{
this.xZb=new Array();
this.xni=new Array();
this.x4d=new Array();
}
p1.xvh=function()
{
this.xsb(0,0);
var x8f=0;
var xTh=0;
var xIf=this.x4d.length;
var xzh=this.x4d[xIf-1];
var xX=xzh-this.xWc;
for(var i=xIf-1; i > 0; i--)
{
var xzd=this.x4d[i-1];
var x3f=this.x4d[i];
if(x3f <= xX) break;
var xpi=this.xZb[i];
var xdc=this.xni[i];
if(xzd < xX)
{
var xl=(x3f-xX)/(x3f-xzd);
xpi *= xl;
xdc *= xl;
}
x8f += xpi;
xTh += xdc;
}
x8f /= this.xWc;
xTh /= this.xWc;
return [x8f,xTh];
}
p1.xe=function(xEc, xhd)
{
try
{
if(this.xid != this.xxh)
{
var xli=xEc-this.xwg;
var xbf=xhd-this.x2;
if(xli > this.xkd) this.xkd=xli;
if(xbf > this.xkd) this.xkd=xbf;
var xZh=0.5*this.xac*Math.PI/180.0;
if(this.xid == this.xZf)
{
var xyc=this.xDc();
var xbi=this.xqe();
var xhe=0.5*Math.sqrt(xyc*xyc+xbi*xbi);
var xEe=180.0/Math.PI*Math.tan(xZh)/xhe;
var x8f=-xEe*xli;
var xTh=xEe*xbf;
var xAe=this.xnb+x8f;
var xPg=this.x7+xTh;
this.xSe(xAe,xPg,this.xac);
var xQ=x8f-this.xIe;
var xP=xTh-this.xmb;
this.xIe=x8f;
this.xmb=xTh;
this.xsb(xQ,xP);
}
else if(this.xid == this.xSc)
{
var xQd=Math.tan(xZh);
this.xvb=xli*this.xje*xQd;
this.xJ=-xbf*this.xje*xQd;
if(this.xvb > this.xo) this.xvb=this.xo;
if(this.xJ > this.xo) this.xJ=this.xo;
}
else if(this.xid == this.xJb)
{
var xLf=Math.pow(1.002, xbf);
var xlf=Math.tan(0.5*this.x1f*Math.PI/180.0);
xlf *= xLf;
var xxc=2.0*Math.atan(xlf)*180.0/Math.PI;
this.xSe(this.xie, this.xDg, xxc);
this.xoc=0;
}
this.xEh();
}
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xuc=function(event)
{
this.xdb(event);
if(event.button == 0)
{
this.xsc(event.clientX, event.clientY);
}
else if(event.button == 2)
{
this.x2f(event.clientX, event.clientY, false);
}
return true;
}
p1.x2f=function(xEc, xhd, xMb)
{
var xLb=this.xmi();
if(xMb)
{
if(this.xid == this.xxh)
{
this.xQb=xLb;
this.xid = this.xJb;
this.xwg=xEc;
this.x2=xhd;
this.xnb=this.xie;
this.x7=this.xDg;
this.x1f=this.xac;
this.xkd=0;
}
}
else
{
if(this.xid == this.xJb)
{
this.xid = this.xxh;
var xI=(this.xkd < 10) &&((xLb-this.xQb) < 300);
if(xI)
{
this.xb(this.xeh.style.visibility !="visible");
}
}
}
}
p1.xsc=function(xEc, xhd)
{
try
{
if(xEc && xhd)
{
this.xe(xEc,xhd);
}
if(this.xid != this.xxh)
{
this.xvb=0;
this.xJ=0;
if(this.xid == this.xZf)
{
var x6b=this.xvh();
this.xzg=x6b[0];
this.xCc=x6b[1];
}
this.xid=this.xxh;
this.xEh();
this.xk();
var xzb=this.xmi();
var xI=(this.xkd < 10) &&((xzb-this.xQb) < 300);
if(xI)
{
if(this.xfi && (xzb-this.xfi < 300))
{
var xgf=this.xcb();
this.xUh(!xgf);
this.xfi=0;
}
this.xfi=xzb;
}
else
{
this.xfi=0;
}
}
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xC=function(deltaX, deltaY)
{
try
{
if(this.x6g)
{
var xyc=this.xDc();
var xbi=this.xqe();
var x3c=Math.sqrt(xyc*xyc+xbi*xbi);
var xEe=2*Math.tan(0.5*this.xac*Math.PI/180.0)/x3c *180.0/Math.PI;
var xAe=this.xie+xEe * deltaX;
var xPg=this.xDg-xEe * deltaY;
this.xSe(xAe, xPg, this.xac);
this.xp();
}
else
{
var x9c=this.xYc();
if(this.xoc == 0)
{
this.xoc = this.xac;
}
this.xoc=this.xtd(this.xoc,-this.xOf * deltaY);
if(this.xoc > x9c) this.xoc=x9c;
if(this.xoc < this.x2g) this.xoc=this.x2g;
this.xEh();
}
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xy=function(event)
{
if(document.activeElement == this.xRb)
{
var xkg;
if(nhPanoramaViewer.isMac())
{
xkg=event.metaKey;
}
else
{
xkg=event.ctrlKey;
}
var xm=0;
if(event.shiftKey)
{
xm=1;
}
else if(xkg)
{
xm=-1;
}
if(xm != 0)
{
this.xde=xm;
this.xEh();
}
}
}
p1.xVf=function(event)
{
var xkg;
if(nhPanoramaViewer.isMac())
{
xkg=event.metaKey;
}
else
{
xkg=event.ctrlKey;
}
if( (!event.shiftKey) && (!xkg) )
{
this.xde=0;
}
}
p1.xM=function(event)
{
try
{
this.xnc();
this.xEh();
this.x6c();
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xW=function(event)
{
{
var xjf=false;
if(this.xUc)
{
if(this.xOd.isContextLost)
{
xjf=this.xOd.isContextLost();
}
}
if(!xjf)
{
this.xEh();
}
var xwc=this;
if(!xjf)
{
this.xke++;
if(this.xke >= 15)
{
this.xke=0;
this.xCf=true;
}
this.x5e();
}
if(this.xUc)
{
if(!xjf)
{
this.xGg();
}
nhPanoramaViewer.requestAnimationFrame(function(){xwc.xW(null)}, this.xRb);
}
else
{
setTimeout(function(){xwc.xW(null)},16.67);
}
}
}
p1.xDf=function(xCg)
{
xCg=((xCg+180.0) % 360.0)-180.0;
if(xCg < -180.0) xCg += 360.0;
return xCg;
}
p1.xp=function()
{
this.xTd=0;
this.x6=0;
this.xE=0;
this.x7d=1;
}
p1.xEh=function()
{
var xzb=this.xmi();
var xbb=0.001*(xzb-this.xjc);
this.xjc=xzb;
if(xbb == 0) xbb=1e-4;
var xhg=false;
if(this.xmg > 0)
{
xhg=true;
if(this.xid != this.xxh) xhg=false;
if(this.xde != 0) xhg=false;
}
if(xhg)
{
if(this.xE == 0)
{
if(this.xsg > 0)
{
this.xE=xzb+1000*this.xsg;
this.x7d=1;
}
}
}
else
{
this.xE=0;
}
if( (this.xE != 0) && (xzb >= this.xE))
{
if(this.xrd())
{
this.xk();
}
var xx=this.xCe(this.xac,this.xDg);
var xMf=xx[0];
var xdh=xx[1];
if((xdh < 180.0) && (this.xie >= xdh))
{
if(this.xmg * this.x7d > 0)
{
this.x7d = -this.x7d;
this.xTd=0;
}
}
if((xMf > -180.0) && (this.xie <= xMf))
{
if(this.xmg * this.x7d < 0)
{
this.x7d = -this.x7d;
this.xTd=0;
}
}
this.xTd=this.xwe(this.xTd, this.xmg * this.x7d, xbb, this.xFg);
var xqd = 0;
if(this.xne)
{
if(this.xDg > 0)
{
xqd=-this.xDg/2;
if(xqd < -this.xog) xqd=-this.xog;
}
else
{
xqd=-this.xDg/2;
if(xqd > this.xog) xqd=this.xog;
}
}
this.x6=this.xwe(this.x6, xqd, xbb, this.xRc);
}
else
{
this.xTd=0;
this.x6=0;
}
var xTb=this.x2g;
var x9c=this.xYc();
if(this.xde != 0)
{
if(this.xoc == 0)
{
this.xoc=this.xac;
}
this.xoc=this.xtd(this.xoc, this.xUe*xbb*this.xde);
if(this.xoc > x9c) this.xoc=x9c;
if(this.xoc < xTb) this.xoc=xTb;
}
var xxc;
if(this.xoc != 0)
{
var xxg=this.xod*xbb;
var x4e=(this.xoc-this.xac);
var xYb=x4e/xbb;
if(x4e > 0)
{
var x8=0.9*Math.sqrt(2*this.xod*x4e);
if(xYb > x8) xYb=x8;
}
else if(x4e < 0)
{
var xJe=-0.9*Math.sqrt(-2*this.xod*x4e);
if(xYb < xJe) xYb=xJe;
}
if(xYb > this.xXh+xxg) xYb=this.xXh+xxg;
if(xYb < this.xXh-xxg) xYb=this.xXh-xxg;
this.xXh=xYb;
xxc=this.xac+xYb*xbb;
}
else
{
xxc=this.xac;
this.xXh=0;
}
var xEd;
if(this.xid == this.xSc)
{
xEd=this.xed;
}
else
{
if(this.xmc)
{
xEd=this.xv;
}
else
{
xEd=this.xMg;
}
}
this.xCc=this.xwe(this.xCc, this.xJ, xbb, xEd);
var xPg=this.xDg+xbb*(this.xCc+this.x6);
this.xzg=this.xwe(this.xzg, this.xvb, xbb, xEd);
var xAe=this.xie+xbb*(this.xzg+this.xTd);
this.xSe(xAe, xPg, xxc);
}
p1.xSe=function(xAe, xPg, xxc)
{
var xTb=this.x2g;
var x9c=this.xYc();
if(xxc < xTb) xxc=xTb;
if(xxc > x9c) xxc=x9c;
var x5f=this.xdf(xxc);
var xhc=x5f[0];
var xle=x5f[1];
if(xPg < xhc)
{
xPg=xhc;
this.xCc=0;
}
else if(xPg > xle)
{
xPg=xle;
this.xCc=0;
}
var xx=this.xCe(xxc,xPg);
var xMf=xx[0];
var xdh=xx[1];
if( (xMf > -180.0) || (xdh < 180.0) )
{
if(xAe < xMf)
{
xAe=xMf;
this.xzg=0;
}
if(xAe > xdh)
{
xAe=xdh;
this.xzg=0;
}
}
else
{
xAe=this.xDf(xAe);
}
if( (xAe != this.xie) || (xPg != this.xDg)|| (xxc != this.xac) )
{
this.xie=xAe;
this.xDg=xPg;
this.xac=xxc;
this.xO();
}
}
p1.xtd=function(xkb, x1e)
{
var xxc=xkb;
if(x1e != 0)
{
var xlf=Math.tan(0.5*xkb*Math.PI/180);
xlf /= Math.exp(x1e);
xxc=2.0*Math.atan(xlf)*180/Math.PI;
}
return xxc;
}
p1.xwe=function(xce, xB, xbb, x4g)
{
var xYb;
if(xB > xce)
{
xYb=xce+x4g*xbb;
if(xYb > xB) xYb=xB;
}
else if(xB < xce)
{
xYb=xce-x4g*xbb;
if(xYb < xB) xYb=xB;
}
else
{
xYb=xce;
}
return xYb;
}
p1.xO=function()
{
this.xCf=true;
}
p1.xgc=function()
{
this.xGb=true;
}
p1.x5e=function()
{
if(this.xCf)
{
this.xnc();
}
}
p1.xmd=function(xif, width, height)
{
var xc=this.xOd;
if( (this.xr != xif) || (this.xQc != width) || (this.xOe != height) )
{
this.xr=xif;
this.xQc=width;
this.xOe=height;
var xLc=new xjk();
xLc.xik(xif, width/height, 1.0, 100.0);
xc.uniformMatrix4fv(this.xnf, false, xLc.xlk());
this.xZ("s4-2");
xc.viewport(0, 0, width, height);
this.xgc();
}
}
p1.xFd=function(xCg, x9d)
{
var xc=this.xOd;
if( (this.xsh != xCg) || (this.x2h != x9d) )
{
this.xsh=xCg;
this.x2h=x9d;
var x3b=new xjk();
x3b.xfk(1,xCg);
var xLc=new xjk();
xLc.xfk(0,-x9d);
x3b.xck(xLc);
xc.uniformMatrix4fv(this.x7h, false, x3b.xlk());
this.xZ("s4-1");
this.xgc();
}
}
p1.xnc=function()
{
this.xCf=false;
if(this.xn) return;
var xhi=false;
if(this.xRb)
{
var xyc=this.xDc();
var xbi=this.xqe();
this.xRb.width=xyc;
this.xRb.height=xbi;
if(xyc < 1) xyc=1;
if(xbi < 1) xbi=1;
if(this.xUc)
{
var xc=this.xOd;
this.xmd(this.xac, xyc, xbi);
this.xFd(this.xie, this.xDg);
}
else
{
var x3c=Math.sqrt(xyc*xyc+xbi*xbi);
var focalLength=x3c/(2*Math.tan(0.5*this.xac*Math.PI/180));
this.xRb.style.msPerspective=this.xRb.style.webkitPerspective=this.xRb.style.MozPerspective=focalLength+"px";
xhi=true;
}
}
if(xhi)
{
var xvf=this.xng();
if(this.xfb)
{
for(var i=0; i < xvf; i++)
{
if(this.xfb[i])
{
this.xfb[i].xnc();
}
}
}
}
}
p1.xhb=function()
{
}
p1.xKg=function()
{
for(var i=0; i < this.xih.length; i++)
{
this.log(this.xih[i]);
}
this.xih.length=0;
}
p1.log=function(xyf)
{
if(this.xRb)
{
if(!this.xrf)
{
var area=document.createElement("textArea");
area.style.position="absolute";
area.style.width="50%";
area.style.height="50%";
area.style.top="0px";
area.style.left="0px";
area.style.zindex="1000";
this.xPc.appendChild(area);
this.xrf=area;
}
this.xrf.value += xyf+"\n";
this.xrf.scrollTop=this.xrf.scrollHeight;
}
else
{
this.xih.push(xyf);
}
}
p1.xug=function(xyf)
{
this.log(xyf);
}
p1.x0g=function(xTg)
{
this.log(xTg.message);
}
p1.xng=function()
{
return 14;
}
p1.xoh=function(xIc)
{
var xze, xKb, xif;
xif=68;
if(xIc < 6)
{
xKb=30;
xze=xIc*60;
}
else if(xIc < 12)
{
xKb=-30;
xze=(xIc-6)*60;
}
else if(xIc == 12)
{
xKb=90;
xze=0;
}
else
{
xKb=-90;
xze=0;
}
return new Array(xze,xKb,xif);
}
p1.xjb=function(xIc)
{
var xab;
var xPe=".jpg";
var xvc;
if(xIc < 10)
{
xvc="0"+xIc;
}
else
{
xvc=""+xIc;
}
var xwh=this.xXb+xvc+xPe;
return xwh;
}
p1.xId=function()
{
if(!this.xfb)
{
this.xfb=new Array();
var xvf=this.xng();
for(var i=0; i < xvf; i++)
{
var xwh=this.xjb(i+1);
var xSf=this.xoh(i);
var xVh=xSf[0];
var xci=xSf[1];
var xV=xSf[2];
var xIh=0;
if(nhPanoramaViewer.isIOS())
{
xIh=this.xGf;
}
var xWg=new xEj(this, xwh, xVh, xci, xV, i, xIh);
this.xfb[i]=xWg;
}
}
}
p1.xXd=function()
{
return this.xie;
}
p1.xob=function()
{
return this.xDg;
}
p1.xBh=function()
{
return this.xRb;
}
p1.x6e=function(xWf)
{
try
{
if(this.xUc)
{
this.xgc();
}
this.xdg--;
this.x8e++;
this.xZe();
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xZe=function()
{
if(this.x1g && this.xfb)
{
var xvf=this.xng();
while(true)
{
if(this.xdg >= this.xlg) break;
var xDh=xvf-this.xdg-this.x8e;
if(xDh == 0) break;
var x4h=this.xPf();
if(!x4h) break;
}
}
}
p1.xPf=function()
{
var x4h=false;
if(this.x1g && this.xfb)
{
var x8h=this.xie;
var xKc=this.xDg;
var xvf=this.xng();
var xAd=-1;
var xef;
for(var i=0; i < xvf; i++)
{
var xWg=this.xfb[i];
var xAh=xWg.xui();
if(xAh == xWg.lsNotLoaded)
{
var xdd=this.xig(x8h, xKc, xWg.xOj(), xWg.xDi());
if( (xAd == -1) || (xdd < xef) )
{
xAd=i;
xef=xdd;
}
}
}
if(xAd >= 0)
{
this.xdg++;
this.xfb[xAd].xgj();
x4h=true;
}
}
return x4h;
}
p1.xVb=function()
{
var xeb=this.xjb(0);
this.xTc.src=xeb;
}
p1.xS=function()
{
return window.document.location.toString();
}
p1.xKh=function(xwh, xg)
{
var xud;
if(xwh.search(new RegExp(":\\/\\/")) >= 0)
{
xud=xwh;
}
else
{
if(xwh.search(new RegExp("\\/")) == 0)
{
var xtb=xg.match(new RegExp("^[^\\/]*:\\/\\/[^\\/]*\\/"));
var xic=xg;
if(xtb.length > 0)
{
xic=xtb[0];
}
xic=xic.replace(/\/$/,"");
xud=xic+xwh;
}
else
{
var xgb=xg.replace(/\/[^\/]*$/,"/");
xud=xgb+xwh;
}
}
return xud;
}
p1.xN=function(event)
{
var xeb=this.xjb(0);
this.xug("Failed to load image: "+xeb);
return true;
}
p1.x0c=function(event)
{
try
{
this.x1g=true;
if(this.xsf)
{
this.xyd();
}
if(this.xUc)
{
this.xbc();
}
this.xZe();
}
catch (xpb)
{
this.x0g(xpb);
}
return true;
}
p1.xbc=function()
{
var x8i=this.xTc.width;
var xte=this.xPh(this.xTc);
var xjg=x8i/4;
var xvf=this.xng();
for(var xVe=0; xVe < xvf; xVe++)
{
var xUb=new Array((xVe%4)*xjg,Math.floor(xVe/4)*xjg,xjg,xjg);
this.xfb[xVe].xzi(xte, x8i, xUb);
}
this.xgc();
}
p1.xyd=function()
{
var xeb=this.xjb(0);
var x8i=this.xTc.width;
var xjg=x8i/4;
var xvf=this.xng();
for(var xVe=0; xVe < xvf; xVe++)
{
var xUb=new Array((xVe%4)*xjg,Math.floor(xVe/4)*xjg,xjg,xjg);
this.xfb[xVe].xwi(this.xTc, xUb);
}
}
p1.xig=function(xJh, xMc,xtg, xqb)
{
var xmf=xMc*Math.PI/180.0;
var xpf=xqb*Math.PI/180.0;
var x2c=xJh*Math.PI/180.0;
var xYd=xtg*Math.PI/180.0;
var xud=Math.acos(Math.sin(xmf)*Math.sin(xpf)+Math.cos(xmf)*Math.cos(xpf)*Math.cos(x2c-xYd)) * 180.0/Math.PI;
return xud;
}
p1.x6c=function()
{
}
p1.xcb=function()
{
return this.xcd;
}
p1.xue=function(xh, x9g)
{
}
p1.xyg=function(event)
{
try
{
var xgf=this.xcb();
this.xUh(!xgf);
}
catch (xpb)
{
this.x0g(xpb);
}
}
p1.xve=function()
{
return this.xxf;
}
p1.xAc=function()
{
var x6h=this.xve();
if(!("pano"in x6h))
{
throw new Error("No panorama file is given. Include a 'pano' variable.");
}
this.xXb=x6h["pano"];
if(!("format"in x6h))
{
throw new Error("The 'format' parameter is missing. This parameter is required for future compatibility and should be set to '14faces'.");
}
var x8b=x6h["format"];
if(x8b !="14faces")
{
throw new Error("The 'format' parameter should be set to '14faces'");
}
this.xG=this.x4("maxfov",this.xG,1,179);
this.x2g=this.x4("minfov",this.x2g,1,179);
if(this.x2g > this.xG)
{
this.log("Warning: parameter 'minfov' cannot be greater than 'maxfov'");
this.x2g=this.xG;
}
this.xme=this.x4("fov",this.xme,1,179);
if(this.xme < this.x2g) this.xme=this.x2g;
if(this.xme > this.xG) this.xme=this.xG;
this.xZc=this.x4("maxpan",this.xZc,-180,180);
this.x3h=this.x4("minpan",this.x3h,-180,180);
if(this.x3h > this.xZc)
{
this.log("Warning: parameter 'minpan' cannot be greater than 'maxpan'");
this.x3h=this.xZc;
}
this.xnd=this.x4("pan",this.xnd,-180,180);
if(this.xnd < this.x3h) this.xnd=this.x3h;
if(this.xnd > this.xZc) this.xnd=this.xZc;
this.xMd=this.x4("maxtilt",this.xMd,-90,90);
this.x3d=this.x4("mintilt",this.x3d,-90,90);
if(this.x3d > this.xMd)
{
this.log("Warning: parameter 'mintilt' cannot be greater than 'maxtilt'");
this.x3d=this.xMd;
}
this.xBg=this.x4("tilt",this.xBg,-90,90);
if(this.xBg < this.x3d) this.xBg=this.x3d;
if(this.xBg > this.xMd) this.xBg=this.xMd;
this.xmg=this.x4("autorotatespeed",this.xmg,-1000,1000);
this.xsg=this.x4("autorotatedelay",this.xsg,0,1000);
this.xne=this.xJf("autorotatetohorizon",true);
this.xGf=this.x4("maxiosdimension",this.xGf,0,10000);
this.xrc=this.xJf("showfullscreenbutton_html",true);
if(nhPanoramaViewer.isMac())
{
this.x6g=this.xJf("enablemactouchpad",true);
}
else
{
this.x6g=false;
}
this.xFe=this.xJf("enablegyroscope",true);
if("licensekey"in x6h)
{
this.xwd=x6h["licensekey"];
}
if("flashcontextmenutext"in x6h)
{
this.xad=x6h["flashcontextmenutext"];
}
if("flashcontextmenuurl"in x6h)
{
this.xJd=x6h["flashcontextmenuurl"];
}
if("rightclickhtml"in x6h)
{
this.xR=x6h["rightclickhtml"];
}
}
p1.xJf=function(xSb, xNf)
{
var xud=xNf;
var x6h=this.xve();
if(xSb in x6h)
{
xud=true;
if( (x6h[xSb] === 0)
|| (x6h[xSb] === false)
|| (x6h[xSb] === null)
|| (x6h[xSb] ==="")
|| (x6h[xSb] ==="null")
|| (x6h[xSb] ==="0")
|| (x6h[xSb] ==="false") )
{
xud=false;
}
}
else
{
}
return xud;
}
p1.x4=function(xSb, xNf, xzf, xkh)
{
var x6h=this.xve();
var xud=xNf;
if(xSb in x6h)
{
var xib=x6h[xSb];
xud=xib-0.0;
if(xud < xzf)
{
this.log("Warning: parameter '"+xSb+"' should be at least "+xzf);
xud=xzf;
}
if(xud > xkh)
{
this.log("Warning: parameter '"+xSb+"' should not be greater than "+xkh);
xud=xkh;
}
}
return xud;
}
p1.xYc=function()
{
var xpc=179;
if( (this.xMd < 90) || (this.x3d > -90) )
{
xpc=this.xMd-this.x3d;
if(xpc < 1) xpc=179;
}
var xSh=179;
if( (this.xZc < 90) || (this.x3h > -90) )
{
xSh=this.xZc-this.x3h;
if(xSh < 1) xSh=179;
if(xSh > 179) xSh=179;
}
var x2d=this.xOb();
var xQh=1.0;
var xHf=Math.sqrt(1.0/(x2d*x2d+1.0));
var xec=x2d*xHf;
var xCd=this.xAb(xSh,xec,xQh);
var xvg=this.xAb(xpc,xHf,xQh);
var x3g=this.xG;
if(x3g > xCd) x3g=xCd;
if(x3g > xvg) x3g=xvg;
if(x3g < this.x2g) x3g=this.x2g;
return x3g;
}
p1.xdf=function(xMh)
{
var x2d=this.xOb();
var xQh=1.0;
var xHf=Math.sqrt(1.0/(x2d*x2d+1.0));
var xec=x2d*xHf;
var xQf=this.xAb(xMh,1.0,xHf);
var xNh=this.xAb(xMh,1.0,xec);
var xle=this.xMd;
if(this.xMd < 90)
{
xle=this.xMd-0.5*xQf;
}
var xhc=this.x3d;
if(this.x3d > -90)
{
xhc=this.x3d+0.5*xQf;
}
if(xhc > xle)
{
xhc=0.5*(xhc+xle);
xle=xhc;
}
return new Array(xhc, xle);
}
p1.xCe=function(xMh, x9d)
{
var x2d=this.xOb();
var xQh=1.0;
var xHf=Math.sqrt(1.0/(x2d*x2d+1.0));
var xec=x2d*xHf;
var xQf=this.xAb(xMh,1.0,xHf);
var xNh=this.xAb(xMh,1.0,xec);
var xHb=x9d+0.5*xQf;
var x9=x9d-0.5*xQf;
var xAf;
if( (xHb >= 90) || (x9 <= -90) )
{
xAf=90;
}
else
{
if(xHb > (-x9))
{
xAf=xHb;
}
else
{
xAf=-x9;
}
}
var xU=Math.cos(xAf*Math.PI/180.0);
if(xU < 1e-4) xU=1e-4;
var x1b=xNh/xU;
var xMf=this.x3h;
var xdh=this.xZc;
if( (this.x3h > -180.0) || (this.xZc < 180.0) )
{
xMf=this.x3h+0.5*x1b;
xdh=this.xZc-0.5*x1b;
}
if(xMf > xdh)
{
xMf=0.5*(xMf+xdh);
xdh=xMf;
}
return new Array(xMf, xdh);
}
p1.xOb=function()
{
var x2d=1;
if( (this.width > 0) && (this.height > 0) )
{
x2d=this.width/this.height;
}
return x2d;
}
p1.xAb=function(xHd, xqf, x0e)
{
return 2.0*180.0/Math.PI*Math.atan(x0e/xqf*Math.tan(0.5*xHd*Math.PI/180.0));
}
p1.xmi=function()
{
return new Date().getTime();
}
p1.xDc=function()
{
var xud=0;
if(this.xRb)
{
xud=this.xRb.offsetWidth;
}
return xud;
}
p1.xqe=function()
{
var xud=0;
if(this.xRb)
{
xud=this.xRb.offsetHeight;
}
return xud;
}
p1.x0d=function()
{
var xgf=this.xcb();
this.xUh(!xgf);
}
nhPanoramaViewer.showNavigator=function()
{
var properties=new Array("appCodeName","appName","appVersion","buildID","oscpu","platform","product","productSub",
"userAgent","vendor","vendorSub");
var xq;
for(var xKf in properties)
{
var property=properties[xKf];
xq += property+": "+window.navigator[property]+"\n";
}
alert(xq);
}
nhPanoramaViewer.isWebKit=function()
{
return !!(window.navigator.userAgent.match(/ applewebkit\/.*/i));
}
nhPanoramaViewer.isIOS=function()
{
if(!nhPanoramaViewer.isWebKit()) return false;
return !!(window.navigator.userAgent.match(/ mobile\/.*/i));
}
nhPanoramaViewer.isIPad=function()
{
if(!nhPanoramaViewer.isIOS()) return false;
return !!(window.navigator.userAgent.match(/ipad\;/i));
}
nhPanoramaViewer.isChrome=function()
{
if(!nhPanoramaViewer.isWebKit()) return false;
return !!(window.navigator.userAgent.match(/ chrome\/.*/i));
}
nhPanoramaViewer.isFirefox=function()
{
return !!(window.navigator.userAgent.match(/ firefox\/.*/i));
}
nhPanoramaViewer.getChromeVersion=function()
{
var xtb=window.navigator.userAgent.match(/ Chrome\/([0-9]+)\.([0-9]+)\./);
var version=[0,0];
if(xtb !== null)
{
version=xtb.slice(1,3).map(function(xGl){
return xGl-0;
});
}
return version;
}
nhPanoramaViewer.isAndroid=function()
{
var xud=false;
if(window.navigator.userAgent.match(/ android /i)) xud=true;
if(window.navigator.userAgent.match(/\(android;/i)) xud=true;
return xud;
}
nhPanoramaViewer.isMac=function()
{
return !!(window.navigator.platform.match(/^mac/i));
}
p1.xBd=function(event)
{
var touch=event.touches[0];
event.preventDefault();
if(event.touches.length == 1)
{
this.xLd(event.touches[0].clientX, event.touches[0].clientY);
}
else
{
if(this.xid != this.xxh)
{
this.xsc();
}
if(event.touches.length == 2)
{
var xub=this.xki(event);
this.xai=xub[0];
this.xIb=xub[1];
this.xIg=xub[2];
this.xWh=window.pageXOffset;
this.xNd=window.pageYOffset;
this.xid=this.xgg;
this.x8g=this.xac;
}
else
{
this.xid=this.xxh;
}
}
}
p1.xDe=function(event)
{
event.preventDefault();
if( (this.xid == this.xSc) || (this.xid == this.xZf))
{
this.xe(event.touches[0].clientX, event.touches[0].clientY);
}
else if(this.xid == this.xgg)
{
var xTb=this.x2g;
var x9c=this.xYc();
var xub=this.xki(event);
var x9h=xub[0];
var xUd=xub[1];
var x8c=xub[2];
var xLf;
if(x9h < 1)
{
xLf=100000;
}
else
{
xLf=this.xai / x9h;
}
var xlf=Math.tan(0.5*this.x8g*Math.PI/180.0);
xlf *= xLf;
var xxc=2.0*Math.atan(xlf)*180.0/Math.PI;
if(xxc < xTb) xxc=xTb;
if(xxc > x9c) xxc=x9c;
if(this.xac != xxc)
{
this.xac=xxc;
this.xoc=0;
this.xO();
}
if(!this.xcb())
{
var xA=this.xIb+this.xWh-xUd;
var x3=this.xIg+this.xNd-x8c;
window.scroll(xA, x3);
}
}
}
p1.xvd=function(event)
{
event.preventDefault();
if( (this.xid == this.xSc) || (this.xid == this.xZf))
{
this.xsc();
}
else if(this.xid == this.xgg)
{
this.xid=this.xxh;
}
}
p1.xki=function(event)
{
var xZc=event.touches[0].clientX;
var xFb=event.touches[0].clientY;
var xse=event.touches[1].clientX;
var xhf=event.touches[1].clientY;
var xli=xse-xZc;
var xbf=xhf-xFb;
var xdd=Math.sqrt(xli*xli+xbf*xbf);
var xT=(xZc+xse)/2;
var xRf=(xFb+xhf)/2;
return new Array(xdd, xT, xRf);
}
p1.xBc=function()
{
var xld=document.getElementsByTagName("meta");
for(var i=0; i < xld.length; i++)
{
var xuh=xld[i];
if(xuh.name ==="viewport") return xuh;
}
return null;

}
p1.xCh=function()
{
var xud="";
var xuh=this.xBc();
if(xuh)
{
xud=xuh.getAttribute("content");
}
return xud;
}
p1.x6f=function(content)
{
var xuh=this.xBc();
if(!xuh)
{
xuh=document.createElement("meta");
xuh.setAttribute("name","viewport");
document.head.appendChild(xuh);
}
xuh.setAttribute("content",content);
}
p1.xWe=function()
{
var isfullscreen=(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement);
this.xcd=isfullscreen;
if(isfullscreen) this.m_TrueFullScreen=true;
this.xWd();
}
p1.x0h=function(xgf)
{
if(this.xcd != xgf)
{
var done=false;
if(xgf)
{
if(document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled)
{
var xYh = this.xPc;
if (xYh.requestFullscreen) {
xYh.requestFullscreen();
done=true;
}else if (xYh.mozRequestFullScreen) {
xYh.mozRequestFullScreen();
done=true;
}else if (xYh.webkitRequestFullscreen) {
xYh.webkitRequestFullscreen();
done=true;
}
}
}
else
{
if(this.m_TrueFullScreen)
{
if (document.cancelFullScreen) {
document.cancelFullScreen();
}else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
done=true;
}
}
if(done)
{
this.xO();
}
else
{
this.m_TrueFullScreen=false;
var xwc=this;
if(nhPanoramaViewer.isIOS())
{
xwc.xn=true;
xwc.x1c(xwc.xmh, xwc.xRb);
xwc.xmh.style.visibility="visible";
setTimeout(function(){
xwc.xn=false;
xwc.xNb(xgf);
xwc.xmh.style.visibility="hidden";
},100);
}
else
{
xwc.xNb(xgf);
}
}
}
}
p1.xNb=function(xgf)
{
if(this.xcd != xgf)
{
if(xgf)
{
this.xt=document.body;
this.xrh=document.documentElement.style.cssText;
var xwc=this;
var xdi=document.createElement("body");
xdi.appendChild(xwc.xPc);
xdi.style.margin="0px";
xdi.style.padding="0px";
xdi.style.width="100%";
xdi.style.height="100%";
document.body=xdi;
document.documentElement.style.cssText="width:100%;height:100%";
window.scroll(100000,0);
xwc.xPc.style.visibility="hidden";
setTimeout(function(){
xwc.xPc.style.visibility="visible";
},1);
xwc.xnc();
}
else
{
document.body=this.xt;
document.documentElement.style.cssText=this.xrh;
this.xfh.appendChild(this.xPc);
this.xnc();
}
this.xcd=xgf;
this.xWd();
}
}

p1.xlc=function(xyf)
{
var xud="";
for(var i=0; i < xyf.length; i++)
{
var x8j=xyf.charCodeAt(i);
if( (x8j >= 48) && (x8j < 128) )
{
x8j=((x8j-48))^0x46+48;
}
xud += String.fromCharCode(x8j);
}
return xud;
}
nhPanoramaViewer.isSupported=function()
{
if(!document.addEventListener) return false;
if(nhPanoramaViewer.has3dCss()) return true;
if(nhPanoramaViewer.hasWebGL()) return true;
return false;
}
nhPanoramaViewer.has3dCss=function()
{
var xRg=document.createElement("div");
if(!xRg) return false;
if(typeof xRg.style.webkitPerspective =="string") {}
else if(typeof xRg.style.MozPerspective =="string") {}
else return false;
if(nhPanoramaViewer.isChrome())
{
var chromeversion=nhPanoramaViewer.getChromeVersion();
if(chromeversion[0]-0 < 22) return false;
}
if(window.navigator.userAgent.match(/ firefox\/.*/i))
{
if(window.navigator.userAgent.match(/[^xWj-zA-Z]linux[^xWj-zA-Z]/i))
{
return false;
}
}
return true;
}
nhPanoramaViewer.hasWebGL=function()
{
var xc=null;
var xBf=document.createElement("canvas");
try
{
xc = xBf.getContext("webgl");
}
catch(xfe) {}
if(!xc)
{
try
{
xc = xBf.getContext("experimental-webgl");
}
catch(xfe) {}
}
return (xc != null);
}
p1.xRh=function(xtf)
{
var xc;
try
{
xc = xtf.getContext("webgl");
}
catch(xfe) {}
if(!xc)
{
try
{
xc = xtf.getContext("experimental-webgl");
}
catch(xfe) {}
}
if(!xc)
{
throw new Error("Could not initialize WebGL");
}
this.xOd=xc;
xc.clearColor(0.0, 0.0, 0.0, 1.0);
xc.clearDepth(1.0)
xc.enable(xc.DEPTH_TEST);
xc.depthFunc(xc.LEQUAL);
this.xZ("s1-1");
var xKe="attribute vec3 vertexPosition;attribute vec2 vTexCoord;uniform mat4 modelViewMatrix,perspectiveMatrix;varying vec2 v_texCoord;void main(){gl_Position = perspectiveMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);v_texCoord = vTexCoord;}";
var x7e="uniform sampler2D sampler2d; varying mediump vec2 v_texCoord;void main(void){gl_FragColor = texture2D(sampler2d, v_texCoord);}";
this.xL=this.xAg(xKe,x7e);
this.x0b=new xjk();
this.xff=new xjk();
this.x7h=xc.getUniformLocation(this.xL,"modelViewMatrix");
this.xZ("s1-2");
this.xnf=xc.getUniformLocation(this.xL,"perspectiveMatrix");
this.xZ("s1-3");
this.xgi = xc.getAttribLocation(this.xL,"vertexPosition");
this.xZ("s1-4");
xc.enableVertexAttribArray(this.xgi);
this.xZ("s1-5");
this.x7f = xc.getAttribLocation(this.xL,"vTexCoord");
this.xZ("s1-6");
xc.enableVertexAttribArray(this.x7f);
this.xZ("s1-7");
var loc=xc.getUniformLocation(this.xL,"sampler2d");
this.xZ("s1-10");
xc.uniform1i(loc, 0);
this.xZ("s1-11");
}
p1.xZ=function(xZd)
{
var xTg=this.xOd.getError();
if(xTg != this.xOd.NO_ERROR)
{
throw new Error("webGL error: "+xZd+": "+xTg);
}
}
p1.xuf=function(xfd, xof)
{
var xc=this.xOd;
var xxd=xc.createShader(xfd);
this.xZ("s2-1");
xc.shaderSource(xxd, xof);
this.xZ("s2-2");
xc.compileShader(xxd);
this.xZ("s2-3");
if(!xc.getShaderParameter(xxd, xc.COMPILE_STATUS))
{
var xLg=xc.getShaderInfoLog(xxd);
xc.deleteShader(xxd);
throw new Error("Couldn't compile shader:\n"+xLg);
}
return xxd;
}
p1.xAg=function(xRd, x7e)
{
var xc=this.xOd;
var xae=null;
var xoi=null;
var xqh=null;
try
{
xoi=this.xuf(xc.VERTEX_SHADER, xRd);
xqh=this.xuf(xc.FRAGMENT_SHADER, x7e);
var xae = xc.createProgram();
this.xZ("s3-1");
xc.attachShader(xae, xoi);
this.xZ("s3-2");
xc.attachShader(xae, xqh);
this.xZ("s3-3");
xc.linkProgram(xae);
this.xZ("s3-4");
if(!xc.getProgramParameter(xae, xc.LINK_STATUS))
{
var xLg=xc.getProgramInfoLog(xae);
throw new Error("Couldn't link program:\n"+xLg);
}
xc.useProgram(xae);
this.xZ("s3-5");
}
catch(xfe)
{
try
{
if(xoi) xc.deleteShader(xoi);
if(xqh) xc.deleteShader(xqh);
if(xae) xc.deleteProgram(xae);
}catch(x7m) {}
throw xfe;
}
return xae;
}
p1.xGg=function()
{
if(this.xGb)
{
this.xGb=false;
var xc=this.xOd;
xc.clear(xc.COLOR_BUFFER_BIT | xc.DEPTH_BUFFER_BIT);
var xvf=this.xng();
if(this.xfb)
{
for(var i=0; i < xvf; i++)
{
var xWg=this.xfb[i];
if(xWg)
{
var xcg=xWg.xQi();
if(xcg)
{
xc.bindTexture(xc.TEXTURE_2D, xcg[0]);
xc.bindBuffer(xc.ARRAY_BUFFER, xcg[1]);
xc.vertexAttribPointer(this.xgi, 3.0, xc.FLOAT, false, 0, 0);
xc.bindBuffer(xc.ARRAY_BUFFER, xcg[2]);
xc.vertexAttribPointer(this.x7f, 2.0, xc.FLOAT, false, 0, 0);
xc.drawArrays(xc.TRIANGLE_STRIP, 0, 4);
}
}
}
}
xc.flush();
this.xZ("s5-6");
xc.finish();
this.xZ("s5-7");
}
}
p1.xnh=function(xXe)
{
var xc=this.xOd;
var xre = xc.createBuffer();
this.xZ("s5-1");
xc.bindBuffer(xc.ARRAY_BUFFER, xre);
this.xZ("s5-2");
xc.bufferData(xc.ARRAY_BUFFER, new Float32Array(xXe), xc.STATIC_DRAW);
this.xZ("s5-3");
return xre;
}
p1.xPh=function(xBe)
{
var xc=this.xOd;
var xte=xc.createTexture();
this.xZ("s7-1");
xc.bindTexture(xc.TEXTURE_2D, xte);
this.xZ("s7-2");
xc.pixelStorei(xc.UNPACK_FLIP_Y_WEBGL, true);
xc.texParameteri(xc.TEXTURE_2D, xc.TEXTURE_MIN_FILTER, xc.LINEAR);
xc.texParameteri(xc.TEXTURE_2D, xc.TEXTURE_MAG_FILTER, xc.LINEAR);
xc.texParameteri(xc.TEXTURE_2D, xc.TEXTURE_WRAP_S, xc.CLAMP_TO_EDGE);
xc.texParameteri(xc.TEXTURE_2D, xc.TEXTURE_WRAP_T, xc.CLAMP_TO_EDGE);
this.xZ("s7-3");
try
{
xc.texImage2D(xc.TEXTURE_2D, 0, xc.RGBA, xc.RGBA, xc.UNSIGNED_BYTE, xBe);
}
catch(xfe)
{
if( (xfe.name =="SecurityError")
&& (nhPanoramaViewer.isChrome())
&& window.location.href.match(/^file\:\/\/.*/)
&& xBe.src.match(/^file\:\/\/.*/) )
{
throw new Error("Failed to load panorama. Due to security restrictions in Chrome the panorama viewer cannot access images stored locally on your computer."
+" To resolve the problem, upload the panorama to a web server and access it over the web. Or launch Chrome with the --allow-file-access-from-files flag"
+" (google for more information) to disable this security restriction.\n\n"
+"Note that this error will not appear when the panorama is viewed on the web."
+"\n\nDetails: "+xfe.message
);
}
else
{
throw xfe;
}
}
this.xZ("s7-4");
return xte;
}
nhPanoramaViewer.requestAnimationFrameFunc=null;
nhPanoramaViewer.requestAnimationFrame=function(callback, element)
{
if(!nhPanoramaViewer.requestAnimationFrameFunc)
{
var xtc = [
"mozRequestAnimationFrame",
"oRequestAnimationFrame",
"requestAnimationFrame",
"webkitRequestAnimationFrame",
"msRequestAnimationFrame"
];
for (var i = 0; i < xtc.length; ++i)
{
if(window[xtc[i]])
{
var thefunc=window[xtc[i]];
nhPanoramaViewer.requestAnimationFrameFunc=function(callback,element) {
thefunc.call(window, callback, element);
};
break;
}
}
if(!nhPanoramaViewer.requestAnimationFrameFunc)
{
nhPanoramaViewer.requestAnimationFrameFunc=function(callback,element) {
window.setTimeout(callback,16.67);
};
}
}
nhPanoramaViewer.requestAnimationFrameFunc(callback,element);
}


p1.xoe=function(xfe)
{
var xzb=this.xmi() / 1000.0;
var deltanow=0.01;
if(this.m_PrevDeviceMotionTime)
{
deltanow=xzb-this.m_PrevDeviceMotionTime;
}
this.m_PrevDeviceMotionTime=xzb;
if(xfe.rotationRate && xfe.accelerationIncludingGravity)
{
var xwf=xfe.rotationRate;
var xah=xfe.accelerationIncludingGravity;
var interval=deltanow;
if( (!isNaN(xah.x)) && (!isNaN(xah.y)) && (!isNaN(xah.z))
&& (!isNaN(xwf.alpha)) && (!isNaN(xwf.beta)) && (!isNaN(xwf.gamma))
&& (!isNaN(interval)) )
{
if(this.xwb == 0)
{
this.xwb=xzb+1.0;
}
if(xzb >= this.xwb)
{
var xi=[xah.x, xah.y, xah.z];
if(this.m_gravityReversed)
{
xi[0]=-xi[0];
xi[1]=-xi[1];
xi[2]=-xi[2];
}
if(this.xWb != null)
{
var xrg=this.x5h;
xrg=Math.pow(xrg,interval);
var xch=1.0-xrg;
xi[0]=xch*xi[0]+xrg*this.xWb[0];
xi[1]=xch*xi[1]+xrg*this.xWb[1];
xi[2]=xch*xi[2]+xrg*this.xWb[2];
}
this.xWb=xi;
var x5d=Math.sqrt(xi[0]*xi[0]+xi[1]*xi[1]+xi[2]*xi[2]);
if(x5d > 0)
{
var xbe=1.0/x5d;
xi[0] *= xbe;
xi[1] *= xbe;
xi[2] *= xbe;
}
this.xDb=xi;

var xKb=Math.asin(xi[2]);
var xEb=0;
if( (xi[0] != 0) || (xi[1] != 0) )
{
xEb=Math.atan2(xi[0],-xi[1]);
}
xEb *= 180.0/Math.PI;
xKb *= 180.0/Math.PI;
if(this.xid == this.xxh)
{
if(this.xbg == this.xrb)
{
var xMe=xi[0]-this.x2e[0];
var xVd=xi[1]-this.x2e[1];
var xgh=xi[2]-this.x2e[2];
var xHc=xMe*xMe+xVd*xVd+xgh*xgh;
if(xHc > 0.1)
{
this.x9e(xKb);
}
}
else if(this.xbg == this.xYf)
{
if(xKb > -60)
{
this.x9e(xKb);
}
}
}
if(this.xbg == this.xu)
{
if( (Math.abs(xwf.alpha) > 20)
|| (Math.abs(xwf.beta) > 20)
|| (Math.abs(xwf.gamma) > 20) )
{
this.xp();
}
}
var xxe=xwf.alpha;
var xLh=xwf.beta;
var xw=xwf.gamma;
xxe *= interval;
xLh *= interval;
xw *= interval;
if(this.m_rotationRateRadians)
{
xxe *= 180.0/Math.PI;
xLh *= 180.0/Math.PI;
xw *= 180.0/Math.PI;
}
var xd=new xjk();
var xTf=new xjk();
xTf.xfk(2,xw);
xd.xck(xTf);
xTf.xfk(1,xLh);
xd.xck(xTf);
xTf.xfk(0,xxe);
xd.xck(xTf);
var xBb=new xjk();
xTf.xfk(2,-xEb);
xBb.xck(xTf);
xTf.xfk(0,xKb);
xBb.xck(xTf);
var xRe=new xjk(xBb);
xRe.x5j();
var xNg=new xjk();
xNg.xck(xRe);
xNg.xck(xd);
xNg.xck(xBb);
var xOg=xNg.x6j([1,0,0]);
var x4c=Math.atan2(xOg[2],xOg[0]);
x4c *= 180.0/Math.PI;
var xAe=this.xie;
if(this.xTd == 0)
{
xAe += x4c;
}
var xPg;
if( (this.xid == this.xxh)
&& (this.xbg == this.xu)
)
{
var xbh=interval*180;
if(this.xHg > 0)
{
this.xHg -= xbh;
if(this.xHg < 0) this.xHg=0;
}
else if(this.xHg < 0)
{
this.xHg += xbh;
if(this.xHg > 0) this.xHg=0;
}
xPg=xKb+this.xHg;
if(xPg < -90) xPg=-90;
if(xPg > 90) xPg=90;
}
else
{
xPg=this.xDg;
}
if( (!isNaN(xAe)) && (!isNaN(xPg)))
{
this.xSe(xAe,xPg,this.xac);
}
}
}
}
}
p1.xs=function(xfe)
{
this.log("Error: WebGL context lost");
}
p1.xTe=function(xfe)
{
this.log("WebGL context restored");
}
p1.xrd=function()
{
return (this.xbg == this.xu);
}
p1.xk=function()
{
if(this.xbg != this.xYf)
{
this.x2e=this.xDb;
this.xbg=this.xrb;
}
}
p1.x9e=function(xGe)
{
if(xGe < -60)
{
this.xbg=this.xYf;
}
else
{
this.xbg=this.xu;
this.xHg=this.xDg-xGe;
this.xp();
}
}
p1.xyb=function()
{
var xse="The publisher of this panorama should check the contents of the 'licensekey' field in the parameters for this panorama.";
if(this.xVg < 0)
{
this.xVg=0;
if(this.xwd !="")
{
var xDd=this.x9f(this.xwd);
if(xDd.valid)
{
var xpd=this.xqc();
if(xpd =="")
{
this.log("License key ('licensekey' field) ignored since the panorama is viewed on the local computer.");
}
else
{
var xeg=false;
if(xpd == xDd.host)
{
xeg=true;
}
else
{
var xcf="."+xDd.host;
var x7b=xpd.lastIndexOf(xcf);
if( (x7b >= 0) && (x7b == (xpd.length-xcf.length)) )
{
xeg=true;
}
}
if(xeg)
{
this.xVg=1;
}
else
{
this.log("Invalid license: the license is valid for '"+xDd.host+"' but the panorama is stored on '"+xpd+"'. "+xse);
}
}
}
else
{
this.log("Invalid license key. "+xse);
}
}
}
return (this.xVg > 0);
}
p1.xNc=function(x7g)
{
var valid=false;
var x7b=x7g.lastIndexOf(":");
if(x7b >= 0)
{
var xq=x7g.substr(0,x7b);
var xUf=x7g.substr(x7b+1,x7g.length-x7b-1);
var x4b=new xTk(this.x4f);
var xEf=new xTk(this.xJc);
var xpg=new xtp();
xpg.xPn(x4b, xEf);
valid=xpg.xkp(xq, xUf);
}
return valid;
}
p1.x9f=function(x7g)
{
var xud=new Object();
try
{
xud.valid=this.xNc(x7g);
}
catch(xfe)
{
xud.valid=false;
}
if(xud.valid)
{
var components=x7g.split(":");
if(components.length < 3)
{
xud.valid=false;
}
else
{
xud.host=components[0];
xud.version=components[1];
}
}
return xud;
}
p1.xx8944hjkxx7jk=function(xkf, xOh)
{
xkf=xkf.toLowerCase();
var xq=xkf.toLowerCase()+":1";
var xEf=new xTk(this.xJc);
var xK=new xTk(xOh);
var x4b=new xTk(this.x4f);
var xpg=new xtp();
xpg.xon(xK, xEf);
xpg.xPn(x4b, xEf);
var xUf=xpg.x8o(xq,true);
var x7c=xq+":"+xUf;
var xY=this.x9f(x7c);
if(!xY.valid)
{
xY=this.x9f(x7c);
throw new Error("Check failed");
}
return x7c;
}
p1.xqc=function()
{
var xXf=this.xjb(0);
var xg=this.xS();
xXf=this.xKh(xXf,xg);
var host="";
if(xXf.indexOf("://") >= 0)
{
host=xXf.replace(new RegExp("^.*:\\/\\/"),"");
host=host.replace(new RegExp("\\/.*$"),"");
host=host.replace(new RegExp(":.*$"),"");
}
host=host.toLowerCase();
return host;
}

var p2=xEj.prototype;
p2.lsNotLoaded=0;
p2.xij=1;
p2.xPj=2;
p2.xuj=3;
p2.x1g=false;
p2.xsi=0;
function xEj(xZi, xzj, xze, xKb, xif, xIc, xIh)
{
this.xSj=this.lsNotLoaded;
this.xrj=xZi;
this.xBj=xzj;
this.xUj=xze;
this.xVi=xKb;
this.xQj=xif;
this.xRj=xIc;
this.xbj=xIh;
if(this.xrj.xsf)
{
var xYe=document.createElement("div");
xYe.style.position="absolute";
xYe.style.msBackfaceVisibility=xYe.style.webkitBackfaceVisibility=xYe.style.MozBackfaceVisibility="hidden";
xYe.style.MozTransformStyle="preserve-3d";
xYe.style.top="0px";
xYe.style.left="0px";
var xdj=xZi.xBh();
xdj.appendChild(xYe);
this.xRb=xYe;
}
if(this.xrj.xUc)
{
this.x7i();
}
var xD=document.createElement("img");
xD.style.position="absolute";
xD.style.top="0px";
xD.style.left="0px";
xD.style.visibility="hidden";
this.xvi=xD;
var xwc=this;
if(document.addEventListener)
{
xD.addEventListener("load", function(xfe){return xwc.xCi(xfe? xfe : window.event)}, false);
xD.addEventListener("error", function(xfe){return xwc.xBi(xfe? xfe : window.event)}, false);
}
else if(document.attachEvent)
{
xD.attachEvent("onload", function(xfe){return xwc.xCi(xfe? xfe : window.event)});
xD.attachEvent("onerror", function(xfe){return xwc.xBi(xfe? xfe : window.event)});
}
if(this.xrj.xsf)
{
this.xRb.appendChild(this.xvi);
var x3i=document.createElement("canvas");
x3i.style.position="absolute";
x3i.style.top="0px";
x3i.style.left="0px";
x3i.style.visibility="hidden";
xYe.appendChild(x3i);
this.xLj=x3i;
}
this.xlj();
}
p2.x7i=function()
{
var xdd=10;
var width=xdd*Math.tan(0.5*this.xQj*Math.PI/180);
var xNj=new xjk();
xNj.xfk(0,this.xVi);
var xLc=new xjk();
xLc.xfk(1,-this.xUj);
xNj.xck(xLc);
var xqi=[];
for(var xqj=0; xqj < 4; xqj++)
{
var xJj=[];
xJj[0]=(xqj & 1)? -width : width;
xJj[1]=(xqj & 2)? -width : width;
xJj[2]=-xdd;
xJj=xNj.x6j(xJj);
xqi=xqi.concat(xJj);
}
this.xWi=this.xrj.xnh(xqi);
}
p2.xgj=function()
{
this.xAi();
}
p2.xAi=function()
{
this.xSj=this.xij;
if(this.xsi > 0)
{
var xwc=this;
window.setTimeout(function(){xwc.xvi.src=xwc.xBj}, this.xsi*1000);
}
else
{
this.xvi.src=this.xBj;
}
}
p2.xBi=function(event)
{
this.xrj.xug("Failed to load image: "+this.xBj);
this.xSj=this.xuj;
this.xrj.x6e(this);
return true;
}
p2.xCi=function(event)
{
this.xSj=this.xPj;
if(this.xvi.width != this.xvi.height)
{
this.xrj.xug("Image "+this.xBj+" should be square");
}
var xpj=this.xvi.width;
if(this.xbj && (this.xvi.width > this.xbj))
{
this.xvi.width=this.xbj;
this.xvi.height=this.xbj;
var xwc=this;
}
this.xCj=new Array(this.xvi.width, this.xvi.height);
if(this.xrj.xsf)
{
this.xnc();
this.xLj.style.visibility="hidden";
this.xvi.style.visibility="visible";
this.xRb.style.width=this.xCj[0]+"px";
this.xRb.style.height=this.xCj[1]+"px";
}
else
{
this.xkj=this.xrj.xPh(this.xvi);
this.xsj(0.0, 0.0, 1.0, 1.0);
}
if(nhPanoramaViewer.isIOS())
{
var xwc=this;
setTimeout(function(){
xwc.xrj.x6e(this);
},100);
}
else
{
this.xrj.x6e(this);
}
return true;
}
p2.xlj=function()
{
}
p2.xPi=function(event)
{
try
{
xRi(this.xKj,false);
this.xKj=null;
this.xrj.x6e(this);
}
catch (xpb)
{
this.xrj.xug(xpb.toString());
}
}
p2.xnc=function()
{
if((this.xSj == this.xPj) || this.x1g)
{
this.xIj();
}
}
p2.xIj=function()
{
if(this.xrj.xsf)
{
var xfj=this.xrj.xXd();
var xtj=this.xrj.xob();
var xvj=this.xrj.xDc();
var x2i=this.xrj.xqe();
var x8i=this.xCj[0];
var xKi=this.xCj[1];
var xwj=1000.0*(this.xRj+1);
var ownerstyle=this.xrj.xBh().style;
var xyj=1;
if(typeof ownerstyle.webkitPerspective =="string")
{
xyj=ownerstyle.webkitPerspective;
}
else if(typeof ownerstyle.MozPerspective =="string")
{
xyj=ownerstyle.MozPerspective;
}
else
{
xyj=ownerstyle.msPerspective;
}
xyj=xyj.replace(/\s*px\s*$/,"");
xyj=xyj-0;
var xLi=0.5*xwj/Math.tan(0.5*this.xQj*Math.PI/180);

var xDj="translate3d("+(-(x8i-xvj)/2).toFixed(4)+"px,"+(-(xKi-x2i)/2).toFixed(4)+"px,"+xyj.toFixed(4)+"px)"
+" rotateX("+xtj.toFixed(4)+"deg)"
+" rotateY("+(xfj-this.xUj).toFixed(4)+"deg)"
+" rotateX("+(-this.xVi).toFixed(4)+"deg)"
+" translate3d(0px,0px,"+(-xLi).toFixed(4)+"px)"
+" scale3d("+(xwj/x8i).toFixed(4)+","+(xwj/xKi).toFixed(4)+",1)";
this.xRb.style.msTransform=this.xRb.style.webkitTransform=this.xRb.style.MozTransform=xDj;
}
}
p2.xui=function()
{
return this.xSj;
}
p2.x9i=function()
{
return this.x1g;
}
p2.xOj=function()
{
return this.xUj;
}
p2.xDi=function()
{
return this.xVi;
}
p2.xwi=function(x3i, xUb)
{
this.x1g=true;
if(this.xSj != this.xij) this.xSj=this.lsNotLoaded;
var xjg=xUb[2];
var xri=xUb[3];
var previewimage=this.xLj;
previewimage.width=xjg;
previewimage.height=xri;
var xxi = previewimage.getContext('2d');
xxi.drawImage(x3i, xUb[0], xUb[1], xjg, xri, 0, 0, xjg, xri);
previewimage.style.visibility="visible";
this.xRb.style.width=previewimage.width+"px";
this.xRb.style.height=previewimage.height+"px";
this.xCj=new Array(previewimage.width,previewimage.height);
this.xnc();
}
p2.xzi=function(xHj, x8i, xUb)
{
this.xkj=xHj;
var x4i=xUb[0]/x8i;
var xyi=(xUb[0]+xUb[2])/x8i;
var xoj=1.0-(xUb[1]+xUb[3])/x8i;
var xmj=1.0-xUb[1]/x8i;
this.xsj(x4i, xoj, xyi, xmj);
this.x1g=true;
if(this.xSj != this.xij) this.xSj=this.lsNotLoaded;
}
p2.xsj=function(x4i, xoj, xyi, xmj)
{
this.xTj=this.xrj.xnh([xyi, xmj, x4i, xmj, xyi, xoj, x4i, xoj]);
}
p2.xQi=function()
{
if(this.xkj)
{
return [this.xkj, this.xWi, this.xTj];
}
else
{
return null;
}
}

var p3=xjk.prototype;
p3.x1j=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
function xjk(src)
{
if(src)
{
this.x1j=src.x1j.slice(0);
}
}
p3.xck=function(xhk)
{
var xkk=[];
var x0j=0;
var x4j=0;
var xWj;
var xak;
var xmk;
while(true)
{
xWj=0;
xak=x0j;
xmk=x4j;
while(true)
{
xWj += this.x1j[xak++]*xhk.x1j[xmk];
xmk += 4;
if(xmk >= 16) break;
}
xkk.push(xWj);
x4j++;
if(x4j == 4)
{
x0j += 4;
if(x0j == 16) break;
x4j=0;
}
}
this.x1j=xkk;
return this;
}
p3.xik=function(xMh, x2d, xYj, x7j)
{
var xZh=0.5 * xMh * Math.PI / 180.0;
var xoj=xYj * Math.tan(xZh) / Math.sqrt(1+x2d*x2d);
var xyi=xoj*x2d;
var xdk=1.0/(x7j-xYj);
this.x1j = [
xYj/xyi, 0, 0, 0,
0, xYj/xoj, 0, 0,
0, 0, -(xYj+x7j)*xdk, -1,
0, 0, -2*x7j*xYj*xdk, 0
];
return this;
}
p3.xfk=function(xZj,x2j)
{
var x9j=Math.PI * x2j / 180.0;
var x8j=Math.cos(x9j);
var s=Math.sin(x9j);
if(xZj == 0)
{
this.x1j = [
1, 0, 0, 0,
0, x8j, s, 0,
0, -s, x8j, 0,
0, 0, 0, 1
];
}
else if(xZj == 1)
{
this.x1j = [
x8j, 0, -s, 0,
0, 1, 0, 0,
s, 0, x8j, 0,
0, 0, 0, 1
];
}
else
{
this.x1j = [
x8j, s, 0, 0,
-s, x8j, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
];
}
return this;
}
p3.xlk=function()
{
return new Float32Array(this.x1j);
}
p3.x6j=function(xnk)
{
var xkk=this.x1j;
var x=xkk[0]*xnk[0]+xkk[4]*xnk[1]+xkk[8]*xnk[2]+xkk[12];
var y=xkk[1]*xnk[0]+xkk[5]*xnk[1]+xkk[9]*xnk[2]+xkk[13];
var z=xkk[2]*xnk[0]+xkk[6]*xnk[1]+xkk[10]*xnk[2]+xkk[14];
var xyc=xkk[3]*xnk[0]+xkk[7]*xnk[1]+xkk[11]*xnk[2]+xkk[15];
if(xyc != 1.0)
{
var xgk=1.0/xyc;
x *= xgk;
y *= xgk;
z *= xgk;
}
return [x,y,z];
}
p3.x5j=function()
{
var xkk=this.x1j;
this.x1j=[
xkk[0], xkk[4], xkk[8], xkk[12],
xkk[1], xkk[5], xkk[9], xkk[13],
xkk[2], xkk[6], xkk[10], xkk[14],
xkk[3], xkk[7], xkk[11], xkk[15]
];
return this;
}

var p4=xTk.prototype;

p4.xam="";
p4.xrm=false;
p4.xIm=14;

function xTk(value)
{
this.xNk=Math.floor(Math.pow(10,this.xIm-1)+0.1);
var xpm=typeof value;
if( (xpm =="undefined") || (value === null) )
{
}
else if(xpm =="number")
{
this.xGk(value);
}
else if(xpm =="string")
{
this.xRk(value);
}
else if(xpm =="object")
{
if(value instanceof xTk)
{
this.x3l(value);
}
else
{
var xyk="(unknown)";
if(value && value.constructor && value.constructor.toString)
{
xyk=value.constructor.toString();
}
throw new Error("Invalid type: "+xyk);
}
}
else
{
throw new Error("Invalid type: "+xpm);
}
}
p4.x3l=function(xGl)
{
this.xam=xGl.xam;
this.xrm=xGl.xrm;
}
p4.toString=function()
{
if(this.xrm)
{
return"-"+this.xam;
}
else
{
return this.xam;
}
}
p4.xEk=function()
{
return (this.xam =="");
}
p4.xUm=function(value, xgm)
{
this.xam=this.x5k(value);
if(this.xEk()) xgm=false;
this.xrm=xgm;
}
p4.xRk=function(value)
{
var xgm=false;
if(value.charAt(0) =="-")
{
xgm=true;
value=value.substr(1);
}
if(! value.match(/^[0-9]*$/))
{
throw new Error("Invalid value");
}
value=this.x5k(value);
if(value =="")
{
xgm=false;
}
this.xam=value;
this.xrm=xgm;
}
p4.xlm=function(xfm, xcn, length)
{
var xem=xfm.length-xcn;
if(xem <= 0)
{
return 0;
}
else
{
var xRl=xem-length;
if(xRl < 0) xRl=0;
var substr=xfm.substring(xRl,xem);
substr=substr.replace(/^0+/,"");
if(substr.length == 0) return 0;
return parseInt(substr);
}
}

p4.xtl=function(i, length)
{
var xud=""+i;
xud=this.xsk(length-xud.length)+xud;
return xud;
}
p4.xTl=function(xpl, xXl)
{
xpl=this.x5k(xpl);
xXl=this.x5k(xXl);
if(xpl.length > xXl.length) return 1;
if(xpl.length < xXl.length) return -1;
var xJl=xpl.length;
var xZl, xCl;
for(var i=0; i < xJl; i++)
{
xZl=xpl.charCodeAt(i);
xCl=xXl.charCodeAt(i);
if(xZl > xCl) return 1;
if(xZl < xCl) return -1;
}
return 0;
}
p4.xNm=function(s)
{
var xDk=s.length;
var x6k=0;
var xQl;
while(xDk > 0)
{
xQl=xDk-1;
if(s.charAt(xQl) !="0") break;
x6k++;
xDk--;
}
if(x6k > 0)
{
s=s.substr(0,xDk);
}
return [s,x6k];
}
p4.x5k=function(s)
{
var xHm=0;
while(xHm < s.length)
{
if(s.charAt(xHm) !="0") break;
xHm++;
}
if(xHm > 0)
{
return s.substr(xHm);
}
else
{
return s;
}
}
p4.x4m=function(xSl,xJl)
{
if(xSl.length < xJl)
{
xSl=this.xsk(xJl-xSl.length)+xSl;
}
return xSl;
}
p4.xsk=function(xhm)
{
var s="000000000000000000000000000000000000000000000000000000000";
var xud="";
while(xud.length < xhm)
{
xud += s.substr(0,xhm-xud.length);
}
return xud;
}
p4.xWl=function(xpl)
{
if(xpl < 0.0)
{
throw new Error("Negative");
}
if(xpl < 1.0)
{
return"";
}
var x1k=""+xpl;
if(/^[0-9]+$/.test(x1k))
{
return x1k;
}
else
{
var exp=Math.floor(Math.log(xpl)/Math.log(10))+1;
xpl *= Math.pow(10,-exp);
if(xpl >= 1.0)
{
exp += 1;
xpl *= 0.1;
}
else if(xpl < 0.1)
{
exp -= 1;
xpl *= 10;
}
var xCm=""+xpl;
if(xCm.substr(0,2) !="0.")
{
throw new Error("Internal error");
}
xCm=xCm.substr(2);
if(xCm.length < exp)
{
xCm += this.xsk(exp-xCm.length);
}
else
{
xCm=xCm.substr(0,exp);
}
return xCm;
}
}
p4.xVl=function(s)
{
s=this.x5k(s);
if(s =="")
{
return 0.0;
}
else
{
var xuk=17;
if(s.length > xuk)
{
return parseFloat(s.substr(0,xuk))*Math.pow(10,s.length-xuk);
}
else
{
return parseFloat(s);
}
}
}
p4.xSm=function()
{
var xpl=this.xam;
var xud="";
var xBk=this.xIm-1;
var xMm=this.xNk;
var xVk=Math.floor(1+(xpl.length-1)/xBk);
var xcn=(xVk-1)*xBk;
var xal;
var xDm=0;
for(var xhl=0; xhl < xVk; xhl++)
{
xal=this.xlm(xpl,xcn,xBk);
xal += xDm;
xDm=(xal & 1)? xMm : 0;
xal=Math.floor(0.5*xal);
xud += this.xtl(xal, xBk);
xcn -= xBk;
}
var xQk=new xTk();
if(xDm != 0)
{
xQk.xam="1";
xQk.xrm=this.xrm;
}
this.xam=this.x5k(xud);
return xQk;
}
p4.xDl=function(xqm, xEl)
{
var xOl=17;
var xdl=1e17;
var x9k=0;
var xpl=new xTk(xqm);
var xXl=new xTk(xEl);
if(xpl.xam.length > xOl)
{
x9k += xpl.xam.length-xOl;
xpl.xam=xpl.xam.substr(0,xOl);
}
if(xXl.xam.length > xOl)
{
x9k -= xXl.xam.length-xOl;
xXl.xam=xXl.xam.substr(0,xOl);
}
var xBl=xpl.xkm();
var xcm=xXl.xkm();
var xMk=xBl/xcm;
xMk *= xdl;
x9k -= xOl;
var xum=new xTk(xMk);
if(x9k > 0)
{
xum.xam += this.xsk(x9k);
}
else
{
var xJl=xum.xam.length;
if(xJl <= -x9k)
{
xum.xGk(0);
}
else
{
xum.xam=xum.xam.substr(0,xJl+x9k);
}
}
return xum;
}
p4.xwm=function(xtm)
{
if(xtm.xEk())
{
throw new Error("Divide by zero");
}
if( (xtm.xam =="2") && (xtm.xrm == false) )
{
return this.xSm();
}
var xum=new xTk();
var xQk=new xTk(this);
var xrk;
while(true)
{
if(xQk.xEk())
{
break;
}
xrk=this.xDl(xQk,xtm);
if(xrk.xEk())
{
if(this.xrm != xQk.xrm)
{
if(xQk.xrm == xtm.xrm)
{
xrk.xGk(1);
}
else
{
xrk.xGk(-1);
}
}
else
{
break;
}
}
xum=xum.x6l(xrk);
xQk=xQk.xim(xrk.xjm(xtm));
}
this.x3l(xum);
return xQk;
}
p4.xIk=function(xpl, xXl)
{
xpl=this.x5k(xpl);
xXl=this.x5k(xXl);
var xan=this.xTl(xpl,xXl);
if(xan == 0) return ["",false];
var xgm=false;
if(xan < 0)
{
var xpm=xXl;
xXl=xpl;
xpl=xpm;
xgm=true;
}
var xud="";
var xcg=this.xNm(xXl);
var xbm=xcg[1];
if(xbm > 0)
{
xXl=xcg[0];
var xWk=xpl.length-xbm;
xcg=this.xZk(xpl,xWk);
xud=xcg[1]+xud;
xpl=xcg[0];
}
var xBk=this.xIm-1;
var x1l=this.xNk;
var xAl=xpl.length;
var xFk=xXl.length;
var xcn=0;
var xDm=0;
var xrl, xbl, xsm;
while(xcn < xAl)
{
if( (xcn >= xFk) && (xDm == 0) )
{
xud=xpl.substr(0,xAl-xcn)+xud;
break;
}
xrl=this.xlm(xpl,xcn,xBk);
xbl=this.xlm(xXl,xcn,xBk);
xsm=xrl-xbl+xDm;
if(xsm >= 0)
{
xDm=0;
}
else
{
xDm=-1;
xsm += x1l;
}
xud=this.xtl(xsm, xBk)+xud;
xcn += xBk;
}
return [xud,xgm];
}
p4.x8m=function(s, xBk)
{
var xud=[];
var xHl=s.length;
var xLl;
var xbn;
while(true)
{
if(xHl <= 0) break;
xLl=xHl-xBk;
if(xLl < 0) xLl=0;
xbn=s.substring(xLl,xHl);
xbn=xbn.replace(/^0+/,"");
xud.push(parseInt(xbn));
xHl -= xBk;
}
return xud;
}
p4.xOm=function(xpl, xXl)
{
xpl=this.x5k(xpl);
xXl=this.x5k(xXl);
var x0l=0;
var xcg=this.xNm(xpl);
xpl=xcg[0];
x0l += xcg[1];
xcg=this.xNm(xXl);
xXl=xcg[0];
x0l += xcg[1];
var xud="";
var xBk=Math.floor((this.xIm-3)/2);
if(xBk < 1) xBk=1;
var xCk=Math.floor(1+(xpl.length-1)/xBk);
var xQm=Math.floor(1+(xXl.length-1)/xBk);
var x8k=xCk+xQm-1;
var xdm, xLm, x3m, xul, xKm, xwl, xvl;
var xDm=0;
var x0k;


var xPl=this.x8m(xpl,xBk);
var xZm=this.x8m(xXl,xBk);
for(x0k=0; x0k < x8k; x0k++)
{
xLm=x0k-xQm+1;
if(xLm < 0) xLm=0;
x3m=x0k+1;
if(x3m > xCk) x3m=xCk;
xKm=0;
xul=x0k-xLm;
for(xdm=xLm; xdm < x3m; xdm++)
{
var xnm=xPl[xdm];
var xzk=xZm[xul];
xKm += xnm*xzk;
xul--;
}
xKm += xDm;
xwl=this.xtl(xKm, xBk);
if(xwl.length > xBk)
{
xvl=xwl.length-xBk;
xDm=parseInt(xwl.substr(0, xvl));
xwl=xwl.substr(xvl);
}
else
{
xDm=0;
}
xud=xwl+xud;
}
if(xDm != 0)
{
xud=(""+xDm)+xud;
}
if(x0l != 0)
{
xud += this.xsk(x0l);
}
return xud;
}
p4.xZk=function(s, xWk)
{
var x1m, x8l;
if(xWk < 0)
{
x1m="";
x8l=this.xsk(-xWk)+s;
}
else if(xWk > s.length)
{
x1m=s+this.xsk(xWk-s.length);
x8l="";
}
else
{
x1m=s.substr(0,xWk);
x8l=s.substr(xWk);
}
return [x1m,x8l];
}
p4.xUl=function(xpl, xXl)
{
xpl=this.x5k(xpl);
xXl=this.x5k(xXl);
if(xpl.length < xXl.length)
{
var xNl=xpl;
xpl=xXl;
xXl=xNl;
}
var xud="";
var xcg=this.xNm(xpl);
var xbm=xcg[1];
var xWk;
if(xbm > 0)
{
xpl=xcg[0];
xWk=xXl.length-xbm;
xcg=this.xZk(xXl,xWk);
xud=xcg[1]+xud;
xXl=xcg[0];
}
xcg=this.xNm(xXl);
xbm=xcg[1];
if(xbm > 0)
{
xXl=xcg[0];
xWk=xpl.length-xbm;
xcg=this.xZk(xpl,xWk);
xud=xcg[1]+xud;
xpl=xcg[0];
}
var xBk=this.xIm;
var xAl=xpl.length;
var xFk=xXl.length;
var xcn=0;
var xDm=0;
var xrl, xbl, xwl, xvl;
while(xcn < xAl)
{
if( (xcn >= xFk) && (xDm == 0) )
{
xud=xpl.substr(0,xAl-xcn)+xud;
break;
}
xrl=this.xlm(xpl,xcn,xBk);
xbl=this.xlm(xXl,xcn,xBk);
xwl=this.xtl(xrl+xbl+xDm, xBk);
if(xwl.length > xBk)
{
xvl=xwl.length-xBk;
xDm=parseInt(xwl.substr(0, xvl));
xwl=xwl.substr(xvl);
}
else
{
xDm=0;
}
xud=xwl+xud;
xcn += xBk;
}
if(xDm != 0)
{
xud=(""+xDm)+xud;
}
return xud;
}
p4.xsl=function(xpl, xKl, xXl, xtk)
{
var xPm, xgm;
if(xKl == xtk)
{
xPm=this.xUl(xpl,xXl);
xgm=xKl;
}
else
{
var xud=this.xIk(xpl,xXl);
xPm=xud[0];
xgm=xKl;
if(xud[1])
{
xgm=!xgm;
}
}
return [xPm,xgm];
}
p4.x6l=function(xXl)
{
var xPm=this.xsl(this.xam, this.xrm, xXl.xam, xXl.xrm);
var xud=new xTk();
xud.xUm(xPm[0],xPm[1]);
return xud;
}
p4.xim=function(xXl)
{
var xPm=this.xsl(this.xam, this.xrm, xXl.xam, !xXl.xrm);
var xud=new xTk();
xud.xUm(xPm[0],xPm[1]);
return xud;
}
p4.xxm=function(xXl)
{
if(this.xrm && (!xXl.xrm)) return -1;
if(xXl.xrm && (!this.xrm)) return 1;
var xud=this.xTl(this.xam, xXl.xam);
if(this.xrm) xud=-xud;
return xud;
}
p4.xjm=function(xXl)
{
var xgm=this.xrm;
if(xXl.xrm) xgm=!xgm;
var xFl=this.xOm(this.xam, xXl.xam);
var xud=new xTk();
xud.xUm(xFl,xgm);
return xud;
}
p4.xel=function(xXl)
{
var xum=new xTk(this);
var xQk=xum.xwm(xXl);

return [xum,xQk];
}
p4.xkl=function(xXl)
{
var xud=this.xel(xXl);
return xud[0];
}
p4.x7l=function(xXl)
{
var xud=this.xel(xXl);
return xud[1];
}
p4.xqk=function(xXl)
{
return ((this.xam == xXl.xam) && (this.xrm == xXl.xrm));
}
p4.xGk=function(x7m)
{
this.xrm=(x7m < 0.0);
if(this.xrm)
{
x7m=-x7m;
}
this.xam=this.xWl(x7m);
}
p4.xkm=function()
{
var xud=this.xVl(this.xam);
if( (!this.xEk()) && (this.xrm) )
{
xud=-xud;
}
return xud;
}
p4.xil=function()
{
if(this.xrm)
{
throw new Error("Not supported");
}
var xhm=new xTk(this);
var xcg;
var xud=[];
var xtm=new xTk("4294967296");
while(true)
{
xcg=xhm.xel(xtm);
xhm=xcg[0];
var xml=xhm.xEk();
var x5l=xcg[1].xkm();
for(var i=0; i < 4; i++)
{
if(xml && (x5l == 0)) break;
xud.push(x5l & 0xff);
x5l >>= 8;
}
if(xml) break;
}
xud.reverse();

return xud;
}

p4.xPk=function(xYk)
{
var xXm=3-((xYk.length+3)&3);
var xcg=[];
while(xXm-- > 0)
{
xcg.push(0);
}
xcg=xcg.concat(xYk);
var xud=new xTk();
var xdl=new xTk("4294967296");
for(var xMl=0; xMl < xcg.length; xMl += 4)
{
xud=xud.xjm(xdl);
var x5l=(xcg[xMl]<<24) | (xcg[xMl+1]<<16) | (xcg[xMl+2]<<8) | (xcg[xMl+3]);
if(x5l < 0)
{
x5l += 0x100000000;
}
var x6l=new xTk(x5l);
xud=xud.x6l(x6l);
}
this.x3l(xud);
}
p4.xHk=function(x4l, x6m)
{
if(this.xrm || x4l.xrm || x6m.xrm)
{
throw new Error("Negative");
}
var x9m=new xTk(this);
var xym=new xTk("2");
var xTm=new xTk(x4l);
var xvk;
var xud=new xTk("1");
while(true)
{
xvk=xTm.xwm(xym);
if(!xvk.xEk())
{
xud=xud.xjm(x9m);
xud=xud.x7l(x6m);
}
if(xTm.xEk())
{
break;
}
x9m=x9m.xjm(x9m);
x9m=x9m.x7l(x6m);
}
return xud;
}
p4.xRm=function()
{
return this.xrm;
}

var p5=xBn.prototype;
p5.xin=null;
p5.xIn=null;
p5.xAn=null;
function xBn()
{
}



p5.xtn=function(xpn, xfn)
{
var xMn=new xTk("1");
var xEf=xpn.xjm(xfn);
var xFn=xpn.xim(xMn).xjm(xfn.xim(xMn));
var x4b=new xTk(17);
var xqn=this.xdn(x4b,xFn);
var xQn=xqn[2];
if(!xQn.xqk(xMn))
{
if(!xFn.x7l(xQn).xEk())
{
throw new Error("internal error");
}
throw new Error("not coprime");
}
var xK=xqn[0];
if(xK.xRm())
{
xK=xK.x6l(xFn);
}
if(xK.xRm())
{
throw new Error("negative");
}
if(xK.xxm(xFn) >= 0)
{
throw new Error("too large");
}
var xY=xK.xjm(x4b).x7l(xFn);
if(!xY.xqk(xMn))
{
throw new Error("failed2");
}
return [x4b,xK,xEf];
}
p5.xPn=function(xcn, xEf)
{
this.xIn=new xTk(xcn);
this.xin=new xTk(xEf);
}
p5.xon=function(xcn, xEf)
{
this.xAn=new xTk(xcn);
this.xin=new xTk(xEf);
}
p5.xkn=function()
{
return this.xIn;
}
p5.xOn=function()
{
return this.xAn;
}
p5.xzn=function()
{
return this.xin;
}
p5.xen=function()
{
if( (!this.xin) || (!this.xAn) )
{
throw new Error("Need private key");
}
}
p5.xRn=function()
{
if( (!this.xin) || (!this.xIn) )
{
throw new Error("Need public key");
}
}
p5.xSn=function(message)
{
this.xen();
if(message.xxm(this.xin) >= 0)
{
throw new Error("Message too large");
}
return message.xHk(this.xAn,this.xin);
}
p5.xyn=function(message)
{
this.xRn();
if(message.xxm(this.xin) >= 0)
{
throw new Error("Message too large");
}
return message.xHk(this.xIn,this.xin);
}

p5.xdn=function(xsn, xDn)
{
var xWj=new xTk(xsn);
var xxl=new xTk(xDn);
var x=new xTk();
var y=new xTk("1");
var xLn=new xTk("1");
var xmn=new xTk();
while(!xxl.xEk())
{
var xnn=xWj.xel(xxl);
var xum=xnn[0];
xWj.x3l(xxl);
xxl=xnn[1];
var xCn=xLn.xim(xum.xjm(x));
var xxn=xmn.xim(xum.xjm(y));
xLn=x;
xmn=y;
x=xCn;
y=xxn;
}
var xY=xLn.xjm(xsn).x6l(xmn.xjm(xDn));
if(!xY.xqk(xWj))
{
throw new Error("Failed3");
}
if(!xsn.x7l(xWj).xEk())
{
throw new Error("Failed4");
}
if(!xDn.x7l(xWj).xEk())
{
throw new Error("Failed5");
}
return [xLn, xmn, xWj];
}

var p6=xqo.prototype;
function xqo()
{
}

p6.x9n=function(xmo)
{
this.xho();
var xbo=xmo.length;
var xMl=0;
var xoo=xbo;
while(true)
{
if(xoo >= 64)
{
this.xFo(xmo.slice(xMl,xMl+64));
xoo -= 64;
xMl += 64;
}
else
{
this.x1n(xmo.slice(xMl,xMl+xoo),xbo);
break;
}
}
return this.xfo(this.x5n);
}
p6.xVn=function(s)
{
var xno=this.xro(s);
this.x9n(xno);
}
p6.xlo=function()
{
return this.xfo(this.x5n);
}
p6.xEo=function()
{
var xno=this.xfo(this.x5n);
return this.xyo(xno);
}
p6.xyo=function(xWj)
{
var xud="";
for(var i=0; i < xWj.length; i++)
{
var xxl=xWj[i];
for(var x0k=0; x0k < 2; x0k++)
{
var xwo=(xxl >> 4)&0x0f;
if(xwo < 10)
{
xud += String.fromCharCode(48+xwo);
}
else
{
xud += String.fromCharCode(87+xwo);
}
xxl <<= 4;
}
}
return xud;
}
//////////// private: ///////////////
p6.xho=function()
{
this.x5n=[0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
}
p6.xDo=function(xXn)
{
if(xXn.length != 16)
{
throw new Error("Should be 16");
}
var xyc=[];
var i;
for(i=0; i < 16; i++)
{
xyc[i]=xXn[i];
}
for(i=16; i < 80; i++)
{
xyc[i] = this.xzo(xyc[i-3] ^ xyc[i-8] ^ xyc[i-14] ^ xyc[i-16], 1);
}
var x2n=this.x5n.slice(0);
var x7m, xWn, x7n;
for(i=0; i < 80; i++)
{
if(i < 20)
{
x7m = (x2n[1] & x2n[2]) | ((x2n[1]^0xffffffff) & x2n[3]);
xWn = 0x5A827999;
}
else if(i < 40)
{
x7m = x2n[1] ^ x2n[2] ^ x2n[3];
xWn = 0x6ED9EBA1;
}
else if(i < 60)
{
x7m = (x2n[1] & x2n[2]) | (x2n[1] & x2n[3]) | (x2n[2] & x2n[3]);
xWn = 0x8F1BBCDC;
}
else
{
x7m = x2n[1] ^ x2n[2] ^ x2n[3];
xWn = 0xCA62C1D6;
}
x7n = (this.xzo(x2n[0], 5)+x7m+x2n[4]+xWn+xyc[i]) & 0xffffffff;
x2n[4] = x2n[3];
x2n[3] = x2n[2];
x2n[2] = this.xzo(x2n[1], 30);
x2n[1] = x2n[0];
x2n[0] = x7n;
}
for(i=0; i < 5; i++)
{
x7n=this.x5n[i]+x2n[i];
x7n &= 0xffffffff;
this.x5n[i]=x7n;
}
}
p6.xFo=function(xmo)
{
if(xmo.length != 64)
{
throw new Error("Should be 64");
}
var xAo=this.xto(xmo);
this.xDo(xAo);
}
p6.x1n=function(xmo, xso)
{
var x0n=xso & 63;
var xeo=xmo.slice(0,x0n);
xeo.push(128);
if(xeo.length < 56)
{
while(xeo.length < 56)
{
xeo.push(0);
}
}
else
{
while(xeo.length < 120)
{
xeo.push(0);
}
}
xso *= 8;
var xvo=this.xfo([Math.floor(xso/0x100000000), xso&0xffffffff]);
xeo=xeo.concat(xvo);
if(xeo.length == 64)
{
this.xFo(xeo);
}
else
{
this.xFo(xeo.slice(0,64));
this.xFo(xeo.slice(64,128));
}
}
p6.xzo=function(xxl, xuo)
{
xxl &= 0xffffffff;
var xud=this.x6n(xxl, xuo);
var xY=this.x6n(xud, -xuo);
if(xxl != xY)
{
throw new Error("Failed");
}
return xud;
}
p6.x6n=function(xxl, xuo)
{
xuo &= 31;
if(xuo == 0) return xxl;
var xud=(xxl << xuo)&0xffffffff;
var xjo=32-xuo;
var xCo=0x7fffffff >> (xjo-1);
var xpo=(xxl >> xjo)&xCo;
xud |= xpo;
return xud;
}
p6.xto=function(xmo)
{
if(xmo.length & 3)
{
throw new Error("Should be multiple of 4");
}
var xAo=[];
var xGl=0;
var i=0;
while(i < xmo.length)
{
xGl <<= 8;
xGl |= (xmo[i] & 0xff);
i++;
if( (i & 3) == 0)
{
xAo.push(xGl);
xGl=0;
}
}
return xAo;
}
p6.xfo=function(xXn)
{
var xno=[];
var xyc, i, xYn;
for(i=0; i < xXn.length; i++)
{
xyc=xXn[i];
xno.push((xyc >> 24)&0xff);
xno.push((xyc >> 16)&0xff);
xno.push((xyc >> 8)&0xff);
xno.push((xyc)&0xff);
}
return xno;
}
p6.xro=function(s)
{
var xud=[];
for(var i=0; i < s.length; i++)
{
xud=xud.concat(this.xxo(s.charCodeAt(i)));
}
return xud;
}
p6.xxo=function(x8j)
{
var xud;
if(x8j <= 0x7f)
{
xud=[x8j];
}
else if(x8j <= 0x07ff)
{
xud=[0xc0|((x8j>>6)&0x1f), 0x80|(x8j&0x3f)];
}
else if(x8j <= 0xffff)
{
xud=[0xc0|((x8j>>12)&0x0f), 0x80|((x8j>>6)&0x3f), 0x80|(x8j&0x3f)];
}
else if(x8j <= 0x1fffff)
{
xud=[0xc0|((x8j>>18)&0x07), 0x80|((x8j>>12)&0x3f), 0x80|((x8j>>6)&0x3f), 0x80|(x8j&0x3f)];
}
else if(x8j <= 0x3ffffff)
{
xud=[0xc0|((x8j>>24)&0x03), 0x80|((x8j>>18)&0x3f), 0x80|((x8j>>12)&0x3f), 0x80|((x8j>>6)&0x3f), 0x80|(x8j&0x3f)];
}
else
{
xud=[0xc0|((x8j>>30)&0x01), 0x80|((x8j>>24)&0x3f), 0x80|((x8j>>18)&0x3f), 0x80|((x8j>>12)&0x3f), 0x80|((x8j>>6)&0x3f), 0x80|(x8j&0x3f)];
}
return xud;
}

var p7=x2o.prototype;
function x2o()
{
this.xJo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
}

p7.xYo=function(xno)
{
var xud="";
var xbo=xno.length;
var xIc=0;
var xHl;
while(xIc < xbo)
{
xHl=xIc+3;
if(xHl > xbo) xHl=xbo;
xud += this.xNo(xno.slice(xIc,xHl));
xIc=xHl;
}

return xud;
}
p7.xZo=function(xSl)
{
var xud=[];
if( (xSl.length % 4) != 0)
{
this.xKo();
}
var xIc=0;
var x0o;
while(xIc < xSl.length)
{
x0o=this.x3o(xSl.substr(xIc,4));
xud=xud.concat(x0o);
xIc += 4;
}
return xud;
}
p7.xNo=function(xno)
{
var xud="";
var xwo=xno[0] >> 2;
xud += this.xJo.substr(xwo,1);
var xxl;
if(xno.length < 2)
{
xxl=0;
}
else
{
xxl=xno[1];
}
xwo=((xno[0] & 0x03) << 4) | (xxl >> 4);
xud += this.xJo.substr(xwo,1);
if(xno.length < 2)
{
xud +="==";
}
else
{
if(xno.length < 3)
{
xxl=0;
}
else
{
xxl=xno[2];
}
xwo=((xno[1] & 0x0f) << 2) | (xxl >> 6);
xud += this.xJo.substr(xwo,1);
if(xno.length < 3)
{
xud +="=";
}
else
{
xwo=xxl & 0x3f;
xud += this.xJo.substr(xwo,1);
}
}
return xud;
}
p7.x3o=function(xSl)
{
if(xSl.length != 4)
{
this.xKo();
}
var xud=[];
var xXo=this.x4o(xSl.charCodeAt(0));
var x1o=this.x4o(xSl.charCodeAt(1));
xud[0]=(xXo << 2) | (x1o >> 4);
var i=xSl.charCodeAt(2);
if(i != 61)
{
xXo=x1o;
x1o=this.x4o(i);
xud[1]=((xXo & 0x0f) << 4) | (x1o >> 2);
i=xSl.charCodeAt(3);
if(i != 61)
{
xXo=x1o;
x1o=this.x4o(i);
xud[2]=((xXo & 0x03) << 6) | x1o;
}
}
return xud;
}
p7.x4o=function(xWo)
{
if( (xWo >= 65) && (xWo <= 90))
{
return xWo-65;
}
else if( (xWo >= 97) && (xWo <= 122))
{
return xWo-71;
}
else if( (xWo >= 48) && (xWo <= 57))
{
return xWo+4;
}
else if(xWo == 43)
{
return 62;
}
else if(xWo == 47)
{
return 63;
}
this.xKo();
return 0;
}
p7.xKo=function()
{
throw new Error("Faulty Base64 data");
}

var p8=xtp.prototype;
function xtp()
{
this.xvp=new xBn();
this.x6o=new xqo();
this.xap=new x2o();
}

p8.x8o=function(message, xkp)
{
this.xvp.xen();
if(xkp)
{
this.xvp.xRn();
}
this.x6o.xVn(message);
var xko=this.x6o.xlo();
var xEf=this.xvp.xzn();
var xhp=xEf.xil();
var xgp=xhp.length-1;
if(xko.length > xgp)
{
throw new Error("Key too short");
}
var xqp="";
while(xko.length < xgp)
{
var x7b=Math.floor(Math.random()*255);
xko[xko.length]=x7b;
xqp += x7b+",";
}
var xjp=new xTk();
xjp.xPk(xko);
var xln=this.xvp.xSn(xjp);
if(xkp)
{
var xip=this.xvp.xyn(xln);
if(! xip.xqk(xjp))
{
throw new Error("Internal error");
}
}
var xfp=xln.xil();
var xlp=this.xap.xYo(xfp);
return xlp;
}
p8.xkp=function(message, xUf)
{
this.xvp.xRn();
var xcp=this.xap.xZo(xUf);
var xrp=new xTk();
xrp.xPk(xcp);
var xip=this.xvp.xyn(xrp);
var xpp=xip.xil();
this.x6o.xVn(message);
var xko=this.x6o.xlo();
if(xpp.length < xko.length) return false;
for(var i=0; i < xko.length; i++)
{
if(xpp[i] != xko[i]) return false;
}
return true;
}
p8.xPn=function(xcn, xEf)
{
this.xvp.xPn(xcn, xEf);
}
p8.xon=function(xcn, xEf)
{
this.xvp.xon(xcn, xEf);
}

