function MediaViewer(aLanguageId, aResolution, anElementName, anElementMode, anElementId, aConfigFolder, aMediaFolder)
{	
	// set glogal vars
	this.domain
	this.languageId    = aLanguageId;
	this.elementId     = anElementId;
	this.elementName   = anElementName;
	this.elementMode   = parseInt(anElementMode);
	this.resolution    = aResolution;
	this.configFolder  = aConfigFolder;
	this.labelsFolder  = aConfigFolder;
	this.mediaFolder   = aMediaFolder;
	
	// Append an instance of this object to the window for reference out of scope
	window.mediaViewerGlobalObj = this;	
	
	// Text for labels and alt-tags for images
	this.labels         = new Object();
	this.labels.httpObj = this.getXmlHttpObject();
	this.labels.text    = new Object();
	
	// Image Viewer object for 2d Zoom-able Images
	this.imageViewer = new Object();
	this.imageViewer.imgSize;
	
	// Media Column section including thunbnails, title, pagination
	this.mediaColumn                = new Object();
	this.mediaColumn.httpObj        = this.getXmlHttpObject();
	this.mediaColumn.contents       = new Array();
	this.mediaColumn.title          = document.getElementById('thumbsTitle');
	this.mediaColumn.container      = document.getElementById('thumbs');
	this.mediaColumn.controls       = document.getElementById('thumbsControls');
	this.mediaColumn.pagePos        = 25;
	this.mediaColumn.contents.delta = 400;	
	this.pageTitle = document.getElementById('banner');
	
	// Virtual environment related variables
	this.virtEnv                        = new Object();
	this.virtEnv.httpObj                = this.getXmlHttpObject();
	this.virtEnv.maps;
	this.virtEnv.dropDown;
	this.virtEnv.dropDownContainer      = document.getElementById('timeInHistory');
	this.virtEnv.dropDownTitleContainer = document.getElementById('timeInHistoryTitle');
	this.virtEnv.currentQtvrMap;
	this.virtEnv.currentQtvrMapNode;
	this.virtEnv.currentQtvrTimeline    = '';
	this.virtEnv.hotspotIntervalId      = 0;
	this.virtEnv.qtvrDefaultView        = true;
	this.virtEnv.timelines              = new Object();
	this.virtEnv.timelines.timelineText;
	this.virtEnv.timelines.httpObj      = this.getXmlHttpObject();
	this.virtEnv.map                    = false;
		
	// Various global variables
	this.accelerateTime      = 0;	
	this.accelerateInterval;
	this.accelerateRunning   = false;	
	this.flashIntervalId;	
	this.replacingMedia      = false;	
	this.zoomTool;
	this.imgViewer;
	this.flashMovie          = window.document.flash1;
	this.qtvrMovie           = window.document.movie1;	
	this.qtvrLoading         = false;
	
	// Array of zoom levels
	this.zoomLevels = new Array(1,.8,.6,.4,.2,.1,0);
	this.overviewZoomLevels = new Array(.6,.5,.4,.35,.3,.25,.2);
	
	// Zoom related variables and zoom title/label
	this.currentZoomLevel    = 0;
	this.zoomTitleContainer        = document.getElementById('zoomTitle');	
	this.zoomTitle                 = document.createElement('div');
	this.zoomTitle.style.height    = '20px';
	this.zoomTitle.style.width     = '112px';
	this.zoomTitle.style.position  = 'absolute';
	this.zoomTitle.style.top       = '242px';
	this.zoomTitle.style.left      = '0px';
	this.zoomTitle.style.textAlign = 'center';
	this.zoomTitle.style.display   = 'none';
	this.zoomTitleContainer.appendChild(this.zoomTitle);
	
	// Webcam related variables
	this.webcam                              = new Object();
	this.webcam.httpObj                      = this.getXmlHttpObject();
	this.webcam.currHour                     = 0;
	this.webcam.dropDown;
	this.webcam.dropDownContainer            = document.getElementById('timeOfDay');
	this.webcam.dropDownTitleContainer       = document.getElementById('timeOfDayTitle');
	this.webcamDropdownTitle                 = document.createElement('div');	
	this.webcamDropdownTitle.style.width     = '118px';
	this.webcamDropdownTitle.style.textAlign = 'center';
	this.webcamDropdownTitle.style.position  = 'absolute';
	this.webcamDropdownTitle.style.top       = '292px';
	this.webcamDropdownTitle.style.left      = '0px';
	this.webcamDropdownTitle.style.display   = 'none';
	this.webcam.dropDownTitleContainer.appendChild(this.webcamDropdownTitle);
	
	// Overview related variables
	this.miniViewContainer2d             = document.getElementById('miniView2d');	
	this.miniViewContainer               = document.getElementById('miniView');	
	this.miniView                        = document.createElement('div');	
	this.miniViewImage                   = document.createElement('img');
	this.miniViewImage.style.border      = '1px';
	this.miniViewImage.style.borderStyle = 'solid';
	this.miniViewImage.style.borderColor = '#A4814E';
	this.miniView.style.width            = '118px';
	this.miniView.style.position         = 'absolute';
	this.miniView.style.textAlign        = 'center';
	this.miniView.style.left             = '0px';
	this.miniView.style.top              = '0px';
	this.miniView.style.overflow         = 'hidden';	
	this.miniView.appendChild(this.miniViewImage);
	this.miniViewContainer.appendChild(this.miniView);
	
	this.xPosImg = 0;
	this.yPosImg = 0;
	this.overImageWidth = 100;
	this.overImageHeight = 100;
	this.viewerImageWidth = aResolution;
	this.viewerImageHeight = aResolution;
	this.viewerResolution = aResolution;
	
	// Animation related variables
	this.movieControlsContainer                        = document.getElementById('movieControls');	
	this.movieControls                                 = document.createElement('div');	
	this.movieControlsPlayImage                        = document.createElement('img');
	this.movieControlsPlayImage.src                    = '../images/viewerPlay.jpg';
	this.movieControlsPlayImage.style.marginRight      = '4px';
	this.movieControlsPlayImage.style.cursor           = 'pointer';	
	this.movieControlsPlayImage.onclick                = function(event){window.mediaViewerGlobalObj.onFlashMoviePlayClickEvent(event)};
	this.movieControlsStatusBarImage                   = document.createElement('img');
	this.movieControlsStatusBarImage.src               = '../images/viewerStatusBar.jpg';
	this.movieControlsStatusBarImage.style.marginRight = '4px';
	this.movieControlsReverseImage                     = document.createElement('img');
	this.movieControlsReverseImage.src                 = '../images/viewerReverse.jpg';
	this.movieControlsReverseImage.style.marginRight   = '4px';
	this.movieControlsReverseImage.style.cursor        = 'pointer';
	this.movieControlsReverseImage.onclick             = function(event){window.mediaViewerGlobalObj.onFlashMovieRewindClickEvent(event)};		
	this.movieControls.appendChild(this.movieControlsPlayImage);
	this.movieControls.appendChild(this.movieControlsStatusBarImage);
	this.movieControls.appendChild(this.movieControlsReverseImage);			
	this.movieControlsContainer.appendChild(this.movieControls);	
	
	// Containers for the media types
	this.qtvrMovieContainer  = document.getElementById('qtvrMovieContainer');	
	this.flashMovieContainer = document.getElementById('flashMovieContainer');	
	this.imageContainer      = document.getElementById('imageContainer')
	
	// Arrows
	this.upArrow    = document.getElementById('upArrow');
	this.leftArrow  = document.getElementById('leftArrow');
	this.rightArrow = document.getElementById('rightArrow');
	this.downArrow  = document.getElementById('downArrow');	
	
	// Browser detection
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		this.browserType = "IE";
	}else if(navigator.appName == "Opera"){
		this.browserType = "Opera";
	}else if(navigator.vendor.indexOf("Apple")!=-1){
		this.browserType = "Safari";
	}else{
		this.browserType = "Other";
	}
	
	// Loading page
	this.createLoadingScreen();
	
	// Everything is dependent on the labels, so get labels into a variable object
	this.getLabelsText();
}

MediaViewer.prototype.createLoadingScreen = function ()
{	
	this.loadingTransWhiteBox = document.createElement('div');
	this.loadingTransWhiteBox.style.zIndex = '100';
	this.loadingTransWhiteBox.style.display = 'none';
	this.loadingTransWhiteBox.style.height = '100%';
	this.loadingTransWhiteBox.style.width = '100%';
	this.loadingTransWhiteBox.style.backgroundColor = '#FFFFFF';
	this.loadingTransWhiteBox.style.position = 'absolute';
	this.loadingTransWhiteBox.style.left = 0 + 'px';
	this.loadingTransWhiteBox.style.top = 0 + 'px';
	this.loadingTransWhiteBox.style.opacity = '.5';
	this.loadingTransWhiteBox.style.filter = 'alpha(opacity=50)';
		
	this.loadingTextBox = document.createElement('div');
	this.loadingTextBox.style.zIndex = '2';
	this.loadingTextBox.style.display = 'none';
	this.loadingTextBox.style.width = 100 + '%';
	this.loadingTextBox.style.height = 50 + 'px';
	this.loadingTextBox.style.textAlign = 'center';
	this.loadingTextBox.style.position = 'relative';
	this.loadingTextBox.style.top = 45 + '%';
	this.loadingTextBox.style.backgroundColor = '#FFFFFF';
	this.loadingTextBox.style.border = 1 + 'px';
	this.loadingTextBox.style.borderColor = '#000000';
	this.loadingTextBox.style.borderStyle = 'solid';
	this.loadingTextBox.style.fontSize = 36 + 'px';
	this.loadingTextBox.style.fontWeight = 'bold';
	this.loadingTextBox.style.color = '#BF2700';
	this.loadingTextBox.id = 'loadingTextBox';
	
	if (this.languageId == 3) { this.loadingTextBox.style.direction = "rtl"; }
		
	document.getElementById('loading').appendChild(this.loadingTransWhiteBox);	
	document.getElementById('mediaContent').appendChild(this.loadingTextBox);
}
MediaViewer.prototype.createHelpBtn = function () 
{
	this.helpBtn = document.createElement('div');
	this.helpBtn.style.height = '25px';
	this.helpBtn.style.width  = '58px';
	this.helpBtn.style.textAlign = 'center';
	this.helpBtn.style.position = 'absolute';
	this.helpBtn.style.right = '35px';
	this.helpBtn.style.top = '1px';
		
	this.helpBtn.text = document.createElement('div');
	this.helpBtn.text.helpBtn = this;	 
	this.helpBtn.text.style.position = 'absolute';	
	this.helpBtn.text.style.textAlign = 'center';
	this.helpBtn.text.style.fontFamily = 'arial narrow, sans';
	this.helpBtn.text.style.fontSize = '14px';
	this.helpBtn.text.style.fontWeight = 'bold';
	this.helpBtn.text.style.left = '0px';
	this.helpBtn.text.style.top = '0px';
	this.helpBtn.text.style.width = '100%';
	this.helpBtn.text.style.color = '#FFFFFF';
	this.helpBtn.text.style.marginTop = '4px';
	this.helpBtn.text.style.textDecoration = 'none';
	this.helpBtn.text.style.zIndex = 5;	
	this.helpBtn.text.style.cursor = 'pointer';
	this.helpBtn.text.innerHTML = this.labels.text.Lhelp;
	
	this.helpBtn.shadow = document.createElement('div');
	this.helpBtn.shadow.style.position = 'absolute';	
	this.helpBtn.shadow.style.textAlign = 'center';
	this.helpBtn.shadow.style.fontFamily = 'arial narrow, sans';
	this.helpBtn.shadow.style.fontSize = '14px';
	this.helpBtn.shadow.style.fontWeight = 'bold';
	this.helpBtn.shadow.style.left = '1px';
	this.helpBtn.shadow.style.top = '1px';
	this.helpBtn.shadow.style.width = '100%';
	this.helpBtn.shadow.style.color = '#000000';
	this.helpBtn.shadow.style.marginTop = '4px';
	this.helpBtn.shadow.style.textDecoration = 'none';
	this.helpBtn.shadow.style.zIndex = 4;	
	this.helpBtn.shadow.style.cursor = 'pointer';
	this.helpBtn.shadow.innerHTML = this.labels.text.Lhelp;
	
	this.helpBtn.imageOff              = document.createElement('img');
	this.helpBtn.imageOff.helpBtnOff   = this;
	this.helpBtn.imageOff.src          = '../images/viewerHelpButton_off.jpg';
	this.helpBtn.imageOff.onload       = function(event){this.helpBtnOff.onHelpBtnOffLoadEvent(event);}
	//this.helpBtn.imageOff.onmouseover  = function(event){this.helpBtnOff.onHelpBtnOffMouseOverEvent(event)};
	this.helpBtn.imageOff.onmouseout   = function(event){this.helpBtnOff.onHelpBtnOverMouseOutEvent(event)};
	
	this.helpBtn.imageOver             = document.createElement('img');
	this.helpBtn.imageOver.helpBtnOver = this;
	this.helpBtn.imageOver.src         = '../images/viewerHelpButton_over.jpg';
	this.helpBtn.imageOver.onload      = function(event){this.helpBtnOver.onHelpBtnOverLoadEvent(event);}
	this.helpBtn.imageOver.onmouseout  = function(event){this.helpBtnOver.onHelpBtnOverMouseOutEvent(event)};
	this.helpBtn.imageOver.onclick     = function(event){this.helpBtnOver.onHelpBtnOverClickEvent(event)};
	
	this.helpBtn.imageOn               = document.createElement('img');
	this.helpBtn.imageOn.helpBtnOn     = this;
	this.helpBtn.imageOn.src           = '../images/viewerHelpButton_on.jpg';
	this.helpBtn.imageOn.onload        = function(event){this.helpBtnOn.onHelpBtnOnLoadEvent(event);}
	
	this.helpBtn.text.onmouseover  = function(event){this.helpBtn.onHelpBtnOffMouseOverEvent(event)};
	this.helpBtn.text.onclick      = function(event){this.helpBtn.onHelpBtnOverClickEvent(event)};
	this.helpBtn.text.onmouseout   = function(event){this.helpBtn.onHelpBtnOverMouseOutEvent(event)};
			
} // end createHelpBtn

