//extracted from /tenantwiz/store/propertyDetails.asp
var intPhotoViewer = 1;
var intPhotoViewerMax = 0;
var arrPhotoViewer = [];
var arrPhotoViewerLarge = [];
function RotatePhotoViewer(iDelta){
	intPhotoViewer += iDelta;
	while(intPhotoViewer < 1)  intPhotoViewer += intPhotoViewerMax;
	while(intPhotoViewer >intPhotoViewerMax)  intPhotoViewer -= intPhotoViewerMax;
	LoadPhotoViewer();
}
function preLoadImage(imageObject, imagePath){
	imageObject.src = imagePath;
	//pause(1500);
}
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}
function SetPhotoViewer(iIndex){
	intPhotoViewer = iIndex;
	LoadPhotoViewer();
}
function LoadPhotoViewer() {
	if(document.images)
		document.images['imgPhotoView'].src = arrPhotoViewer[intPhotoViewer-1];
	
	if(document.all)
			document.all('spnPhotoViewCount').innerHTML = '' + intPhotoViewer;
	else if(document.getElementById)
		document.getElementById('spnPhotoViewCount').innerHTML = '' + intPhotoViewer;
}

//open new browser window for single image
function js_openBrowserWindow(theURL,winName,features, imagePath) {
	var imageFilePath = arrPhotoViewer[intPhotoViewer-1];
	var imageWidth = document.images['imgPhotoView'].width;
	var imageHeight = document.images['imgPhotoView'].height;

	//These will hold the path to the image that will be displayed
	//in the popup window
	var localImageWidth = imageWidth; //assign default path to 'medium' image
	var localImageHeight = imageHeight; //assign default path to 'medium' image

	//-----------------------------
	//To Show High Detail Images
	//-----------------------------

	//EXTRACT FILE PATH (Not in use)
	//var myString = new String(imageFilePath);
	//var rExp = /_medium/gi;
	//var replaceWithString = new String ("_large");
	//var largeImagePath = myString.replace(rExp, replaceWithString);

	var largeImagePath = arrPhotoViewerLarge[intPhotoViewer-1];
	if(largeImagePath==undefined){
		alert("Sorry, no higher detail image avaliable.");
		//largeImagePath = imageFilePath; //if large image isn't avaliable, we can use medium image
		return;
	}
	var oNewLocalImage = new Image;
	//oNewLocalImage.src=largeImagePath;
	preLoadImage(oNewLocalImage, largeImagePath); //using pause to pre-load
	localImageWidth = oNewLocalImage.width;
	localImageHeight = oNewLocalImage.height;

	theURL+="image="+largeImagePath //Path of medium image
	//adjustments var's made based on popup window layout
	var localImageWidthAdjustments = 20+5+2+2+20;
	var localImageHeightAdjustments = 20+5+2+2+15+15+10+22;//div padding, correction, img border, img padding, img margin, th label padding, th font size, 22=increase size buttons
	features = "width="+(localImageWidth+localImageWidthAdjustments)+" ,height="+(localImageHeight+localImageHeightAdjustments);
	theURL+="&width="+(localImageWidth+localImageWidthAdjustments)+"&height="+(localImageHeight+localImageHeightAdjustments)
	window.open(theURL,winName,features);
}