/*
* INIT OOG LIGHTBOX
*
* Adds the html for lightbox to document and inits some variables/events.
*
* Parameter:
* String phpBackEnd (path to requests.php)
* String flowplayer (path to flowplayer swf)
*
* Returns: -
*/
function initOogLightbox(phpBackEnd, flowplayer) {
oogLightboxRequests = phpBackEnd;
flowplayer_swf = flowplayer;
var oog_lightbox_html = '
' +
'' +
'
' +
'
Hier klicken, um abzubrechen
' +
'
' +
'';
document.write(oog_lightbox_html);
lightbox_overlay = document.getElementById('oog_lightbox_overlay');
lightbox_main = document.getElementById('oog_lightbox_main');
lightbox_loading = document.getElementById('oog_lightbox_loading');
var first_windowheight = (window.innerHeight) ? window.innerHeight : window.document.documentElement.clientHeight;
var first_windowwidth = (window.innerWidth) ? window.innerWidth : window.document.documentElement.clientWidth;
lightbox_main_height_percent = lightbox_main.offsetHeight / first_windowheight * 100;
lightbox_main_width_percent = lightbox_main.offsetWidth / first_windowwidth * 100;
lightbox_main_top_percent = (100 - lightbox_main_height_percent) / 2;
lightbox_main_left_percent = (100 - lightbox_main_width_percent) / 2;
lightbox_main.style.top = lightbox_main_top_percent + '%';
lightbox_main.style.left = lightbox_main_left_percent + '%';
lightbox_slideshow = 0;
lightbox_timeout = false;
lightbox_extended = '';
lightbox_firsttitle = document.title;
isDescription = false;
descriptionFocused = false;
show_error_filedescription = true;
lightbox_loading_height = lightbox_loading.offsetHeight;
lightbox_loading_width = lightbox_loading.offsetWidth;
document.getElementById('oog_lightbox_next_radius').onmouseover = function() {
document.getElementById('oog_lightbox_next_but').style.backgroundPosition='-54px 0px';
}
document.getElementById('oog_lightbox_next_radius').onmouseout = function() {
document.getElementById('oog_lightbox_next_but').style.backgroundPosition='0px 0px';
}
document.getElementById('oog_lightbox_previous_radius').onmouseover = function() {
document.getElementById('oog_lightbox_previous_but').style.backgroundPosition='-54px 0px';
}
document.getElementById('oog_lightbox_previous_radius').onmouseout = function() {
document.getElementById('oog_lightbox_previous_but').style.backgroundPosition='0px 0px';
}
/*document.getElementById('oog_lightbox_playlist_but').onmouseover = function() {
document.getElementById('oog_lightbox_playlist_but').style.backgroundPosition = (lightbox_slideshow == 0) ? '-17px 0px' : '-17px -17px';
}
document.getElementById('oog_lightbox_playlist_but').onmouseout = function() {
document.getElementById('oog_lightbox_playlist_but').style.backgroundPosition = (lightbox_slideshow == 0) ? '0px 0px' : '0px -17px';
}*/
}
/*
* RESIZE LIGHTBOX
*
*
*
* Parameter: -
* Returns: -
*/
function resizelightbox() {
refresh_lightbox_extended_box('', false);
var windowheight = (window.innerHeight) ? window.innerHeight : window.document.documentElement.clientHeight;
var windowwidth = (window.innerWidth) ? window.innerWidth : window.document.documentElement.clientWidth;
var extra_margin_top = 0;
var extra_height = 0;
if(lightbox_extended != '') {
extra_margin_top = extra_margin_top - 100;
extra_height = extra_height - 150;
}
if(isDescription) {
extra_margin_top = extra_margin_top - 12;
extra_height = extra_height - 36;
}
heightspace = Math.round(windowheight / 100 * lightbox_main_height_percent - 64 + extra_height);
widthspace = Math.round(windowwidth / 100 * lightbox_main_width_percent - 54);
new_photo_height = 0;
new_photo_width = 0;
if(resize_photos == 'all') {
new_photo_height = heightspace;
new_photo_width = heightspace * (firstimgwidth / firstimgheight);
if(new_photo_width > widthspace) {
new_photo_width = widthspace;
new_photo_height = widthspace * (firstimgheight / firstimgwidth);
}
} else {
if(firstimgheight > heightspace || firstimgwidth > widthspace) {
new_photo_height = heightspace;
new_photo_width = heightspace * (firstimgwidth / firstimgheight);
if(new_photo_width > widthspace) {
new_photo_width = widthspace;
new_photo_height = widthspace * (firstimgheight / firstimgwidth);
}
} else {
new_photo_height = firstimgheight;
new_photo_width = firstimgwidth;
}
}
if(firstimgwidth != 0 && firstimgheight != 0) {
if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') {
new_photo_width = ( new_photo_height - 7 ) * ( firstimgwidth / firstimgheight );
lightbox_photo.height = new_photo_height;
lightbox_photo.width = new_photo_width;
} else if(mediafile_extension == 'flv' || mediafile_extension == 'mp4') {
new_photo_width = ( new_photo_height - 24 ) * ( firstimgwidth / firstimgheight );
flowplayer_video.style.height = new_photo_height + 'px';
flowplayer_video.style.width = new_photo_width + 'px';
} else if(mediafile_extension == 'mp3') {
new_photo_width = ( new_photo_height - 7 ) * ( firstimgwidth / firstimgheight );
flowplayer_video.style.width = new_photo_width + 'px';
flowplayer_video.style.height = '40px';
}
}
$('#oog_lightbox_filedescription').css('width', new_photo_width + 'px');
lightbox_main_width = $('#oog_lightbox_main').width();
lightbox_main_height = $('#oog_lightbox_main').height();
document.getElementById('oog_lightbox_next_radius').style.height = ( new_photo_height / 100 * 85 ) + 'px';
document.getElementById('oog_lightbox_next_radius').style.width = ( new_photo_width / 100 * 45 ) + 'px';
document.getElementById('oog_lightbox_next_radius').style.bottom = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + 34 - extra_margin_top ) + 'px';
document.getElementById('oog_lightbox_next_radius').style.right = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 16 ) + 'px';
document.getElementById('oog_lightbox_previous_radius').style.height = ( new_photo_height / 100 * 85 ) + 'px';
document.getElementById('oog_lightbox_previous_radius').style.width = ( new_photo_width / 100 * 45 ) + 'px';
document.getElementById('oog_lightbox_previous_radius').style.bottom = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + 34 - extra_margin_top ) + 'px';
document.getElementById('oog_lightbox_previous_radius').style.left = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 16 ) + 'px';
document.getElementById('oog_lightbox_close_but').style.top = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 - 6 + extra_margin_top ) + 'px';
document.getElementById('oog_lightbox_close_but').style.right = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 10 ) + 'px';
document.getElementById('oog_lightbox_photo_box').style.marginLeft = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 ) + 'px';
document.getElementById('oog_lightbox_photo_box').style.marginTop = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + extra_margin_top ) + 'px';
document.getElementById('oog_lightbox_shad_top').style.width = new_photo_width + 28 + 'px';
document.getElementById('oog_lightbox_shad_bottom').style.width = new_photo_width + 28 + 'px';
document.getElementById('oog_lightbox_shad_left').style.height = new_photo_height + 28 + 'px';
document.getElementById('oog_lightbox_shad_right').style.height = new_photo_height + 28 + 'px';
lightbox_main.style.top = Math.round( windowheight / 100 * lightbox_main_top_percent ) + 'px';
lightbox_main.style.left = Math.round( windowwidth / 100 * lightbox_main_left_percent ) + 'px';
lightbox_overlay.style.position = 'fixed';
lightbox_main.style.position = 'fixed';
lightbox_overlay.style.height = '100%';
lightbox_overlay.style.width = '100%';
}
/*
* LOAD MEDIA
*
*
*
* Parameter: -
* Returns: -
*/
function load_media() {
// make loading visible //
$('#oog_lightbox_loading').fadeOut(0);
lightbox_loading.style.visibility = 'visible';
$('#oog_lightbox_loading').fadeIn(fadeInOut_loading);
// add name of file to document title //
document.title = lightbox_firsttitle + ' - ' + oog_photoname;
// clear filewrapper & description //
document.getElementById('oog_lightbox_photo_wrapper').innerHTML = '';
document.getElementById('oog_lightbox_filedescription').innerHTML = '';
// if have to load an image //
if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') {
// insert img element for photo into the filewrapper //
var img_tag = document.createElement('img');
var img_tag_id = document.createAttribute('id');
img_tag_id.nodeValue = 'oog_lightbox_photo';
var img_tag_src = document.createAttribute('src');
img_tag_src.nodeValue = '';
var img_tag_border = document.createAttribute('border');
img_tag_border.nodeValue = '0px';
img_tag.setAttributeNode(img_tag_id);
img_tag.setAttributeNode(img_tag_src);
img_tag.setAttributeNode(img_tag_border);
document.getElementById('oog_lightbox_photo_wrapper').appendChild(img_tag);
// resizelightbox() needs this for accessing height & width of photo element //
lightbox_photo = document.getElementById('oog_lightbox_photo');
lightbox_img = new Image();
lightbox_img.onload = function() {
// loading photo done //
// take original dimensions (resizelightbox() needs them) //
firstimgheight = lightbox_img.height;
firstimgwidth = lightbox_img.width;
// resize before file will be visible //
resizelightbox();
// hide loading //
$('#oog_lightbox_loading').fadeOut(fadeInOut_loading, function() {
lightbox_loading.style.visibility = 'hidden';
});
// make lightbox visible //
$('#oog_lightbox_main').fadeOut(0);
lightbox_main.style.visibility = 'visible';
document.getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7
$('#oog_lightbox_main').fadeIn(fadeInOut_file, function() {
// display description //
display_filedescription();
// if slideshow is active //
if(lightbox_slideshow == 1) lightbox_timeout = window.setTimeout('next()', timeout_slideshow);
});
}
// insert photo source to load //
lightbox_img.src = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname);
lightbox_photo.src = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname);
} else if(mediafile_extension == 'flv' || mediafile_extension == 'mp4') {
// if have to load a video //
// insert a element for videoplayer (flowplayer) into the filewrapper //
var player = document.createElement('a');
var player_id = document.createAttribute('id');
player_id.nodeValue = 'player';
player.setAttributeNode(player_id);
var player_style = document.createAttribute('style');
player_style.nodeValue = 'width: 1px; height: 1px; display: block; margin-left: 14px;';
player.setAttributeNode(player_style);
document.getElementById('oog_lightbox_photo_wrapper').appendChild(player);
// set lightbox visible or onMetaData event will not fire //
lightbox_main.style.visibility = 'visible';
document.getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7
$('#oog_lightbox_main').fadeIn(0);
// we can hide lightbox by this: //
$('#oog_lightbox_main').css('opacity', '0'); ///////////////////////////////////////////////// have to find solution!!
// load/init flowplayer //
flowplayer('player', {src: flowplayer_swf, wmode: 'window'},{
clip: {
autoPlay: true,
autoBuffering: true,
onMetaData: function(clip) {
// loading/initing flowplayer done //
// resizelightbox() needs this for accessing height & width of flowplayer //
flowplayer_video = this.getParent();
flpl = this;
// hide loading //
$('#oog_lightbox_loading').fadeOut(fadeInOut_loading, function() {
lightbox_loading.style.visibility = 'hidden';
// get original dimensions (resizelightbox() needs them) //
firstimgwidth = clip.metaData.width;
firstimgheight = clip.metaData.height;
// make lightbox visible //
$('#oog_lightbox_main').css('opacity', '1'); ///////////////////////////////////////////////// have to find solution!!
resizelightbox();
});
},
onFinish: function() {
if(lightbox_slideshow == 1) next();
},
url: escape(oogLightboxRequests + 'stream&album=' + oog_album + '&file=' + oog_photoname),
scaling: "fit"
}
});
} else if(mediafile_extension == 'mp3') {
// have to load an audio //
// insert div element for audioplayer (flowplayer) into the filewrapper //
var player = document.createElement('div');
var player_href = document.createAttribute('href');
player_href.nodeValue = oogLightboxRequests + 'read&album=' + escape(oog_album) + '&file=' + escape(oog_photoname);
player.setAttributeNode(player_href);
var player_id = document.createAttribute('id');
player_id.nodeValue = 'player';
player.setAttributeNode(player_id);
var player_style = document.createAttribute('style');
player_style.nodeValue = 'width: 1px; height: 1px; display: block; margin-left: 14px;';
player.setAttributeNode(player_style);
document.getElementById('oog_lightbox_photo_wrapper').appendChild(player);
// set following or onMetaData event will not fire //
lightbox_main.style.visibility = 'visible';
document.getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7
$('#oog_lightbox_main').fadeIn(0);
// we can hide lightbox by this: //
$('#oog_lightbox_main').css('opacity', '0'); ///////////////////////////////////////////////// have to find solution!!
// load/init flowplayer //
flowplayer('player', {src: flowplayer_swf, wmode: 'window'},{
plugins: {
controls: {
fullscreen: false,
height: 40
}
},
clip: {
autoPlay: true,
onStart: function(clip) {
// loading/initing flowplayer done //
// resizelightbox() needs this for accessing height & width of flowplayer //
flowplayer_video = this.getParent();
flpl = this;
// hide loading //
$('#oog_lightbox_loading').fadeOut(fadeInOut_loading, function() {
lightbox_loading.style.visibility = 'hidden';
// set dimensions (resizelightbox() needs them) //
firstimgwidth = 800;
firstimgheight = 100;
// make lightbox visible //
$('#oog_lightbox_main').css('opacity', '1'); ///////////////////////////////////////////////// have to find solution!!
resizelightbox();
});
},
onFinish: function() {
if(lightbox_slideshow == 1) next();
},
url: escape(oogLightboxRequests + 'stream&album=' + oog_album + '&file=' + oog_photoname),
scaling: "fit"
}
});
} else {
alert('Error: Unknown Format');
exitlightbox();
}
}
/*
* START LIGHTBOX
*
* Have to be called if you want to show a file with Lightbox.
*
* Parameter:
* String albumpath (path to album. format: '../albums/[somePath]/')
* String photoname (filename to show in lightbox including extension)
* Boolean descEditable (makes description editable)
* Boolean focusDesc (focus the description.)
*
* Returns: -
*/
function startlightbox(albumpath, photoname, descEditable, focusDesc) {
if(photoname == 'startSlideshow') {
lightbox_slideshow = 1;
photoname = document.getElementsByName('thumb')[0].title;
}
if(lightbox_slideshow == 1) lightbox_timeout = null;
// init onresize event //
window.onresize = function() {
if(document.getElementById('oog_lightbox_main').style.visibility == 'visible') resizelightbox();
}
// init onkeydown event //
window.document.onkeydown = function(event) {
if(!event) event = window.event;
var keycode = event.which || event.keyCode;
// left arrowkey //
if(keycode==37 && document.getElementById('oog_lightbox_main').style.visibility=='visible' && !descriptionFocused) previous();
// right arrowkey //
if(keycode==39 && document.getElementById('oog_lightbox_main').style.visibility=='visible' && !descriptionFocused) next();
// esc //
if(keycode==27) exitlightbox();
}
// init original dimensions //
firstimgwidth = 0;
firstimgheight = 0;
// make some parameters global //
oog_album = albumpath;
oog_photoname = photoname;
if(descEditable) {
descriptionEditable = true;
} else {
descriptionEditable = false;
}
if(focusDesc && descEditable) {
focusDescription = true;
} else {
focusDescription = false;
}
// get extension of file //
mediafile_extension = oog_photoname.substring(oog_photoname.lastIndexOf('.') + 1, oog_photoname.length).toLowerCase();
//mediafile_extension = oog_photoname.split('.').pop().toLowerCase();
// if a file is displayed at this moment //
if(document.getElementById('oog_lightbox_main').style.visibility == 'visible') {
// hide lightbox, means the file & buttons and then start loading //
$('#oog_lightbox_main').fadeOut(fadeInOut_file, function() {
lightbox_main.style.visibility = 'hidden';
document.getElementById('oog_lightbox_photo_box').style.display = 'none'; //for IE7
document.getElementById('oog_lightbox_photo_wrapper').innerHTML = '';
document.getElementById('oog_lightbox_filedescription').innerHTML = '';
// start loading file //
load_media();
});
} else {
// normal: no file is displayed //
// make overlay visible //
lightbox_overlay.style.width = '100%';
lightbox_overlay.style.height = '100%';
$('#oog_lightbox_overlay').fadeOut(0);
lightbox_overlay.style.visibility = 'visible';
$('#oog_lightbox_overlay').fadeIn(fadeInOut_overlay);
// start loading file //
load_media();
}
}
/*
* EXIT LIGHTBOX
*
*
*
* Parameter: -
* Returns: -
*/
function exitlightbox() {
// clear slideshow timeout and set slideshow off //
if(lightbox_slideshow == 1) {
window.clearTimeout(lightbox_timeout);
lightbox_slideshow = 0;
}
// cancle current loading //
if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') {
lightbox_img.onload = null;
lightbox_img.src = null;
if(self.stop) {
window.stop();
} else if(document.execCommand) {
document.execCommand('Stop');
}
} else if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') {
try { flpl.stop(); } catch(e) {}
try { flpl.stopBuffering(); } catch(e) {}
}
$('#oog_lightbox_extended_box').css('display', 'none');
// hide loading //
$('#oog_lightbox_loading').fadeOut(fadeInOut_loading, function() {
lightbox_loading.style.visibility = 'hidden';
});
// hide lightbox //
$('#oog_lightbox_main').fadeOut(fadeInOut_file, function() {
lightbox_main.style.visibility = 'hidden';
document.getElementById('oog_lightbox_photo_box').style.display = 'none'; //for IE7
document.getElementById('oog_lightbox_photo_wrapper').innerHTML = '';
document.getElementById('oog_lightbox_filedescription').innerHTML = '';
});
// restore document title //
document.title = lightbox_firsttitle;
// hide overlay //
$('#oog_lightbox_overlay').fadeOut(fadeInOut_overlay, function() {
lightbox_overlay.style.width = '0px';
lightbox_overlay.style.height = '0px';
lightbox_overlay.style.visibility = 'hidden';
});
}
/*
* PREVIOUS
*
* Will call startlightbox() with previous mediafile of album as parameter.
* If there are pages defined it will show previous page when previous file is there.
*
* Parameter: -
* Returns: -
*/
function previous() {
if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') {
flpl.stop();
flpl.stopBuffering();
}
// find out previousphoto //
var count = document.getElementsByName('thumb').length;
for(var i = 0; i < count; i++) {
if(document.getElementsByName('thumb')[i].title == oog_photoname) {
if(i == 0) {
// if there are pages defined //
if(typeof current_page != 'undefined' && typeof num_pages != 'undefined' && typeof all_thumbs != 'undefined' && typeof max_thumbs != 'undefined') {
if(current_page != 0) {
show_page(current_page - 1);
} else {
show_page(num_pages-1);
}
var previousphoto = document.getElementsByName('thumb')[document.getElementsByName('thumb').length - 1].title;
} else {
// if no pages //
var previousphoto = document.getElementsByName('thumb')[count-1].title;
}
} else {
var previousphoto = document.getElementsByName('thumb')[i-1].title;
}
break;
}
}
// start presentation of previous file in album //
startlightbox(oog_album, previousphoto, descriptionEditable, focusDescription);
}
/*
* NEXT
*
* Will call startlightbox() with next mediafile of album as parameter.
* If there are pages defined it will show next page when next file is there.
*
* Parameter: -
* Returns: -
*/
function next() {
if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') {
flpl.stop();
flpl.stopBuffering();
}
// find out nextphoto //
var count = document.getElementsByName('thumb').length;
for(var i = 0; i < count; i++) {
if(document.getElementsByName('thumb')[i].title == oog_photoname) {
if(i == count - 1) {
// if there are pages defined //
if(typeof current_page != 'undefined' && typeof num_pages != 'undefined' && typeof all_thumbs != 'undefined' && typeof max_thumbs != 'undefined') {
if(current_page != num_pages-1) {
show_page(current_page + 1);
} else {
show_page(0);
}
var nextphoto = document.getElementsByName('thumb')[0].title;
} else {
// if no pages //
var nextphoto = document.getElementsByName('thumb')[0].title;
}
} else {
var nextphoto = document.getElementsByName('thumb')[i+1].title;
}
break;
}
}
// start presentation of next file in album //
startlightbox(oog_album, nextphoto, descriptionEditable, focusDescription);
}
function save_file() {
window.location.href = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname);
}
/*
* DISPLAY FILE DESCRIPTION
*
* Sends a get_filedescription request.
* Needs global vars oog_album and oog_photoname!
* Will display description if exists.
*
* Parameter: -
* Returns: -
*/
function display_filedescription() {
// define ajax_request to get filedescription //
var filedescription_request = false;
filedescription_request = new XMLHttpRequest();
filedescription_request.onreadystatechange = function() {
if(filedescription_request.readyState == 4) {
if(filedescription_request.status == 200) {
if(descriptionEditable) {
document.getElementById('oog_lightbox_filedescription').contentEditable = 'true';
$('#oog_lightbox_filedescription').css('cursor', 'text');
} else {
document.getElementById('oog_lightbox_filedescription').contentEditable = 'false';
$('#oog_lightbox_filedescription').css('cursor', 'default');
}
$('#oog_lightbox_filedescription').text(filedescription_request.responseText);
if(filedescription_request.responseText == '' || filedescription_request.responseText == '
' || filedescription_request.responseText == '
' || filedescription_request.responseText == '
') {
document.getElementById('oog_lightbox_filedescription').style.height = '0px';
document.getElementById('oog_lightbox_filedescription').innerHTML = '';
isDescription = false;
} else {
document.getElementById('oog_lightbox_filedescription').style.height = '';
isDescription = true;
}
resizelightbox();
if(descriptionEditable) {
var div = document.getElementById('oog_lightbox_filedescription');
div.onfocus = function() {
window.setTimeout(function() {
if($('#oog_lightbox_filedescription').text() == '' && !descriptionFocused) $('#oog_lightbox_filedescription').text('Write some text in here..');
descriptionFocused = true;
isDescription = true;
resizelightbox();
document.getElementById('oog_lightbox_filedescription').style.height = '';
var sel, range;
if (window.getSelection && document.createRange) {
range = document.createRange();
range.selectNodeContents(div);
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(div);
range.select();
}
}, 5);
};
div.onblur = function() {
window.setTimeout(function() {
descriptionFocused = false;
save_filedescription($('#oog_lightbox_filedescription').text());
if(document.getElementById('oog_lightbox_filedescription').innerHTML == '
' || document.getElementById('oog_lightbox_filedescription').innerHTML == '
' || document.getElementById('oog_lightbox_filedescription').innerHTML == '
') {
document.getElementById('oog_lightbox_filedescription').innerHTML = '';
document.getElementById('oog_lightbox_filedescription').style.height = '0px';
isDescription = false;
} else {
document.getElementById('oog_lightbox_filedescription').style.height = '';
isDescription = true;
}
resizelightbox();
}, 5);
};
$('#oog_lightbox_filedescription').live('keyup paste', function() {
save_filedescription($('#oog_lightbox_filedescription').text());
});
if(focusDescription) div.focus();
}
}
}
}
// send get filedescription request //
filedescription_request.open('GET', oogLightboxRequests + 'get_filedescription&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true);
filedescription_request.send(null);
}
/*
* SAVE FILE DESCRIPTION
*
* Sends a save_filedescription request.
* Needs global vars oog_album and oog_photoname!
*
* Parameter: -
* Returns: -
*/
function save_filedescription(description) {
// define ajax_request to save filedescription //
var save_filedescription_request = false;
save_filedescription_request = new XMLHttpRequest();
save_filedescription_request.onreadystatechange = function() {
if(save_filedescription_request.readyState == 4) {
if(save_filedescription_request.status == 200) {
// if saving description faild show error msg //
if(save_filedescription_request.responseText != 'succeed') {
if(show_error_filedescription) alert(save_filedescription_request.responseText);
show_error_filedescription = false;
setTimeout(function () { show_error_filedescription = true; }, 3000);
}
}
}
}
// send save filedescription request //
save_filedescription_request.open('GET', oogLightboxRequests + 'save_filedescription&album=' + escape(oog_album) + '&file=' + escape(oog_photoname) + '&description=' + escape(description), true);
save_filedescription_request.send(null);
}
function refresh_lightbox_extended_box(command, resize) {
if(!command) { command = ''; }
var http_request = false;
try {
http_request = new XMLHttpRequest();
} catch(e) {
alert('Error: Can not create XMLHttpRequest');
return false;
}
http_request.onreadystatechange = function() {
if(http_request.readyState == 4) {
if(http_request.status == 200) {
document.getElementById('oog_lightbox_extended_box_request').innerHTML = http_request.responseText;
} else {
http_request = false;
alert('Error: Can not load data. Reload page and try again.');
lightbox_extended = '';
$('#oog_lightbox_extended_box').css('display', 'none');
resizelightbox();
return false;
}
}
}
if(command == 'exif' || command == 'comments') {
if(lightbox_extended == command) {
lightbox_extended = '';
$('#oog_lightbox_extended_box').css('display', 'none');
if(resize) {
resizelightbox();
}
return false;
}
lightbox_extended = command;
$('#oog_lightbox_extended_box').css('display', 'block');
http_request.open('GET', oogLightboxRequests + command + '&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true);
http_request.send(null);
} else {
if(lightbox_extended != '') {
$('#oog_lightbox_extended_box').css('display', 'block');
http_request.open('GET', oogLightboxRequests + lightbox_extended + '&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true);
http_request.send(null);
}
}
if(resize) {
resizelightbox();
}
}
function slideshow() {
if(lightbox_slideshow == 0) {
if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png')
lightbox_timeout = window.setTimeout('next()',timeout_slideshow);
document.getElementById('oog_lightbox_slideshow_but').style.backgroundPosition = '-17px -17px';
lightbox_slideshow = 1;
} else {
document.getElementById('oog_lightbox_slideshow_but').style.backgroundPosition = '-17px 0px';
window.clearTimeout(lightbox_timeout);
lightbox_slideshow = 0;
}
}