MediaViewer.prototype.onHelpBtnOffLoadEvent = function (evt)
{
	this.helpBtn.imageOff.alt = this.labels.text.Lhelp;
	this.helpBtn.imageOff.style.position = 'absolute';
	this.helpBtn.imageOff.style.top = 0 + 'px';
	this.helpBtn.imageOff.style.left = 0 + 'px';
	this.helpBtn.imageOff.style.zIndex = 3;
	this.helpBtn.imageOff.style.cursor = 'pointer';
	
	// Append the image button to the container div
	this.helpBtn.appendChild(this.helpBtn.imageOff);
	
	// Append the text to the container div already with button image
	this.helpBtn.appendChild(this.helpBtn.text);
	this.helpBtn.appendChild(this.helpBtn.shadow);
	
	// Append the Container to the html div element with the button and text
	document.getElementById('help').appendChild(this.helpBtn);
	
} // end onHelpBtnOffLoadEvent

MediaViewer.prototype.onHelpBtnOffMouseOverEvent = function (evt)
{
	this.helpBtn.imageOff.style.zIndex = 2;
	this.helpBtn.imageOver.style.zIndex = 3;
	this.helpBtn.imageOn.style.zIndex = 1;	
	
} // end onHelpBtnOffMouseOverEvent

MediaViewer.prototype.onHelpBtnOverLoadEvent = function (evt)
{
	this.helpBtn.imageOver.alt = this.labels.text.Lhelp;
	this.helpBtn.imageOver.style.position = 'absolute';
	this.helpBtn.imageOver.style.top = 0 + 'px';
	this.helpBtn.imageOver.style.left = 0 + 'px';
	this.helpBtn.imageOver.style.zIndex = 2;
	this.helpBtn.imageOver.style.cursor = 'pointer';
	this.helpBtn.appendChild(this.helpBtn.imageOver);
		
} // end onHelpBtnOverLoadEvent

MediaViewer.prototype.onHelpBtnOverMouseOutEvent = function (evt)
{
	this.helpBtn.imageOff.style.zIndex = 3;
	this.helpBtn.imageOver.style.zIndex = 2;
	this.helpBtn.imageOn.style.zIndex = 1;
	
} // end onHelpBtnOverMouseOutEvent

MediaViewer.prototype.onHelpBtnOverClickEvent = function (evt)
{
	this.helpBtn.imageOff.style.zIndex = 2;
	this.helpBtn.imageOver.style.zIndex = 1;
	this.helpBtn.imageOn.style.zIndex = 3;
	openNamedWindow('help','http://www.eternalegypt.org/EternalEgyptWebsiteWeb/HomeServlet?ee_website_action_key=action.display.help&language_id='+this.languageId+'&help_page=c_image_viewer',550,450,150,150,'no');

} // end onHelpBtnOverClickEvent

MediaViewer.prototype.onHelpBtnOnLoadEvent = function (evt)
{
	this.helpBtn.imageOn.alt = this.labels.text.Lhelp;
	this.helpBtn.imageOn.style.position = 'absolute';
	this.helpBtn.imageOn.style.top = 0 + 'px';
	this.helpBtn.imageOn.style.left = 0 + 'px';
	this.helpBtn.imageOn.style.zIndex = 1;
	this.helpBtn.imageOn.style.cursor = 'pointer';
	this.helpBtn.appendChild(this.helpBtn.imageOn);	
	
} // end onHelpBtnOnLoadEvent

MediaViewer.prototype.createMapBtn = function () 
{
	this.mapBtn = document.createElement('div');
	this.mapBtn.style.width     = 118 + 'px';
	this.mapBtn.style.textAlign = 'center';
	this.mapBtn.style.position  = 'absolute';
	this.mapBtn.style.right     = 0 + 'px';
	this.mapBtn.style.top       = 325 + 'px';
	
	this.mapBtn.text                      = document.createElement('div');
	this.mapBtn.text.mapBtn               = this;	 
	this.mapBtn.text.style.position       = 'absolute';	
	this.mapBtn.text.style.textAlign      = 'center';
	this.mapBtn.text.style.fontFamily     = 'arial narrow, sans';
	this.mapBtn.text.style.fontSize       = '14px';
	this.mapBtn.text.style.fontWeight     = 'bold';
	this.mapBtn.text.style.left           = 0 + 'px';
	this.mapBtn.text.style.top            = 0 + 'px';
	this.mapBtn.text.style.width          = 78 + 'px';
	this.mapBtn.text.style.color          = '#FFFFFF';
	this.mapBtn.text.style.marginLeft     = 22 + 'px';
	this.mapBtn.text.style.marginRight    = 22 + 'px';
	this.mapBtn.text.style.marginTop      = 4 + 'px';
	this.mapBtn.text.style.textDecoration = 'none';
	this.mapBtn.text.style.zIndex         = 5;	
	this.mapBtn.text.style.cursor         = 'pointer';
	this.mapBtn.text.innerHTML            = this.labels.text.Lmap;
	
	this.mapBtn.shadow                      = document.createElement('div');
	this.mapBtn.shadow.style.position       = 'absolute';	
	this.mapBtn.shadow.style.textAlign      = 'center';
	this.mapBtn.shadow.style.fontFamily     = 'arial narrow, sans';
	this.mapBtn.shadow.style.fontSize       = '14px';
	this.mapBtn.shadow.style.fontWeight     = 'bold';
	this.mapBtn.shadow.style.left           = 1 + 'px';
	this.mapBtn.shadow.style.top            = 1 + 'px';
	this.mapBtn.shadow.style.width          = 78 + 'px';
	this.mapBtn.shadow.style.color          = '#000000';
	this.mapBtn.shadow.style.marginLeft     = 22 + 'px';
	this.mapBtn.shadow.style.marginRight    = 22 + 'px';
	this.mapBtn.shadow.style.marginTop      = 4 + 'px';
	this.mapBtn.shadow.style.textDecoration = 'none';
	this.mapBtn.shadow.style.zIndex         = 4;	
	this.mapBtn.shadow.style.cursor         = 'pointer';
	this.mapBtn.shadow.innerHTML            = this.labels.text.Lmap;
			
	this.mapBtn.imageOff                   = document.createElement('img');
	this.mapBtn.imageOff.mapBtnOff         = this;
	this.mapBtn.imageOff.src               = '../images/viewerButton_off.jpg';
	this.mapBtn.imageOff.style.width       = 83 + 'px';
	this.mapBtn.imageOff.alt               = this.labels.text.Lmap;
	this.mapBtn.imageOff.style.position    = 'absolute';
	this.mapBtn.imageOff.style.top         = 0 + 'px';
	this.mapBtn.imageOff.style.left        = 0 + 'px';
	this.mapBtn.imageOff.style.marginLeft  = 20 + 'px';
	this.mapBtn.imageOff.style.marginRight = 20 + 'px';
	this.mapBtn.imageOff.style.zIndex      = 3;
	this.mapBtn.imageOff.style.cursor      = 'pointer';
	this.mapBtn.appendChild(this.mapBtn.imageOff);	
	this.mapBtn.appendChild(this.mapBtn.text);
	this.mapBtn.appendChild(this.mapBtn.shadow);
	document.getElementById('mapBtn').appendChild(this.mapBtn);	
	
	this.mapBtn.imageOff.onload       = function(event){this.mapBtnOff.onMapBtnOffLoadEvent(event);}
	//this.mapBtn.imageOff.onmouseover  = function(event){this.mapBtnOff.onMapBtnOffMouseOverEvent(event)};
	this.mapBtn.imageOff.onmouseout   = function(event){this.mapBtnOff.onMapBtnOverMouseOutEvent(event)};
	
	this.mapBtn.imageOver             = document.createElement('img');
	this.mapBtn.imageOver.mapBtnOver  = this;
	this.mapBtn.imageOver.style.width = 83 + 'px';
	this.mapBtn.imageOver.src         = '../images/viewerButton_over.jpg';
	this.mapBtn.imageOver.onload      = function(event){this.mapBtnOver.onMapBtnOverLoadEvent(event);}
	this.mapBtn.imageOver.onmouseout  = function(event){this.mapBtnOver.onMapBtnOverMouseOutEvent(event)};
	this.mapBtn.imageOver.onmousedown = function(event){this.mapBtnOver.onMapBtnOverClickEvent(event)};
	
	this.mapBtn.imageOn               = document.createElement('img');
	this.mapBtn.imageOn.mapBtnOn      = this;
	this.mapBtn.imageOn.style.width   = 83 + 'px';
	this.mapBtn.imageOn.src           = '../images/viewerButton_on.jpg';
	this.mapBtn.imageOn.onload        = function(event){this.mapBtnOn.onMapBtnOnLoadEvent(event);}
	
	this.mapBtn.text.onmouseover      = function(event){this.mapBtn.onMapBtnOffMouseOverEvent(event)};
	this.mapBtn.text.onmousedown      = function(event){this.mapBtn.onMapBtnOverClickEvent(event)};
	this.mapBtn.text.onmouseout       = function(event){this.mapBtn.onMapBtnOverMouseOutEvent(event)};

} // end createMapBtn

MediaViewer.prototype.onMapBtnOffLoadEvent = function (evt)
{
	this.mapBtn.imageOff.alt = this.labels.text.Lmap;
	this.mapBtn.imageOff.style.position = 'absolute';
	this.mapBtn.imageOff.style.top = 0 + 'px';
	this.mapBtn.imageOff.style.left = 0 + 'px';
	this.mapBtn.imageOff.style.marginLeft = 20 + 'px';
	this.mapBtn.imageOff.style.marginRight = 20 + 'px';
	this.mapBtn.imageOff.style.zIndex = 3;
	this.mapBtn.imageOff.style.cursor = 'pointer';
	this.mapBtn.appendChild(this.mapBtn.imageOff);	
	this.mapBtn.appendChild(this.mapBtn.text);
	this.mapBtn.appendChild(this.mapBtn.shadow);
	document.getElementById('mapBtn').appendChild(this.mapBtn);	
	
} // end onMapBtnOffLoadEvent

MediaViewer.prototype.onMapBtnOffMouseOverEvent = function (evt)
{
	this.mapBtn.imageOff.style.zIndex = 2;
	this.mapBtn.imageOver.style.zIndex = 3;
	this.mapBtn.imageOn.style.zIndex = 1;	
	
} // end onMapBtnOffMouseOverEvent

MediaViewer.prototype.onMapBtnOverLoadEvent = function (evt)
{
	this.mapBtn.imageOver.alt = this.labels.text.Lmap;
	this.mapBtn.imageOver.style.position = 'absolute';
	this.mapBtn.imageOver.style.top = 0 + 'px';
	this.mapBtn.imageOver.style.left = 0 + 'px';
	this.mapBtn.imageOver.style.marginLeft = 20 + 'px';
	this.mapBtn.imageOver.style.marginRight = 20 + 'px';
	this.mapBtn.imageOver.style.zIndex = 2;
	this.mapBtn.imageOver.style.cursor = 'pointer';
	this.mapBtn.appendChild(this.mapBtn.imageOver);	
	
} // end onMapBtnOverLoadEvent

MediaViewer.prototype.onMapBtnOverMouseOutEvent = function (evt)
{
	this.mapBtn.imageOff.style.zIndex = 3;
	this.mapBtn.imageOver.style.zIndex = 2;
	this.mapBtn.imageOn.style.zIndex = 1;
	
} // onMapBtnOverMouseOutEvent

