// JavaScript Document


var win=null;
messages=new Array()
pan=new Array()
tilt=new Array()
file=new Array()
still_desc=new Array()
still_file=new Array()
still_orient=new Array()

function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
// -->

function launchTour(tourId) {
	NewWindow("tours_"+tourId+".html","JenImpactTour",800,400,"center",1);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function rc(evnt){
	if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null)
		{
			if (evnt.which>=2) {return false;}
		} else {
			if (event.button>=2){ return false;}
		}
}

document.onmousedown=rc
if (document.layers) window.captureEvents(Event.MOUSEDOWN);window.onmousedown=rc

document.oncontextmenu = function(){ return false ;}

var degrees=0;


function changeView(viewIndex) {
	if ( 		viewIndex != "none") {
		if ( currentView == "Tour" ) {
			document.ptviewer.newPanoFromList(parseInt(viewIndex))
			changeText(viewIndex)
			document.forms[0].viewList.options[parseInt(viewIndex)+1].selected = true
		} else {
			targetURL = window.location.protocol + '//'  + window.location.hostname + window.location.pathname + '?tourNo=' + viewIndex
			window.location = targetURL
		}
	}
}	

function changeTour(viewIndex) {
			document.ptviewer.newPanoFromList(parseInt(viewIndex))
}	

function changeStill(viewIndex) {
	if ( 		viewIndex != "none" ) {
		if ( currentView == "Still" && !(bw.ns4)) {
			document.stillImage.src = still_file[viewIndex]
			if ( still_orient[viewIndex] == "P" ) {
					pWidth = pictureHeight*.75
					pHeight =  pictureWidth*.75
			} else {
					pWidth = pictureWidth
					pHeight = pictureHeight  
			}
			document.stillImage.width = pWidth
			document.stillImage.height = pHeight
			messages[noStills] = "Virtual Tours by JenImpact"
			changeText(noStills)
			document.forms[1].stillList.options[parseInt(viewIndex)+1].selected = true
		} else {
			targetURL = window.location.protocol + '//'  + window.location.hostname + window.location.pathname + '?stillNo=' + viewIndex
			window.location = targetURL
		}
	}
}	


function showCurrentView() {
		var curPan = document.ptviewer.pan()
		var curTilt = document.ptviewer.tilt()
		var curFov = document.ptviewer.fov()
		messages[noTours] = "Pan : " + curPan + "  Tilt : " + curTilt + "  FOV : " + curFov 
		changeText(noTours)
}	

function startPan(leftRight){
		document.ptviewer.startAutoPan(leftRight,0,1.0);

}

function panUp(){
		document.ptviewer.startAutoPan(0,1.0,1.0);
//		document.ptviewer.panUp();
}

function panDown(){
		document.ptviewer.startAutoPan(0,-1.0,1.0);
//		document.ptviewer.panDown();
}

function panLeft(){
		document.ptviewer.panLeft();
}

function panRight(){
		document.ptviewer.panRight();
}

function stopPan(){
			document.ptviewer.stopAutoPan();
	}


function startZoomIn() {
	document.ptviewer.startAutoPan( 0.0, 0.0, 1.0/1.03 );
}
function startZoomOut() {
	document.ptviewer.startAutoPan( 0.0, 0.0, 1.03 );
}

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}



if(document.layers){ //NS4 resize fix...
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}


//ChangeText object constructor.
function makeChangeTextObj(obj){
   	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;	
   	this.writeref = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj].document:0;	
	this.writeIt = b_writeIt;					
}
function b_writeIt(text,num){
	if (bw.ns4){
		this.writeref.write(text)
		this.writeref.close()
	}
    else this.writeref.innerHTML = messages[num]
}

//The mouoseover function. Calls the writeIt method to write the text to the div.
function changeText(num){
	if(bw.bw) oMessage.writeIt(messages[num], num)
}

//The init function. Calls the object constructor and initiates some properties.
function changeTextInit(){
	//Fixing the browsercheck for opera... this can be removed if the browsercheck has been updated!!
	if (bw.opera5) bw.ns6 = 0
	
	oMessage = new makeChangeTextObj('divMessage')
	//Setting the style properties of the text layer.
	//Both layers are hidden by default to prevent users from mousing over them and creating errors while the page loads.
	oMessage.css.visibility= "visible"
}

//If the browser is ok, the init function is called on pageload. 

