// init vars needed
var isPreviewLoaded = false;
var galleryRolloverObj = null;
var galleryRolloverImg = null;
var tempX = 0;
var tempY = 0;
var IE = document.all ? true : false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
if (IE) document.execCommand("BackgroundImageCache", false, true);


// build preview objects
function buildPreview() {
	if (isPageLoaded) {
		galleryRolloverObj = eval(doc + "'galleryRollover'" + sty);
		galleryRolloverImg = eval(doc + "'galleryRolloverImage'" + sty);
		isPreviewLoaded = true;
	} else {
		setTimeout("buildPreview();", 500);
	}
}
buildPreview();

// function that captures mouse coords and adjusts objs
function mouseCoords(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	if (isPreviewLoaded) {
		galleryRolloverObj.left = posx - 60 + "px";
		galleryRolloverObj.top = posy - 165 + "px";
	}
}
// function to call to stop mouse coord tracking (called when hiding preview panel)
function mouseCoordsStop() {
	// do nothing, but assigning this function to document.onmousemove stops the mousemove
}

// function to open gallery preview panel and set contents
function showGalleryPreview(strImgFilename, strTopMargin, strLeftMargin) {
	if (isPreviewLoaded) {
		document.preview_image.src = strGalleryImagePath + strImgFilename;
		galleryRolloverImg.margin = strTopMargin + "px 0px 0px " + strLeftMargin + "px";
		document.onmousemove = mouseCoords;
		galleryRolloverObj.visibility = "visible";
	}
	
}
// function to close gallery preview panel and clear contents
function hideGalleryPreview() {
	if (isPreviewLoaded) {
		galleryRolloverObj.visibility = "hidden";
		document.preview_image.src = "/_images/blank.gif";
		galleryRolloverImg.margin = "0px 0px 0px 0px";
		document.onmousemove = mouseCoordsStop;
	}
}