MediaViewer.prototype.onMapBtnOverClickEvent = function (evt)
{
	this.mapBtn.imageOff.style.zIndex = 2;
	this.mapBtn.imageOver.style.zIndex = 1;
	this.mapBtn.imageOn.style.zIndex = 3;
	
	eval(this.mapBtn.link);
	
} // end onMapBtnOverClickEvent

MediaViewer.prototype.onMapBtnOnLoadEvent = function (evt)
{
	this.mapBtn.imageOn.alt = this.labels.text.Lmap;
	this.mapBtn.imageOn.style.position = 'absolute';
	this.mapBtn.imageOn.style.top = 0 + 'px';
	this.mapBtn.imageOn.style.left = 0 + 'px';
	this.mapBtn.imageOn.style.marginLeft = 20 + 'px';
	this.mapBtn.imageOn.style.marginRight = 20 + 'px';
	this.mapBtn.imageOn.style.zIndex = 1;
	this.mapBtn.imageOn.style.cursor = 'pointer';
	this.mapBtn.appendChild(this.mapBtn.imageOn);	
	
} // end onMapBtnOnLoadEvent

MediaViewer.prototype.onFlashMoviePlayClickEvent = function (evt)
{
    this.flashMovie.Play();
    
} // end onFlashMoviePlayClickEvent

MediaViewer.prototype.onFlashMovieRewindClickEvent = function (evt)
{
	this.flashMovie.Rewind();
	
} // end onFlashMovieRewindClickEvent

MediaViewer.prototype.createResetBtn = function () 
{
	this.resetBtn                 = document.createElement('div');
	this.resetBtn.style.width     = 118 + 'px';
	this.resetBtn.style.textAlign = 'center';
	this.resetBtn.style.position  = 'absolute';
	this.resetBtn.style.right     = 0 + 'px';
	this.resetBtn.style.top       = 360 + 'px';
	this.resetBtn.link            = '';
	
	this.resetBtn.text                      = document.createElement('div');
	this.resetBtn.text.resetBtn             = this;	 
	this.resetBtn.text.style.position       = 'absolute';	
	this.resetBtn.text.style.textAlign      = 'center';	
	this.resetBtn.text.style.fontFamily     = 'arial narrow, sans';
	this.resetBtn.text.style.fontSize       = '14px';
	this.resetBtn.text.style.fontWeight     = 'bold';
	this.resetBtn.text.style.left           = 0 + 'px';
	this.resetBtn.text.style.top            = 0 + 'px';
	this.resetBtn.text.style.width          = 78 + 'px';
	this.resetBtn.text.style.color          = '#FFFFFF';
	this.resetBtn.text.style.marginLeft     = 22 + 'px';
	this.resetBtn.text.style.marginRight    = 22 + 'px';
	this.resetBtn.text.style.marginTop      = 4 + 'px';
	this.resetBtn.text.style.textDecoration = 'none';
	this.resetBtn.text.style.zIndex         = 5;	
	this.resetBtn.text.style.cursor         = 'pointer';
	this.resetBtn.text.innerHTML            = this.labels.text.Lreset;
	
	this.resetBtn.shadow                      = document.createElement('div'); 
	this.resetBtn.shadow.style.position       = 'absolute';	
	this.resetBtn.shadow.style.textAlign      = 'center';	
	this.resetBtn.shadow.style.fontFamily     = 'arial narrow, sans';
	this.resetBtn.shadow.style.fontSize       = '14px';
	this.resetBtn.shadow.style.fontWeight     = 'bold';
	this.resetBtn.shadow.style.left           = 1 + 'px';
	this.resetBtn.shadow.style.top            = 1 + 'px';
	this.resetBtn.shadow.style.width          = 78 + 'px';
	this.resetBtn.shadow.style.color          = '#000000';
	this.resetBtn.shadow.style.marginLeft     = 22 + 'px';
	this.resetBtn.shadow.style.marginRight    = 22 + 'px';
	this.resetBtn.shadow.style.marginTop      = 4 + 'px';
	this.resetBtn.shadow.style.textDecoration = 'none';
	this.resetBtn.shadow.style.zIndex         = 4;	
	this.resetBtn.shadow.style.cursor         = 'pointer';
	this.resetBtn.shadow.innerHTML            = this.labels.text.Lreset;
			
	this.resetBtn.imageOff               = document.createElement('img');
	this.resetBtn.imageOff.resetBtnOff   = this;
	this.resetBtn.imageOff.style.width   = 83 + 'px';
	this.resetBtn.imageOff.src           = '../images/viewerButton_off.jpg';
	this.resetBtn.imageOff.onload        = function(event){this.resetBtnOff.onResetBtnOffLoadEvent(event);}
	//this.resetBtn.imageOff.onmouseover   = function(event){this.resetBtnOff.onResetBtnOffMouseOverEvent(event)};
	this.resetBtn.imageOff.onmouseout    = function(event){this.resetBtnOff.onResetBtnOverMouseOutEvent(event)};
		
	this.resetBtn.imageOver              = document.createElement('img');
	this.resetBtn.imageOver.resetBtnOver = this;
	this.resetBtn.imageOver.style.width  = 83 + 'px';
	this.resetBtn.imageOver.src          = '../images/viewerButton_over.jpg';
	this.resetBtn.imageOver.onload       = function(event){this.resetBtnOver.onResetBtnOverLoadEvent(event);}
	this.resetBtn.imageOver.onmouseout   = function(event){this.resetBtnOver.onResetBtnOverMouseOutEvent(event)};
	this.resetBtn.imageOver.onclick      = function(event){this.resetBtnOver.onResetBtnOverClickEvent(event)};
	
	this.resetBtn.imageOn                = document.createElement('img');
	this.resetBtn.imageOn.resetBtnOn     = this;
	this.resetBtn.imageOn.style.width    = 83 + 'px';
	this.resetBtn.imageOn.src            = '../images/viewerButton_on.jpg';
	this.resetBtn.imageOn.onload         = function(event){this.resetBtnOn.onResetBtnOnLoadEvent(event);}
	
	this.resetBtn.text.onmouseover       = function(event){this.resetBtn.onResetBtnOffMouseOverEvent(event)};
	this.resetBtn.text.onclick           = function(event){this.resetBtn.onResetBtnOverClickEvent(event)};
	this.resetBtn.text.onmouseout        = function(event){this.resetBtn.onResetBtnOverMouseOutEvent(event)};

} // end createResetBtn

MediaViewer.prototype.onResetBtnOffLoadEvent = function (evt)
{
	this.resetBtn.imageOff.alt = this.labels.text.Lreset;
	this.resetBtn.imageOff.style.position = 'absolute';
	this.resetBtn.imageOff.style.top = 0 + 'px';
	this.resetBtn.imageOff.style.left = 0 + 'px';
	this.resetBtn.imageOff.style.marginLeft = 20 + 'px';
	this.resetBtn.imageOff.style.marginRight = 20 + 'px';
	this.resetBtn.imageOff.style.zIndex = 3;
	this.resetBtn.imageOff.style.cursor = 'pointer';
	this.resetBtn.appendChild(this.resetBtn.imageOff);	
	this.resetBtn.appendChild(this.resetBtn.text);
	this.resetBtn.appendChild(this.resetBtn.shadow);
	document.getElementById('resetBtn').appendChild(this.resetBtn);	

} //  end onResetBtnOffLoadEvent

MediaViewer.prototype.onResetBtnOffMouseOverEvent = function (evt)
{
	this.resetBtn.imageOff.style.zIndex = 2;
	this.resetBtn.imageOver.style.zIndex = 3;
	this.resetBtn.imageOn.style.zIndex = 1;	
	
} // end onResetBtnOffMouseOverEvent

MediaViewer.prototype.onResetBtnOverLoadEvent = function (evt)
{
	this.resetBtn.imageOver.alt = this.labels.text.Lreset;
	this.resetBtn.imageOver.style.position = 'absolute';
	this.resetBtn.imageOver.style.top = 0 + 'px';
	this.resetBtn.imageOver.style.left = 0 + 'px';
	this.resetBtn.imageOver.style.marginLeft = 20 + 'px';
	this.resetBtn.imageOver.style.marginRight = 20 + 'px';
	this.resetBtn.imageOver.style.zIndex = 2;
	this.resetBtn.imageOver.style.cursor = 'pointer';
	this.resetBtn.appendChild(this.resetBtn.imageOver);	
	
} // end onResetBtnOverLoadEvent

MediaViewer.prototype.onResetBtnOverMouseOutEvent = function (evt)
{
	this.resetBtn.imageOff.style.zIndex = 3;
	this.resetBtn.imageOver.style.zIndex = 2;
	this.resetBtn.imageOn.style.zIndex = 1;
	
} // end onResetBtnOverMouseOutEvent

MediaViewer.prototype.onResetBtnOverClickEvent = function (evt)
{
	this.resetBtn.imageOff.style.zIndex = 2;
	this.resetBtn.imageOver.style.zIndex = 1;
	this.resetBtn.imageOn.style.zIndex = 3;
	
	eval(this.resetBtn.link);
		
} // end onResetBtnOverClickEvent

MediaViewer.prototype.onResetBtnOnLoadEvent = function (evt)
{
	this.resetBtn.imageOn.alt = this.labels.text.Lreset;
	this.resetBtn.imageOn.style.position = 'absolute';
	this.resetBtn.imageOn.style.top = 0 + 'px';
	this.resetBtn.imageOn.style.left = 0 + 'px';
	this.resetBtn.imageOn.style.marginLeft = 20 + 'px';
	this.resetBtn.imageOn.style.marginRight = 20 + 'px';
	this.resetBtn.imageOn.style.zIndex = 1;
	this.resetBtn.imageOn.style.cursor = 'pointer';
	this.resetBtn.appendChild(this.resetBtn.imageOn);	
	
} // end onResetBtnOnLoadEvent

MediaViewer.prototype.changeTimeInHistory = function (aMap, aNodeId)
{
	var myFov = this.qtvrMovie.GetFieldOfView();
	var myPan = this.qtvrMovie.GetPanAngle();
	var myTilt = this.qtvrMovie.GetTiltAngle();
	
	this.showVirtEnv(aMap, aNodeId, myFov, myPan, myTilt);
	
} // end changeTimeInHistory

MediaViewer.prototype.isMovieLoaded = function (aMap, aNodeId, aFov, aPan, aTilt)
{
	var myStatus;
	myStatus = this.qtvrMovie.GetPluginStatus();
			
	if (myStatus == 'Complete')
	{ 	
		this.qtvrLoading = false;
		clearInterval(this.virtEnv.hotspotIntervalId);
		
		// Only for virtual env
		if (this.elementMode == 6)
		{
			// set hotspots on the movie to allow walking throught the environment
			var hotspots = this.virtEnv.maps[aMap].nodes[aNodeId].hotspots;
			for (h = 0; h < hotspots.length; h++)
			{	
				try {
					this.qtvrMovie.SetHotspotUrl(hotspots[h].hotspotId,'javascript:window.mediaViewerGlobalObj.showVirtEnv("' + aMap + '",' + hotspots[h].linkId + ','+hotspots[h].fov+','+hotspots[h].pan+','+hotspots[h].tilt+')');
				} catch (e4) {			
					alert('Error setting hotspot links');
				}	
			}
			// For initial load, show default field of view, pan, and tilt
			if (aFov == -9) 
			{
				try{
					this.qtvrMovie.ShowDefaultView();				
				} catch (e3) {
					// catch
				}
			}
			else
			{	
				this.qtvrMovie.SetPanAngle(aPan);
				this.qtvrMovie.SetTiltAngle(aTilt);
			}
			// Fix for Firefox on Mac to reload movie upon click on map
			if (aFov == -8) {
				this.qtvrMovie.SetURL(this.mediaFolder + "dswmedia/" + this.virtEnv.maps[aMap].nodes[aNodeId].src);
			}	
		} else if (this.elementMode == 4 || this.elementMode == 5) {
		
			this.qtvrMovie.SetURL(this.mediaFolder + this.elementName + '_1_' + this.languageId + '_' + this.resolution + '.mov');		
		}
		
		// Create and show zoom control
		this.showZoom();
		this.replacingMedia = false;
		
		// Set size of the media object to the appropriate resolution
		this.qtvrMovie.width = this.resolution;
		this.qtvrMovie.height = this.resolution;
		
		if (this.elementMode == 3 || this.elementMode == 5 || this.elementMode == 6)
		{
			this.overViewIntervalId = setInterval("window.mediaViewerGlobalObj.syncOverview()", 1200);
		}
		this.loadMiniView();
		
		this.loading('hide');			
	}	
} // end isMovieLoaded

