//Add oImg to the hideFrame function in this file, and add "this" to the hideFrame() of the onMouseOut of the image.
//1. This few line of code are adding the iFrame to the document. The Width and Height are 1 so it is invisible:
var z_nApp, z_oMainImage = new Image(), z_nTimeOut = 0, z_oHourGlass = new Image(), z_oZoomDiv, z_oZoomImage, 
	z_oZoomTitle, z_cZoomTitle, z_oZoomFrame, z_nDivWidth, z_nDivHeight, z_nFrameBorderWidth, z_oZoomTop, 
	nScreenWidth = screenSize(1), nScreenHeight = screenSize(2), z_nDivOffset = 10, z_nZoomTopHeight, z_nPadding, z_nOfset

	
//Change the wating animated gif file here:
z_oHourGlass.src = "../ZoomImages/Spin.gif"
z_cZoomTitle = "A Beautiful Bedroom Zoom-In"
z_nDivWidth = 480
z_nDivHeight = 360
z_nFrameBorderWidth = 2
z_nZoomTopHeight = 46
z_nPadding = 4
z_nOfset = 20

switch (navigator.appName)
	{
	case "Netscape":
		z_nApp = 1;
		break;
	default: //Explorer
		z_nApp = 0;
		break;
	}

//Create the DIV string
cFrame = '<div id="zoomFrame" style="visibility:hidden;z-index:1005;position:absolute;px;padding:' + z_nPadding + 'px;margin:0px;">' + 
	'<div id="zoomTop"  style="width:'  + (z_nDivWidth - z_nPadding * 2) + 'px;height:' + 
	(z_nZoomTopHeight - z_nPadding * 4) + 'px;padding:' + z_nPadding + 'px;margin:0px;">' + 
	'<p id="zoomTitle" style="margin:5px 0px 5px 0px;"></p></div><div id="zoomDiv" style="width:' + (z_nDivWidth - z_nPadding * 2) + 'px;height:' + 
	(z_nDivHeight - z_nZoomTopHeight - z_nPadding * 4) + 'px;overflow:hidden;position:relative;padding:' + z_nPadding + 'px;">' + 
	'<img id="zoomImage" style="position:absolute;padding:30px"></div></div>'

document.writeln('<link rel="stylesheet" type="text/css" href="/ZoomImages/zoomStyles.css">')
document.writeln(cFrame)

//Store DIVs in variables for later use
z_oZoomDiv = document.getElementById("zoomDiv")
z_oZoomTop = document.getElementById("zoomTop")
z_oZoomImage = document.getElementById("zoomImage")
z_oZoomTitle = document.getElementById("zoomTitle")
z_oZoomFrame = document.getElementById("zoomFrame")

z_oZoomFrame.style.borderWidth = z_nFrameBorderWidth + "px"

//2. This function will set the Width and Height, Lef and Right of the iFrame and load the LARGE image in it:
//Optional: cSrc: Pass FULL URL for image to be used as the LARGE version of the smaller image
//Optional: cTitle: Pass a title for the top of table
function setFrame(oImg, cSrc, cTitle)
	{	
	//Set the title for the window
	z_oZoomTitle.innerHTML = (cTitle ? cTitle : z_cZoomTitle)
	var oPic,
		oObject=oImg.offsetParent,
		nTop=oImg.offsetTop,
		nLeft=oImg.offsetLeft

	if (typeof(cSrc)=="undefined")
		{
		cSrc = oImg.src
		cSrc = cSrc.replace("/Lawrence-Home/images/","/Lawrence-Home/W1024/")
		}

	while (oObject != null)
		{
		nTop = nTop + oObject.offsetTop
		nLeft = nLeft + oObject.offsetLeft
		oObject = oObject.offsetParent
		}

	if (nLeft < (nScreenWidth * 0.45))
		{
		//nLeft = nLeft + oImg.width + z_nDivOffset
		nLeft = nLeft + oImg.offsetWidth + z_nDivOffset
		}
		else
		{
		nLeft = nLeft - z_oZoomFrame.offsetWidth - z_nDivOffset
		}

	oImg.style.cursor='url(/ZoomImages/arrow.cur)'

	z_oZoomImage.src=z_oHourGlass.src

	//z_oZoomFrame.style.top = (nTop - (z_nDivHeight - oImg.offsetWidth) / 3) + "px"
	//z_oZoomFrame.style.top = nTop + "px"
	z_oZoomFrame.style.top = (nTop - z_nZoomTopHeight) + "px"
	z_oZoomFrame.style.left = nLeft + "px"

	z_oMainImage.src = cSrc
	z_nTimeOut = setInterval("loadImage()",500)

	z_oZoomFrame.style.visibility="visible"
	}

//3. This function hide the frame when mouse goes off the image
function hideFrame(oImg)
	{
	z_oZoomImage.src=""
	z_oZoomFrame.style.visibility="hidden";
	}

//4. This function is scrolling the image in the fram according to mouse movement.
function moveImage(oImg,evt)
	{
	var wRat, hRat, oObject, nTop, nLeft
	wRat = ((z_oZoomImage.offsetWidth - z_oZoomDiv.offsetWidth) / oImg.width)
	hRat = ((z_oZoomImage.offsetHeight - z_oZoomDiv.offsetHeight) / oImg.height)

	switch (z_nApp)
		{
		case 1: //Netscape / Firefox
			oObject=oImg.offsetParent,
			nTop=oImg.offsetTop,
			nLeft=oImg.offsetLeft

			while (oObject != null)
				{
				nTop = nTop + oObject.offsetTop
				nLeft = nLeft + oObject.offsetLeft
				oObject = oObject.offsetParent
				}
			nLeft = (nLeft - evt.pageX) * wRat
			nTop = (nTop - evt.pageY) * hRat
			break;
		default: //Explorer
			{
			nLeft = (-event.offsetX * wRat)
			nTop = (-event.offsetY * hRat)
			break
			}
		}
		z_oZoomImage.style.left = nLeft + "px"
		z_oZoomImage.style.top = nTop + "px"
	}
	
//When main image loaded, will show it.
function loadImage()
    {
    if (z_oMainImage.height)
        {
        clearInterval(z_nTimeOut)
		z_oZoomImage.src = z_oMainImage.src
		}
    }

function setFrame1(oImg, cSrc)
	{
	//Keep this functon till next time compile Veratex. Then change the veratex to setFrame( from setFrame1(
	setFrame(oImg, cSrc)
	}

function screenSize(nWhat)
	{
	switch (nWhat)
		{
		case 1:
			if (self.innerHeight) {return self.innerWidth;}
			if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}
			if (document.body) {return document.body.clientWidth}
			break
		case 2: 
			if (self.innerHeight) {return self.innerHeight;}
			if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}
			if (document.body) {return document.body.clientHeight}
			break
		}
	return -1
	}

