/* Panoview 0.1 - script for demonstration of circular panoramas
*  Copyright (c) 2004-2009 Anton Petrunich  www.elebis.org	
*
*
*/

pano_width=1;pano_height=2;pano_image=3;pano_start_speed=4;pano_start_direct=5;pano_round=6;pano_step=7;function Panoram(a,b){this.st_x=0;this.st_y=0;this.defaultSpeed=0;this.index=b;this.width=0;this.height=0;this.can_recalc=true;this.round=1;this.div1=null;this.div2=null;this.containerX=0;this.containerY=0;this.img1=new Image();this.img2=new Image();this.direct=-1;this.container=document.getElementById(a);if(this.container==null){alert("Achtung!");return null}this.container.objId=b;this.container.isPano=1;this.container.style.pasition="relative"}Panoram.prototype.setOpt=function(a,b){switch(a){case pano_width:this.width=parseInt(b);break;case pano_height:this.height=parseInt(b);break;case pano_image:this.img1.src=b;break;case pano_start_speed:this.defaultSpeed=parseInt(b);break;case pano_start_direct:this.direct=b;break;case pano_round:this.round=b;break;case pano_step:this.step=b;break}};Panoram.prototype.doMove=function(){if(this.round){var b=parseInt(this.div1.style.left);if(isNaN(b)){b=0}var a=b+this.direct*this.step;this.div1.style.left=a+"px";if(a>this.width-this.step-parseInt(this.div1.style.width)){this.div2.style.left=a-parseInt(this.div2.style.width)}if(a<this.width+this.step-parseInt(this.div1.style.width)){this.div2.style.left=a+parseInt(this.div1.style.width)}if((a+parseInt(this.div1.style.width)<0)||(parseInt(this.div1.style.left)>this.width)){dtmp=this.div1;this.div1=this.div2;this.div2=dtmp}}else{var b=parseInt(this.div1.style.left);if(isNaN(b)){b=0}new_pos=b+this.direct*this.step;if((new_pos<0)&&(new_pos>this.width-parseInt(this.div1.style.width))){this.div1.style.left=new_pos}}};Panoram.prototype.setSpeed=function(b,a){delta=this.width/2-(b-this.containerX);if(delta>0){this.direct=-1}else{this.direct=1}this.speed=Math.round(Math.abs(200*(delta/this.width)))};Panoram.prototype.init=function(){this.div1=document.createElement("div");k=1;this.img2.src=this.img1.src;if(this.img1.height!=this.height){k=this.height/this.img1.height;this.img1.height=this.img1.height*k;this.img1.width=this.img1.width*k;this.img2.height=this.img2.height*k;this.img2.width=this.img2.width*k}this.container.style.width=this.width;this.container.style.height=this.height;this.container.style.overflow="hidden";this.container.style.position="relative";this.div1.style.width=this.img1.width;this.div1.style.position="absolute";this.div1.style.visibility="visible";this.div1.style.display="inline";ob=this.container;x=0;y=0;while(ob){x+=ob.offsetLeft;y+=ob.offsetTop;ob=ob.offsetParent}this.containerX=x;this.containerY=y;this.div1.style.left=-(parseInt(this.div1.style.width)-this.width)/2;this.div1.style.top=0;this.speed=0;this.div1.appendChild(this.img1);this.container.appendChild(this.div1);if(this.round){this.div2=document.createElement("div");this.div2.style.width=this.img1.width;this.div2.style.position="absolute";this.div2.style.visibility="visible";this.div2.style.display="inline";this.div2.appendChild(this.img2);this.div2.style.left=-parseInt(this.div2.style.width);this.div2.style.top=0;this.container.appendChild(this.div2)}this.container.onmousemove=onPanoMouseMove;this.container.onmouseover=onPanoMouseOver;this.container.onmouseout=onPanoMouseOut};Panoram.prototype.setImage=function(a){this.img1.src=a;this.img2.src=a};Panoram.prototype.setDefaultSpeed=function(){this.speed=this.defaultSpeed};function pano_init(a){window.panorams[window.pano_length]=new Panoram(a,window.pano_length);window.pano_length++;return window.panorams[window.pano_length-1]}function pano_setopt(a,b,c){a.setOpt(b,c)}function pano_exec(a){if(a.img1==null){alert("Image not set!");return}if(!a.img1.complete){setTimeout("pano_exec(window.panorams["+a.index+"])",100);return}a.init();intervals[a.index]=setInterval("movePanoram('"+a.index+"')",100-a.speed)}function onPanoMouseOver(a){a=(a)?a:(window.event)?window.event:"";if(a){t=(a.target)?a.target:a.srcElement;while(t&&!t.isPano){t=t.parentNode}if(t){pano=window.panorams[t.objId];if(pano){pano.setSpeed(a.screenX,a.screenY);clearInterval(intervals[pano.index]);intervals[pano.index]=setInterval("movePanoram('"+pano.index+"')",100-pano.speed)}}}}function onPanoMouseMove(a){a=(a)?a:(window.event)?window.event:"";if(a){t=(a.target)?a.target:a.srcElement;while(t&&!t.isPano){t=t.parentNode}if(t){pano=window.panorams[t.objId];if(pano){if(pano.can_recalc){pano.can_recalc=false;pano.setSpeed(a.screenX,a.screenY);clearInterval(intervals[pano.index]);intervals[pano.index]=setInterval("movePanoram('"+pano.index+"')",100-pano.speed);setTimeout("panorams["+pano.index+"].can_recalc = true",100-pano.speed+1)}}}}}function onPanoMouseOut(a){a=(a)?a:(window.event)?window.event:"";if(a){t=(a.target)?a.target:a.srcElement;while(t&&!t.isPano){t=t.parentNode}if(t){pano=window.panorams[t.objId];pano.setDefaultSpeed();clearInterval(intervals[pano.index]);if(pano.speed){intervals[pano.index]=setInterval("movePanoram('"+pano.index+"')",100-pano.speed);setTimeout("panorams["+pano.index+"].can_recalc = true",100-pano.speed+1)}}}}function movePanoram(a){window.panorams[parseInt(a)].doMove()}window.panorams=new Array();intervals=new Array();window.pano_length=0;