MediaViewer.prototype.showTimelineDropDown = function (anXmlFilesContents)
{		
	var myTimelines = this.virtEnv.maps[this.virtEnv.currentQtvrMap].timelines;
	
	// only show the dropdown object if there is more than one map/timeline
	if (myTimelines.length > 1 ) 
	{
		var myMapNameLength = this.virtEnv.currentQtvrMap.length -1;
		var myMapName;					
		
		myMapName = this.virtEnv.currentQtvrMap.slice(0, myMapNameLength);
		
		if (this.virtEnv.dropDown == null)
		{	
			// init and add items to dropdown
			this.virtEnv.dropDown = new DropDown(118, 22, '../images/', 'timeInHistory', this.languageId);
			for ( i = 0; i < myTimelines.length; i++ )
			{		
				this.virtEnv.dropDown.addItem("javascript:window.mediaViewerGlobalObj.changeTimeInHistory('" + myMapName + myTimelines[i] + "', window.mediaViewerGlobalObj.virtEnv.maps['" + myMapName + myTimelines[i] + "'].nodes[" + this.virtEnv.currentQtvrMapNode + "].id);",this.virtEnv.timelines.timelineText[myMapName][myTimelines[i]][this.languageId]);
				if ( this.virtEnv.currentQtvrMap == myMapName + myTimelines[i] ) 
				{ 
					this.virtEnv.dropDown.selectedIndex = i; 
					this.virtEnv.currentQtvrTimeline = myTimelines[i];
				}			
			}		
		}
		else
		{			
			for ( i = 0; i < myTimelines.length; i++ )
			{	
				// update items in dropdown
				this.virtEnv.dropDown.updateItem(i, "javascript:window.mediaViewerGlobalObj.changeTimeInHistory('" + myMapName + myTimelines[i] + "', window.mediaViewerGlobalObj.virtEnv.maps['" + myMapName + myTimelines[i] + "'].nodes[" + this.virtEnv.currentQtvrMapNode + "].id);",this.virtEnv.timelines.timelineText[myMapName][myTimelines[i]][this.languageId]);
				if ( this.virtEnv.currentQtvrMap == myMapName + myTimelines[i] ) 
				{
					this.virtEnv.dropDown.selectedIndex = i;
					this.virtEnv.dropDown.updateSelectedItemTitle();					
					this.virtEnv.currentQtvrTimeline = myTimelines[i];					
				}			
			}		
		}		
		this.virtEnv.dropDown.appendElement();
	}
	
	// Update overview image with the corrent map/timeline and node
	if (this.virtEnv.currentQtvrTimeline != '')
	{
		this.miniViewImage.src = this.mediaFolder + this.elementName + '_2_' + this.languageId + '_Node' + this.virtEnv.currentQtvrMapNode + '_' + this.virtEnv.currentQtvrTimeline + '.jpg';
	}
	else
	{
		this.miniViewImage.src = this.mediaFolder + this.elementName + '_2_' + this.languageId + '_Node' + this.virtEnv.currentQtvrMapNode + '.jpg';
	}
	
	// update map button link
	this.mapBtn.link = "this.showQtvrMap('" + this.elementName + this.virtEnv.currentQtvrTimeline + "Map');";
	
} // end showTimelineDropDown

MediaViewer.prototype.onTimelinesLoadEvent = function (evt)
{	
	// if ready
	if (this.virtEnv.timelines.httpObj.readyState==4) 
	{
		// if ready and successful
		if (this.virtEnv.timelines.httpObj.status==200)
		{   			
			var myTimelineTextObj = new Object();
				var maps = this.virtEnv.timelines.httpObj.responseXML.documentElement.getElementsByTagName('MAP'); 	
				
			for (j = 0; j < maps.length; j++)
			{	
				var mapTimeline = new Object();
						
				mapId = maps[j].getAttribute('id');					
				var timelines = maps[j].getElementsByTagName('TIMELINE');
				for (i = 0; i < timelines.length; i++)
				{
					var myTimeline = new Object();
						
					var timelineId = timelines[i].getAttribute('id');
					var languages = timelines[i].getElementsByTagName('Language');
					for (h = 0; h < languages.length; h++)
					{							
						var languageId = languages[h].getAttribute('id');
						var languageText = languages[h].getAttribute('text');	
						myTimeline[languageId] = languageText;					
					}		
					mapTimeline[timelineId] = myTimeline;
				}
				myTimelineTextObj[mapId] = mapTimeline;
			}	
			this.virtEnv.timelines.timelineText = myTimelineTextObj;
			
			// show the dropdown object	
			this.showTimelineDropDown();	
		}
		else
		{
			alert('Error retrieving virtual environment timelines configuration file');
		}
	}
} // end onTimelinesLoadEvent

MediaViewer.prototype.getTimelineText = function ()
{	
	//changed by mriad to remove js errors from test servers (isis , preview)
	//NB  timelinetext.xml must be copied from production to local servers

	//var myTimelineTextFile = this.mediaFolder + '/dswmedia/timelinetext.xml';
	var myTimelineTextFile = this.labelsFolder + '../images/elements/dswmedia/timelinetext.xml';

	this.virtEnv.timelines.httpObj.open("GET", myTimelineTextFile, true);
	this.virtEnv.timelines.httpObj.onreadystatechange=function(event){window.mediaViewerGlobalObj.onTimelinesLoadEvent(event);}
	this.virtEnv.timelines.httpObj.send(null);	
		
} // getTimelineText

MediaViewer.prototype.showVirtEnv = function (aMap, aNodeId, aFov, aPan, aTilt)
{
	// only try to load another movie if there isn't one already loading (avoid infinite loop effect)
	if (this.qtvrLoading == false)
	{
		this.loading('show');
		this.qtvrMovie.SetResetPropertiesOnReload(false);
		
		// hide non QTVR media objects off the screen
		this.flashMovieContainer.style.left = -3000 + 'px';
		this.qtvrMovieContainer.style.left = 0 + 'px';
		this.imageContainer.style.left = -2000 + 'px';
		
		// show/hide elements
		this.upArrow.style.display = '';
		this.leftArrow.style.display = '';
		this.rightArrow.style.display = '';
		this.downArrow.style.display = '';
		this.movieControlsContainer.style.display = 'none';				
		this.mapBtn.style.display = '';
		this.resetBtn.style.display = '';
		this.zoomTitle.style.display = '';
		this.miniViewContainer.style.display = '';
		this.virtEnv.dropDownContainer.style.display = '';
		
		// init ZoomTool with level 1
		this.currentZoomLevel = 1;	
		this.resetBtn.link = 'this.showVirtEnv(this.virtEnv.currentQtvrMap, this.virtEnv.currentQtvrMapNode, -9, '+aPan+', '+aTilt+');';
		
		// set current map (timeline)
		this.virtEnv.currentQtvrMap     = aMap;
		// Set current node (location within the environment)
		this.virtEnv.currentQtvrMapNode = aNodeId;	
	
		// load movie
		this.qtvrMovie.SetURL(this.mediaFolder + "dswmedia/" + this.virtEnv.maps[aMap].nodes[aNodeId].src);	
		this.qtvrLoading = true;
		
		// loop until loaded
		this.virtEnv.hotspotIntervalId = setInterval("window.mediaViewerGlobalObj.isMovieLoaded('" + this.virtEnv.currentQtvrMap + "', " + this.virtEnv.currentQtvrMapNode + ", " + aFov + ", " + aPan + ", " + aTilt + ")", 50);		
		
		// get config file for dropdown and show
		this.getTimelineText();	
	}			
	
} // end showVirtEnv

MediaViewer.prototype.setVirtEnv = function ()
{
	var maps;
	var mapId;
	var nodes;
	var timelines;
	var nodesMap;
	var myMapObj;
	var myQtvrNode;
	var myStartPos;
	var hotspots;
	var hotspotArray;
	var mySwing;
	var hotspot;
	var qtvrMapObjects = new Object();
			
	maps = this.virtEnv.httpObj.responseXML.documentElement.getElementsByTagName('MAP');
	for (j = 0; j < maps.length; j++)
	{		
		mapId     = maps[j].getAttribute('id');
		timelines = maps[j].getAttribute('timelines').split(',');
																	
		myMapObj = new Object();
		myMapObj.id = mapId;
		myMapObj.timelines = timelines;
							
		nodesMap = new Object();
		nodes = maps[j].getElementsByTagName('NODE');	
		
		if (this.virtEnv.currentQtvrMap == null)
		{
			this.virtEnv.currentQtvrMap = mapId;
			this.virtEnv.currentQtvrMapNode = nodes[0].getAttribute('id');
		}		
						
		for (i = 0; i < nodes.length; i++)
		{
			nodeId = nodes[i].getAttribute('id');
													
			myQtvrNode = new Object();
			myQtvrNode.id = nodeId;
			myQtvrNode.width = this.resolution;
			myQtvrNode.height = this.resolution;
			myQtvrNode.src = mapId + "_Node" + nodeId + "_" + this.resolution + ".mov";			
			myQtvrNode.type = 'video/quicktime';
			myQtvrNode.pluginspage = 'http://www.apple.com/quicktime/download/';
			myQtvrNode.autoplay = 'true';
			myQtvrNode.controller = 'false';
			myQtvrNode.codebase = 'http://www.apple.com/qtactivex/qtplugin.cab';			
			myQtvrNode.startPos = parseSwing(nodes[i].getElementsByTagName('Info')[0].getAttribute('startPos'));
						
			hotspots = nodes[i].getElementsByTagName('HOTSPOTS')[0].getElementsByTagName('info');
			
			hotspotArray = new Array(hotspots.length);			
			for (h = 0; h < hotspots.length; h++)
			{									
				mySwing = parseSwing(hotspots[h].getAttribute('swing'));
							
				hotspot           = new Object();
				hotspot.hotspotId = hotspots[h].getAttribute('hotspotid');
				hotspot.linkId    = hotspots[h].getAttribute('linkid');
				hotspot.fov       = mySwing.fov;
				hotspot.pan       = mySwing.pan;
				hotspot.tilt      = mySwing.tilt;
							
				hotspotArray[h] = hotspot;
			}						
			myQtvrNode.hotspots = hotspotArray;
			nodesMap[nodeId]=myQtvrNode;		
		}					
		myMapObj.nodes = nodesMap;
		qtvrMapObjects[mapId] = myMapObj;					
	}		
	this.virtEnv.maps = qtvrMapObjects;
	
	// Load movie
	this.showVirtEnv(this.virtEnv.currentQtvrMap, this.virtEnv.currentQtvrMapNode, -9, -9, -9);
	
} // end setVirtEnv

MediaViewer.prototype.onVirtEnvLoadEvent = function (evt)
{	
	if (this.virtEnv.httpObj.readyState==4) 
	{
		if (this.virtEnv.httpObj.status==200)
		{   
			// set variable with contents of xml
			this.setVirtEnv();
		}
	}
} // end onVirtEnvLoadEvent

MediaViewer.prototype.getVirtEnvXml = function ()
{
	
	myVirtEnvFile = this.configFolder + '../EternalEgyptWebsiteWeb/' + this.elementName + '.xml';

	this.virtEnv.httpObj.open("GET", myVirtEnvFile, true);
	this.virtEnv.httpObj.onreadystatechange=function(event){window.mediaViewerGlobalObj.onVirtEnvLoadEvent(event);}
	this.virtEnv.httpObj.send(null);

} // end getVirtEnvXml

MediaViewer.prototype.show360View = function ()
{
	this.loading('show');
	
	// Hide media objects which are not QTVR
	this.flashMovieContainer.style.left = -3000 + 'px';
	this.qtvrMovieContainer.style.left = 0 + 'px';
	this.imageContainer.style.left = -2000 + 'px';
	
	// instantiate ZoomTool at this level
	this.currentZoomLevel = 2;
	this.miniViewImage.src = this.mediaFolder + this.elementName + '_2_' + this.languageId + '.jpg';			
	this.virtEnv.qtvrDefaultView = true;
	
	// update reset button link
	this.resetBtn.link = 'this.show360View();';
	
	// load movie
	this.qtvrMovie.SetURL(this.mediaFolder + this.elementName + '_1_' + this.languageId + '_' + this.resolution + '.mov');
	
	// loop until loaded
	this.virtEnv.hotspotIntervalId = setInterval("window.mediaViewerGlobalObj.isMovieLoaded()", 50);		
	
} // end show360View

MediaViewer.prototype.show3dView = function ()
{	
	this.loading('show');
	
	this.qtvrMovie.SetResetPropertiesOnReload(false);
	
	// Hide media objects which are not QTVR
	this.flashMovieContainer.style.left = -3000 + 'px';
	this.imageContainer.style.left = -2000 + 'px';
	this.qtvrMovieContainer.style.left = 0 + 'px';

	// load movie
	this.qtvrMovie.SetURL(this.mediaFolder + this.elementName + '_1_' + this.languageId + '_' + this.resolution + '.mov');

	// set init zoom level, and show default view
	this.currentZoomLevel = 0;	
	this.virtEnv.qtvrDefaultView = true;
	
	// loop until loaded
	this.virtEnv.hotspotIntervalId = setInterval("window.mediaViewerGlobalObj.isMovieLoaded()", 50);	
	
	// set reset button
	this.resetBtn.link = 'this.show3dView();';	

} // end show3dView

