";
TB_load_position();
$('TB_overlay').set('tween', {
duration: 400
});
$('TB_overlay').tween('opacity', 0, 0.6);
}
if (!$("TB_load")) {
new Element('div').setProperty('id', 'TB_load').injectInside(document.body);
$('TB_load').innerHTML = "
";
TB_load_position();
}
if (!$("TB_window")) {
new Element('div').setProperty('id', 'TB_window').injectInside(document.body);
$('TB_window').setOpacity(0);
}
$("TB_overlay").onclick = TB_remove;
window.onscroll = TB_position;
// check if a query string is involved
var baseURL = url.match(/(.+)?/)[1] || url;
// regex to check if a href refers to an image
var imageURL = /\.(jpe?g|png|gif|bmp)/gi;
// check for images
if (baseURL.match(imageURL)) {
var dummy = {
caption: "",
url: "",
html: ""
};
var prev = dummy, next = dummy, imageCount = "";
// if an image group is given
if (rel) {
function getInfo(image, id, label){
return {
caption: image.title,
url: image.href,
html: " " + label + ""
}
}
// find the anchors that point to the group
var imageGroup = [];
$$("a.smoothbox").each(function(el){
if (el.rel == rel) {
imageGroup[imageGroup.length] = el;
}
})
var foundSelf = false;
// loop through the anchors, looking for ourself, saving information about previous and next image
for (var i = 0; i < imageGroup.length; i++) {
var image = imageGroup[i];
var urlTypeTemp = image.href.match(imageURL);
// look for ourself
if (image.href == url) {
foundSelf = true;
imageCount = "Image " + (i + 1) + " of " + (imageGroup.length);
}
else {
// when we found ourself, the current is the next image
if (foundSelf) {
next = getInfo(image, "next", "Next >");
// stop searching
break;
}
else {
// didn't find ourself yet, so this may be the one before ourself
prev = getInfo(image, "prev", "< Prev");
}
}
}
}
imgPreloader = new Image();
imgPreloader.onload = function(){
imgPreloader.onload = null;
// Resizing large images
var x = window.getWidth() - 150;
var y = window.getHeight() - 150;
var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;
if (imageWidth > x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight > y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
}
else
if (imageHeight > y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth > x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}
// End Resizing
// TODO don't use globals
TB_WIDTH = imageWidth + 30;
TB_HEIGHT = imageHeight + 60;
// TODO empty window content instead
$("TB_window").innerHTML += "