function gallery_caption()
{
this.ctext = document.getElementById("caption_text");
this.caption_open_width = 200;
this.caption_close_width = 0;
image_container_a = document.getElementById("primary_a");
image_top_y = getOffsetY(image_container_a);
image_left_x = getOffsetX(image_container_a);
//YAHOO.util.Dom.setStyle('caption', 'top', image_top_y+"px")
//YAHOO.util.Dom.setStyle('caption', 'left', (image_left_x+400)+"px")
}
gallery_caption.prototype.resetCoords = function()
{
image_container_a = document.getElementById("primary_a");
image_top_y = getOffsetY(image_container_a);
image_left_x = getOffsetX(image_container_a);
//YAHOO.util.Dom.setStyle('caption', 'top', image_top_y+"px")
//YAHOO.util.Dom.setStyle('caption', 'left', (image_left_x+400)+"px")
}
gallery_caption.prototype.swapCaption = function(new_caption)
{
this.ctext.innerHTML = new_caption;
if (new_caption == "")
$("#caption_button").css('visibility', "hidden");
else
$("#caption_button").css('visibility', "visible");
}
gallery_caption.prototype.show_caption = function(x,y)
{
this.ctext = document.getElementById("caption_text");
if (ajax_rollovers_active && this.ctext.innerHTML != "")
{
$("#caption").css('top', (y+10)+"px");
$("#caption").css('left', (x+10)+"px");
$("#caption").css('visibility', "visible");
$("#caption").css('width', this.caption_open_width+"px");
var divh = document.getElementById('caption_text').scrollHeight;
$("#caption").css('height', divh+"px");
}
}
gallery_caption.prototype.hide_caption = function()
{
$("#caption").css('visibility', "hidden");
$("#caption").css('width', "0px");
$("#caption").css('height', "0px");
}
function slider(num_items)
{
this.num_items = num_items;
}
slider.prototype.slideLeft = function(howmuch)
{
if (!(howmuch > 0))
{
howmuch = 1;
}
if (current_position < this.num_items -3) {
current_position = current_position + howmuch;
scroll_target = initial_x - (scroll_width * current_position);
$("#images").animate({
left: scroll_target
}, 500);
}
this.toggleLRButtons();
}
slider.prototype.slideRight = function(howmuch)
{
if (!(howmuch > 0))
{
howmuch = 1;
}
if (current_position > 0) {
current_position = current_position - howmuch;
scroll_target = initial_x - (scroll_width * current_position);
$("#images").animate({
left: scroll_target
}, 500);
}
this.toggleLRButtons();
}
// Disable left or right scrolling buttons when they're at the limit
slider.prototype.toggleLRButtons = function()
{
if (current_position == 0 && this.num_items < 5)
{
$("#gallery_left_button").css('visibility', "hidden");
$("#gallery_right_button").css('visibility', "hidden");
}
else if (current_position == 0)
{
$("#gallery_left_button").css('visibility', "hidden");
}
else if (current_position > this.num_items - 4)
{
$("#gallery_right_button").css('visibility', "hidden");
}
else
{
$("#gallery_left_button").css('visibility', "visible");
$("#gallery_right_button").css('visibility', "visible");
}
}
function primary_container(id)
{
this.id = id;
}
primary_container.prototype.show = function()
{
$("#"+this.id).animate({
opacity: 1
}, 500);
}
primary_container.prototype.hide = function()
{
$("#"+this.id).css('opacity', "0");
$("#"+this.id).html("")
}
function gallery_video(embed_obj)
{
this.embed_obj = embed_obj;
this.primary_a = new primary_container("primary_a");
this.primary_b = new primary_container("primary_b");
}
gallery_video.prototype.prep_display = function()
{
showcase = document.getElementById("primary_"+showcase_in_use);
showcase.innerHTML = "Get the Flash Player to see this player.";
this.embed_obj.write("primary_"+showcase_in_use);
}
gallery_video.prototype.showcase = function()
{
$("#tools").css('visibility', "hidden");
this.prep_display();
var byline_display = document.getElementById("byline_display");
byline_display.innerHTML = "";
if (showcase_in_use == "a") {
showcase_in_use = "b";
this.primary_b.hide();
$("#primary_b").css('height', "0px");
$("#primary_a").css('height', "100%");
this.primary_a.show();
}
else {
showcase_in_use = "a";
this.primary_a.hide();
$("#primary_a").css('height', "0px");
$("#primary_b").css('height', "100%");
this.primary_b.show();
}
}
function gallery_image(id, caption, credit, image_url, image_height, image_width, thumb_image_url, thumb_image_height, thumb_image_width)
{
this.caption = caption;
this.credit = credit;
this.image_url = image_url;
this.image_height = image_height;
this.image_width = image_width;
this.thumb_image_url = thumb_image_url;
this.thumb_image_height = thumb_image_height;
this.thumb_image_width = thumb_image_width;
this.primary_a = new primary_container("primary_a");
this.primary_b = new primary_container("primary_b");
this.preload = new Image();
this.preload.src = image_url;
}
gallery_image.prototype.prep_display = function()
{
showcase = document.getElementById("primary_"+showcase_in_use);
var x = '
';
showcase.innerHTML = x;
}
gallery_image.prototype.showcase = function()
{
$("#tools").css('visibility', "visible");
this.prep_display();
// Decided not to fade in the byline for now. Hardcode to byline_a for now unless we decide we wan't that effect.
//byline = document.getElementById("image_byline_"+showcase_in_use);
var byline_display = document.getElementById("byline_display");
byline_display.innerHTML = "Credit: "+ this.credit;
new_height = showcase.height + 80;
if (showcase_in_use == "a") {
showcase_in_use = "b";
this.primary_b.hide();
$("#primary_b").css('height', "0px");
$("#primary_a").css('height', "100%");
this.primary_a.show();
}
else {
showcase_in_use = "a";
this.primary_a.hide();
$("#primary_a").css('height', "0px");
$("#primary_b").css('height', "100%");
this.primary_b.show();
}
caption.swapCaption(this.caption);
}
// Handle click on a thumbnail image, trigger sowcase method on the object in the items array
function showcase_item(id)
{
if (id > 0) {
item_id = id;
}
else {
item_id = (id).replace(/[^0-9]/g, ''); // strip image_container_2 down to just the number 2
}
gallery_items[item_id].showcase();
}
// Handle clicks on the left/right buttons
function handle_scroll(id)
{
if (id == "gallery_left_button")
{
gallery_slider.slideRight(1);
}
if (id == "gallery_right_button")
{
gallery_slider.slideLeft(1);
}
}
function update(e)
{
image_container_a = document.getElementById("primary_a");
image_container_b = document.getElementById("primary_b");
// Get the boundries for the image container
image_left_x = getOffsetX(image_container_a);
image_top_y = getOffsetY(image_container_a);
// Calculate height and width of the image
//if (YAHOO.util.Dom.getStyle('primary_b', 'height') == "0px")
if ($("#primary_b").css('height') == "0px")
{
i_height = image_container_a.offsetHeight;
i_width = image_container_a.offsetWidth;
}
else
{
i_height = image_container_b.offsetHeight;
i_width = image_container_b.offsetWidth;
}
// Add width & height to upper left coordinate to get lower right coordinates
image_bottom_y = image_top_y + i_height;
image_right_x = image_left_x + i_width;
// Find the boundries for the caption button
c_button = document.getElementById("caption_button");
c_button_left_x = getOffsetX(c_button);
c_button_top_y = getOffsetY(c_button);
c_button_bottom_y = c_button_top_y + c_button.offsetHeight;
c_button_right_x = c_button_left_x + c_button.offsetWidth;
// Grab Mouse coordinates
var docX, docY;
if( e )
{
if( typeof( e.pageX ) == 'number' )
{
docX = e.pageX;
docY = e.pageY;
}
else
{
docX = e.clientX;
docY = e.clientY;
}
}
else
{
e = window.event;
docX = e.clientX;
docY = e.clientY;
if( document.documentElement
&& ( document.documentElement.scrollTop
|| document.documentElement.scrollLeft ) )
{
docX += document.documentElement.scrollLeft;
docY += document.documentElement.scrollTop;
}
else if( document.body
&& ( document.body.scrollTop
|| document.body.scrollLeft ) )
{
docX += document.body.scrollLeft;
docY += document.body.scrollTop;
}
}
var mouse_X = docX
var mouse_Y = docY
//c = document.getElementById("coords");
//c.innerHTML = "mouse_x = " + mouse_X + " mouse_Y = " + mouse_Y + " image_left_x = " + image_left_x + " image_top_y = "+image_top_y+" image_right_x = " + image_right_x + " image_bottom_y = "+image_bottom_y + "current_position = " + current_position + " c_button_left_x = " + c_button_left_x +" c_button_top_y = "+c_button_top_y+" c_button_bottom_y = " + c_button_bottom_y + " c_button_right_x = " + c_button_right_x;
var caption_visibility_switch = false;
// Check if the mouse is hovering over the image
if (mouse_X > image_left_x && mouse_X < image_right_x && mouse_Y < image_bottom_y && mouse_Y > image_top_y)
{
caption_visibility_switch = true;
}
// Check if the mouse is hovering over the caption button
if (mouse_X > c_button_left_x && mouse_X < c_button_right_x && mouse_Y < c_button_bottom_y && mouse_Y > c_button_top_y)
{
caption_visibility_switch = true;
}
// Trigger a show or hide action based on mouse coordinates
if (caption_visibility_switch && item_id > 3)
{
caption.show_caption(mouse_X,mouse_Y);
}
else
{
caption.hide_caption();
}
}
function gallery_init(num_items) {
// Had to disable bookmarking temporarily due to an image preloader issue
// If there's a bookmark, show that image
if (bookmark > 0)
{
showcaseImage(bookmark);
if (bookmark > 3)
{
showcase_item(bookmark);
}
}
else
{
// Display first video. Else first image, else there's nothing here so hide this gallery
var i;
var hideGallery = true;
for (i = 1; i < 12; i++)
{
if (typeof(gallery_items[i]) == "object")
{
showcase_item(i);
hideGallery = false;
break;
}
}
if (hideGallery)
{
$("#photo_gallery_container").css('display', 'none')
$("#image_extras").css('display', 'none')
}
}
if (num_items < 2)
{
$("#scrolling_box").css('display', 'none')
$("#divider_curve").css('display', 'none')
caption.resetCoords();
}
gallery_slider.toggleLRButtons();
}