MediaViewer.prototype.displayWebcamDropdown = function ()
{
	var hour;
	var str;
	
	if (this.webcam.dropDown == null)
	{
		// instantiate a new DropDown instance
		this.webcam.dropDown = new DropDown(118, 22, '../images/', 'timeOfDay', this.languageId);
		
		// add 24 items to the drop down
		for ( var i = 0; i < 24; i++ )
		{						
			str = new String(i);
			if (str.length == 1) {hour = "0" + str;} else {hour = str;}
		
			if ( this.webcam.currHour == i ) { this.webcam.dropDown.selectedIndex = i; }	
			this.webcam.dropDown.addItem("javascript:window.mediaViewerGlobalObj.displayWebcam('" + hour + "')", hour + ':00 GMT');
		}	
	}
	else
	{	// Update items in dropdown, this is to avoid reloading/reinstantiating the drop down
		for ( var i = 0; i < 24; i++ )
		{						
			str = new String(i);
			if (str.length == 1) {hour = "0" + str;} else {hour = str;}
		
			if ( this.webcam.currHour == i ) { this.webcam.dropDown.selectedIndex = i; }	
			this.webcam.dropDown.updateItem(i, "javascript:window.mediaViewerGlobalObj.displayWebcam('" + hour + "')", hour + ':00 GMT');
		}					
	}
	this.webcam.dropDown.appendElement();
		
} // end displayWebcamDropdown

MediaViewer.prototype.displayWebcam = function (anHour)
{	
	this.loading('show');
	
	var langId = this.languageId;
		
	switch (langId)
	{
		case '2':	
			langId = 'FR';	
			break;		
		case '3':	
			langId = 'AR';			
			break;		
		default:
			langId = 'EN';
	}	
		
	this.webcam.currHour = anHour;
	this.currentZoomLevel = 1;
	
	// set the reset button
	this.resetBtn.link = 'this.displayWebcam(this.webcam.currHour);';

	// show webcam dropdown
	this.displayWebcamDropdown(anHour);
	
	// load movie
	this.qtvrMovie.SetURL(this.mediaFolder + this.elementName + '-' + anHour + '-' + langId + '-' + this.resolution + '_3992x1532.mov');
	
	// loop until loaded
	this.virtEnv.hotspotIntervalId = setInterval('window.mediaViewerGlobalObj.isMovieLoaded();', 50);		
			
} // end display webcam

MediaViewer.prototype.onWebcamHoursLoadEvent = function (evt)
{	
	if (this.webcam.httpObj.readyState==4) 
	{
		if (this.webcam.httpObj.status==200)
		{   		 			
    		var cameraId = this.elementName.split('camera')[1];	    			   			
    		var timeIdAry;	    			
    		var cameraAry = this.webcam.httpObj.responseText.split('&');   			
    			
  			for (var i = 0; i < cameraAry.length; i++)
    		{
    			timeIdAry = cameraAry[i].split('=');
    			if ( timeIdAry[0].indexOf('time' + cameraId) != -1) 
    			{ 
    				this.webcam.currHour = timeIdAry[1]; 
    			}    			
    		}    
    		// Display the Webcam QTVR		 				
 			this.displayWebcam(this.webcam.currHour);		
		}
		else
		{
			alert('Error retrieveing Webcam Hours');
		}
	}
} // end onWebcamHoursLoadEvent

MediaViewer.prototype.getWebcamHours = function()
{	
	//changed by mriad to remove js errors from test servers (isis , preview)
	//NB  ctime.txt must be copied from production to local servers

	//var myWebcamHoursFile = this.mediaFolder + 'dswmedia/ctime.txt';

	var myWebcamHoursFile = this.labelsFolder + '../images/elements/dswmedia/ctime.txt';
	
	this.webcam.httpObj.open("GET", myWebcamHoursFile, true);
	this.webcam.httpObj.onreadystatechange=function(event){window.mediaViewerGlobalObj.onWebcamHoursLoadEvent(event);}
	this.webcam.httpObj.send(null);
	
} // end getWebcamhours

MediaViewer.prototype.isFlashLoaded = function ()
{
	if (this.flashMovie.PercentLoaded() == 100) 
	{ 	
		clearInterval(this.flashIntervalId);
		
		this.flashMovie.width  = this.resolution;
		this.flashMovie.height = this.resolution;
		this.replacingMedia    = false;
		
		this.loading('hide');
	}				
} // end isFlashLoaded

MediaViewer.prototype.showAnimation = function ()
{	
	this.loading('show');
	
	myElement = document.getElementById('zoom');		
	if ( myElement.childNodes.length > 0) { myElement.removeChild(myElement.firstChild);}
		
	// Hide 2d viewer and qtvr media objects and only show the flash object
	this.flashMovieContainer.style.left = 0 + 'px';
	this.qtvrMovieContainer.style.left = -2000 + 'px';
	this.imageContainer.style.left = -3000 + 'px';
		
	// show/hide elements	
	this.upArrow.style.display = 'none';
	this.leftArrow.style.display = 'none';
	this.rightArrow.style.display = 'none';
	this.downArrow.style.display = 'none';
	this.virtEnv.dropDownContainer.style.display = 'none';	
	this.webcam.dropDownContainer.style.display = 'none';	
	this.mapBtn.style.display = 'none';
	this.resetBtn.style.display = 'none';
	this.zoomTitle.style.display = 'none';
	this.webcamDropdownTitle.style.display = 'none';
	this.miniViewContainer.style.display = 'none';
	this.miniViewContainer2d.style.display = 'none';
	
	// The virtual environment's map has a different naming style
	if (this.virtEnv.map) 
	{	
		this.flashMovie.LoadMovie(0, this.virtEnv.mapSrc);
		this.virtEnv.map = false;
	}
	else
	{	// set alt tags to elements and show controls
		this.movieControlsPlayImage.alt = this.labels.text.Lplay_alt;
		this.movieControlsReverseImage.alt = this.labels.text.Lreverse_alt;
		this.movieControlsContainer.style.display = 'block';
		
		// load the requested flash movie and set its parameters to show text within movie
		this.flashMovie.LoadMovie(0, this.mediaFolder + this.elementName + '_1_' + this.languageId + '_' + this.resolution + '.swf');
		this.flashMovie.SetVariable('lan', this.languageId);
		this.flashMovie.SetVariable('path', this.mediaFolder + 'dswmedia/');
	}		
	// Loop until the movie is loaded
	this.flashIntervalId = setInterval("window.mediaViewerGlobalObj.isFlashLoaded();", 50);
	
} // showAnimation 

MediaViewer.prototype.accelerateTo = function (startX, endX, aTime, aCmd)
{	
	if (this.accelerateRunning == false) 
	{
		this.accelerateInterval = setInterval('window.mediaViewerGlobalObj.accelerateTo('+startX+', '+endX+', '+aTime+', \''+aCmd+'\')', 25);
		this.accelerateRunning = true;
	}
	
	if (this.accelerateTime > aTime)
	{
		clearInterval(this.accelerateInterval);
		this.accelerateRunning = false;
	}
	else
	{
		var aNum = easeOutQuad(++this.accelerateTime, startX, endX-startX, aTime);
		try {
			eval(aCmd + '(' + aNum + ')');
		} catch (e) {
			//alert('cannot move right anymore');
		}		
	}	
} // end accelerateTo 

MediaViewer.prototype.showZoom = function ()
{
	myElement = document.getElementById('zoom');		
	if ( myElement.childNodes.length > 0) { myElement.removeChild(myElement.firstChild);}
	
	// Instantiate the ZoomTool
	this.zoomTool = new ZoomTool('../images/',15,130,this.currentZoomLevel,this, this.labels.text);
	this.zoomTool.currentZoomLevel = this.currentZoomLevel;
	this.setZoom(this.currentZoomLevel);
			
} // end showZoom

MediaViewer.prototype.setZoom = function (aLevel)
{
	this.currentZoomLevel = aLevel;
	
	var minFov = 0;
	var maxFov = 0;
	var myMinFov = 0;
	var myMaxFov = 0;
	var fov = 0;
	
	// set min and max zoom level defaults
	// there is no such method as GetMaxFieldOfView or GetMinFieldOfView
	// so specifying them here manually
	switch (this.elementMode)
	{	
		case 3: 
			minFov = 30;
			maxFov = 65;
			break;
			
		case 4:  
			minFov = 50;
			maxFov = 125;
			break;
		case 5:  
			minFov = 30;
			maxFov = 120;
			break;
		case 6:	 
			minFov = 40;
			maxFov = 120;
			break;			
		default:
			maxFov = 0;
			minFov = 0;
			break;
	}
			
	var myValue = ((maxFov - minFov) * this.zoomLevels[this.currentZoomLevel]) + minFov;

	// show default view of movie, the parameters are retrieved from the movie while it was recorded
	if (this.virtEnv.qtvrDefaultView)
	{
		try{
			this.qtvrMovie.ShowDefaultView();				
		} catch (e3) {
			// catch
		}
		this.virtEnv.qtvrDefaultView = false;
	}
	else
	{	// accelerate effect to desired zoom level
		try {
			this.accelerateTime = 0;	
			this.accelerateTo(this.qtvrMovie.GetFieldOfView(), parseInt(myValue), 10, 'this.qtvrMovie.SetFieldOfView');
		} catch (e6) {
			// catch
		}
	}
	
	this.panBoxRectangleResize();
} // end setZoom

MediaViewer.prototype.zoomIn = function ()
{
	this.setZoom(this.currentZoomLevel+1);	
	
} // end zoomIn

MediaViewer.prototype.zoomOut = function ()
{
	this.setZoom(this.currentZoomLevel-1);
		
} // end zoomOut

MediaViewer.prototype.loading = function (anAction)
{	
	switch (anAction)
	{
		case 'show':
			// minimize elements so we can see the loading box
			this.qtvrMovie.width = 4;
			this.qtvrMovie.height = 4;
			this.flashMovie.width = 4;
			this.flashMovie.height = 4;
			
			this.loadingTransWhiteBox.style.display = 'block';
			this.loadingTextBox.style.display = 'block';
		break;
		
		case 'hide':
			this.loadingTransWhiteBox.style.display = 'none';
			this.loadingTextBox.style.display = 'none';
		break;
		
		default:		
	}	
} // end loading

MediaViewer.prototype.onMediaControlsLeftArrowClickEvent = function (evt)
{
	// pagination function in media column
	// show right arrow
	this.mediaColumn.controls.rightArrow.style.visibility = 'visible';
	this.mediaColumn.contents.startElement -= 3;
	
	if (this.mediaColumn.contents.endElement == this.mediaColumn.contents.length) 
	{
		this.mediaColumn.contents.endElement = this.mediaColumn.contents.startElement + 2;
	}
	else
	{
		this.mediaColumn.contents.endElement -= 3;
	}
	
	// hide left arrow if on page 1
	if (this.mediaColumn.contents.startElement - 3 < 1) 
	{
		this.mediaColumn.contents.startElement = 1;			
		this.mediaColumn.controls.leftArrow.style.visibility = 'hidden';	
	}
	
	// set labels, and reverse if language is Arabic
	if (this.languageId != 3)
	{
		this.mediaColumn.controls.text.innerHTML = '&nbsp;'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;' + this.labels.text.Lof + '&nbsp;' + this.mediaColumn.contents.length + '&nbsp;';
	}
	else
	{
		this.mediaColumn.controls.text.innerHTML = '&nbsp;<span dir="rtl">'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;'+this.labels.text.Lof+'&nbsp;' + this.mediaColumn.contents.length + '</span>&nbsp;';
	}
	
	this.mediaColumn.pagePos += this.mediaColumn.contents.delta;	
	this.mediaColumn.container.style.top = this.mediaColumn.pagePos + 'px';
	
} // end onMediaControlsLeftArrowClickEvent

MediaViewer.prototype.onMediaControlsRightArrowClickEvent = function (evt)
{
	this.mediaColumn.contents.startElement += 3;
	this.mediaColumn.contents.endElement += 3;
		
	// show left arrow
	this.mediaColumn.controls.leftArrow.style.visibility = 'visible';
	
	// hide right arrow because we are on last page
	if (this.mediaColumn.contents.startElement + 3 > this.mediaColumn.contents.length) 
	{
		this.mediaColumn.contents.endElement    = this.mediaColumn.contents.length;			
		this.mediaColumn.controls.rightArrow.style.visibility = 'hidden';	
	}
	
	// set labels, and reverse if language is Arabic
	if (this.languageId != 3)
	{
		this.mediaColumn.controls.text.innerHTML = '&nbsp;'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;' + this.labels.text.Lof + '&nbsp;' + this.mediaColumn.contents.length + '&nbsp;';
	}
	else
	{
		this.mediaColumn.controls.text.innerHTML = '&nbsp;<span dir="rtl">'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;'+this.labels.text.Lof+'&nbsp;' + this.mediaColumn.contents.length + '</span>&nbsp;';
	}
	
	this.mediaColumn.pagePos -= this.mediaColumn.contents.delta;	
	this.mediaColumn.container.style.top = this.mediaColumn.pagePos + 'px';
	
} // end onMediaControlsRightArrowClickEvent

