var pixel       = 1 //1
var tempo       = 10
var pano_lenght = 0
preloadtime     = 100
var arr=new Array()

function moveIt(objectName,divString,xinit,yinit,speed) {

 this.IE5=this.NN4=this.NN6=false
 if(document.all)this.IE5=true
 else if(document.layers)this.NN4=true
 else if(document.getElementById)this.NN6=true
 
 var netscapestring=""
 var tmp
 var bgn, end
 var i
 var divstring=divString

 i=0
 bgn=0
 end=0
 do { 
  i++
  tmp = ""
  netscapestring += "document."
  end = divstring.indexOf(",")
  if( end > -1 ){
   tmp = divstring.substring(bgn,end)
   divstring = divstring.substring(end+1,divstring.length)
  } else {
   end = divstring.length
   tmp = divstring.substring(bgn,end)
   divstring = null
  }
  netscapestring += tmp
  if(divstring)netscapestring += "."
 } while( divstring )

 if(this.NN4)this.obj=eval(netscapestring)
 if(this.IE5)this.obj=eval("document.all."+tmp+".style")
 if(this.NN6)this.obj=eval("document.getElementById(\""+tmp+"\")"+".style")

 this.hx=xinit
 this.hy=yinit
 this.speed=speed

 this.clip = visible_pano
 this.getx = getX
 this.gety = getY
 this.setx = setX
 this.sety = setY
 this.warp = goTo
 this.warp(this.hx,this.hy)
}
function visible_pano(top,right,bottom,left){
 if(this.IE5) {
  this.obj.clip="rect("+top+","+right+","+bottom+","+left+")"
 } else {
  this.obj.clip.top=top
  this.obj.clip.right=right
  this.obj.clip.bottom=bottom
  this.obj.clip.left=left
 }
}
function getX() {
 if(this.IE5)return parseInt(this.obj.pixelLeft)
 else if(this.NN4)return parseInt(this.obj.left)
 else if(this.NN6)return parseInt(this.obj.left)
}
function getY() {
 if(this.IE5)return parseInt(this.obj.pixelTop)
 else if(this.NN4)return parseInt(this.obj.top)
 else if(this.NN6)return parseInt(this.obj.top)
}
function setX(x) {
 if(!this.constrainX) {
  if(this.IE5)this.obj.pixelLeft=x
  else if(this.NN4)this.obj.left=x
  else if(this.NN6)this.obj.left=x + "px"
 }
}
function setY(y) {
 if(!this.constrainY) {
  if(this.IE5)this.obj.pixelTop=y
  else if(this.NN4)this.obj.top=y
  else if(this.NN6)this.obj.top=y + "px"
 }
}
function goTo(x,y) {
 if(this.active)clearTimeout(this.timer)
 if(this.IE5) {
  this.obj.pixelLeft=x
  this.obj.pixelTop=y
 } else if(this.NN4) {
  this.obj.moveTo(x,y)
 } else if(this.NN6) {
  this.obj.left = x + "px"
  this.obj.top = y + "px"
 }
}
function moveLayers() {
 if(arr[0].getx()<-pano_lenght) arr[0].warp(arr[1].getx()+pano_lenght,0)
 if(arr[1].getx()<-pano_lenght) arr[1].warp(arr[0].getx()+pano_lenght,0)
 arr[0].warp(arr[0].getx()-pixel,0)
 arr[1].warp(arr[1].getx()-pixel,0)
}
function startup() {
 arr[0] = new moveIt("arr[0]","visible_pano,pano1",0,0,30,false)
 arr[1] = new moveIt("arr[1]","visible_pano,pano2",pano_lenght,0,30,false)
 setInterval("moveLayers()", tempo);
}

function changePanoLoading(preloadpanofolder, preloadpanonumber, preloadpanowidth) {
 preloadtime = 1000;
 panofolder = preloadpanofolder;
 panowidth  = preloadpanowidth;
 panonumber = preloadpanonumber;
 document.getElementById('panoimg1').src = 'images/blank.gif';
 document.getElementById('panoimg2').src = 'images/blank.gif';
 self.setTimeout('changePano(panofolder,panonumber,panowidth)', preloadtime)  }

function changePano(panofolder, panonumber, panowidth)  {
 panofolder = panofolder.replace(" ","");
 newpanourl = 'home/'+panofolder+'/pans/'+panonumber+'.jpg';
 document.getElementById('panoimg1').src = newpanourl;
 document.getElementById('panoimg2').src = newpanourl;
 pano_lenght = panowidth;
 arr[0] = new moveIt("arr[0]","visible_pano,pano1",0,0,30,false)
 arr[1] = new moveIt("arr[1]","visible_pano,pano2",pano_lenght,0,30,false)
}

