if(typeof MOVI=="undefined"||!MOVI){var MOVI={};}
MOVI.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=MOVI;for(j=(d[0]=="MOVI")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]];}}
return o;};MOVI.extend=YAHOO.extend;MOVI.log=YAHOO.log;MOVI.init=function(callback,moviBase,yuiReadyCallback,yuiModules){var _YUI_BASE_DIR="http://yui.yahooapis.com/2.7.0/build/";if(!YAHOO.lang.isFunction(callback))callback=function(){};if(!YAHOO.lang.isFunction(yuiReadyCallback))yuiReadyCallback=undefined;if(!YAHOO.lang.isArray(yuiModules))yuiModules=[];var yuiLoader=new YAHOO.util.YUILoader({require:yuiModules.concat(["yahoo","dom","element","get","event","logger","slider","container"]),base:_YUI_BASE_DIR,loadOptional:true,filter:"RAW",onSuccess:function(){if(yuiReadyCallback)
yuiReadyCallback();YAHOO.widget.Logger.enableBrowserConsole();if(!YAHOO.lang.isString(moviBase)){throw new Error("MOVI base directory is not specified.","movi.js");return false;}
YAHOO.util.Get.css(moviBase+"/style/movi.css",{});if(YAHOO.env.ua.ie>0){YAHOO.util.Get.css(moviBase+"/style/movi_ie.css",{});}
YAHOO.util.Get.script([moviBase+"/config.js",moviBase+"/modelviewer.js",moviBase+"/stencil.js",moviBase+"/stencilset.js",moviBase+"/shape.js",moviBase+"/node.js",moviBase+"/edge.js",moviBase+"/canvas.js",moviBase+"/marker.js",moviBase+"/annotation.js",moviBase+"/modelnavigator.js",moviBase+"/shapeselect.js",moviBase+"/toolbar.js",moviBase+"/zoom.js"],{onSuccess:callback,onFailure:function(){throw new Error("Unable to load MOVI modules from base dir '"+moviBase+"'","movi.js");}});},onFailure:function(msg,xhrobj){var m="Unable to load YUI modules from base dir '"+_YUI_BASE_DIR+"': "+msg;if(xhrobj){m+=", "+YAHOO.lang.dump(xhrobj);}
throw new Error(m,"movi.js");}});yuiLoader.insert();};MOVI.namespace("config");MOVI.config={MODEL_MARGIN:50}
MOVI.namespace("widget");(function(){var _SCROLLBOX_CLASS_NAME="movi-scrollbox",_MODELIMG_CLASS_NAME="movi-modelimg";var _instances=new Array();MOVI.widget.ModelViewer=function(el){this._index=_instances.length;_instances[this._index]=this;MOVI.widget.ModelViewer.superclass.constructor.call(this,el);this.onZoomLevelChange=new YAHOO.util.CustomEvent("movi-zoomLevelChange",this);this.onZoomLevelChangeStart=new YAHOO.util.CustomEvent("movi-zoomLevelChangeStart",this);this.onZoomLevelChangeEnd=new YAHOO.util.CustomEvent("movi-zoomLevelChangeEnd",this);var existingScrollboxArr=this.getElementsByClassName(_SCROLLBOX_CLASS_NAME);if(existingScrollboxArr.length==1){this._scrollbox=new YAHOO.util.Element(existingScrollboxArr[0]);}else{this._scrollbox=new YAHOO.util.Element(document.createElement("div"));this._scrollbox.addClass(_SCROLLBOX_CLASS_NAME);this.appendChild(this._scrollbox);}
this._scrollbox.set("id",_SCROLLBOX_CLASS_NAME+this._index);this._scrollbox.set("innerHTML","<img id=\""+_MODELIMG_CLASS_NAME+this._index+"\" alt=\"oryx model\" class=\""+_MODELIMG_CLASS_NAME+"\" />");this._image=new YAHOO.util.Element(_MODELIMG_CLASS_NAME+this._index);this._loadOptions={};};MOVI.widget.ModelViewer.getInstance=function(id){if(YAHOO.lang.isNumber(id)){return _instances[id];}else{for(var i=0;i<_instances.length;i++){if(_instances[i].get("id")==id)
return _instances[i];}}};MOVI.extend(MOVI.widget.ModelViewer,YAHOO.util.Element,{_modelUri:"",_loadOptions:null,_scrollbox:null,_image:null,_imageWidth:0,_imageHeight:0,_zoomLevel:100,_syncResources:null,canvas:null,onZoomLevelChange:null,onZoomLevelChangeStart:null,onZoomLevelChangeEnd:null,_onSuccess:function(){MOVI.log("Model loaded successfully.","info","modelviewer.js");var scope=this._loadOptions.scope||window;if(this._loadOptions.onSuccess)
this._loadOptions.onSuccess.call(scope,this);},_onLoadFailure:function(){MOVI.log("Could not load model.","error","modelviewer.js");var scope=this._loadOptions.scope||window;if(this._loadOptions.onFailure)
this._loadOptions.onFailure.call(scope,this);},_onLoadTimeout:function(){MOVI.log("A timeout occured while trying to load model.","error","modelviewer.js");var scope=this._loadOptions.scope||window;if(this._loadOptions.onTimeout)
this._loadOptions.onTimeout.call(scope,this);else if(this._loadOptions.onFailure)
this._loadOptions.onFailure.call(scope,this);},_onStencilSetLoadFailure:function(){MOVI.log("Could not load stencil set for model.","error","modelviewer.js");var scope=this._loadOptions.scope||window;if(this._loadOptions.onFailure)
this._loadOptions.onFailure.call(scope,this);},_onStencilSetLoadTimeout:function(){MOVI.log("A timeout occured while trying to load stencil set for model.","error","modelviewer.js");var scope=this._loadOptions.scope||window;if(this._loadOptions.onTimeout)
this._loadOptions.onTimeout.call(scope,this);else if(this._loadOptions.onFailure)
this._loadOptions.onFailure.call(scope,this);},_syncLoadingReady:function(resource){for(var i=0;i<this._syncResources.length;i++){if(this._syncResources[i]==resource)break;}
if(i>=0){this._syncResources.splice(i,1);}
if(this._syncResources.length==0)
this._onSuccess();},getIndex:function(){return this._index;},loadModel:function(uri,opt){if(!YAHOO.lang.isString(uri)){throw new URIError("No valid URI passed to loadModel.","modelviewer.js");this._onLoadFailure();}
/*if(uri.charAt(uri.length-1)=="/")uri=uri.substr(0,uri.length-1);*/this._modelUri=uri;this._loadOptions=opt||{};if(!this._loadOptions.timeout)
this._loadOptions.timeout=15000;this._syncResources=new Array();this._syncResources.push("data");var jsonp=encodeURIComponent("MOVI.widget.ModelViewer.getInstance("+
this._index+").loadModelCallback");var url=uri+"json?jsonp="+jsonp;var transactionObj=YAHOO.util.Get.script(url,{onFailure:this._onLoadFailure,onTimeout:this._onLoadTimeout,timeout:this._loadOptions.timeout,scope:this});this._loadImage(uri);},_loadImage:function(uri){this._syncResources.push("image");var imgUrl=uri+"png?"+(new Date()).getTime();this._image.set("src",imgUrl);var img=new Image();var self=this;img.onload=function(){self._imageWidth=parseInt(self._image.getStyle("width"),10);self._imageHeight=parseInt(self._image.getStyle("height"),10);self._syncLoadingReady("image");};img.src=imgUrl;},loadModelCallback:function(jsonObj){if(this.canvas!=null)
this._scrollbox.removeChild(this.canvas);this.canvas=jsonObj;if(!this.canvas.stencilset){MOVI.log("Could not find stencilset definition for model.","error","canvas.js");this._onFailure();}
if(this.canvas.stencilset.url.substring(0,7)!="http://"){var index=this._modelUri.substring(7).indexOf("/");this.canvas.stencilset.url=this._modelUri.substring(0,7+index)+this.canvas.stencilset.url;}
var jsonp=encodeURIComponent("MOVI.widget.ModelViewer.getInstance("+
this._index+").loadStencilSetCallback");var i=this.canvas.stencilset.url.indexOf("/stencilsets/");var url=this.canvas.stencilset.url.substring(0,i)+"/jsonp?resource="+encodeURIComponent(this.canvas.stencilset.url.substring(i+13))+"&jsonp="+jsonp;var transactionObj=YAHOO.util.Get.script(url,{onFailure:this._onStencilSetLoadFailure,onTimeout:this._onStencilSetLoadTimeout,data:this._loadOptions,timeout:this._loadOptions.timeout,scope:this});},loadStencilSetCallback:function(jsonObj){var prefix="movi_"+this._index+"-";try{this.canvas.stencilset=new MOVI.stencilset.Stencilset(jsonObj);this.canvas=new MOVI.model.Canvas(this,this.canvas,prefix);}catch(e){MOVI.log("A "+e.name+" occured while trying to load model: "+
e.message,"error","modelviewer.js");this._onLoadFailure();return;}
this._scrollbox.appendChild(this.canvas);this._syncLoadingReady("data");},getImgWidth:function(){return this._imageWidth;},getImgHeight:function(){return this._imageHeight;},getModelUri:function(){return this._modelUri;},getScrollboxEl:function(){return this._scrollbox;},scrollToShape:function(shape){if("string"==typeof(shape)){shape=this.canvas.getShape(shape);if(null==shape){return null;}}
if(null!=(h=this.getScrollboxEl().getStyle("height").match(/(\d+)px/))&&null!=(w=this.getScrollboxEl().getStyle("width").match(/(\d+)px/)))
{var bounds=shape.getAbsBounds();var origin={x:bounds.upperLeft.x+(bounds.lowerRight.x-bounds.upperLeft.x)/2,y:bounds.upperLeft.y+(bounds.lowerRight.y-bounds.upperLeft.y)/2}
var zoomFactor=this.getZoomLevel()/100;var target={x:parseInt(origin.x*zoomFactor-parseInt(w[1])/2),y:parseInt(origin.y*zoomFactor-parseInt(h[1])/2)}
this.getScrollboxEl().set("scrollTop",target.y);this.getScrollboxEl().set("scrollLeft",target.x);}
else{throw new Error("Unable to calculate scrollbox dimensions","modelviewer.js");}
return shape;},centerScrollTo:function(x,y){if(!YAHOO.lang.isNumber(x)||!YAHOO.lang.isNumber(y)){throw new TypeError("The coordinates passed to centerScrollTo(x, y) have to be of type Integer.","modelviewer.js");}
var left=Math.round(x-parseInt(this.getScrollboxEl().getStyle("width"),10)/2),top=Math.round(y-parseInt(this.getScrollboxEl().getStyle("height"),10)/2);this.getScrollboxEl().set("scrollLeft",left);this.getScrollboxEl().set("scrollTop",top);},setZoomLevel:function(percent,notifyStartEnd){if(!YAHOO.lang.isNumber(percent)){throw new TypeError("The parameter passed to have to setZoomLevel has to be of type Number.","modelviewer.js");}
if(percent<=0){throw new RangeError("The zoom level must be greater than 0.","modelviewer.js");}else if(percent>100){throw new RangeError("The zoom level must not be greater than 100.","modelviewer.js");}
this._zoomLevel=percent;this._image.setStyle("width",Math.round(this.getImgWidth()*this._zoomLevel/100)+"px");this._image.setStyle("height",Math.round(this.getImgHeight()*this._zoomLevel/100)+"px");if(notifyStartEnd!==false)this.onZoomLevelChangeStart.fire(this._zoomLevel);this.onZoomLevelChange.fire(this._zoomLevel);if(notifyStartEnd!==false)this.onZoomLevelChangeEnd.fire(this._zoomLevel);},getZoomLevel:function(){return this._zoomLevel;},fitModelToViewer:function(){var scaleHorizontal=(parseInt(this.getScrollboxEl().getStyle("width"),10)-5)/this.getImgWidth();var scaleVertical=(parseInt(this.getScrollboxEl().getStyle("height"),10)-5)/this.getImgHeight();var scale=(scaleHorizontal<scaleVertical)?scaleHorizontal:scaleVertical;if(scale>1)scale=1;this.setZoomLevel(scale*100);}});})();MOVI.namespace("stencilset");(function(){MOVI.stencilset.Stencil=function(jsonObject){YAHOO.lang.augmentObject(this,jsonObject,true);}})();MOVI.namespace("stencilset");(function(){MOVI.stencilset.Stencilset=function(jsonObj){this.title=jsonObj.title;this.namespace=jsonObj.namespace;this.description=jsonObj.description;this.stencils={};if(!jsonObj.stencils){MOVI.log("Stencilset contains no stencil definitions","warning","stencilset.js");}
for(key in jsonObj.stencils){if(!YAHOO.lang.hasOwnProperty(jsonObj.stencils,key))continue;var stencil=jsonObj.stencils[key];this.stencils[stencil.id]=new MOVI.stencilset.Stencil(stencil);}};MOVI.stencilset.Stencilset.prototype={stencils:null,getStencil:function(id){return this.stencils[id]||null;}}})();MOVI.namespace("model");(function(){var _createHostElement=function(){var el=document.createElement('div');return el;};var _getSubclassForJSONObj=function(jsonObj,stencilset){var stencil=stencilset.getStencil(jsonObj.stencil.id);if(stencil){if(stencil.type=="node")
return MOVI.model.Node;else if(stencil.type=="edge")
return MOVI.model.Edge;}
return MOVI.model.Shape;}
MOVI.model.Shape=function(jsonObj,stencilset,parent,prefix,attr){YAHOO.lang.augmentObject(this,jsonObj,true);if(!stencilset){throw new Error("No stencilset associated for shape with resource id"+
this.resourceId+".","shape.js");return false;}
if(!this.resourceId){throw new Error("The shape has no resource id.","shape.js");return false;}
if(!this.stencil||!this.stencil.id){throw new Error("No stencil definition found for shape with resource id "+
this.resourceId,"shape.js");return false;}
var sId=this.stencil.id;this.stencil=stencilset.getStencil(sId);if(!this.stencil){throw new Error("Could not find definition for stencil "+sId+" in stencilset "+stencilset.namespace+".","shape.js");return false;}
this.parentShape=parent;attr=attr||{};el=_createHostElement.call(this,attr);MOVI.model.Shape.superclass.constructor.call(this,el,attr);this.set("id",prefix+this.resourceId);var childSh=this.childShapes;this.childShapes={};for(var i=0;i<childSh.length;i++){var child=childSh[i];var subclass=_getSubclassForJSONObj(child,stencilset);child=new subclass(child,stencilset,this,prefix);this.childShapes[child.resourceId]=child;this.appendChild(child);}}
MOVI.extend(MOVI.model.Shape,YAHOO.util.Element,{parentShape:null,getCanvas:function(){var e=this;while(e.parentShape!=null)
e=e.parentShape;return e;},getAbsBounds:function(){var absBounds={upperLeft:{x:this.bounds.upperLeft.x,y:this.bounds.upperLeft.y},lowerRight:{x:this.bounds.lowerRight.x,y:this.bounds.lowerRight.y}};var e=this;while(e.parentShape!=null&&e.parentShape.parentShape!=null){e=e.parentShape;absBounds.upperLeft.x+=e.bounds.upperLeft.x;absBounds.upperLeft.y+=e.bounds.upperLeft.y;absBounds.lowerRight.x+=e.bounds.upperLeft.x;absBounds.lowerRight.y+=e.bounds.upperLeft.y;}
return absBounds;},hasChildShapes:function(){for(key in this.childShapes){if(!YAHOO.lang.hasOwnProperty(this.childShapes,key))continue;return true;}
return false;},getStencil:function(){return this.stencil;}});})();MOVI.namespace("model");(function(){var _CLASS_NAME="movi-node";MOVI.model.Node=function(jsonObj,stencilset,parent,prefix){var attr={};MOVI.model.Node.superclass.constructor.call(this,jsonObj,stencilset,parent,prefix,attr);this.set("className",_CLASS_NAME);this.getCanvas().getModelViewer().onZoomLevelChangeEnd.subscribe(this.update,this,true);this.update();}
MOVI.extend(MOVI.model.Node,MOVI.model.Shape,{update:function(){var zoomFactor=this.getCanvas().getModelViewer().getZoomLevel()/100;var left=Math.round(this.bounds.upperLeft.x*zoomFactor);var top=Math.round(this.bounds.upperLeft.y*zoomFactor);var width=Math.round((this.bounds.lowerRight.x-this.bounds.upperLeft.x)*zoomFactor);var height=Math.round((this.bounds.lowerRight.y-this.bounds.upperLeft.y)*zoomFactor);this.setStyle("left",left+"px");this.setStyle("top",top+"px");this.setStyle("width",width+"px");this.setStyle("height",height+"px");}});})();MOVI.namespace("model");(function(){var _CLASS_NAME="movi-edge";MOVI.model.Edge=function(jsonObj,stencilset,parent,prefix){var attr={};MOVI.model.Node.superclass.constructor.call(this,jsonObj,stencilset,parent,prefix,attr);this.set("className",_CLASS_NAME);}
MOVI.extend(MOVI.model.Edge,MOVI.model.Shape,{update:function(){}});})();MOVI.namespace("model");(function(){var _CLASS_NAME="movi-canvas";MOVI.model.Canvas=function(modelviewer,jsonObj,prefix){this._modelviewer=modelviewer;var attr={};MOVI.model.Canvas.superclass.constructor.call(this,jsonObj,jsonObj.stencilset,null,prefix,attr);this.set("className",_CLASS_NAME);this.shapes={};this._indexShapes();this._modelviewer.onZoomLevelChangeEnd.subscribe(this._update,this,true);this._update();}
MOVI.extend(MOVI.model.Canvas,MOVI.model.Shape,{_modelviewer:null,shapes:null,_indexShapes:function(recShape){recShape=recShape||this;for(key in recShape.childShapes){if(!YAHOO.lang.hasOwnProperty(recShape.childShapes,key))continue;var child=recShape.childShapes[key];this.shapes[child.resourceId]=child;this._indexShapes(child);}},_update:function(){var zoomFactor=this._modelviewer.getZoomLevel()/100;var minX,minY;for(i in this.childShapes){if(!YAHOO.lang.hasOwnProperty(this.childShapes,i))continue;if(minX==undefined)minX=this.childShapes[i].getAbsBounds().upperLeft.x;else minX=Math.min(minX,this.childShapes[i].getAbsBounds().upperLeft.x);if(minY==undefined)minY=this.childShapes[i].getAbsBounds().upperLeft.y;else minY=Math.min(minY,this.childShapes[i].getAbsBounds().upperLeft.y);}
for(i in this.childShapes){if(!YAHOO.lang.hasOwnProperty(this.childShapes,i))continue;this.childShapes[i].bounds.upperLeft.x-=minX;this.childShapes[i].bounds.upperLeft.y-=minY;this.childShapes[i].bounds.lowerRight.x-=minX;this.childShapes[i].bounds.lowerRight.y-=minY;this.childShapes[i].update();}
var left=(MOVI.config.MODEL_MARGIN/2)*zoomFactor+"px";var top=(MOVI.config.MODEL_MARGIN/2)*zoomFactor+"px";var width=(this._modelviewer.getImgWidth()-MOVI.config.MODEL_MARGIN)*zoomFactor+"px";var height=(this._modelviewer.getImgHeight()-MOVI.config.MODEL_MARGIN)*zoomFactor+"px";this.setStyle("left",left);this.setStyle("top",top);this.setStyle("width",width);this.setStyle("height",height);},getShape:function(resourceId){return this.shapes[resourceId]||null;},getModelViewer:function(){return this._modelviewer;},getNodes:function(){var nodes={};for(key in this.shapes){if(!YAHOO.lang.hasOwnProperty(this.shapes,key))continue;if(this.shapes[key].stencil.type=="node")
nodes[key]=this.shapes[key];}
return nodes;},getEdges:function(){var edges={};for(key in this.shapes){if(!YAHOO.lang.hasOwnProperty(this.shapes,key))continue;if(this.shapes[key].stencil.type=="edge")
edges[key]=this.shapes[key];}
return edges;}});})();MOVI.namespace("util");(function(){var _MARKER_RECT_CLASS_NAME="movi-marker",_ICON_CLASS_NAME="movi-marker-icon",_ICON_MARGIN=-10;MOVI.util.Marker=function(shapes,style){if(!shapes)shapes=[];if(!YAHOO.lang.isArray(shapes))shapes=[shapes];this._icons={north:null,west:null,south:null,east:null,northwest:null,southwest:null,northeast:null,southeast:null};this._style=style||{};this.shapeRects={};this._shapes={};for(var i=0;i<shapes.length;i++){var s=shapes[i];this._shapes[s.resourceId]=s;this.shapeRects[s.resourceId]=new YAHOO.util.Element(document.createElement('div'));this.shapeRects[s.resourceId].setStyle("position","absolute");s.appendChild(this.shapeRects[s.resourceId]);}
this.markerRect=new YAHOO.util.Element(document.createElement('div'));this.markerRect.set("className",_MARKER_RECT_CLASS_NAME);this._update();};MOVI.util.Marker.PADDING=4;MOVI.util.Marker.prototype={_style:null,_className:"",_shapes:null,_changedCallback:null,_canvasAvailableCallback:null,_icons:null,shapeRects:null,markerRect:null,canvas:null,_update:function(){var canvas=null;for(i in this._shapes){if(!YAHOO.lang.hasOwnProperty(this._shapes,i))continue;var shape=this._shapes[i];var rect=this.shapeRects[i];if(canvas==null)canvas=shape.getCanvas();var zoomFactor=canvas.getModelViewer().getZoomLevel()/100;for(prop in this._style){if(!YAHOO.lang.hasOwnProperty(this._style,prop))continue;rect.setStyle(prop,this._style[prop]);}
var bTWidth=parseInt(rect.getStyle("border-top-width")),bRWidth=parseInt(rect.getStyle("border-right-width")),bBWidth=parseInt(rect.getStyle("border-bottom-width")),bLWidth=parseInt(rect.getStyle("border-left-width"));var left=-MOVI.util.Marker.PADDING;var top=-MOVI.util.Marker.PADDING;var width=Math.round((shape.bounds.lowerRight.x
-shape.bounds.upperLeft.x)*zoomFactor)+2*MOVI.util.Marker.PADDING
-bLWidth-bRWidth;var height=Math.round((shape.bounds.lowerRight.y
-shape.bounds.upperLeft.y)*zoomFactor)+2*MOVI.util.Marker.PADDING
-bTWidth-bBWidth;rect.setStyle("left",left+"px");rect.setStyle("top",top+"px");rect.setStyle("width",width+"px");rect.setStyle("height",height+"px");rect.set("className",this._className);}
if(canvas!=null){if(this.canvas==null){this.canvas=canvas;this.canvas.appendChild(this.markerRect);for(orientation in this._icons){if(!YAHOO.lang.hasOwnProperty(this._icons,orientation))continue;if(this._icons[orientation])
this.canvas.appendChild(this._icons[orientation]);}
this.canvas.getModelViewer().onZoomLevelChangeStart.subscribe(function(){if(this.markerRect.getStyle("display")=="none"){this._showOnZoomEnd=false;}else{this.hide();this._showOnZoomEnd=true;}},this,true);this.canvas.getModelViewer().onZoomLevelChangeEnd.subscribe(function(){this._update();if(this._showOnZoomEnd)this.show();},this,true);this._onCanvasAvailable();}
var bTWidth=parseInt(this.markerRect.getStyle("border-top-width")),bRWidth=parseInt(this.markerRect.getStyle("border-right-width")),bBWidth=parseInt(this.markerRect.getStyle("border-bottom-width")),bLWidth=parseInt(this.markerRect.getStyle("border-left-width"));var left=Math.round(this.getAbsBounds().upperLeft.x)*zoomFactor-MOVI.util.Marker.PADDING;var top=Math.round(this.getAbsBounds().upperLeft.y)*zoomFactor-MOVI.util.Marker.PADDING;var width=Math.round((this.getAbsBounds().lowerRight.x
-this.getAbsBounds().upperLeft.x)*zoomFactor)+2*MOVI.util.Marker.PADDING
-bLWidth-bRWidth;var height=Math.round((this.getAbsBounds().lowerRight.y
-this.getAbsBounds().upperLeft.y)*zoomFactor)+2*MOVI.util.Marker.PADDING
-bTWidth-bBWidth;this.markerRect.setStyle("left",left+"px");this.markerRect.setStyle("top",top+"px");this.markerRect.setStyle("width",width+"px");this.markerRect.setStyle("height",height+"px");}
this._updateIcons()},_updateIcons:function(){if(this.canvas)
var zoomFactor=this.canvas.getModelViewer().getZoomLevel()/100;else
var zoomFactor=1.0;var bounds=this.getAbsBounds();for(orientation in this._icons){if(!YAHOO.lang.hasOwnProperty(this._icons,orientation))continue;var left,top,margin;var icon=this._icons[orientation];if(icon){var width=parseInt(icon.getStyle("width"),10);var height=parseInt(icon.getStyle("height"),10);if(orientation=="north"){left=Math.round(bounds.upperLeft.x*zoomFactor+((bounds.lowerRight.x-bounds.upperLeft.x)*zoomFactor-width)/2);top=bounds.upperLeft.y*zoomFactor-height;margin=-_ICON_MARGIN+"px 0 0 0";}else if(orientation=="west"){left=bounds.lowerRight.x*zoomFactor;top=Math.round(bounds.upperLeft.y*zoomFactor+((bounds.lowerRight.y-bounds.upperLeft.y)*zoomFactor-height)/2);margin="0 0 0 "+_ICON_MARGIN+"px";}else if(orientation=="south"){left=Math.round(bounds.upperLeft.x*zoomFactor+((bounds.lowerRight.x-bounds.upperLeft.x)*zoomFactor-width)/2);top=bounds.lowerRight.y*zoomFactor;margin=_ICON_MARGIN+"px 0 0 0";}else if(orientation=="east"){left=bounds.upperLeft.x*zoomFactor-width;top=Math.round(bounds.upperLeft.y*zoomFactor+((bounds.lowerRight.y-bounds.upperLeft.y)*zoomFactor-height)/2);margin="0 0 0 "+-_ICON_MARGIN+"px";}else if(orientation=="northwest"){left=bounds.lowerRight.x*zoomFactor;top=bounds.upperLeft.y*zoomFactor-height;margin=-_ICON_MARGIN+"px 0 0 "+_ICON_MARGIN+"px";}else if(orientation=="southwest"){left=bounds.lowerRight.x*zoomFactor;top=bounds.lowerRight.y*zoomFactor;margin=_ICON_MARGIN+"px 0 0 "+_ICON_MARGIN+"px";}else if(orientation=="northeast"){left=bounds.upperLeft.x*zoomFactor-width;top=bounds.upperLeft.y*zoomFactor-height;margin=-_ICON_MARGIN+"px 0 0 "+-_ICON_MARGIN+"px";}else if(orientation=="southeast"){left=bounds.upperLeft.x*zoomFactor-width;top=bounds.lowerRight.y*zoomFactor;margin=_ICON_MARGIN+"px 0 0 "+-_ICON_MARGIN+"px";}
icon.setStyle("left",left+"px");icon.setStyle("top",top+"px");icon.setStyle("margin",margin);}}},_onChanged:function(){if(!this._changedCallback)return;this._changedCallback.callback.call(this._changedCallback.scope,this,this._changedCallback.data);},_onCanvasAvailable:function(){if(!this._canvasAvailableCallback)return;this._canvasAvailableCallback.callback.call(this._canvasAvailableCallback.scope,this,this._canvasAvailableCallback.data);},setRectStyle:function(property,value){this._style[property]=value;this._update();},getRectStyle:function(property){return this._style[property];},setRectClassName:function(className){this._className=className;this._update();},getRectClassName:function(){return this._className;},addShape:function(shape){if(this._shapes[shape.resourceId])
return;this._shapes[shape.resourceId]=shape;var rect=new YAHOO.util.Element(document.createElement('div'));rect.set("className",this.getRectClassName());rect.setStyle("position","absolute");shape.appendChild(rect);this.shapeRects[shape.resourceId]=rect;this._update();this._onChanged();},removeShape:function(shape){shape.removeChild(this.shapeRects[shape.resourceId]);delete this.shapeRects[shape.resourceId];delete this._shapes[shape.resourceId];this._update();this._onChanged()},removeAllShapes:function(){for(key in this._shapes){if(!YAHOO.lang.hasOwnProperty(this._shapes,key))continue;this._shapes[key].removeChild(this.shapeRects[key]);delete this.shapeRects[key];delete this._shapes[key];}
this._update();this._onChanged()},getShapes:function(){var marked=new Array();for(key in this._shapes){if(!YAHOO.lang.hasOwnProperty(this._shapes,key))continue;marked.push(this._shapes[key]);}
return marked;},show:function(){this.markerRect.setStyle("display","block");this.setRectStyle("display","block");for(orientation in this._icons){if(!YAHOO.lang.hasOwnProperty(this._icons,orientation))continue;if(this._icons[orientation])
this._icons[orientation].setStyle("display","block");}},hide:function(){this.markerRect.setStyle("display","none");this.setRectStyle("display","none");for(orientation in this._icons){if(!YAHOO.lang.hasOwnProperty(this._icons,orientation))continue;if(this._icons[orientation])
this._icons[orientation].setStyle("display","none");}},toggle:function(){if(this.markerRect.getStyle("display")=="none")
this.show();else
this.hide();},remove:function(){for(i in this._shapes){if(!YAHOO.lang.hasOwnProperty(this._shapes,i))continue;var rect=this.shapeRects[i];rect.get("element").parentNode.removeChild(rect.get("element"));delete this._shapes[i];delete this.shapeRects[i];}
this.markerRect.get("element").parentNode.removeChild(this.markerRect.get("element"));delete this.markerRect;},getAbsBounds:function(){var upperLeft={x:undefined,y:undefined};lowerRight={x:undefined,y:undefined};for(i in this._shapes){if(!YAHOO.lang.hasOwnProperty(this._shapes,i))continue;var bounds=this._shapes[i].getAbsBounds();if(upperLeft.x==undefined||bounds.upperLeft.x<upperLeft.x)
upperLeft.x=bounds.upperLeft.x;if(upperLeft.y==undefined||bounds.upperLeft.y<upperLeft.y)
upperLeft.y=bounds.upperLeft.y;if(lowerRight.x==undefined||bounds.lowerRight.x>lowerRight.x)
lowerRight.x=bounds.lowerRight.x;if(lowerRight.y==undefined||bounds.upperLeft.y>lowerRight.y)
lowerRight.y=bounds.lowerRight.y;}
return{upperLeft:upperLeft,lowerRight:lowerRight};},onChanged:function(callback,scope,data){if(!YAHOO.lang.isFunction(callback)){throw new TypeError("Specified callback is not a function.","error","marker.js");return;}
if(!scope)scope=this;this._changedCallback={callback:callback,scope:scope,data:data};},onCanvasAvailable:function(callback,scope,data){if(!YAHOO.lang.isFunction(callback)){throw new TypeError("Specified callback is not a function.","error","marker.js");return;}
if(!scope)scope=this;this._canvasAvailableCallback={callback:callback,scope:scope,data:data};},addIcon:function(orientation,icon){if(!YAHOO.lang.isString(orientation)){throw new TypeError("The orientation paramter is expected to be of type String","error","marker.js");return;}
if(YAHOO.lang.isString(icon)){var img=new Image();var self=this;img.onload=function(){self._updateIcons.call(self);};img.src=icon;icon=new YAHOO.util.Element(img);}else{icon=new YAHOO.util.Element(icon);}
icon.set("className",_ICON_CLASS_NAME);for(var key in this._icons){if(!YAHOO.lang.hasOwnProperty(this._icons,key))continue;if(key===orientation){if(this._icons[orientation])this.removeIcon(orientation);if(this.canvas)this.canvas.appendChild(icon);this._icons[key]=icon;this._updateIcons();return icon;}}
throw new Error("The specified orientation is not valid.","error","marker.js");},removeIcon:function(orientation){if(this._icons[orientation]&&this.canvas)
this.canvas.removeChild(this._icons[orientation]);this._icons[orientation]=null;},getIcon:function(orientation){return this._icons[orientation];}}})();MOVI.namespace("util");(function(){var _BUBBLE_VISIBLE_CLASS_NAME="movi-bubble-visible",_BUBBLE_HIDDEN_CLASS_NAME="movi-bubble-hidden",_BUBBLE_UL_CLASS_NAME="movi-bubble-ul",_BUBBLE_UR_CLASS_NAME="movi-bubble-ur",_BUBBLE_LL_CLASS_NAME="movi-bubble-ll",_BUBBLE_LR_CLASS_NAME="movi-bubble-lr",_BUBBLE_BORDERTOP_CLASS_NAME="movi-bubble-bt",_BUBBLE_BORDERBOTTOM_CLASS_NAME="movi-bubble-bb",_BUBBLE_ARROW_CLASS_NAME="movi-bubble-ar",_BUBBLE_CONTENT_CLASS_NAME="movi-bubble-bc",_BUBBLE_CLOSEBUTTON_CLASS_NAME="movi-bubble-closebutton"
var Event=YAHOO.util.Event,Element=YAHOO.util.Element;MOVI.util.Annotation=function(marker,content){if(!marker){throw new Error("No marker specified for annotation.","annotation.js");return false;}
if(!YAHOO.lang.isString(content)){throw new TypeError("A String is expected for the annotation's content.","annotation.js");}
el=_createHostElement.call(this);MOVI.util.Annotation.superclass.constructor.call(this,el,{});_createBubble.call(this,content);this._content=new Element(this.getElementsByClassName(_BUBBLE_CONTENT_CLASS_NAME)[0]);this._marker=marker;this._marker.onChanged(this._update,this);(new Element(this.getElementsByClassName(_BUBBLE_CLOSEBUTTON_CLASS_NAME)[0])).addListener("click",this._close,this,this);this.addListener("mouseover",function(ev){Event.stopPropagation(ev)});this.addListener("mouseout",function(ev){Event.stopPropagation(ev)});this.addListener("click",function(ev){Event.stopPropagation(ev)});this._update();}
MOVI.extend(MOVI.util.Annotation,Element,{_contentElement:null,_marker:null,_canvas:null,_closeCallback:null,_close:function(){this.hide();if(this._closeCallback){this._closeCallback.callback.call(this._closeCallback.callback.scope,this,this._closeCallback.callback.data);}},_update:function(){var zoomFactor=1;if(!this._canvas){this._canvas=this._marker.canvas;if(this._canvas){this._canvas.appendChild(this);this._canvas.getModelViewer().onZoomLevelChangeStart.subscribe(function(){if(!this.hasClass(_BUBBLE_VISIBLE_CLASS_NAME)){this._showOnZoomEnd=false;}else{this.hide();this._showOnZoomEnd=true;}},this,true);this._canvas.getModelViewer().onZoomLevelChangeEnd.subscribe(function(){this._update();if(this._showOnZoomEnd)this.show();},this,true);zoomFactor=this._canvas.getModelViewer().getZoomLevel()/100;}else{this._marker.onCanvasAvailable(this._update,this);}}else{zoomFactor=this._canvas.getModelViewer().getZoomLevel()/100;}
var bounds=this._marker.getAbsBounds();var left=Math.round(bounds.lowerRight.x*zoomFactor);var top=Math.round((bounds.upperLeft.y+(bounds.lowerRight.y-bounds.upperLeft.y)*0.6)*zoomFactor);this.setStyle("left",left+"px");this.setStyle("top",top+"px");},show:function(){this._marker.show();this.set("className",_BUBBLE_VISIBLE_CLASS_NAME);this.bringToFront();},hide:function(){this.set("className",_BUBBLE_HIDDEN_CLASS_NAME);},toggle:function(){if(this.hasClass(_BUBBLE_VISIBLE_CLASS_NAME))
this.hide();else
this.show();},remove:function(){this.get("element").parentNode.removeChild(this.get("element"));},onClose:function(callback,scope,data){this._closeCallback={callback:callback,scope:scope,data:data};},bringToFront:function(){if(!this.get("element").parentNode)return;var maxZIndex=0;var canvasEl=new Element(this.get("element").parentNode.parentNode);var elements=canvasEl.getElementsByClassName(_BUBBLE_VISIBLE_CLASS_NAME);for(key in elements){if(!YAHOO.lang.hasOwnProperty(elements,key))continue;var zIndex=parseInt((new Element(elements[key].parentNode)).getStyle("z-index"),10);if(zIndex>maxZIndex)maxZIndex=zIndex;}
this._marker.markerRect.setStyle("z-index",maxZIndex+1);}});var _createHostElement=function(){var el=document.createElement('div');return el;};var _createBubble=function(content){this.set("className",_BUBBLE_HIDDEN_CLASS_NAME);this.set("innerHTML","<div class=\""+_BUBBLE_UL_CLASS_NAME+"\"><div class=\""+_BUBBLE_UR_CLASS_NAME+"\">"+"<div class=\""+_BUBBLE_LL_CLASS_NAME+"\"><div class=\""+_BUBBLE_LR_CLASS_NAME+"\">"+"<div class=\""+_BUBBLE_BORDERTOP_CLASS_NAME+"\"></div>"+"<div class=\""+_BUBBLE_CONTENT_CLASS_NAME+"\">"+"<div class=\""+_BUBBLE_CLOSEBUTTON_CLASS_NAME+"\"></div>"+
content+"</div>"+"<div class=\""+_BUBBLE_BORDERBOTTOM_CLASS_NAME+"\"></div>"+"</div></div>"+"</div></div>"+"<div class=\""+_BUBBLE_ARROW_CLASS_NAME+"\"/>");}})();MOVI.namespace("widget");(function(){var _NAVIGATOR_CLASS_NAME="movi-navigator",_CLIPPING_RECT_CLASS_NAME="movi-navigator-clippingrect",_NAVIGATOR_IMG_CLASS_NAME="movi-navigator-img";var _setUpHostElement=function(){if(this.getStyle("position")=="static")
this.setStyle("position","relative");this.set("innerHTML","<img class=\""+_NAVIGATOR_IMG_CLASS_NAME+"\" />"+"<div class=\""+_CLIPPING_RECT_CLASS_NAME+"\" />");};MOVI.widget.ModelNavigator=function(el,modelviewer){if(!modelviewer){throw new Error("No model viewer specified for model navigator","modelnavigator.js");return false;}
this.modelviewer=modelviewer;MOVI.widget.ModelNavigator.superclass.constructor.call(this,el);_setUpHostElement.call(this);this._clippingRect=new YAHOO.util.Element(this.getElementsByClassName(_CLIPPING_RECT_CLASS_NAME)[0]);this._image=new YAHOO.util.Element(this.getElementsByTagName("img")[0]);this.addClass(_NAVIGATOR_CLASS_NAME);var scrollboxId=this.modelviewer.getScrollboxEl().get("id");if(!scrollboxId||!YAHOO.util.Event.addListener(scrollboxId,"scroll",this.update,this,true)){throw new Error("Could not add event listener to scrollbox","modelnavigator.js");}
this.modelviewer.onZoomLevelChange.subscribe(this.update,this,true);this._clippingRect.addListener("mousedown",this._onClippingRectDrag,this,this,true);this._clippingRect.addListener("click",function(ev){YAHOO.util.Event.stopEvent(ev);},this,this,true);this.addListener("click",this._onClick,this,this,true);YAHOO.util.Event.addListener(document,"mouseup",this._onMouseUp,this,this,true);this._absXY=[];this._mouseOffset={x:0,y:0};this.update();};MOVI.extend(MOVI.widget.ModelNavigator,YAHOO.util.Element,{_clippingRect:null,_image:null,_absXY:null,_mouseOffset:null,modelviewer:null,_onClippingRectDrag:function(ev){YAHOO.util.Event.preventDefault(ev);this._absXY=YAHOO.util.Dom.getXY(this);var mouseAbsXY=YAHOO.util.Event.getXY(ev);var clippingRectAbsXY=YAHOO.util.Dom.getXY(this._clippingRect);this._mouseOffset.x=mouseAbsXY[0]-clippingRectAbsXY[0];this._mouseOffset.y=mouseAbsXY[1]-clippingRectAbsXY[1];this.addListener("mousemove",this._onClippingRectMove,this,this,true);},_onMouseUp:function(ev){YAHOO.util.Event.preventDefault(ev);this.removeListener("mousemove",this._onClippingRectMove);},_onClick:function(ev){YAHOO.util.Event.preventDefault(ev);this._absXY=YAHOO.util.Dom.getXY(this);var mouseAbsXY=YAHOO.util.Event.getXY(ev);var navigatorWidth=parseInt(this.getStyle("width"),10);var scale=this.modelviewer.getImgWidth()/navigatorWidth;var zoomFactor=this.modelviewer.getZoomLevel()/100;var centerX=Math.round(scale*(mouseAbsXY[0]-this._absXY[0])*zoomFactor);var centerY=Math.round(scale*(mouseAbsXY[1]-this._absXY[1])*zoomFactor);this.modelviewer.centerScrollTo(centerX,centerY);},_onClippingRectMove:function(ev){YAHOO.util.Event.preventDefault(ev);var mouseAbsXY=YAHOO.util.Event.getXY(ev);var x=mouseAbsXY[0]-this._absXY[0]-this._mouseOffset.x,y=mouseAbsXY[1]-this._absXY[1]-this._mouseOffset.y;var navigatorWidth=parseInt(this.getStyle("width"),10);var scale=this.modelviewer.getImgWidth()/navigatorWidth;var zoomFactor=this.modelviewer.getZoomLevel()/100;var scrollboxEl=this.modelviewer.getScrollboxEl();scrollboxEl.set("scrollLeft",Math.round(scale*x*zoomFactor));scrollboxEl.set("scrollTop",Math.round(scale*y*zoomFactor));},update:function(){var zoomFactor=this.modelviewer.getZoomLevel()/100;var pngUrl=this.modelviewer.getModelUri()+"png";var scrollboxEl=this.modelviewer.getScrollboxEl();if(this._image.get("src")!=pngUrl)
this._image.set("src",pngUrl);var navigatorWidth=parseInt(this.getStyle("width"),10);var scale=navigatorWidth/this.modelviewer.getImgWidth();if(scale>1){navigatorWidth=this.modelviewer.getImgWidth();this.setStyle("width",navigatorWidth+"px");scale=1;}
var navigatorHeight=Math.round(scale*this.modelviewer.getImgHeight());this.setStyle("height",navigatorHeight+"px");var left=Math.round(scale*scrollboxEl.get("scrollLeft")/zoomFactor);var top=Math.round(scale*scrollboxEl.get("scrollTop")/zoomFactor);var scrollboxWidth=parseInt(scrollboxEl.getStyle("width"),10);var scrollboxHeight=parseInt(scrollboxEl.getStyle("height"),10);var clippingRectWidth=Math.round(scale*scrollboxWidth/zoomFactor);var clippingRectHeight=Math.round(scale*scrollboxHeight/zoomFactor);if(left+clippingRectWidth>navigatorWidth)clippingRectWidth=navigatorWidth-left;if(top+clippingRectHeight>navigatorHeight)clippingRectHeight=navigatorHeight-top;this._clippingRect.setStyle("width",clippingRectWidth+"px");this._clippingRect.setStyle("height",clippingRectHeight+"px");this._clippingRect.setStyle("left",left+"px");this._clippingRect.setStyle("top",top+"px");}});})();MOVI.namespace("util");(function(){var _SELECT_RECT_CLASS_NAME="movi-select-rect",_HIGHLIGHT_RECT_CLASS_NAME="movi-highlight-rect";var Marker=MOVI.util.Marker,Event=YAHOO.util.Event;MOVI.util.ShapeSelect=function(modelviewer,shapes,multiselect){if(!modelviewer){throw new Error("No model viewer specified for shape select.","error","shapeselect.js");return false;}
if(!YAHOO.lang.isArray(shapes)){if(shapes==true)multiselect=true;shapes=modelviewer.canvas.getNodes();}
this._allowMultiselect=multiselect;this._selectableShapes={};this._selectedShapes={};this._highlightMarkers={};for(key in shapes){if(!YAHOO.lang.hasOwnProperty(shapes,key))continue;var shape=modelviewer.canvas.shapes[key];if(shape.parentShape!=null){shape.addListener("mouseover",this._onMouseOver,shape,this);shape.addListener("mouseout",this._onMouseOut,shape,this);shape.addListener("click",this._onClick,shape,this);this._selectableShapes[shape.resourceId]=shape;}}
modelviewer.canvas.addListener("click",this.reset,null,this)
this._selectionMarker=new Marker();this._selectionMarker.setRectClassName(_SELECT_RECT_CLASS_NAME);this._selectionMarker.show();this._init();};MOVI.util.ShapeSelect.prototype={_selectableShapes:null,_selectedShapes:null,_highlightMarkers:null,_selectionMarker:null,_selectionChangedCallback:null,_allowMultiselect:false,_init:function(){for(key in this._selectableShapes){if(!YAHOO.lang.hasOwnProperty(this._selectableShapes,key))continue;var s=this._selectableShapes[key];var marker=new Marker(s);marker.setRectClassName(_HIGHLIGHT_RECT_CLASS_NAME);marker.hide();this._highlightMarkers[s.resourceId]=marker;}},_onMouseOver:function(ev,shape){Event.stopPropagation(ev);if(!this._selectedShapes[shape.resourceId])
this.highlight(shape);},_onMouseOut:function(ev,shape){Event.stopPropagation(ev);if(!this._selectedShapes[shape.resourceId])
this.unhighlight(shape);},_onClick:function(ev,shape){Event.stopPropagation(ev);if(this._selectedShapes[shape.resourceId]){this.deselect(shape);}else{if(!this._allowMultiselect)
this._reset();this.select(shape);}},_onSelectionChanged:function(){if(!this._selectionChangedCallback)return;this._selectionChangedCallback.callback.call(this._selectionChangedCallback.scope,this,this._selectionChangedCallback.data);},_reset:function(){for(key in this._selectedShapes){if(!YAHOO.lang.hasOwnProperty(this._selectableShapes,key))continue;var s=this._selectedShapes[key];this._selectionMarker.removeShape(s);delete this._selectedShapes[key];}},select:function(shapes){if(!YAHOO.lang.isArray(shapes))shapes=[shapes];for(key in shapes){if(!YAHOO.lang.hasOwnProperty(shapes,key))continue;var s=shapes[key];this.unhighlight(s);if(!this._selectableShapes[s.resourceId]){MOVI.log("Specified shape with resource id "+s.resourceId+" is not selectable.","warn","shapeselect.js");continue;}
this._selectedShapes[s.resourceId]=s;this._selectionMarker.addShape(s);}
this._onSelectionChanged();},deselect:function(shapes){if(!YAHOO.lang.isArray(shapes))shapes=[shapes];for(key in shapes){if(!YAHOO.lang.hasOwnProperty(shapes,key))continue;var s=shapes[key];delete this._selectedShapes[s.resourceId];this._selectionMarker.removeShape(s);}
this._onSelectionChanged();},highlight:function(shape){this._highlightMarkers[shape.resourceId].show();},unhighlight:function(shape){this._highlightMarkers[shape.resourceId].hide();},reset:function(){if(this.getSelectedShapes().length==0)
return;this._reset();this._onSelectionChanged();},getSelectedShapes:function(){var selected=new Array();for(key in this._selectedShapes){if(!YAHOO.lang.hasOwnProperty(this._selectedShapes,key))continue;selected.push(this._selectedShapes[key]);}
return selected;},getSelectionMarker:function(){return this._selectionMarker;},onSelectionChanged:function(callback,scope,data){if(!YAHOO.lang.isFunction(callback)){throw new TypeError("Specified callback is not a function.","shapeselect.js");return;}
if(!scope)scope=this;this._selectionChangedCallback={callback:callback,scope:scope,data:data};}}})();MOVI.namespace("widget");(function(){var _TOOLBAR_CLASS_NAME="movi-toolbar",_TOOLBAR_BUTTON_CLASS_NAME="movi-toolbar-button",_TOOLBAR_GROUP_CLASS_NAME="movi-toolbar-group";_TOOLBAR_GROUP_LABEL_CLASS_NAME="movi-toolbar-group-label"
var _DEFAULT_GROUP_NAME="movi-toolbar-default-group";MOVI.widget.Toolbar=function(el,modelviewer){this.modelviewer=modelviewer;this._groups={};MOVI.widget.Toolbar.superclass.constructor.call(this,el);this.addClass(_TOOLBAR_CLASS_NAME);};MOVI.extend(MOVI.widget.Toolbar,YAHOO.util.Element,{_groups:null,modelviewer:null,_update:function(){this.set("innerHTML","");for(key in this._groups){if(!YAHOO.lang.hasOwnProperty(this._groups,key))continue;var group=this._groups[key];var groupEl=new YAHOO.util.Element(document.createElement("div"));groupEl.set("className",_TOOLBAR_GROUP_CLASS_NAME);this.appendChild(groupEl);if(this._showGroupCaptions){var groupLabelEl=new YAHOO.util.Element(document.createElement("div"));groupLabelEl.set("className",_TOOLBAR_GROUP_LABEL_CLASS_NAME);groupEl.appendChild(groupLabelEl);if(key!=_DEFAULT_GROUP_NAME)groupLabelEl.set("innerHTML",key);}
for(var i=0;i<group.length;i++){if(group[i])groupEl.appendChild(group[i]);}}
var clearDiv=new YAHOO.util.Element(document.createElement("div"));clearDiv.setStyle("clear","left");this.appendChild(clearDiv);},addButton:function(config){if(!YAHOO.lang.isFunction(config.callback)){throw new Error("No valid callback method specified","toolbar.js");return null;}
var button=new YAHOO.util.Element(document.createElement("div"));button.set("className",_TOOLBAR_BUTTON_CLASS_NAME);var scope=config.scope?config.scope:this;button.on("click",config.callback,config.data,scope);if(config.icon){if(!YAHOO.lang.isString(config.icon)){throw new TypeError("The icon has to be a String value","toolbar.js");return null;}
var iconEl=new YAHOO.util.Element(document.createElement("img"));iconEl.set("src",config.icon);button.appendChild(iconEl);}
if(config.caption){if(!YAHOO.lang.isString(config.caption)){throw new TypeError("The caption has to be a String value","toolbar.js");return null;}
var captionEl=new YAHOO.util.Element(document.createElement("span"));captionEl.set("html",config.caption);}
if(!config.icon&&!config.caption){throw new Error("At least one - icon or caption - must be specified","toolbar.js");return false;}
if(config.tooltip){if(!YAHOO.lang.isString(config.tooltip)){throw new TypeError("The tooltip has to be a String value","toolbar.js");return null;}
button.set("title",config.tooltip);if(iconEl)iconEl.set("alt",config.tooltip);}
if(config.group){if(!YAHOO.lang.isString(config.group)){throw new TypeError("The group has to be a String value","toolbar.js");return null;}
var groupName=config.group;var buttonId=groupName;}else{var groupName=_DEFAULT_GROUP_NAME;var buttonId="";}
if(!this._groups[groupName])
this._groups[groupName]=new Array();this._groups[groupName].push(button);buttonId+="_"+this._groups[groupName].length-1;this._update();return buttonId;},removeButton:function(id){var i=id.lastIndexOf("_");var groupName=id.substring(0,i-1);var index=id.substring(i+1);this._groups[groupName][index]=undefined;this._update();},showGroupCaptions:function(){this._showGroupCaptions=true;this._update();},hideGroupCaptions:function(){this._showGroupCaptions=false;this._update();}});})();MOVI.namespace("widget");(function(){var _SLIDER_CLASS_NAME="movi-zoomslider",_SLIDER_THUMB_CLASS_NAME="movi-zoomslider-thumb",_SLIDER_WIDTH=100,_SLIDER_STEP=1,_FULLSCREEN_LIGHTBOX_CLASS_NAME="movi-fullscreen-lightbox",_FULLSCREEN_CONTAINER_CLASS_NAME="movi-fullscreen-modelcontainer";var _setUpHostElementZoomSlider=function(){this.set("innerHTML","<div id=\""+_SLIDER_CLASS_NAME+this.modelviewer.getIndex()+"\" class=\""+_SLIDER_CLASS_NAME+"\" title=\"Zoom Slider\">"+"<div id=\""+_SLIDER_THUMB_CLASS_NAME+this.modelviewer.getIndex()+"\" class=\""+_SLIDER_THUMB_CLASS_NAME+"\"></div>"+"</div>");};var _getMinZoomLevel=function(modelviewer){var scaleHorizontal=(parseInt(modelviewer.getScrollboxEl().getStyle("width"),10))/modelviewer.getImgWidth();var scaleVertical=(parseInt(modelviewer.getScrollboxEl().getStyle("height"),10))/modelviewer.getImgHeight();var scale=(scaleHorizontal<scaleVertical)?scaleHorizontal:scaleVertical;if(scale>1)scale=1;return scale*100;};MOVI.widget.ZoomSlider=function(el,modelviewer){if(!modelviewer){throw new Error("No model viewer specified for zoom slider","zoom.js");return false;}
this.modelviewer=modelviewer;MOVI.widget.ZoomSlider.superclass.constructor.call(this,el);_setUpHostElementZoomSlider.call(this);this.slider=YAHOO.widget.Slider.getHorizSlider(_SLIDER_CLASS_NAME+this.modelviewer.getIndex(),_SLIDER_THUMB_CLASS_NAME+this.modelviewer.getIndex(),0,_SLIDER_WIDTH,_SLIDER_STEP);this.update();this.slider.subscribe('change',this.onChange,this,true);this.slider.subscribe('slideStart',this._onSlideStart,this,true);this.slider.subscribe('slideEnd',this._onSlideEnd,this,true);};MOVI.extend(MOVI.widget.ZoomSlider,YAHOO.util.Element,{slider:null,_onSlideStart:function(){this.modelviewer.onZoomLevelChangeStart.fire(this.modelviewer.getZoomLevel());},_onSlideEnd:function(){this.modelviewer.onZoomLevelChangeEnd.fire(this.modelviewer.getZoomLevel());},onChange:function(){var minZoomLevel=_getMinZoomLevel(this.modelviewer);var maxZoomLevel=100;var zoomStep=(maxZoomLevel-minZoomLevel)/_SLIDER_WIDTH;this.modelviewer.setZoomLevel(minZoomLevel+this.slider.getValue()*zoomStep,false);},update:function(){var minZoomLevel=_getMinZoomLevel(this.modelviewer);var maxZoomLevel=100;var zoomStep=(maxZoomLevel-minZoomLevel)/_SLIDER_WIDTH;this.slider.setValue((this.modelviewer.getZoomLevel()-minZoomLevel)*zoomStep);}});var _swapNode=function(n1,n2){if(n1.swapNode){n1.swapNode(n2);}else{var p=n2.parentNode;var s=n2.nextSibling;if(s==n1){p.insertBefore(n1,n2);}else if(n2==n1.nextSibling){p.insertBefore(n2,n1);}else{n1.parentNode.replaceChild(n2,n1);p.insertBefore(n1,s);}}};var _setUpHostElementFullscreenViewer=function(){var el=new YAHOO.util.Element(document.createElement('div'));el.set("innerHTML","<div class=\"hd\"></div>"+"<div class=\"bd\"><div class=\""+_FULLSCREEN_CONTAINER_CLASS_NAME+"\"></div></div>"+"<div class=\"ft\"></div>");(new YAHOO.util.Element(document.body)).appendChild(el);return el;};MOVI.widget.FullscreenViewer=function(modelviewer){this.modelviewer=modelviewer;var el=_setUpHostElementFullscreenViewer();el.addClass(_FULLSCREEN_LIGHTBOX_CLASS_NAME);var elId=_FULLSCREEN_LIGHTBOX_CLASS_NAME+this.modelviewer.getIndex();el.set("id",elId);MOVI.widget.FullscreenViewer.superclass.constructor.call(this,el);this.dialog=new YAHOO.widget.Dialog(elId,{fixedcenter:true,visible:false,draggable:true,modal:true,close:true,constraintoviewport:true});this.dialog.render();YAHOO.util.Event.on(YAHOO.util.Dom.getElementsByClassName("container-close","a",elId),"click",this.close,this,true);this._fullscreenContainer=new YAHOO.util.Element(el.getElementsByClassName(_FULLSCREEN_CONTAINER_CLASS_NAME)[0]);this._modelViewerPlaceholder=new YAHOO.util.Element(document.createElement("div"));this._fullscreenContainer.appendChild(this._modelViewerPlaceholder);};MOVI.extend(MOVI.widget.FullscreenViewer,YAHOO.util.Element,{_fullscreenContainer:null,_modelViewerPlaceholder:null,dialog:null,open:function(){this.dialog.cfg.setProperty("width",(YAHOO.util.Dom.getViewportWidth()-20)+"px");this.dialog.cfg.setProperty("height",(YAHOO.util.Dom.getViewportHeight()-20)+"px");_swapNode(this.modelviewer.getScrollboxEl().get("element"),this._modelViewerPlaceholder.get("element"));var minZoomLevel=_getMinZoomLevel(this.modelviewer);this._originalZoomLevel=this.modelviewer.getZoomLevel();this.modelviewer.setZoomLevel(minZoomLevel);this.dialog.show();},close:function(){_swapNode(this.modelviewer.getScrollboxEl().get("element"),this._modelViewerPlaceholder.get("element"));this.modelviewer.setZoomLevel(this._originalZoomLevel);this.dialog.hide();}});})();