MediaViewer.prototype.showMediaColumnControls = function ()
{	
	this.mediaColumn.contents.startElement = 1;
	this.mediaColumn.contents.endElement = 3;
	
	// Only display controls if the number of items is greater than 3
	if (this.mediaColumn.contents.length > 3) 
	{
		this.mediaColumn.controls.leftArrow                  = document.createElement('img');
		this.mediaColumn.controls.leftArrow.leftArr          = this;
		this.mediaColumn.controls.leftArrow.src              = '../images/0000_g_arrow_o_a.gif';
		this.mediaColumn.controls.leftArrow.alt              = this.labels.text.Lprevious_alt;	
		this.mediaColumn.controls.leftArrow.style.cursor     = 'pointer';
		this.mediaColumn.controls.leftArrow.style.visibility = 'hidden';
		this.mediaColumn.controls.leftArrow.onclick          = function(event){this.leftArr.onMediaControlsLeftArrowClickEvent(event)};
	
		this.mediaColumn.controls.text                  = document.createElement('span');
		this.mediaColumn.controls.text.style.fontFamily = 'verdana, serif';
		this.mediaColumn.controls.text.style.fontWeight = 'bold';
		this.mediaColumn.controls.text.style.fontSize   = 12 + 'px';
		
		// Switch text alignment is language is Arabic
		if (this.languageId != 3)
		{
			this.mediaColumn.controls.text.innerHTML = '&nbsp;'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;' + this.labels.text.Lof + '&nbsp;' + this.mediaColumn.contents.length + '&nbsp;';
		}
		else
		{	
			this.mediaColumn.controls.text.innerHTML = '&nbsp;<span dir="rtl">'+this.mediaColumn.contents.startElement+'-'+this.mediaColumn.contents.endElement+'&nbsp;'+this.labels.text.Lof+'&nbsp;' + this.mediaColumn.contents.length + '</span>&nbsp;';
		}
			
		this.mediaColumn.controls.rightArrow              = document.createElement('img');
		this.mediaColumn.controls.rightArrow.rightArr     = this;
		this.mediaColumn.controls.rightArrow.src          = '../images/0000_g_arrow_o.gif';
		this.mediaColumn.controls.rightArrow.alt          = this.labels.text.Lnext_alt;	
		this.mediaColumn.controls.rightArrow.style.cursor = 'pointer';
		this.mediaColumn.controls.rightArrow.onclick      = function(event){this.rightArr.onMediaControlsRightArrowClickEvent(event)};
	
		this.mediaColumn.controls.appendChild(this.mediaColumn.controls.leftArrow);
		this.mediaColumn.controls.appendChild(this.mediaColumn.controls.text);
		this.mediaColumn.controls.appendChild(this.mediaColumn.controls.rightArrow);
	}	
} // end showMediaColumnControls

MediaViewer.prototype.onThumbClickEvent = function (evt)
{
	var target;
	if (this.browserType == "IE"){
		target = event.srcElement;
	}else{
		target = evt.target;
	}
	// Execute link related to clicked thumbnail
	eval(target.link);
	
} // end onThumbClickEvent

MediaViewer.prototype.displayMediaColumnItems = function()
{	
	var myThumbContainer;
	var myThumbText;
	var iterator = 1;
	var myType;
	this.mediaColumn.container.style.position = 'absolute';
	this.mediaColumn.container.style.top = 20 + 'px';
	
	// for each node in xml file
	for ( i = 0; i < this.mediaColumn.contents.length; i++)
	{
		if ( this.mediaColumn.contents[i].type == 'title' )	
		{ 	
			// Sets the Page Title
			this.pageTitle.innerHTML = this.mediaColumn.contents[i].titleText;
			continue; 
		}
		
		if ( this.mediaColumn.contents[i].type == '2d' && this.elementMode == 1)
		{
			// the reason this could not run asynchronously with other methods
			this.imageViewer.imgSize = this.mediaColumn.contents[i].imgSize;
		}
					
		// create pagination
		if (iterator > 2)
		{
			iterator = 0;
			this.mediaColumn.container.appendChild(myThumbContainer);
		}
		else if (iterator == 1)
		{
			myThumbContainer = document.createElement('div');
			myThumbContainer.style.height = this.mediaColumn.contents.delta + 'px';
			myThumbContainer.style.width = '120px';	
		}
			
		myType = this.mediaColumn.contents[i].type;
		switch (myType)
		{
			case '2d':
				myType = 1;
				break;
	
			case 'map':
				myType = 1;
				break;
			
			case 'anim':
				myType = 2;
				break;
			
			case 'webcam':
				myType = 3;
				break;
			
			case 'rot':
				myType = 4;
				break;
			
			case 'pan':
				myType = 5;
				break;
			
			case 'vir':
				myType = 6;
				break;
		
			default:			
				alert('Invalid media type passed: ' + myType);
		} 
		
		// append thumbnails to the media column
		myThumb = document.createElement('img');
		myThumb.thumb             = this;
		myThumb.src               = this.mediaFolder + this.mediaColumn.contents[i].icon;
		myThumb.link              = "this.replaceMedia('"+this.mediaColumn.contents[i].media+"' ,"+myType+","+this.mediaColumn.contents[i].imgSize+")";
		myThumb.style.height      = 62 + 'px';
		myThumb.style.width       = 62 + 'px';		
		myThumb.style.border      = 1 + 'px';
		myThumb.style.borderColor = '#A4814E';
		myThumb.style.borderStyle = 'solid';
		myThumb.style.cursor      = 'pointer';
		myThumb.onclick           = function(event){this.thumb.onThumbClickEvent(event)};
				
		myBreak = document.createElement('br');							
		
		// add a break if the thumbnail does not have a title	
		if ( this.mediaColumn.contents[i].titleText != '' )
		{
			myThumbText = document.createElement('div');
			myThumbText.innerHTML = this.mediaColumn.contents[i].titleText;
		}
		else
		{
			myThumbText = document.createElement('br');
		}
		
		myThumbContainer.appendChild(myThumb);
		myThumbContainer.appendChild(myBreak);
		myThumbContainer.appendChild(myThumbText);			
					
		iterator++;
		if (i == this.mediaColumn.contents.length -1 ) { this.mediaColumn.container.appendChild(myThumbContainer); }		
	}	
	this.mediaColumn.contents.length -= 1;
	
	// Show Pagination arrows and text if pages > 1
	this.showMediaColumnControls();
	
	// Prepare layout
	this.prepareLayout();

} // end displayMediaColumnItems

MediaViewer.prototype.onMediaColumnLoadEvent = function (evt)
{	
	if (this.mediaColumn.httpObj.readyState==4) 
	{	
		if (this.mediaColumn.httpObj.status==200)
		{			
			var myMediaObj;
			var icElements;
			
			icElements = this.mediaColumn.httpObj.responseXML.documentElement.getElementsByTagName('ic');
			for (j = 0; j < icElements.length; j++)
			{			
				this.mediaColumn.contents[j] = new Object();			
				this.mediaColumn.contents[j].icon      = icElements[j].getAttribute('i');
				this.mediaColumn.contents[j].type      = icElements[j].getAttribute('t');
				this.mediaColumn.contents[j].media     = icElements[j].getAttribute('m');
				this.mediaColumn.contents[j].titleText = icElements[j].getAttribute('tl');
				// This variable is specific to 2D Images only (e.g. 2000 or 3000)
				this.mediaColumn.contents[j].imgSize   = icElements[j].getAttribute('s'); 									
			} 				
			this.displayMediaColumnItems();
		}
		else
		{
			alert("Problem retrieving XML data for Media Column Content");
		}
	}
} // end onMediaColumnLoadEvent

MediaViewer.prototype.showMediaColumn = function()
{	
	var myMediaColumnConfigFile;
		
	this.mediaColumn.title.innerHTML = this.labels.text.Lviews.replace(':','');
	
	myMediaColumnConfigFile = this.configFolder + this.languageId + '/viewer/' + this.elementId + '.xml';
	
	this.mediaColumn.httpObj.open("GET", myMediaColumnConfigFile, true);
	this.mediaColumn.httpObj.onreadystatechange=function(event){window.mediaViewerGlobalObj.onMediaColumnLoadEvent(event);}
	this.mediaColumn.httpObj.send(null);
		
} // end setMediaColumn

MediaViewer.prototype.onLabelsLoadEvent = function (evt)
{	
	if (this.labels.httpObj.readyState==4) 
	{
		if (this.labels.httpObj.status==200)
		{   			
			var myLabelsAry = this.labels.httpObj.responseText.split('&');		   			
			var myLabelAry;
			var myLabelInfo;
   			
   			for (var i = 0; i < myLabelsAry.length; i++)
   			{
   				myLabelAry = myLabelsAry[i].split('=');    				
  		 		this.labels.text[myLabelAry[0]] = myLabelAry[1];
  		 	} 				
			
			// Set loading box text in the proper language
			this.loadingTextBox.innerHTML = this.labels.text.Lloading;
			
			// Create the Help Button
			this.createHelpBtn();
			
			// Display the media Column	
			this.showMediaColumn();				
		}
		else
		{
			alert("Problem retrieving XML data for Labels Text");
		}
	}
} // end onLabelsLoadEvent

MediaViewer.prototype.getLabelsText = function()
{	
	var myLabelsFile = this.labelsFolder + this.languageId + 'labels.txt';

	this.labels.httpObj.open("GET", myLabelsFile, true);
	this.labels.httpObj.onreadystatechange=function(event){window.mediaViewerGlobalObj.onLabelsLoadEvent(event);}
	this.labels.httpObj.send(null);
	
} // end getLabelsText

MediaViewer.prototype.prepareLayout = function()
{
	// Alt tags for arrows
	this.upArrow.alt    = this.labels.text.Lup_alt;
	this.leftArrow.alt  = this.labels.text.Lleft_alt;
	this.rightArrow.alt = this.labels.text.Lright_alt;
	this.downArrow.alt  = this.labels.text.Ldown_alt;
	
	// Create reset button
	this.createResetBtn();
	
	// Create map button
	this.createMapBtn();
	
	// display requested media
	this.replaceMedia(this.elementName,this.elementMode,this.imageViewer.imgSize);
	
} // end prepareLayout

MediaViewer.prototype.showQtvrMap = function (aMapName)
{
	this.loading('show');
	
	this.qtvrMovie.width = 4;
	this.qtvrMovie.height = 4;
		
	this.virtEnv.map = true;
	//changed by mriad to make map work from local swf files for test machines (isis ,preview)
	//this.virtEnv.mapSrc = this.mediaFolder + aMapName + '_1_' + this.languageId + '.swf';
	//NB  Some swf files  must be copied from production to local servers
	//AlexMap_1_1.swf AlexMap_1_2.swf AlexMap_1_3.swf AlexMap_1_5.swf AlexMap_1_6.swf GizaAMap_1_1.swf 
	//AlexMap_1_*.swf GizaAMap_1_*.swf GizaMMap_1_*.swf LuxorAMap_1_*.swf LuxorCMap_1_*.swf 
	//LuxorPMap_1_*.swf LuxorRMap_1_*.swf TutTombMap_1_*.swf TutTombMap_1_*.swf


	this.virtEnv.mapSrc = this.labelsFolder + '../images/elements/' + aMapName + '_1_' + this.languageId + '.swf';
			
	this.showAnimation();
} // end showQtvrMap

