// the variable photoCount comes from the BuildDetail sub in propertydetail_include.asp...
// it sets the number of images for the innerHTML

var curPhoto = 1;

function changeImage(mlsid, photonum)
{
	curPhoto = photonum
	var imgSource = "/mlsphotos/" + mlsid + "_" + photonum + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + photonum + " of " + photoCount;
}

function nextImage(mlsid)
{
	if (curPhoto == photoCount)
		curPhoto = 1;
	else
		curPhoto += 1;
	var imgSource = "/mlsphotos/" + mlsid + "_" + curPhoto + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + curPhoto + " of " + photoCount;
}
function prevImage(mlsid)
{
	if (curPhoto == 1)
		curPhoto = photoCount;
	else
		curPhoto -= 1;
	var imgSource = "/mlsphotos/" + mlsid + "_" + curPhoto + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + curPhoto + " of " + photoCount;
}


function changeVTImage(mlsid, photonum)
{
	curPhoto = photonum
	var imgSource = "/vtphotos/" + mlsid + String.fromCharCode(photonum+96) + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + photonum + " of " + photoCount;
}

function nextVTImage(mlsid)
{
	if (curPhoto == photoCount)
		curPhoto = 1;
	else
		curPhoto += 1;
	var imgSource = "/vtphotos/" + mlsid + String.fromCharCode(curPhoto+96) + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + curPhoto + " of " + photoCount;
}
function prevVTImage(mlsid)
{
	if (curPhoto == 1)
		curPhoto = photoCount;
	else
		curPhoto -= 1;
	var imgSource = "/vtphotos/" + mlsid + String.fromCharCode(curPhoto+96) + '.jpg';
	document.getElementById('mainimage').src=imgSource;
	document.getElementById('phototext').innerHTML="Picture " + curPhoto + " of " + photoCount;
}


function printListing(mlsid, listtype, imgwidth, imgheight)
{
	wWidth = imgwidth;
	wHeight = imgheight + 60;
	wResizeWidth = imgwidth + 12;
	wResizeHeight = imgheight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	printWindow = window.open("printlisting.asp?type=" + listtype + "&id="+mlsid, "print", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes");
	printWindow.resizeTo(wResizeWidth,wResizeHeight);
	printWindow.moveTo(wLeft,wTop);
	printWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ printWindow.window.focus(); }
}
function emailListing(mlsid, listtype, imgwidth, imgheight)
{
	wWidth = imgwidth;
	wHeight = imgheight + 60;
	wResizeWidth = imgwidth + 12;
	wResizeHeight = imgheight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	emailWindow = window.open("emaillisting.asp?listtype=" + listtype + "&id="+mlsid, "email", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=no");
	emailWindow.resizeTo(wResizeWidth,wResizeHeight);
	emailWindow.moveTo(wLeft,wTop);
	emailWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ emailWindow.window.focus(); }
}

function setMortgageAmount(amount, percentage)
{
	var newmortgageAmount = (amount * (100-percentage)) / 100;
	document.mortgage.AMOUNT.value = newmortgageAmount;
	document.mortgage.PAYMENT.value = "";
}
	
