/*
Copyright, Woodland Engineering, 2009
For documentation, please request by email from (pardon format, but it's to avoid bots from picking it up).
  mail.kencurtis // AT // gmail // DOT COM //
Please identify yourself and tell us why you want it.
*/
var WePhotoShow =
{
overlayFolder: "../images/",
photoFolder: "../photos/",
BGND_Z_IDX: "300",
FGND_Z_IDX: "301",
photoData: [],
NAME_IDX:   0,
IMG_IDX:    1,
TITLE_IDX:  2,
DESCR_IDX:  3,
DISPBOX_XOFF: 20,
DISPBOX_YOFF: 20,
DISPBOX_XPLUS: 20,
DISPBOX_YPLUS: 20,
displayBoxObj: null
};
WePhotoShow.CreatePhotoHTML = function
(
elemNum
)
{
var li;
var button;
var photoHtmlObj;
var photoHtml = function (photoIdx)
{
var that = this;
this.activePhotoIdx = photoIdx < WePhotoShow.photoData.length ? photoIdx : -1;
this.isDisplayed = false;
this.overlayObj = WePhotoShow.CreateOverlayObj();
this.div = document.createElement("DIV");
this.div.className = "wephotoshowdiv";
this.div.style.position = "absolute";
this.div.style.visibility = "hidden";
this.div.style.zIndex = WePhotoShow.FGND_Z_IDX;
this.ul = document.createElement("UL");
this.ul.className = "wephotoshowdisplist";
this.ul = this.div.appendChild(this.ul);
li = document.createElement("LI");
li.className = "wephotoshowcntl";
li = this.ul.appendChild(li);
button = document.createElement("IMG");
button.className = "wephotoshowbtn";
button.id = "prev_cntl";
button.src = "../images/prev_5bb6ef.gif";
this.prevButton = li.appendChild(button);
button = document.createElement("IMG");
button.className = "wephotoshowbtn";
button.id = "next_cntl";
button.src = "../images/next_5bb6ef.gif";
this.nextButton = li.appendChild(button);
button = document.createElement("IMG");
button.className = "wephotoshowbtn";
button.id = "done_cntl";
button.src = "../images/close_x.gif";
this.doneButton = li.appendChild(button);
li = document.createElement("LI");
li.className = "wephotoshowphotographer";
this.photographerLi = this.ul.appendChild(li);
li = document.createElement("LI");
li.className = "wephotoshowdispimg";
this.photoImageLi = this.ul.appendChild(li);
li = document.createElement("LI");
li.className = "wephotoshowtitle";
this.photoTitleLi = this.ul.appendChild(li);
li = document.createElement("LI");
li.className = "wephotoshowdesc";
this.photoDescriptLi = this.ul.appendChild(li);
this.GetExtents = function ()
{
var extent = { x: 0, y: 0 };
extent.x = that.div.offsetLeft + that.div.offsetWidth + WePhotoShow.DISPBOX_XPLUS;
extent.y = that.div.offsetTop + that.div.offsetHeight + WePhotoShow.DISPBOX_YPLUS;
return extent;
};
this.ReplaceImageDisplay = function (bInitialDisplay)
{
that.photographerLi.innerHTML = WePhotoShow.photoData[that.activePhotoIdx][WePhotoShow.NAME_IDX];
that.photoImageLi.innerHTML = "<img src='" + WePhotoShow.photoFolder +
WePhotoShow.photoData[that.activePhotoIdx][WePhotoShow.IMG_IDX] +
".jpg' alt='Photo' />";
that.photoTitleLi.innerHTML = WePhotoShow.photoData[that.activePhotoIdx][WePhotoShow.TITLE_IDX];
that.photoDescriptLi.innerHTML = WePhotoShow.photoData[that.activePhotoIdx][WePhotoShow.DESCR_IDX];
if (bInitialDisplay !== true)
that.overlayObj.Resize();
};
this.ReplaceImageDisplay(true);
this.Show = function ()
{
if (that.activePhotoIdx < 0)
return;
if (that.isDisplayed === true)
that.Hide();
that.overlayObj.Show();
that.div = document.body.appendChild(that.div);
var docBody = document.body;
var viewportLeft = window.pageXOffset || document.documentElement.scrollLeft || docBody.scrollLeft;
var viewportTop = window.pageYOffset || document.documentElement.scrollTop || docBody.scrollTop;
that.div.style.left = (20 + viewportLeft) + "px";
that.div.style.top = (20 + viewportTop) + "px";
that.div.style.visibility = "visible";
that.overlayObj.Resize();
that.isDisplayed = true;
if (typeof window.addEventListener !== "undefined")
{
document.addEventListener("keydown", that.OnKeydown, false);
}
else if (typeof window.attachEvent !== "undefined")
{
document.attachEvent("onkeydown", that.OnKeydown);
}
};
this.Hide = function ()
{
if (that.isDisplayed === true)
{
that.div.style.visibility = "hidden";
that.isDisplayed = false;
document.body.removeChild(that.div);
that.overlayObj.Hide();
if (typeof window.removeEventListener !== "undefined")
{
document.removeEventListener("keydown", that.OnKeydown, false);
}
else if (typeof window.detachEvent !== "undefined")
{
document.detachEvent("onkeydown", that.OnKeydown);
}
}
};
this.DoneMouseover = function()
{
that.doneButton.src = "../images/close_x_hl.gif";
}
this.doneButton.onmouseover = this.DoneMouseover;
this.DoneMouseoout = function()
{
that.doneButton.src = "../images/close_x.gif";
}
this.doneButton.onmouseout = this.DoneMouseoout;
this.PrevMouseover = function()
{
that.prevButton.src = "../images/prev_a4ef5b.gif";
}
this.prevButton.onmouseover = this.PrevMouseover;
this.PrevMouseoout = function()
{
that.prevButton.src = "../images/prev_5bb6ef.gif";
}
this.prevButton.onmouseout = this.PrevMouseoout;
this.NextMouseover = function()
{
that.nextButton.src = "../images/next_a4ef5b.gif";
}
this.nextButton.onmouseover = this.NextMouseover;
this.NextMouseoout = function()
{
that.nextButton.src = "../images/next_5bb6ef.gif";
}
this.nextButton.onmouseout = this.NextMouseoout;
this.DoneAction = function ()
{
that.Hide();
delete that.overlay;
delete that;
WePhotoShow.displayBoxObj = null;
};
this.doneButton.onclick = this.DoneAction;
this.PrevAction = function ()
{
if (that.activePhotoIdx > 0)
{
that.activePhotoIdx--;
that.ReplaceImageDisplay();
}
};
this.prevButton.onclick = this.PrevAction;
this.NextAction = function ()
{
if (that.activePhotoIdx < (WePhotoShow.photoData.length - 1))
{
that.activePhotoIdx++;
that.ReplaceImageDisplay();
}
};
this.nextButton.onclick = this.NextAction;
this.OnKeydown = function (evt)
{
if (evt.keyCode === 27)
that.DoneAction();
else if (evt.keyCode === 80 || evt.keyCode === 112)
that.PrevAction();
else if (evt.keyCode === 78 || evt.keyCode === 110)
that.NextAction();
};
};
if (WePhotoShow.displayBoxObj === null)
WePhotoShow.displayBoxObj = new photoHtml(elemNum);
return WePhotoShow.displayBoxObj;
}
WePhotoShow.CreateOverlayObj = function ()
{
var olayObj;
var overLay = function ()
{
var that = this;
var imgUrl = WePhotoShow.overlayFolder + "black_a86_64x64.png";
this.isDisplayed = false;
this.div = document.createElement("DIV");
this.div.style.visibility = "hidden";
this.div.style.position = "absolute";
this.div.style.zIndex = WePhotoShow.BGND_Z_IDX;
this.div.style.margin = "0px";
this.div.style.padding = "0px";
this.div.style.backgroundImage = "url(" + imgUrl + ")";
this.div.style.backgroundRepeat = "repeat";
this.overlayWidth = 0;
this.overlayHeight = 0;
this.div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale', src='" +
imgUrl + "')";
this.Resize = function ()
{
var extent = { x: 0, y: 0 };
var htmlNode = document.getElementsByTagName("HTML")[0];
var htmlWidth = htmlNode.clientWidth > htmlNode.scrollWidth ? htmlNode.clientWidth : htmlNode.scrollWidth;
var htmlHeight = htmlNode.clientHeight > htmlNode.scrollHeight ? htmlNode.clientHeight : htmlNode.scrollHeight;
extent = WePhotoShow.displayBoxObj.GetExtents();
var newWidth = extent.x > htmlWidth ? extent.x : htmlWidth;
var newHeight = extent.y > htmlHeight ? extent.y : htmlHeight;
if (that.overlayWidth < newWidth)
{
that.overlayWidth = newWidth;
that.div.style.width = newWidth + "px";
}
if (that.overlayHeight < newHeight)
{
that.overlayHeight = newHeight;
that.div.style.height = newHeight + "px";
}
};
this.OnScroll = function (evt)
{
if (evt.eventPhase === 3)
that.Resize();
};
this.Show = function ()
{
if (that.isDisplayed === true)
that.Hide();
that.div = document.body.appendChild(that.div);
that.div.style.left = "0px";
that.div.style.top = "0px";
that.Resize();
that.div.style.visibility = "visible";
that.isDisplayed = true;
if (typeof window.addEventListener !== "undefined")
{
window.addEventListener("resize", that.Resize, false);
window.addEventListener("scroll", that.OnScroll, false);
}
else if (typeof window.attachEvent !== "undefined")
{
window.attachEvent("onresize", that.Resize);
window.attachEvent("onscroll", that.OnScroll);
}
};
this.Hide = function ()
{
if (that.isDisplayed === true)
{
that.div.style.visibility = "hidden";
that.isDisplayed = false;
document.body.removeChild(that.div);
if (typeof window.removeEventListener !== "undefined")
{
window.removeEventListener("resize", that.Resize, false);
window.removeEventListener("scroll", that.OnScroll, false);
}
else if (typeof window.detachEvent !== "undefined")
{
window.detachEvent("onresize", that.Resize);
window.detachEvent("onscroll", that.OnScroll);
}
}
};
};
return olayObj = new overLay();
};
WePhotoShow.ShowPhoto = function
(
elemNumStr
)
{
var elemNum = parseInt(elemNumStr);
if (elemNum < WePhotoShow.photoData.length)
{
var photoDispObj = WePhotoShow.CreatePhotoHTML(elemNum);
photoDispObj.Show();
}
else
alert("Possibly corrupt or missing \"cdccphoto\" file.\nRef: Element " + elemNum);
}