MediaViewer.prototype.replaceMedia = function (anElementName, anElementMode, anImgSize)
{
	var myElement;
		
	this.elementName = anElementName;
	this.elementMode = anElementMode;
	this.imgSize     = anImgSize;
	
	// Set text for zoom and dropdown elements
	this.zoomTitle.innerHTML = this.labels.text.Lzoom;
	this.webcamDropdownTitle.innerHTML = this.labels.text.Lhistory;
	
	// Display the proper controls and load requested media
	switch (this.elementMode)
	{
	case 1:
		// 2d image viewer
		
		// show loading screen
		this.loading('show');
	
		var myElement = document.getElementById('zoom');		
		if ( myElement.childNodes.length > 0) { myElement.removeChild(myElement.firstChild);}
		this.resetBtn.style.display = '';	
		this.mapBtn.style.display = 'none';				
		this.zoomTitle.style.display = '';
		this.webcamDropdownTitle.style.display = 'none';
		this.miniViewContainer.style.display = '';
		this.miniViewContainer2d.style.display = '';	
		this.virtEnv.dropDownContainer.style.display = 'none';			
		this.upArrow.style.display = '';
		this.leftArrow.style.display = '';
		this.rightArrow.style.display = '';
		this.downArrow.style.display = '';
		this.movieControlsContainer.style.display = 'none';
		
		// Hide flash and qtvr media elements from the viewer and show 2d image viewer
		this.flashMovieContainer.style.left = -3000 + 'px';
		this.qtvrMovieContainer.style.left = -2000 + 'px';
		this.imageContainer.style.left = 0;
		
		// init ZoomTool with this zoom level
		this.currentZoomLevel = 1;
		this.imgViewer = null;	
		this.zoomTool = null;
		
		// Create an instance of the ImageViewer
		this.imgViewer = new ImageViewer(this.elementName,this.mediaFolder,this.imageViewer.imgSize,0,0,this.resolution);
		// Create an instance of the ZoomTool
		this.zoomTool = new ZoomTool('../images/',15,130,this.currentZoomLevel,this.imgViewer,this.labels.text);
		// Set the zoom tool control
		this.imgViewer.setZoomToolControl(this.zoomTool);
		
		// Set reset button link
		this.resetBtn.link = 'this.replaceMedia(this.elementName,this.elementMode,this.imageViewer.imgSize);';
		this.loading('hide');		
		
		break;
		
	case 2:	
		// Load Flash Animation				
		this.showAnimation();	
		break;
		
	case 3:		
		// Load Webcam and show/hide elements
		this.resetBtn.style.display = '';
		this.mapBtn.style.display = 'none';			
		this.zoomTitle.style.display = '';
		this.webcamDropdownTitle.style.display = '';
		this.miniViewContainer.style.display = '';
		this.miniViewContainer2d.style.display = 'none';		
		this.upArrow.style.display = '';
		this.leftArrow.style.display = '';
		this.rightArrow.style.display = '';
		this.downArrow.style.display = '';
		this.movieControlsContainer.style.display = 'none';
		this.webcam.dropDownContainer.style.display = '';
		this.virtEnv.dropDownContainer.style.display = 'none';
		
		// Hide media objects other than QTVR off the screen
		this.flashMovieContainer.style.left = -3000 + 'px';
		this.qtvrMovieContainer.style.left = 0 + 'px';
		this.imageContainer.style.left = -2000;
		
		this.virtEnv.qtvrDefaultView = false;
		this.miniViewImage.src = this.mediaFolder + this.elementName + '_2_' + this.languageId + '.jpg';
		
		// get the hour of the QTVR webcam we should display before displaying
		this.getWebcamHours();				
		break;
		
	case 4:	
		// show 3d view
		this.resetBtn.style.display = '';
		this.mapBtn.style.display = 'none';			
		this.zoomTitle.style.display = '';
		this.webcamDropdownTitle.style.display = 'none';
		this.miniViewContainer.style.display = 'none';
		this.miniViewContainer2d.style.display = 'none';		
		this.upArrow.style.display = '';
		this.leftArrow.style.display = '';
		this.rightArrow.style.display = '';
		this.downArrow.style.display = '';
		this.movieControlsContainer.style.display = 'none';
			
		// load media 	
		this.show3dView();
		break;
		
	case 5:
		// show 360 degree view
		this.mapBtn.style.display = 'none';			
		this.zoomTitle.style.display = '';
		this.webcamDropdownTitle.style.display = 'none';
		this.resetBtn.style.display = '';
		this.miniViewContainer.style.display = '';
		this.miniViewContainer2d.style.display = 'none';		
		this.upArrow.style.display = '';
		this.leftArrow.style.display = '';
		this.rightArrow.style.display = '';
		this.downArrow.style.display = '';
		this.movieControlsContainer.style.display = 'none';
		
		// load media
		this.show360View();		
		break;
		
	case 6:		
		this.resetBtn.style.display = '';
		this.mapBtn.style.display = '';			
		this.zoomTitle.style.display = '';
		this.webcamDropdownTitle.style.display = 'none';
		this.miniViewContainer.style.display = '';
		this.miniViewContainer2d.style.display = 'none';
		this.webcam.dropDownContainer.style.display = 'none';
		this.virtEnv.dropDownContainer.style.display = '';
		
		this.virtEnv.qtvrDefaultView = true;
		// get hotspot config file and continue loading movie
		this.getVirtEnvXml();		
		break;
	}
	
} // end replaceMedia


MediaViewer.prototype.upArrowAction = function ()
{
	try {	
		if (this.elementMode == 1)
		{	
			this.imgViewer.scrollUp();
		}
		else
		{
			var myCurrDegrees = this.qtvrMovie.GetTiltAngle();
			var myNewDegrees = myCurrDegrees + 30;
			this.accelerateTime = 0;
			this.accelerateTo(myCurrDegrees, myNewDegrees, 10,'this.qtvrMovie.SetTiltAngle');
		}			
	} catch (e) {
		//alert('cannot move up anymore');
	}
} // end upArrowAction

MediaViewer.prototype.leftArrowAction = function ()
{
	try {
		if (this.elementMode == 1)
		{	
			this.imgViewer.scrollLeft();
		}
		else
		{
			var myCurrDegrees = this.qtvrMovie.GetPanAngle();
			var myNewDegrees = myCurrDegrees + 30;
			this.accelerateTime = 0;
			window.mediaViewerGlobalObj.accelerateTo(myCurrDegrees, myNewDegrees, 10,'this.qtvrMovie.SetPanAngle');			
		}		
	} catch (e) {
		//alert('cannot move left anymore');
	}
} // end leftArrowAction

MediaViewer.prototype.rightArrowAction = function ()
{
	try {	
		if (this.elementMode == 1)
		{	
			this.imgViewer.scrollRight();
		}
		else
		{
			var myCurrDegrees = this.qtvrMovie.GetPanAngle();
			var myNewDegrees = myCurrDegrees - 30;
			this.accelerateTime = 0;
			this.accelerateTo(myCurrDegrees, myNewDegrees, 10,'this.qtvrMovie.SetPanAngle');
		}
	} catch (e) {
		//alert('cannot move right anymore');
	}
} // end rightArrowAction

MediaViewer.prototype.downArrowAction = function ()
{
	try {	
		if (this.elementMode == 1)
		{	
			this.imgViewer.scrollDown();
		}
		else
		{
			var myCurrDegrees = this.qtvrMovie.GetTiltAngle();
			var myNewDegrees = myCurrDegrees - 30;
			this.accelerateTime = 0;
			this.accelerateTo(myCurrDegrees, myNewDegrees, 10,'this.qtvrMovie.SetTiltAngle');
		}
	} catch (e) {
		//alert('cannot move down anymore');
	}
} // end downArrowAction


function easeOutQuad (t, b, c, d) 
{
	t /= d;
	return -c*t*(t-2)+b;
	
} // end easeOutQuad

function parseSwing (aSwing)
{ 
	// helper to parse a string while parsing xml in virtual env
	var mySwing = new Object();
	
	var strAry  = aSwing.split(',');
	var panAry  = strAry[0].split(':');
	var tiltAry = strAry[1].split(':');
	var fovAry  = strAry[2].split(':');

	mySwing.pan  = panAry[1];
	mySwing.tilt = tiltAry[1];
	mySwing.fov  = fovAry[1].replace(']','');
	
	return mySwing;
	
} // end parseSwing(aSwing)

MediaViewer.prototype.getXmlHttpObject = function ()
{
	// Cross-browser method to acquire the XmlHttpObject
	var xmlhttp = false;
 	
 	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;
	
} // end getXmlHttpObject

function showQtvr(aMap, aNodeId)
{
	// this function is a wrapper, it catches the event from the flash map movie
	window.mediaViewerGlobalObj.showVirtEnv(aMap,aNodeId,-8,-8,-8);
}

// The help button instantiates this function
function openNamedWindow(name, url, width, height, left, top, scroll)
{
	var resize='yes';
	var scrollbar='auto';
	if( openNamedWindow.arguments.length > 4 )
	{
		resize='no';
	}
	else
	{
		left='152';
		top='10';
	}
	
	if( openNamedWindow.arguments.length > 6 )
		scrollbar=scroll;
	
	Window3=window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbar+',resizable='+resize+',width='+width+',height='+height+',top='+top+',left='+left+'');
	Window3.focus();
	
} // end openNamedWindow

// Window Resize Functions
var winRes = 0;
function snapWindowTo(aWidth, aHeight, aWinRes)
{
	window.mediaViewerGlobalObj.resolution = aWinRes;
	
	if (window.mediaViewerGlobalObj.replacingMedia == false) 
	{	
		window.resizeTo(aWidth,aHeight);
		window.mediaViewerGlobalObj.replaceMedia(window.mediaViewerGlobalObj.elementName, window.mediaViewerGlobalObj.elementMode, window.mediaViewerGlobalObj.imageViewer.imgSize);
		window.mediaViewerGlobalObj.replacingMedia = true;
	}	
} // end snapWindowTo

window.onresize=resizeHandler;
function resizeHandler()
{
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
	else
	{
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	
	screenW = screen.width;
	screenH = screen.height;
	

	if (winW <= 810) 
	{		
		winRes = 400;	
			
		document.getElementById('container').style.width = 440;
		document.getElementById('container').style.height = 440;
			
		document.getElementById('mediaBody').style.width = 440;
		document.getElementById('mediaBody').style.height = 400;
			
		document.getElementById('mediaContent').style.width = 400;
		document.getElementById('mediaContent').style.height = 400;	
		
		document.getElementById('leftArrow').style.marginTop = 170 + 'px';
		document.getElementById('rightArrow').style.marginTop = 170 + 'px';		
		
		if (winRes == 400 && window.mediaViewerGlobalObj.resolution != '400') 
		{	
			if (screenH >= 630)
			{	
				window.mediaViewerGlobalObj.loading('show');				
				try {
					setTimeout("window.snapWindowTo('700','570', "+winRes+")",2000);
				} catch(e) {}
			}
		}		
	}
	else if (winW > 810 && winW <= 920)
	{
		if (winRes != 500) {

			winRes = 500;
			
			if (winRes == 500 && window.mediaViewerGlobalObj.resolution != '500') 
			{
				if (screenH >= 710)
				{
					window.mediaViewerGlobalObj.loading('show');
					
					document.getElementById('container').style.width = 540;
					document.getElementById('container').style.height = 540;
					
					document.getElementById('mediaBody').style.width = 540;
					document.getElementById('mediaBody').style.height = 500;
					
					document.getElementById('mediaContent').style.width = 500;
					document.getElementById('mediaContent').style.height = 500;			
					
					document.getElementById('leftArrow').style.marginTop = 220 + 'px';
					document.getElementById('rightArrow').style.marginTop = 220 + 'px';
		
					try {
						setTimeout("window.snapWindowTo('820','670', "+winRes+")",2000);
					} catch(e) {}
				}
			}		
		}
	}
	else if (winW > 920 && winW <= 1030)
	{
		if (winRes != 600) {
		
			winRes = 600;
			
			if (winRes == 600 && window.mediaViewerGlobalObj.resolution != '600') 
			{
				if (screenH >= 820)
				{
					window.mediaViewerGlobalObj.loading('show');
					
					document.getElementById('container').style.width = 640;
					document.getElementById('container').style.height = 640;
					
					document.getElementById('mediaBody').style.width = 640;
					document.getElementById('mediaBody').style.height = 600;
					
					document.getElementById('mediaContent').style.width = 600;
					document.getElementById('mediaContent').style.height = 600;			
					
					document.getElementById('leftArrow').style.marginTop = 270 + 'px';
					document.getElementById('rightArrow').style.marginTop = 270 + 'px';
			
					try {						
						setTimeout("window.snapWindowTo('935','770', "+winRes+")",2000);
					} catch(e) {}
				}
			}
			window.mediaViewerGlobalObj.resolution = '600';		
		}
	}
	else if (winW > 1030 && winW <= 1160)
	{
		if (winRes != 700) {
		
			winRes = 700;
			
			if (winRes == 700 && window.mediaViewerGlobalObj.resolution != '700') 
			{
				if (screenH >= 920)
				{
					window.mediaViewerGlobalObj.loading('show');
					
					document.getElementById('container').style.width = 740;
					document.getElementById('container').style.height = 740;
			
					document.getElementById('mediaBody').style.width = 740;
					document.getElementById('mediaBody').style.height = 700;
			
					document.getElementById('mediaContent').style.width = 700;
					document.getElementById('mediaContent').style.height = 700;			
			
					document.getElementById('leftArrow').style.marginTop = 320 + 'px';
					document.getElementById('rightArrow').style.marginTop = 320 + 'px';
			
					try {
						setTimeout("window.snapWindowTo('1040','870', "+winRes+")",2000);
					} catch(e) {}
				}
			}
			
			window.mediaViewerGlobalObj.resolution = '700';
		}
	}
	else if (winW > 1160)
	{
		if (winRes != 800) {
		
			winRes = 800;
		
			if (winRes == 800 && window.mediaViewerGlobalObj.resolution != '800') 
			{
				if (screenH >= 1040)
				{
					window.mediaViewerGlobalObj.loading('show');
					
					document.getElementById('container').style.width = 840;
					document.getElementById('container').style.height = 840;
					
					document.getElementById('mediaBody').style.width = 840;
					document.getElementById('mediaBody').style.height = 800;
					
					document.getElementById('mediaContent').style.width = 800;
					document.getElementById('mediaContent').style.height = 800;			
					
					document.getElementById('leftArrow').style.marginTop = 370 + 'px';
					document.getElementById('rightArrow').style.marginTop = 370 + 'px';
					
					try {
						setTimeout("window.snapWindowTo('1170','970', "+winRes+")",2000);					
					} catch(e) {}
				}
			}
			window.mediaViewerGlobalObj.resolution = '800';			
		}
	}
} // end resizeHandler

/////////////////////  OVERVIEW IMG METHODS //////////////
MediaViewer.prototype.loadMiniView = function()
{
	this.imageViewerOverDiv = document.createElement("div");
	//document.body.appendChild(this.imageViewerOverDiv);
	document.getElementById('miniView').appendChild(this.imageViewerOverDiv);
	this.imageViewerOverDiv.style.position = "absolute";
	this.imageViewerOverDiv.style.backgroundColor = "white";
	this.imageViewerOverDiv.style.left = 8 + "px";
	this.imageViewerOverDiv.style.top = 0 + "px";
	//set div dimensions
	this.imageViewerOverDiv.style.width = this.overImageWidth + "px";
	this.imageViewerOverDiv.style.height = this.overImageHeight + "px";
	// Adjust Image
	this.miniViewImage.style.width = this.overImageWidth + "px";
	this.miniViewImage.style.height = this.overImageHeight + "px";
	this.miniViewImage.style.left = 0 + 'px';
	this.miniViewImage.style.top = 0 + 'px';
	this.miniViewImage.style.zIndex = 1;
	// set div dimensions
	this.imageViewerOverDiv.style.overflow = "hidden";
	this.imageViewerOverDiv.appendChild(this.miniViewImage);
	// create
	this.panBoxOverDiv = document.createElement("div");
	this.imageViewerOverDiv.appendChild(this.panBoxOverDiv);
	this.panBoxOverDiv.style.position = "absolute";
	this.panBoxOverDiv.style.top = 0 + "px";
	this.panBoxOverDiv.style.left = 0 + "px";
	this.panBoxOverDiv.style.border = "solid";
	this.panBoxOverDiv.style.borderColor = "red";
	this.panBoxOverDiv.style.borderWidth = "1px";
	this.panBoxOverDiv.style.zIndex = 2;
	if(this.browserType != "IE"){ // other browser do not have event transparency so we use div fo events dispatch
		this.panBoxOverDiv.viewer = this;
		this.panBoxOverDiv.onmousedown  = function(event){window.mediaViewerGlobalObj.onPanBoxOverMouseDown(event);}
		this.panBoxOverDiv.onmouseup    = function(){window.mediaViewerGlobalObj.onPanBoxOverMouseUp();}
		this.panBoxOverDiv.onmouseout   = function(){window.mediaViewerGlobalObj.onPanBoxOverMouseUp();}
		this.panBoxOverDiv.onmousemove  = function(event){window.mediaViewerGlobalObj.onPanBoxOverMouseMove(event);}	
		this.panBoxOverDiv.onmouseover  = function(event){window.mediaViewerGlobalObj.onPanBoxOver(event);}	
	} else {
		this.miniViewImage.ondrag = function(){window.mediaViewerGlobalObj.onPanBoxOverDrag();}
		this.miniViewImage.ondragstart = function(){window.mediaViewerGlobalObj.onPanBoxOverStartDrag();}
		this.miniViewImage.ondragend   = function(){window.mediaViewerGlobalObj.onPanBoxOverMouseUp();}
		this.miniViewImage.onmouseover = function(){window.mediaViewerGlobalObj.onPanBoxOver();}
	}
	
	this.overBoxWidth = (this.overImageWidth * this.overviewZoomLevels[this.currentZoomLevel]);
	this.overBoxHeight = (this.overImageHeight * this.overviewZoomLevels[this.currentZoomLevel]);
		
	this.xPosOverRectImg = Math.abs((this.overImageWidth - this.overBoxWidth)/2);
	this.yPosOverRectImg = Math.abs((this.overImageHeight - this.overBoxHeight)/2);
		
	this.panBoxOverDiv.style.width = this.overBoxWidth + "px";
	this.panBoxOverDiv.style.height = this.overBoxHeight + "px";
		
	this.panBoxOverDiv.style.left = this.xPosOverRectImg + "px";
	this.panBoxOverDiv.style.top = this.yPosOverRectImg + "px";
}
MediaViewer.prototype.panBoxRectangleResize = function(){

	this.minPan = 0;
	this.maxPan = 360;
	
	this.minTilt = -100;
	this.maxTilt = 100;
			
	if(this.panBoxOverDiv != null)
	{
		this.overBoxWidth = (this.overImageWidth * this.overviewZoomLevels[this.currentZoomLevel]);
		this.overBoxHeight = (this.overImageHeight * this.overviewZoomLevels[this.currentZoomLevel]);
						
		this.panBoxOverDiv.style.width = this.overBoxWidth + "px";
		this.panBoxOverDiv.style.height = this.overBoxHeight + "px";
		
		this.panBoxOverDiv.style.left = this.xPosOverRectImg + "px";
		this.panBoxOverDiv.style.top = this.yPosOverRectImg + "px";
	}
}
MediaViewer.prototype.onPanBoxOverDrag = function(evt)
{
	clearInterval(this.overViewIntervalId);
	//alert("onPanBoxOverDrag");
	
	if (this.browserType == "IE"){
		this.dragOverRectX = event.offsetX;
		this.dragOverRectY = event.offsetY;
	}else if(this.browserType == "Opera"){
		this.dragOverRectX = evt.offsetX + this.xPosOverRectImg;
		this.dragOverRectY = evt.offsetY + this.yPosOverRectImg;
	}else{
		this.dragOverRectX = evt.layerX + this.xPosOverRectImg;
		this.dragOverRectY = evt.layerY + this.yPosOverRectImg;
	}
	var xAxisDir = (this.dragOverRectX - this.dragStartOverRectX);
	var yAxisDir = (this.dragOverRectY - this.dragStartOverRectY);
	//alert("xAxisDir:" + xAxisDir + "  yAxisDir:" + yAxisDir);
	
	/// X Axis control /////////////////////
	this.xPosOverRectImg = this.xPosOverRectImg + xAxisDir;
	/// Y Axis control
	if(yAxisDir > 0){//check if we can go down
		if((this.yPosOverRectImg + this.overBoxHeight + yAxisDir) < this.overImageHeight-1){
			//alert("going down-" + " yAxisDir:" + yAxisDir+  " <> this.dragOverRectY:" + this.dragOverRectY + " - this.dragStartOverRectY:" + this.dragStartOverRectY);
			this.yPosOverRectImg = this.yPosOverRectImg + yAxisDir;
		}
	}
	if(yAxisDir <= 0){//check if we can go up
		if((this.yPosOverRectImg + yAxisDir) > 0 ){
			//alert("going up-" + " yAxisDir:" + yAxisDir+  " <> this.dragOverRectY:" + this.dragOverRectY + " - this.dragStartOverRectY:" + this.dragStartOverRectY);
			this.yPosOverRectImg = this.yPosOverRectImg + yAxisDir;
		}
	}
	///////////////////////////////////////
					
	this.panBoxOverDiv.style.left = this.xPosOverRectImg + "px";
	this.panBoxOverDiv.style.top = this.yPosOverRectImg + "px";
    //
    this.dragStartOverRectX = this.dragOverRectX;
	this.dragStartOverRectY = this.dragOverRectY;
	//alert("this.dragOverRectX:" + this.dragOverRectX + "  this.dragStartOverRectX:" + this.dragStartOverRectX);

	// center the zoom
	this.zoomClickX = ((this.xPosOverRectImg + (this.overBoxWidth / 2)) / this.overImageWidth) * this.viewerResolution;
	this.zoomClickY = ((this.yPosOverRectImg + (this.overBoxHeight / 2)) / this.overImageHeight) * this.viewerResolution;
	// update zoom center positions
	this.zoomCenterPositionX = ((this.xPosOverRectImg + (this.overBoxWidth / 2)) / this.overImageWidth) * 100;
	this.zoomCenterPositionY = ((this.yPosOverRectImg + (this.overBoxHeight / 2)) / this.overImageHeight) * 100;
			
	//move main view/media
	try {
		this.qtvrMovie.SetPanAngle((Math.ceil(((this.xPosOverRectImg+(this.overBoxWidth/2))/100)*(Math.abs(this.maxPan - this.minPan)))-this.maxPan)*-1);
		this.qtvrMovie.SetTiltAngle((Math.ceil((this.dragOverRectY/100)*(Math.abs(this.maxTilt - this.minTilt)))-this.maxTilt)*-1);
	} catch (e5) {
		//
	}	
}
MediaViewer.prototype.onPanBoxOverStartDrag = function(evt)
{	
	clearInterval(this.overViewIntervalId);
	var tempStartDragX = event.offsetX;
	var tempStartDragY = event.offsetY;
	
	if((tempStartDragX > this.xPosOverRectImg) && (tempStartDragX < (this.xPosOverRectImg + this.overBoxWidth))){
		if((tempStartDragY > this.yPosOverRectImg) && (tempStartDragY < (this.yPosOverRectImg + this.overBoxHeight))){
			//alert("inside");
			this.dragStartOverRectX = tempStartDragX;
			this.dragStartOverRectY = tempStartDragY;
		}
	}
}
MediaViewer.prototype.onPanBoxOver = function(evt)
{
	clearInterval(this.overViewIntervalId);
}
MediaViewer.prototype.onPanBoxOverMouseMove = function(evt)
{
	clearInterval(this.overViewIntervalId);
	if(this.isDraggingOverBox){
		//alert("onPanBoxOverMouseMove");
		this.onPanBoxOverDrag(evt);
	}	
}
MediaViewer.prototype.onPanBoxOverMouseDown = function(evt)
{
	clearInterval(this.overViewIntervalId);	
	//alert("onPanBoxOverMouseDown evt.button="+evt.button);
	
   	if((evt.button == 0) || ((evt.button == 1) && (this.browserType == "Safari"))){
   		this.isDraggingOverBox = true;
		if ((this.browserType == "IE") || (this.browserType == "Opera")){
			this.dragStartOverRectX = event.offsetX + this.xPosOverRectImg;
			this.dragStartOverRectY = event.offsetY + this.yPosOverRectImg;
		}else{
			this.dragStartOverRectX = evt.layerX + this.xPosOverRectImg;
			this.dragStartOverRectY = evt.layerY + this.yPosOverRectImg;
		}
	}
		
	evt.preventDefault();
}
MediaViewer.prototype.onPanBoxOverMouseUp = function()
{
	//alert("onPanBoxOverMouseUp");
	this.isDraggingOverBox = false;
	this.overViewIntervalId = setInterval("window.mediaViewerGlobalObj.syncOverview()", 1200);
}
MediaViewer.prototype.onMovePanBoxRectangle = function()
{
	clearInterval(this.overViewIntervalId);
	//alert("onMovePanBoxRectangle");
	this.xPosOverRectImg = Math.abs(this.xPosImg / this.viewerImageWidth) * this.overImageWidth;
	this.yPosOverRectImg = Math.abs(this.yPosImg / this.viewerImageHeight) * this.overImageHeight;
	
	this.panBoxOverDiv.style.left = this.xPosOverRectImg + "px";
	this.panBoxOverDiv.style.top = this.yPosOverRectImg + "px";
}
MediaViewer.prototype.syncOverview = function()
{
	//alert("syncOverview");
	try {
		this.yPosOverRectImg = (((this.qtvrMovie.GetTiltAngle()-100)*-1)/100)*100-75;
		
		if (this.yPosOverRectImg < 105 && this.yPosOverRectImg > -50)
		{
			this.panBoxOverDiv.style.top = this.yPosOverRectImg + "px";
		}
		
		this.xPosOverRectImg = (((this.qtvrMovie.GetPanAngle()-360)*-1)/360)*100-25;
		this.panBoxOverDiv.style.left = this.xPosOverRectImg + "px";
		
	} catch (e6) {
		// not loaded yet
	}
}
