//|
//| Copyright 2010 by Ulf Haueisen Systementwicklung, Oberursel, DE. All rights reserved.
//|
var currentalbum = 0;
var currentpicture = 0;
var pictures = null;
var albums = null;
var aeid = 0;
var timerloaddetails = null;
var body;
var boxbottom;
var boxbottomcontent;
var boxcenter;
var boxcentercontent;
var boxleft;
var boxleftcontent;
var boxright;
var boxrightcontent;
var boxtop;
var boxtopcontent;
window.onerror = function ()
{
return true;
};
var donothing = function ()
{
return false;
};
function inithandler ()
{
document.oncontextmenu = donothing;
document.ondragstart = donothing;
document.onselectstart = function ()
{
var e;
var s;
if (event.target) e = event.target; else e = event.srcElement;
s = e.nodeName;
return ((s == 'INPUT') || (s == 'TEXTAREA'));
};
}
function imageloaded ()
{
wait.stop (1);
}
function getthumbnailsize (imagesize, maxsize)
{
var thumbnailsize;
thumbnailsize = new Array();
thumbnailsize[0] = Math.round ((imagesize[0] * maxsize[1]) / imagesize[1]);
if (thumbnailsize[0] > maxsize[0]) {
thumbnailsize[0] = maxsize[0];
thumbnailsize[1] = Math.round ((imagesize[1] * maxsize[0]) / imagesize[0]);
} else {
thumbnailsize[1] = maxsize[1];
}
return thumbnailsize;
}
function defaultkeydown (event)
{
var keycode;
var cancelkey;
var i;
var elem;
if (dialog.isopen ()) {
return true;
} else {
if (window.event) event = window.event;
cancelkey = true;
keycode = event.keyCode;
if (event.target) elem = event.target.nodeName; else elem = event.srcElement.nodeName;
switch (keycode) {
case 8: { 
if ((elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
} else {
toolbar.navigateback ();
}
break;
}
case 27: { 
if ((elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
} else {
}
break;
}
case 13: { 
if ((elem == 'A') || (elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
}
break;
}
default: {
cancelkey = false;
}
}
event.returnValue = !cancelkey;
return (!cancelkey);
}
}
function setfocus (elementname, retries)
{
var elem;
elem = document.getElementById (elementname);
if (elem) {
elem.focus (); elem.focus ();
} else {
if (retries <= 5) {
setTimeout ("setfocus (\"" + elementname + "\", " + (retries + 1) + ");", 50);
}
}
}
function initwindow ()
{
body = document.getElementById ('body');
body.insertAdjacentHTML ('beforeend', '<div class="box" id="boxcenter" style="top: 30px; bottom: 27px; left: 160px; right: 8px; width: auto; height: auto;"><div class="boxcontent" id="boxcentercontent" style="top: 1px; right: 1px; bottom: 1px; left: 1px; width: auto; height: auto;"></div></div>');
body.insertAdjacentHTML ('beforeend', '<div class="box" id="boxbottom" style="bottom: 0px; left: 160px; right: 8px; width: auto; height: 27px;"><div class="box" style="top: 5px; right: 9px; bottom: 2px; left: 9px;"><img class="box" src="images/slate/b0.gif" alt="" /></div><div class="box" style="top: 0px; left: 10px; right: 5px; height: 5px;"><img class="box" src="images/slate/b2.gif" alt="" /></div><div class="box" style="right: 0px; top: 5px; bottom: 2px; width: 9px;"><img class="box" src="images/slate/b4.gif" alt="" /></div><div class="box" style="bottom: 0px; left: 10px; right: 5px; height: 2px;"><img class="box" src="images/slate/b6.gif" alt="" /></div><div class="box" style="left: 0px; top: 5px; bottom: 2px; width: 9px;"><img class="box" src="images/slate/b8.gif" alt="" /></div><div class="box" style="top: 0px; left: 0px; width: 10px; height: 5px;"><img class="box" src="images/slate/b1.gif" alt="" /></div><div class="box" style="bottom: 0px; left: 0px; width: 10px; height: 2px;"><img class="box" src="images/slate/b7.gif" alt="" /></div><div class="box" style="top: 0px; right: 0px;width: 10px; height: 5px;"><img class="box" src="images/slate/b3.gif" alt="" /></div><div class="box" style="bottom: 0px; right: 0px; width: 10px; height: 2px;"><img class="box" src="images/slate/b5.gif" alt="" /></div><div class="boxcontent" id="boxbottomcontent" style="top: 6px; right: 10px; bottom: 3px; left: 10px; width: auto; height: auto;"></div></div>');
body.insertAdjacentHTML ('beforeend', '<div class="box" id="boxleft" style="top: 30px; bottom: 0px; left: 0px; width: 160px; height: auto;"><div class="box" style="top: 0px; right: 6px; bottom: 0px; left: 0px;"><img class="box" src="images/slate/l0.gif" alt="" /></div><div class="box" style="right: 0px; top: 0px; bottom: 0px; width: 6px;"><img class="box" src="images/slate/l4.gif" alt="" /></div><div class="boxcontent" id="boxleftcontent" style="top: 1px; right: 7px; bottom: 1px; left: 1px; width: auto; height: auto;"></div></div>');
body.insertAdjacentHTML ('beforeend', '<div class="box" id="boxright" style="top: 30px; bottom: 0px; right: 0px; width: 8px; height: auto;"><div class="box" style="top: 0px; right: 0px; bottom: 0px; left: 6px;"><img class="box" src="images/slate/r0.gif" alt="" /></div><div class="box" style="left: 0px; top: 0px; bottom: 0px; width: 6px;"><img class="box" src="images/slate/r8.gif" alt="" /></div><div class="boxcontent" id="boxrightcontent" style="top: 1px; right: 1px; bottom: 1px; left: 7px; width: auto; height: auto;"></div></div>');
body.insertAdjacentHTML ('beforeend', '<div class="box" id="boxtop" style="top: 0px; left: 0px; right: 0px; width: 100%; height: 30px;"><div class="box" style="top: 2px; right: 0px; bottom: 5px; left: 0px;"><img class="box" src="images/slate/t0.gif" alt="" /></div><div class="box" style="top: 0px; left: 0px; right: 0px; height: 2px;"><img class="box" src="images/slate/t2.gif" alt="" /></div><div class="box" style="bottom: 0px; left: 0px; right: 0px; height: 5px;"><img class="box" src="images/slate/t6.gif" alt="" /></div><div class="boxcontent" id="boxtopcontent" style="top: 3px; right: 1px; bottom: 6px; left: 1px; width: auto; height: auto;"></div></div>');
boxbottom = document.getElementById ('boxbottom');
boxbottomcontent = document.getElementById ('boxbottomcontent');
boxcenter = document.getElementById ('boxcenter');
boxcentercontent = document.getElementById ('boxcentercontent');
boxleft = document.getElementById ('boxleft');
boxleftcontent = document.getElementById ('boxleftcontent');
boxright = document.getElementById ('boxright');
boxrightcontent = document.getElementById ('boxrightcontent');
boxtop = document.getElementById ('boxtop');
boxtopcontent = document.getElementById ('boxtopcontent');
boxtopcontent.insertAdjacentHTML ('beforeend', '<div id="toolbar" style="position: absolute; top: 0px; left: 0px;"></div>');
}
function main ()
{
try {
document.execCommand ('BackgroundImageCache', false, true);
} catch(e) {
}
initfunctions ();
inithandler ();
initwindow ();
window.onerror = null;
window.defaultStatus = ' ';
boxleft.onclick = sidebars.boxleftclick;
boxleft.onmousemove = sidebars.boxleftmousemove;
boxright.onclick = sidebars.boxrightclick;
boxright.onmousemove = sidebars.boxrightmousemove;
boxbottom.onclick = sidebars.boxbottomclick;
boxbottom.onmousemove = sidebars.boxbottommousemove;
toolbar.init ();
wait.init ();
xml.init ();
xml.request ('user.xml');
}
var previewsize = new Array (90, 90);
var maxthumbnailsize = new Array (120, 120);
var picurl = 'http:\/\/pic1.difo.org\/';
var pic2url = 'http:\/\/pic2.difo.org\/';
function Album()
{
this.loading = false;
this.init = function (aid)
{
var i;
var albumobject;
var n;
var container;
var html;
var ty;
var prvw;
if (timerloaddetails != null) clearTimeout (timerloaddetails);
wait.reset(1);
box = document.getElementById ("boxcentercontent");
box.style.overflow = "auto";
box.style.overflowX = "hidden";
box.style.overflowY = "scroll";
document.onkeydown = keydown;
document.onmousewheel = null;
container = boxcentercontent;
if (albums != null) {
n = albums.length;
for (i = 0; i < n; i++) {
html = '<div class="album" id="'+i+'" _aid="'+albums[i][0]+'" style="position: relative; display: block; overflow: hidden; left: 0px; height: ' + (previewsize[1] + 32) + 'px; width: 100%; border-top: 1px solid #758387; border-bottom: 1px solid #0a0c0c; background-image: url(images/spacer.gif); background-repeat: no-repeat;">';
html += '<div class="albumtitle"><a href="javascript:undefined" onfocus="this.blur(); return true;" onclick="album.execute ('+i+');" class="albumtitle">'+albums[i][1].replace(/</, '&lt;').replace(/>/, '&gt;')+'</a></div>';
html += '<div style="position: absolute; left: 6px; bottom: 4px; width: 66px; height: '+previewsize[1]+'px; text-align: right;">';
ty = -12;
if (albums[i][4] != albums[i][3]) {
html += '<div style="position: absolute; left: 0px; bottom: '+(ty += 12)+'px; width: 100%;">&ndash; '+albums[i][4]+'</div>';
}
html += '<div style="position: absolute; left: 0px; bottom: '+(ty += 12)+'px; width: 100%;">'+albums[i][3]+'</div>';
html += '<div style="position: absolute; left: 0px; bottom: '+(ty += 12)+'px; width: 100%;"><b>'+albums[i][2]+' Fotos</b></div>';
if (albums[i][5] != '') {
html += '<div style="position: absolute; left: 0px; bottom: '+(ty += 12)+'px; width: 100%;">'+albums[i][5]+'</div>';
}
html += '<div style="position: absolute; left: 0px; bottom: '+(ty += 12)+'px; width: 100%;"><b>'+(albums[i][6] == '0' ? 'unsichtbar' : '')+'</b></div>';
html += '</div>';
prvw = albums[i][7];
m = prvw.length;
for (j = 0; j < m; j++) {
html += '<img src="'+picurl+prvw[j]+'.jpg" class="albumpreviewimg" style="left: ' + (77 + j * (previewsize[0] + 4)) + 'px; top: 26px; width: '+previewsize[0]+'px; height: '+previewsize[1]+'px;" />';
}
html += '</div>';
container.insertAdjacentHTML ('beforeend', html);
}
}
i = 0;
k = 0;
while (true) {
albumobject = document.getElementById (i);
if (!albumobject) break;
naid = albumobject.attributes.getNamedItem ("_aid").value;
if (naid == aid) k = i;
albumobject.onclick = this.click;
albumobject.ondblclick = this.dblclick;
i++ ;
}
album.changeselection (k);
}
this.click = function ()
{
album.changeselection (+this.id);
return false;
}
this.dblclick = function ()
{
album.execute (+this.id);
return false;
}
this.changeselection = function (newalbum)
{
var aid;
var na;
var oa;
var i;
var n;
var elem;
var name;
if (newalbum < 0) newalbum = 0;
na = document.getElementById (newalbum);
oa = document.getElementById (currentalbum);
if ((oa) && (na) && (na != oa)) {
oa.style.backgroundColor = "transparent";
n = oa.childNodes.length;
for (i = 0; i < n; i++) {
elem = oa.childNodes.item(i);
if (elem.className == 'albumpreviewimgsel') elem.className = 'albumpreviewimg';
}
currentpicture = 0;
}
if (na) {
na.style.backgroundColor = "#182022";
n = na.childNodes.length;
name = '';
for (i = 0; i < n; i++) {
elem = na.childNodes.item(i);
if (elem.className == 'albumpreviewimg') elem.className = 'albumpreviewimgsel';
if ((name == '') && (elem.tagName == 'DIV')) name = elem.childNodes.item(0).innerHTML;
}
toolbar.button ('forward', null, null, null, 'Album "' + name + '" öffnen');
if (na.offsetTop < na.parentNode.scrollTop) {
na.parentNode.scrollTop = na.offsetTop;
} else if (na.offsetTop + na.offsetHeight > na.parentNode.scrollTop + na.parentNode.clientHeight) {
na.parentNode.scrollTop = na.offsetTop + na.offsetHeight - na.parentNode.offsetHeight;
} else if (newalbum == 0) {
na.parentNode.scrollTop = 0;
}
currentalbum = newalbum;
aid = na.attributes.getNamedItem ("_aid").value;
if (timerloaddetails != null) clearTimeout (timerloaddetails);
timerloaddetails = setTimeout (album.loaddetails, 250); //TODO: Version
}
return currentalbum;
}
this.loaddetails = function ()
{
var na;
var aid;
timerloaddetails = null;
if (album.loading == false) {
na = document.getElementById (currentalbum);
aid = na.attributes.getNamedItem ("_aid").value;
album.loading = aid;
xml.request ('albumdata.xml?aid=' + aid);
}
}
this.finishedloadingdetails = function ()
{
var elem;
var aid;
var lid;
lid = this.loading;
this.loading = false;
elem = document.getElementById (currentalbum);
if (elem) {
aid = elem.attributes.getNamedItem ("_aid").value;
if (lid != aid) {
this.loaddetails();
}
}
}
this.execute = function (album)
{
var na;
var aid;
na = document.getElementById (album);
if (na) {
if (controls.trylock()) {
aid = na.attributes.getNamedItem ("_aid").value;
boxbottomcontent.innerHTML = '<div style="padding: 2px;"><b>Bitte warten...</b></div>';
xml.request ('pictureset.xml?aid=' + aid + '&pid=0');
}
}
}
var keydown = function (event)
{
var keycode;
var cancelkey;
var i;
var elem;
if (window.event) event = window.event;
cancelkey = true;
keycode = event.keyCode;
if (event.target) elem = event.target.nodeName; else elem = event.srcElement.nodeName;
switch (keycode) {
case 8: { 
break;
}
case 27: { 
if ((elem == 'INPUT') ||(elem == 'TEXTAREA')) {
cancelkey = false;
} else {
}
break;
}
case 9: { 
cancelkey = false;
break;
}
case 13: { 
if (event.altKey) {
if (controls.trylock()) album.edit();
} else {
if ((elem == 'A') || (elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
} else {
album.execute (currentalbum);
}
}
break;
}
case 32: { 
sidebars.showhideall();
break;
}
case 33: { 
album.changeselection (currentalbum - 1);
break;
}
case 34: { 
album.changeselection (currentalbum + 1);
break;
}
case 35: { 
i = currentalbum + 1;
while (document.getElementById (i)) i++;
album.changeselection (i - 1);
break;
}
case 36: { 
album.changeselection (0);
break;
}
case 37: { 
break;
}
case 38: { 
album.changeselection (currentalbum - 1);
break;
}
case 39: { 
break;
}
case 40: { 
album.changeselection (currentalbum + 1);
break;
}
case 45: { 
break;
}
case 46: { 
break;
}
default: {
cancelkey = false;
}
}
event.returnValue = !cancelkey;
return (!cancelkey);
}
this.edit = function ()
{
var na;
var aid;
na = document.getElementById (currentalbum);
aid = na.attributes.getNamedItem ("_aid").value;
xml.request ('albumedit.xml?action=edit&id=' + aid);
}
this.assignpictures = function ()
{
var na;
var aid;
na = document.getElementById (currentalbum);
aid = na.attributes.getNamedItem ("_aid").value;
xml.request ('filelist.xml?aid=' + aid);
}
this.assignpreviewpictures = function assignpreviewpictures ()
{
var na;
var aid;
na = document.getElementById (currentalbum);
aid = na.attributes.getNamedItem ("_aid").value;
xml.request ('previews.xml?aid=' + aid);
}
this.remove = function ()
{
var na;
var aid;
na = document.getElementById (currentalbum);
aid = na.attributes.getNamedItem ("_aid").value;
xml.request ('albumdelete.xml?action=delete&id=' + aid);
}
}
var album = new Album();
function Browse ()
{
this.init = function (aid, pid, name, desc)
{
var n;
var i;
var element;
var container;
var picturesize;
var thumbnailsize;
if (timerloaddetails != null) clearTimeout (timerloaddetails);
boxcentercontent.style.overflow = 'hidden';
boxcentercontent.style.overflowX = 'hidden';
boxcentercontent.style.overflowY = 'hidden';
document.getElementById('pdzoom').style.display = 'none';
currentalbum = aid;
document.onkeydown = keydown;
document.onmousewheel = null;
container = document.getElementById ('browsediv');
container.insertAdjacentHTML ('afterbegin',
'<div id="headbar" class="headbar">' +
'<div class="headline">'+name+'</div>' +
'<div class="headsub">'+desc.replace (/\n/g, '<br />')+'</div>' +
'</div>' +
'<div style="position: relative; display: block; height: 4px; line-height: 4px;"></div>'
);
if (pictures != null) {
n = pictures.length;
for (i = 0; i < n; i++) {
picturesize = new Array (pictures[i][1], pictures[i][2]);
thumbnailsize = getthumbnailsize (picturesize, maxthumbnailsize);
wait.start (1);
element = document.createElement ('img');
element.id = i;
element.setAttribute('_pid', pictures[i][0]);
element.alt = '';
element.title = '';
element.className = 'browseimg';
element.onload = imageloaded;
element.onabort = imageloaded;
element.onerror = imageloaded;
element.onclick = click;
element.ondblclick = dblclick;
element.width = thumbnailsize[0];
element.height = thumbnailsize[1];
element.style.width = thumbnailsize[0]+'px';
element.style.height = thumbnailsize[1]+'px';
element.src = picurl + thumbnailsize[0] + 'x' + thumbnailsize[1] + '/' + pictures[i][0] + '-' + pictures[i][3] + '.jpg';
container.appendChild (element);
if (pictures[i][0] == pid) currentpicture = i;
}
}
container.insertAdjacentHTML ('beforeend', '<div style="height: 2px;"></div>');
this.changeselection (currentpicture);
}
this.execute = function ()
{
var cp;
var pid;
cp = document.getElementById (currentpicture);
if (cp) {
if (controls.trylock()) {
boxbottomcontent.innerHTML = '<div style="padding: 2px;"><b>Bitte warten...</b></div>';
pid = cp.attributes.getNamedItem ('_pid').value;
xml.request ('presentation.xml?aid=' + currentalbum + '&pid=' + pid);
}
}
}
this.changeselection = function (newpicture)
{
if (newpicture < 0) newpicture = 0;
np = document.getElementById (newpicture);
op = document.getElementById (currentpicture);
if ((op) && (np) && (np != op)) {
op.className = 'browseimg';
}
if (np) {
np.className = 'browseimgsel';
if (np.offsetTop < np.parentNode.scrollTop) {
np.parentNode.scrollTop = np.offsetTop - 3;
} else if (np.offsetTop + np.offsetHeight > np.parentNode.scrollTop + np.parentNode.clientHeight) {
np.parentNode.scrollTop = np.offsetTop + np.offsetHeight - np.parentNode.offsetHeight + 3;
} else if (newpicture == 0) {
np.parentNode.scrollTop = 0;
}
currentpicture = +newpicture;
pictureview.loaddetails();
}
}
var click = function ()
{
browse.changeselection (+this.id);
}
var dblclick = function ()
{
browse.execute ();
}
var keydown = function (event)
{
var keycode;
var cancelkey;
var i;
var elem;
var k;
var j;
var ci;
var ai;
var img;
if (window.event) event = window.event;
cancelkey = true;
keycode = event.keyCode;
if (event.target) elem = event.target.nodeName; else elem = event.srcElement.nodeName;
switch (keycode) {
case 8: { 
toolbar.navigateback();
break;
}
case 27: { 
if ((elem == 'INPUT') ||(elem == 'TEXTAREA')) {
cancelkey = false;
} else {
}
break;
}
case 9: { 
cancelkey = false;
break;
}
case 13: { 
if (event.altKey) {
if (controls.trylock()) { xml.request('picturecomment.xml?aid='+currentalbum+'&pid='+document.getElementById(currentpicture).attributes.getNamedItem('_pid').value+'&desc=1'); }
} else {
if ((elem == 'A') || (elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
} else {
browse.execute ();
}
}
break;
}
case 32: { 
sidebars.showhideall();
break;
}
case 35: { 
i = currentpicture + 1;
while (document.getElementById (i)) i++;
browse.changeselection (i-1);
break;
}
case 36: { 
browse.changeselection (0);
break;
}
case 37: { 
browse.changeselection (currentpicture - 1);
break;
}
case 33:   
case 38: { 
k = ((keycode == 33) ? 3 : 1);
for (j = 0; j < k; j++) {
ci = document.getElementById (currentpicture);
i = currentpicture - 1;
ai = ci;
while ((img = document.getElementById (i)) && (img.offsetLeft + img.offsetWidth < ai.offsetLeft)) {
i--;
ai = img;
}
while ((img) && (img.offsetLeft + (img.offsetWidth / 2) > ci.offsetLeft + ci.offsetWidth)) {
i--;
img = document.getElementById (i);
}
if (img) browse.changeselection (+img.id); else browse.changeselection (-1);
}
break;
}
case 39: { 
browse.changeselection (currentpicture + 1);
break;
}
case 34:   
case 40: { 
k = ((keycode == 34) ? 3 : 1);
for (j = 0; j < k; j++) {
ci = document.getElementById (currentpicture);
i = currentpicture + 1;
ai = ci;
while ((img = document.getElementById (i)) && (img.offsetLeft > ai.offsetLeft + ai.offsetWidth)) {
i++ ;
ai = img;
}
ai = img;
while ((img) && (img.offsetLeft + (img.offsetWidth / 2) < ci.offsetLeft)) {
i++ ;
ai = img;
img = document.getElementById (i);
}
if (img) browse.changeselection (+img.id); else if (ai != null) browse.changeselection (+ai.id);
}
break;
}
default: {
cancelkey = false;
}
}
event.returnValue = !cancelkey;
if ((cancelkey) && (event.preventDefault)) event.preventDefault();
return (!cancelkey);
}
}
var browse = new Browse();
function Controls ()
{
var counter = 0;
this.trylock = function ()
{
if (counter == 0) {
counter++;
wait.start (2);
return true;
} else {
return false;
}
}
this.release = function ()
{
if (counter > 0) {
counter--;
wait.stop (2);
}
}
this.locked = function ()
{
return (counter != 0);
}
}
var controls = new Controls();
function Dialog ()
{
var oldkeydown;
var oldmousewheel;
var fisopen = false;
var dialogdesktop;
var dialogcontent;
var dialoginner;
var dialogtitle;
this.mousex = 0;
this.mousey = 0;
this.dialogwindow = null;
this.init = function (awidth, aheight)
{
fisopen = true;
oldkeydown = document.onkeydown;
document.onkeydown = defaultkeydown;
oldmousewheel = document.onmousewheel;
document.onmousewheel = null;
body.insertAdjacentHTML ('beforeend',
'<div id="dialogdesktop" class="dialogdesktop">' +
'</div>'
);
body.insertAdjacentHTML ('beforeend',
'<table id="dialogwindow" class="dialogwindow" cellpadding="0" cellspacing="0">' +
'<tr>' +
'<td class="dialog1"></td>' +
'<td class="dialog2"></td>' +
'<td class="dialog3"></td>' +
'</tr>' +
'<tr>' +
'<td class="dialog4"></td>' +
'<td class="dialog5" id="dialogcontent" align="left" valign="top">' +
'<div id="dialogtitle" class="dialogtitle">title</div>' +
'<div id="dialoginner" class="dialoginner"></div>' +
'</td>' +
'<td class="dialog6"></td>' +
'</tr>' +
'<tr>' +
'<td class="dialog7"></td>' +
'<td class="dialog8"></td>' +
'<td class="dialog9"></td>' +
'</tr>' +
'</table>'
);
dialogcontent = document.getElementById ('dialogcontent');
dialogdesktop = document.getElementById ('dialogdesktop');
this.dialogwindow = document.getElementById ('dialogwindow');
dialoginner = document.getElementById ('dialoginner');
dialogtitle = document.getElementById ('dialogtitle');
}
this.setcontent = function (atext, atitle)
{
var h;
var i;
var j;
dialogtitle.innerHTML = atitle;
dialoginner.innerHTML = atext;
this.dialogwindow.style.top = (Math.round(dialogdesktop.offsetHeight / 2) - Math.round(this.dialogwindow.offsetHeight / 2)) + 'px';
this.dialogwindow.style.left = (Math.round(dialogdesktop.offsetWidth / 2) - Math.round(this.dialogwindow.offsetWidth / 2)) + 'px';
this.dialogwindow.style.visibility = 'visible';
this.dialogwindow.onmousedown = dialog.windowmousedown;
}
this.windowmousedown = function (e)
{
var elem;
var p;
var b;
if (!e) var e = window.event;
if (e.srcElement) e.target = e.srcElement;
p = e.target;
b = false;
while (p) {
if (p.className == 'dialoginner') {
b = true;
break;
} else if (p.className == 'dialogwindow') {
break;
}
p = p.parentNode;
}
if (!b) {
dialog.mousex = e.clientX;
dialog.mousey = e.clientY;
document.onmousemove = dialog.windowmousemove;
document.onmouseup = dialog.windowmouseup;
}
return (b);
}
this.windowmousemove = function (e)
{
var nx;
var ny;
var x;
var y;
var elem;
if (!e) var e = window.event;
elem = dialog.dialogwindow;
nx = e.clientX;
ny = e.clientY;
if (elem) {
x = elem.offsetLeft + nx - dialog.mousex;
y = elem.offsetTop + ny - dialog.mousey;
elem.style.left = x + 'px';
elem.style.top = y + 'px';
}
dialog.mousex = nx;
dialog.mousey = ny;
}
this.windowmouseup = function (e)
{
document.onmousemove = null;
document.onmouseup = null;
}
this.close = function ()
{
var elem;
if (elem = document.getElementById ('dialogdesktop')) {
body.removeChild (elem);
dialogdesktop = null;
}
if (elem = document.getElementById ('dialogwindow')) {
body.removeChild (elem);
this.dialogwindow = null;
}
document.onkeydown = oldkeydown;
document.onmousewheel = oldmousewheel;
fisopen = false;
}
this.isopen = function ()
{
return fisopen;
}
}
var dialog = new Dialog;
function initfunctions ()
{
if ((typeof HTMLElement != 'undefined') && (!HTMLElement.insertAdjacentElement)) {
HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sHTML)
{
var df;
var r;
r = this.ownerDocument.createRange ();
switch (String(sWhere).toLowerCase ()) {
case "beforebegin":
r.setStartBefore (this);
df = r.createContextualFragment (sHTML);
this.parentNode.insertBefore (df, this);
break;
case "afterbegin":
r.selectNodeContents (this);
r.collapse (true);
df = r.createContextualFragment (sHTML);
this.insertBefore (df, this.firstChild);
break;
case "beforeend":
r.selectNodeContents (this);
r.collapse (false);
df = r.createContextualFragment (sHTML);
this.appendChild (df);
break;
case "afterend":
r.setStartAfter (this);
df = r.createContextualFragment (sHTML);
this.parentNode.insertBefore (df, this.nextSibling);
break;
}
};
}
if (typeof XMLDocument != 'undefined') {
XMLDocument.prototype.__defineGetter__ ('xml',
function ()
{
return (new XMLSerializer ()).serializeToString (this);
}
);
}
if (typeof Node != 'undefined') {
Node.prototype.__defineGetter__ ('text',
function ()
{
return this.textContent;
}
);
}
if (typeof XMLDocument != 'undefined') {
XMLDocument.prototype.__defineGetter__ ('parseError',
function ()
{
return ((this.getElementsByTagName ('parsererror').length > 0) ? -1 : 0);
}
);
}
if (typeof HTMLElement != 'undefined') {
HTMLElement.prototype.__defineSetter__ ('innerText',
function (sText)
{
this.innerHTML = sText.replace (/\&/g, '&amp;').replace (/</g, '&lt;').replace (/>/g, '&gt;').replace (/\n/g, '<br />');
}
);
}
}
function Fileerror ()
{
this.submit = function ()
{
var pictures;
var elements;
var z;
var inputitem;
var n;
pictures = new Array();
elements = boxcentercontent.getElementsByTagName('input');
n = elements.length;
for (z = 0; z < n; z++) {
inputitem = elements.item(z);
if (inputitem.checked) pictures.push(inputitem.id);
}
xml.request ('fileerror.xml?pictures=' + pictures.toString());
}
}
var fileerror = new Fileerror();
function Filelist ()
{
this.openfolder = function (number, aid, path)
{
var element;
var plusminus;
element = document.getElementById('folder' + number);
plusminus = document.getElementById('folder' + number + 'pm');
if (element.style.display == 'none') {
plusminus.className = 'folderminus';
element.style.display = 'block';
if (element.innerHTML == '') {
element.innerHTML = '<p>Bitte warten...</p><br />';
xml.request ('filelist.xml?aid='+aid+'&folder='+number+'&path='+path);
}
} else {
plusminus.className = 'folderplus';
document.getElementById('folder' + number).style.display = 'none';
}
};
this.submit = function ()
{
var addpictures, removepictures;
var elements;
var i, n;
var inputelement;
addpictures = new Array();
removepictures = new Array();
elements = boxcentercontent.getElementsByTagName('input');
n = elements.length;
for (i = 0; i < n; i++) {
inputelement = elements.item(i);
if (inputelement.type == 'checkbox') {
if (inputelement.checked != inputelement.defaultChecked) {
if (inputelement.checked) {
addpictures.push (+inputelement.value);
} else {
removepictures.push (+inputelement.value);
}
}
}
}
xml.request ('filelist.xml?action=submit&aid=' + aeid + '&add=' + addpictures.toString() + '&remove=' + removepictures.toString());
}
this.selectall = function (folderindex, value)
{
var container;
var elements;
var inputelement;
var i, n;
container = document.getElementById ('folder' + folderindex);
elements = container.getElementsByTagName('input');
n = elements.length;
for (i = 0; i < n; i++) {
inputelement = elements.item(i);
if (inputelement.type == 'checkbox') inputelement.checked = value;
}
}
}
var filelist = new Filelist();
function Fullscreen()
{
this.execute = function ()
{
}
}
var fullscreen = new Fullscreen();
function PictureView()
{
this.loading = false;
this.loaddetails = function ()
{
if (timerloaddetails != null) clearTimeout (timerloaddetails);
timerloaddetails = setTimeout (pictureview.loaddetailshandler, 250); //TODO: Version
}
this.loaddetailshandler = function ()
{
var elem;
var pid;
timerloaddetails = null;
if (pictureview.loading == false) {
elem = document.getElementById (currentpicture);
pid = elem.attributes.getNamedItem ('_pid').value;
pictureview.loading = pid;
xml.request ('picturedata.xml?pid=' + pid);
}
}
this.finishedloadingdetails = function ()
{
var elem;
var pid;
var lid;
lid = this.loading;
this.loading = false;
elem = document.getElementById (currentpicture);
if (elem) {
pid = elem.attributes.getNamedItem ('_pid').value;
if (lid != pid) {
this.loaddetails();
}
}
}
}
var pictureview = new PictureView();
function Presentation ()
{
this.picture = null;
this.oldpicture = null;
this.scrolltarget = null;
this.scrollinterval = null;
this.scrollcountdown = null;
var sizes = null;
var maxsize = null;
var initializing = null;
var scrollfraction = 3;
var scrollrate = 25;
this.init = function (aid, pid)
{
var n;
var i;
var element;
var container;
var x;
initializing = true;
currentpicture = 0;
this.picture = null;
this.oldpicture = null;
if (sizes == null) {
sizes = new Array (
new Array (320, 240),
new Array (480, 360),
new Array (640, 480),
new Array (800, 600),
new Array (1024, 768)
);
}
document.getElementById('pdzoom').style.display = '';
if (timerloaddetails != null) clearTimeout (timerloaddetails);
container = document.getElementById ('thumbdiv');
document.onkeydown = keydown;
if (document.addEventListener) {
document.addEventListener ('DOMMouseScroll', mousewheel, true);
} else {
document.onmousewheel = mousewheel;
}
container.insertAdjacentHTML ('afterbegin', '<img src="images/spacer.gif" style="position: absolute; display: block; left: 0px; height: 15px; width: 15px;" alt="" />');
x = 15;
if (pictures != null) {
n = pictures.length;
for (i = 0; i < n; i++) {
picturesize = new Array (pictures[i][1], pictures[i][2]);
thumbnailsize = getthumbnailsize (picturesize, maxthumbnailsize);
wait.start (1);
element = document.createElement ('img');
element.id = i;
element.setAttribute('_pid', pictures[i][0]);
element.alt = '';
element.title = '';
element.className = 'presentationimg';
element.onload = imageloaded;
element.onabort = imageloaded;
element.onerror = imageloaded;
element.onclick = click;
element.ondblclick = click;
element.width = thumbnailsize[0];
element.height = thumbnailsize[1];
element.style.width = thumbnailsize[0]+'px';
element.style.height = thumbnailsize[1]+'px';
element.style.left = x + 'px';
element.style.top = Math.round ((120 - thumbnailsize[1]) / 2) + 'px';
element.src = picurl + thumbnailsize[0] + 'x' + thumbnailsize[1] + '/' + pictures[i][0] + '-' + pictures[i][3] + '.jpg';
container.appendChild (element);
if (pictures[i][0] == pid) currentpicture = i;
x += +thumbnailsize[0] + 6;
}
}
container.insertAdjacentHTML ('beforeend', '<img src="images/spacer.gif" style="position: absolute; display: block; left: '+x+'px; height: 15px; width: 15px;" alt="" />');
maxsize = new Array (body.offsetWidth - 160 - 8 + 32, body.offsetHeight - 152 - 30 + 32);
this.zoom (false);
}
this.changeselection = function (newpicture)
{
var np;
var op;
var pic;
var pid;
var i;
np = document.getElementById (newpicture);
op = (initializing ? null : document.getElementById (currentpicture));
if ((op) && (np) && (np != op)) {
op.className = 'presentationimg';
}
if ((np) && (np != op)) {
np.className = 'presentationimgsel';
this.scrolltarget = np.offsetLeft - ((np.parentNode.clientWidth - np.clientWidth) / 2);
if (this.scrolltarget < 0) {
this.scrolltarget = 0;
} else {
i = np.parentNode.scrollWidth - (np.parentNode.clientWidth);
if (this.scrolltarget > i) this.scrolltarget = i;
}
if (initializing) {
np.parentNode.scrollLeft = this.scrolltarget;
initializing = false;
} else {
if (this.scrollinterval == null) {
this.scrollcountdown = 8;
this.scrollinterval = setInterval (scroll, scrollrate);
wait.start (4);
}
}
currentpicture = +newpicture;
i = +np.id;
pictureview.loaddetails();
picturesize = new Array (pictures[i][1], pictures[i][2]);
thumbnailsize = getthumbnailsize (picturesize, maxsize);
wait.start (5);
if (this.oldpicture == null) {
pic = document.createElement ('img');
} else {
wait.stop (5);
pic = this.picture;
}
pic.className = 'presentationpic';
pic.alt = '';
pic.title = '';
pic.onabort = picloaded;
pic.onload = picloaded;
pic.onerror = picloaded;
pic.style.left = '50%';
pic.style.top = '50%';
pic.style.width = thumbnailsize[0] + 'px';
pic.style.height = thumbnailsize[1] + 'px';
pic.style.margin = '-' + (Math.round (thumbnailsize[1] / 2)) + 'px 0px 0px -' + (Math.round (thumbnailsize[0] / 2)) + 'px';
boxcentercontent.appendChild (pic);
boxcentercontent.scrollTop = 0;
pic.setAttribute('_pid', pictures[i][0]);
if (this.picture != pic) {
if (this.oldpicture != null) {
try {
boxcentercontent.removeChild (this.oldpicture);
} catch (exception) {
}
this.oldpicture = null;
}
this.oldpicture = this.picture;
this.picture = pic;
}
pic.src = pic2url + thumbnailsize[0] + 'x' + thumbnailsize[1] + '/' + pictures[i][0] + '-' + pictures[i][3] + '.jpg';
}
}
var click = function ()
{
presentation.changeselection (+this.id);
}
var keydown = function (event)
{
var keycode;
var cancelkey;
var i;
var elem;
if (window.event) event = window.event;
cancelkey = true;
keycode = event.keyCode;
if (event.target) elem = event.target.nodeName; else elem = event.srcElement.nodeName;
switch (keycode) {
case 8: { 
toolbar.navigateback();
break;
}
case 27: { 
if ((elem == 'INPUT') ||(elem == 'TEXTAREA')) {
cancelkey = false;
} else {
}
break;
}
case 9: { 
cancelkey = false;
break;
}
case 13: { 
if (event.altKey) {
if (controls.trylock()) { xml.request('picturecomment.xml?aid='+currentalbum+'&pid='+document.getElementById(currentpicture).attributes.getNamedItem('_pid').value+'&desc=1'); }
} else {
if ((elem == 'A') || (elem == 'INPUT') || (elem == 'TEXTAREA')) {
cancelkey = false;
} else {
toolbar.navigateback();
}
}
break;
}
case 32: { 
sidebars.showhideall();
break;
}
case 35: { 
i = currentpicture + 1;
while (document.getElementById (i)) i++ ;
presentation.changeselection (i-1);
break;
}
case 36: { 
presentation.changeselection (0);
break;
}
case 33:   
case 37:   
case 38: { 
presentation.changeselection (currentpicture - 1);
break;
}
case 34:   
case 39:   
case 40: { 
presentation.changeselection (currentpicture + 1);
break;
}
case 107: { 
presentation.zoom (true);
break;
}
case 109: { 
presentation.zoom (false);
break;
}
default: {
cancelkey = false;
}
}
event.returnValue = !cancelkey;
return (!cancelkey);
}
var scroll = function ()
{
var element;
var d;
var stopscrolling;
var l;
if (presentation.scrollcountdown > 0) {
presentation.scrollcountdown--;
} else {
stopscrolling = true;
try {
element = document.getElementById ('thumbdiv');
if (element) {
l = element.scrollLeft;
d = l - presentation.scrolltarget;
if ((d < -scrollfraction) || (d > scrollfraction)) {
d = Math.round (d / scrollfraction);
element.scrollLeft = l - d;
if (element.scrollLeft == l - d) stopscrolling = false;
}
}
} catch (exception) {
stopscrolling = true;
} finally {
if (stopscrolling) {
try {
element.scrollLeft = presentation.scrolltarget;
} catch (exception) {
} finally {
clearInterval (presentation.scrollinterval);
wait.stop(4);
presentation.scrollinterval = null;
}
}
}
}
}
var mousewheel = function (e)
{
var container;
var delta;
var wheeldelta;
if (window.event) e = window.event;
if (e.wheelDelta) {
wheeldelta = e.wheelDelta / 120;
} else {
wheeldelta = -e.detail / 5;
}
container = document.getElementById ('thumbdiv');
if (container) {
delta = Math.round (wheeldelta * container.clientWidth / 3 * 2);
presentation.scrolltarget = container.scrollLeft - delta;
if (presentation.scrolltarget < 0) {
presentation.scrolltarget = 0;
} else {
i = container.scrollWidth - (container.clientWidth);
if (presentation.scrolltarget > i) presentation.scrolltarget = i;
}
if (presentation.scrollinterval == null) {
presentation.scrollinterval = setInterval (scroll, scrollrate);
wait.start (4);
}
}
}
var picloaded = function ()
{
if (presentation.oldpicture != null) {
try {
boxcentercontent.removeChild (presentation.oldpicture);
} catch (exception) {
}
presentation.oldpicture = null;
}
wait.stop (5);
}
this.zoom = function (plus)
{
var i, n;
n = sizes.length;
if (plus) {
for (i = 0; i < n-1; i++) {
if (sizes[i][0] > maxsize[0]) break;
}
} else {
for (i = n-1; i > 0; i--) {
if ((sizes[i][0] < maxsize[0]) && (sizes[i][1] < maxsize[1])) break;
}
}
maxsize[0] = sizes[i][0];
maxsize[1] = sizes[i][1];
document.getElementById('pdmaxsize').innerHTML = maxsize[0] + ' x ' + maxsize[1] + ' max';
i = currentpicture;
currentpicture = -1;
this.changeselection (i);
}
}
var presentation = new Presentation();
function Previews ()
{
this.submit = function ()
{
var addpictures, removepictures;
var elements;
var i, n;
var inputelement;
addpictures = new Array();
removepictures = new Array();
elements = boxcentercontent.getElementsByTagName('input');
n = elements.length;
for (i = 0; i < n; i++) {
inputelement = elements.item(i);
if (inputelement.type == 'checkbox') {
if (inputelement.checked != inputelement.defaultChecked) {
if (inputelement.checked) {
addpictures.push (+inputelement.value);
} else {
removepictures.push (+inputelement.value);
}
}
}
}
xml.request ('previews.xml?action=submit&aid=' + aeid + '&add=' + addpictures.toString() + '&remove=' + removepictures.toString());
}
this.selectall = function (folderindex, value)
{
var container;
var elements;
var inputelement;
var i, n;
container = document.getElementById ('folder' + folderindex);
elements = container.getElementsByTagName('input');
n = elements.length;
for (i = 0; i < n; i++) {
inputelement = elements.item(i);
if (inputelement.type == 'checkbox') inputelement.checked = value;
}
}
}
var previews = new Previews();
function Sidebars ()
{
var stl;
var stb;
var str;
var hl = false;
var hb = false;
var hr = false;
var maxstep = 8;
var animinterval = null;
var animtimestamp = null;
var hideinterval = null;
var hidetimestamp = null;
var hidebegin = false;
var fraction = 3;
var clickborder = 5;
var hiddenwidth = 7;
this.resize = function (r, b, l)
{
boxcentercontent.style.display = 'none';
boxcentercontent.style.visibility = 'hidden';
boxcentercontent.style.display = 'block';
if (l != null) {
if (l < stl) {
boxbottom.style.left = (hl ? hiddenwidth : l) + 'px';
}
stl = l;
}
if (r != null) {
if (r < str) {
boxbottom.style.right = (hr ? hiddenwidth : r) + 'px';
}
str = r;
}
if (b != null) {
if (b < stb) {
}
stb = b;
}
boxcenter.style.left = (hl ? hiddenwidth : stl) + 'px';
boxcenter.style.right = (hr ? hiddenwidth : str) + 'px';
boxcenter.style.bottom = (hb ? hiddenwidth : stb) + 'px';
if (animinterval == null) sidebars.animate();
}
this.animate = function ()
{
var d;
var complete;
var date;
var n;
date = new Date ();
if (animtimestamp == null) {
animtimestamp = date.valueOf();
} else {
}
animtimestamp = date.valueOf();
complete = true;
if (boxleft.offsetWidth != stl) {
if (boxleftcontent.style.visibility != 'hidden') {
boxleftcontent.style.display = 'none';
boxleftcontent.style.visibility = 'hidden';
boxleftcontent.style.display = 'block';
}
d = stl - boxleft.offsetWidth;
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
boxleft.style.width = (boxleft.offsetWidth + d) + 'px';
if ((hl) || (boxleft.offsetLeft < 0)) boxleft.style.left = (boxleft.offsetLeft - d) + 'px';
complete = false;
} else {
boxleftcontent.style.visibility = '';
}
if (boxright.offsetWidth != str) {
if (boxrightcontent.style.visibility != 'hidden') {
boxrightcontent.style.display = 'none';
boxrightcontent.style.visibility = 'hidden';
boxrightcontent.style.display = 'block';
}
d = str - boxright.offsetWidth;
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
boxright.style.width = (boxright.offsetWidth + d) + 'px';
n = (boxright.parentNode.offsetWidth - boxright.offsetLeft - boxright.offsetWidth);
if ((hr) || (n < 0)) {
boxright.style.right = (n - d) + 'px';
if ((boxright.parentNode.offsetWidth - boxright.offsetLeft - boxright.offsetWidth) != (n - d)) boxright.style.right = (n - d - 1) + 'px';
}
complete = false;
} else {
boxrightcontent.style.visibility = '';
}
if (boxbottom.offsetHeight != stb) {
if (boxbottomcontent.style.visibility != 'hidden') {
boxbottomcontent.style.display = 'none';
boxbottomcontent.style.visibility = 'hidden';
boxbottomcontent.style.display = 'block';
}
d = stb - boxbottom.offsetHeight;
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
boxbottom.style.height = (boxbottom.offsetHeight + d) + 'px';
n = (boxbottom.parentNode.offsetHeight - boxbottom.offsetTop - boxbottom.offsetHeight);
if ((hb) || (n < 0)) {
boxbottom.style.bottom = (n - d) + 'px';
if ((boxbottom.parentNode.offsetHeight - boxbottom.offsetTop - boxbottom.offsetHeight) != (n - d)) boxbottom.style.bottom = (n - d - 1) + 'px';
}
complete = false;
} else {
boxbottomcontent.style.visibility = '';
}
if (!complete) {
animinterval = setTimeout ("sidebars.animate();", 25);
wait.start (3);
} else {
wait.reset (3);
animinterval = null;
animtimestamp = null;
n = boxbottom.parentNode.offsetHeight - boxbottom.offsetTop;
boxbottom.style.right = (hr ? hiddenwidth : boxright.parentNode.offsetWidth - boxright.offsetLeft) + 'px';
boxcentercontent.style.visibility = '';
}
}
this.showhide = function ()
{
var d;
var t;
var complete;
var i;
var n;
var date;
hideinterval = null;
date = new Date ();
if (hidetimestamp == null) {
hidetimestamp = date.valueOf();
} else {
}
hidetimestamp = date.valueOf();
complete = true;
t = false;
if ((hl) && (boxleft.offsetLeft > - (boxleft.offsetWidth - hiddenwidth))) {
t = -(boxleft.offsetWidth - hiddenwidth);
} else if ((!hl) && (boxleft.offsetLeft < 0)) {
t = 0;
}
if (t !== false) {
d = t - boxleft.offsetLeft;
if ((hidebegin) && (d < 0)) {
boxbottom.style.left = hiddenwidth + 'px';
}
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
boxleft.style.left = (boxleft.offsetLeft + d) + 'px';
complete = false;
}
t = false;
if ((hr) && (boxright.offsetLeft < boxright.parentNode.offsetWidth - hiddenwidth)) {
t = (boxright.parentNode.offsetWidth - hiddenwidth);
} else if ((!hr) && (boxright.offsetLeft > boxright.parentNode.offsetWidth - boxright.offsetWidth)) {
t = boxright.parentNode.offsetWidth - boxright.offsetWidth;
}
if (t !== false) {
d = t - boxright.offsetLeft;
if ((hidebegin) && (d > 0)) {
boxbottom.style.right = hiddenwidth + 'px';
}
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
i = boxright.offsetLeft;
n = (boxright.parentNode.offsetWidth - boxright.offsetLeft - boxright.offsetWidth - d);
boxright.style.right = n + 'px';
if (i == boxright.offsetLeft) boxright.style.right = (n - (d > 0 ? +1 : -1)) + 'px';
complete = false;
}
t = false;
if ((hb) && (boxbottom.offsetTop < boxbottom.parentNode.offsetHeight - hiddenwidth)) {
t = (boxbottom.parentNode.offsetHeight - hiddenwidth);
} else if ((!hb) && (boxbottom.offsetTop > boxbottom.parentNode.offsetHeight - boxbottom.offsetHeight)) {
t = boxbottom.parentNode.offsetHeight - boxbottom.offsetHeight;
}
if (t !== false) {
d = t - boxbottom.offsetTop;
if ((d > -fraction) && (d < fraction)) {
d = (d > 0 ? +1 : -1);
} else {
d = Math.round (d / fraction);
if (d > maxstep) d = maxstep; else if (d < -maxstep) d = -maxstep;
}
i = boxbottom.offsetTop;
n = (boxbottom.parentNode.offsetHeight - boxbottom.offsetTop - boxbottom.offsetHeight - d);
boxbottom.style.bottom = n + 'px';
if (i == boxbottom.offsetTop) boxbottom.style.bottom = (n - (d > 0 ? +1 : -1)) + 'px';
complete = false;
}
hidebegin = false;
if (!complete) {
if (hideinterval == null) hideinterval = setTimeout ("sidebars.showhide();", 25);
wait.start (3);
} else {
wait.reset (3);
boxcenter.style.left = (boxleft.offsetLeft + boxleft.offsetWidth) + 'px';
boxcenter.style.right = (boxcenter.parentNode.offsetWidth - boxright.offsetLeft) + 'px';
boxcenter.style.bottom = (boxcenter.parentNode.offsetHeight - boxbottom.offsetTop) + 'px';
boxbottom.style.left = (boxleft.offsetLeft + boxleft.offsetWidth) + 'px';
boxbottom.style.right = (boxbottom.parentNode.offsetWidth - boxright.offsetLeft) + 'px';
hidetimestamp = null;
}
}
this.startshowhide = function ()
{
hidebegin = true;
if (hideinterval == null) hideinterval = setTimeout ("sidebars.showhide();", 25);
}
this.showhideall = function ()
{
if ((!hl) || (!hr) || (!hb)) {
hl = true;
hr = true;
hb = true;
} else {
hl = false;
hr = false;
hb = false;
}
sidebars.startshowhide();
}
this.boxleftclick = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
if (event.clientX - boxleft.offsetLeft  >= boxleft.offsetWidth - i) {
hl = !hl;
sidebars.startshowhide();
}
}
this.boxleftmousemove = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
boxleft.style.cursor = ((event.clientX - boxleft.offsetLeft  >= boxleft.offsetWidth - i) ? "pointer" : "auto");
}
this.boxrightclick = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
if (event.clientX - boxright.offsetLeft  < i) {
hr = !hr;
sidebars.startshowhide();
}
}
this.boxrightmousemove = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
boxright.style.cursor = ((event.clientX - boxright.offsetLeft  < i) ? "pointer" : "auto");
}
this.boxbottomclick = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
if (event.clientY - boxbottom.offsetTop  < i) {
hb = !hb;
sidebars.startshowhide();
}
}
this.boxbottommousemove = function (event)
{
var i;
if (hl) i = hiddenwidth + 2; else i = clickborder;
if (!event) event = window.event;
boxbottom.style.cursor = ((event.clientY - boxbottom.offsetTop  < i) ? "pointer" : "auto");
}
}
var sidebars = new Sidebars();
function State ()
{
this.init = function ()
{
};
}
var state = new State;
function Toolbar ()
{
this.naviback = null;
this.naviforward = null;
this.buttoncount = 0;
this.init = function ()
{
var topleftwidth = 224;
boxtop.insertAdjacentHTML ('beforeend',
'<div style="position: absolute; top: 0px; left: 0px; height: 30px; width: '+topleftwidth+'px; overflow: hidden; background-image: url(images/slate/tlc.gif); background-repeat: repeat-x;">'
+   '<img src="images/slate/tlr.gif" width="11" height="30" border="0" alt="" style="position: absolute; right: 0px;" />'
+   '<a href="javascript:if (controls.trylock()) xml.request(\'albums.xml\');" title="difo.org" onmouseover="return toolbar.buttonmouseover(this);" onmouseout="return toolbar.buttonmouseout();" tabindex="0" onfocus="this.blur(); return true;" style="position: absolute; top: 0px; left: 6px; cursor: default;"><img src="images/difologo.png" border="0" alt="" style="width: 83px; height: 30px;" /></a>'
+   '<a tabindex="0" onfocus="this.blur(); return true;" class="toolbarbutton" id="naviback" style="position: absolute; top: 3px; left: 94px; display: block; float: left;"><span id="navibackimg"></span><span style="vertical-align: middle; position: relative; padding: 0px 0px 1px 2px;">toolbar_back</span></a>'
+   '<a tabindex="0" onfocus="this.blur(); return true;" class="toolbarbutton" id="naviforward" style="position: absolute; top: 3px; left: 154px; display: block; float: left;"><span id="naviforwardimg"></span><span style="vertical-align: middle; position: relative; padding: 0px 0px 1px 2px;">toolbar_open</span></a>'
+ '</div>'
);
boxtop.insertAdjacentHTML ('beforeend',
'<div id="topright" style="position: absolute; top: 0px; right: 0px; height: 30px; width: 0px; overflow: hidden; background-image: url(images/slate/tlc.gif); background-repeat: repeat-x;">'
+   '<img src="images/slate/trl.gif" width="11" height="30" border="0" alt="" style="position: absolute; left: 0px;" />'
+   '<div id="waitdiv" style="position: absolute; overflow: hidden; background-color: #202020; top: 4px; width: 6px; height: 19px; right: 5px;"></div>'
+   '<a href="javascript:if (controls.trylock()) xml.request(\'help.xml\');" tabindex="0" onfocus="this.blur(); return true;" class="toolbarbutton" id="helpbutton" style="position: absolute; right: 13px; display: block; margin-right: 2px; top: 3px;"><span id="toolbarhelpimg">'+pngiconstr ('images/help.png', 19, 19, 'vertical-align: middle;')+'</span><span style="vertical-align: middle; position: relative; padding: 0px 0px 1px 2px;">Hilfe</span></a>'
+   '<a href="javascript:undefined" tabindex="0" onfocus="this.blur(); return true;" class="toolbarbutton" id="toolbaruser" style="position: absolute; right: 62px; display: block; margin-right: 2px; top: 3px;"><span id="toolbaruserimg">'+pngiconstr ('images/user-3.png', 19, 19, 'vertical-align: middle;')+'</span><span id="toolbarusertext" style="vertical-align: middle; position: relative; padding: 0px 0px 1px 2px;">&nbsp;</span></a>'
+ '</div>'
);
boxtopcontent.style.left = (topleftwidth + 2) + 'px';
boxtopcontent.style.right = 53 + 'px';
boxtopcontent.style.top = 0 + 'px';
boxtopcontent.style.bottom = 0 + 'px';
this.button ('back', '', null, null, null);
this.button ('forward', '', null, null, null);
};
var pngiconstr = function (filename, width, height, styles)
{
return '<img src="'+filename+'" border="0" alt="" title="" style="width: '+width+'px; height: '+height+'px; '+styles+'" />';
}
this.button = function (type, href, icon, text, hint)
{
var control = null;
var span;
var html;
var container;
if (type == 'back') {
control = document.getElementById('naviback');
span = document.getElementById('navibackimg');
if (href !== null) {
if (href) icon = 'images/navileft.png'; else icon = 'images/navileftd.png';
}
} else if (type == 'forward') {
control = document.getElementById('naviforward');
span = document.getElementById('naviforwardimg');
if (href !== null) {
if (href) icon = 'images/naviright.png'; else icon = 'images/navirightd.png';
}
} else if (type == 'button') {
html = '<a tabindex="0" onfocus="this.blur(); return true;" class="toolbarbutton" id="toolbarbutton'+this.buttoncount+'" style="position: relative; display: block; float: left; margin-right: 2px; top: 3px;"><span id="toolbarbuttonimg'+this.buttoncount+'"></span>' + (text != '' ? '<span style="vertical-align: middle; position: relative; padding: 0px 0px 1px 2px;">'+text+'</span>' : '') + '</a>';
container = document.getElementById('toolbar');
container.insertAdjacentHTML ('beforeend', html);
control = document.getElementById('toolbarbutton'+this.buttoncount);
span = document.getElementById('toolbarbuttonimg'+this.buttoncount);
this.buttoncount++;
} else if (type == 'spacer') {
html = '<span style="position: relative; display: block; float: left; width: 0px; top: 5px; height: 18px; border-left: 1px solid #101010; border-right: 1px solid #a0a0a0; margin-left: 1px; margin-right: 3px;"></span>';
container = document.getElementById('toolbar');
container.insertAdjacentHTML ('beforeend', html);
} else {
alert ('ERROR [toolbar.button]: Unknown button');
}
if (control) {
control.title = hint;
if (href !== null) {
span.innerHTML = pngiconstr (icon, 19, 19, 'vertical-align: middle;');
if (href) {
control.className = 'toolbarbutton';
control.onclick = null;
control.href = href;
} else {
control.className = 'toolbarbuttondisabled';
control.onclick = function (event) { if (window.event) event = window.event; if (event.preventDefault) event.preventDefault(); return false; };
control.href = '#undefined';
}
}
control.onmouseover = this.buttonmouseover;
control.onmouseout = this.buttonmouseout;
}
};
this.buttonmouseover = function (control)
{
if (control == undefined) control = this;
if (window.status != control.title) window.status = control.title;
return true;
}
this.buttonmouseout = function ()
{
window.status = window.defaultStatus;
return true;
}
this.clear = function ()
{
var container;
container = document.getElementById('toolbar');
container.innerHTML = '';
this.buttoncount = 0;
}
this.navigateback = function ()
{
var control;
var s;
control = document.getElementById('naviback');
s = control.href;
if (s.substr(0, 11) == 'javascript:') {
eval (s.substr(11));
} else {
if (controls.trylock()) {
xml.request(s);
}
}
}
this.user = function (username)
{
var control;
var container;
var s;
var t;
if (username) {
s = '<b>' + username + '</b>&nbsp;';
t = 'javascript:if (controls.trylock()) xml.request(\'profile.xml\');';
} else {
s = 'Einloggen';
t = 'javascript:if (controls.trylock()) xml.request(\'login.xml\');';
}
control = document.getElementById('toolbaruser');
control.href = t;
control = document.getElementById('toolbarusertext');
control.innerHTML = s;
container = document.getElementById('topright');
container.style.width = (96 + control.offsetWidth) + 'px';
}
}
var toolbar = new Toolbar;
function Wait ()
{
var timer = null;
var waitdiv = new Array();
var counter = new Array();
var colors = new Array();
var hints = new Array();
var quantity = 6;
var coloroff = '#606060';
this.init = function ()
{
var container;
var element;
var i;
colors[0] = '#ff0000';
colors[1] = '#ffb000';
colors[2] = '#ffff00';
colors[3] = '#00e000';
colors[4] = '#f000ff';
colors[5] = '#ff0080';
hints[0] = '#ff0000';
hints[1] = '#ffb000';
hints[2] = '#ffff00';
hints[3] = '#00e000';
hints[4] = '#f000ff';
hints[5] = '#ff0080';
container = document.getElementById ('waitdiv');
for (i = 0; i < quantity; i++) {
element = document.createElement ('div');
element.id = 'wait'+i;
element.style.position = 'absolute';
element.style.top = (1+i*3)+'px';
element.style.left = '1px';
element.style.width = '4px';
element.style.height = '2px';
element.style.overflow = 'hidden';
element.style.backgroundColor = coloroff;
container.appendChild (element);
waitdiv[i] = element;
counter[i] = 0;
}
};
this.update = function (id)
{
if (counter[id] == 1) {
waitdiv[id].style.backgroundColor = colors[id];
} else if (counter[id] == 0) {
waitdiv[id].style.backgroundColor = coloroff;
}
};
this.start = function (id)
{
counter[id]++;
this.update(id);
};
this.stop = function (id)
{
if (counter[id] > 0) counter[id]--;
this.update(id);
};
this.reset = function (id)
{
counter[id] = 0;
this.update(id);
};
}
var wait = new Wait;
function XMLRequest ()
{
this.comp = false;
if (window.XMLHttpRequest) {
this.comp = new XMLHttpRequest ();
} else if (window.ActiveXObject) {
try {
this.comp = new ActiveXObject ('MSXML2.XMLHTTP');
} catch (exception) {
this.comp = false;
}
}
if (!this.comp) alert ('ERROR: Cannot instantiate XMLHttpRequest');
}
var readystatechangearray = new Array();
readystatechangearray[0] = function () { xml.readystatechange (0); };
readystatechangearray[1] = function () { xml.readystatechange (1); };
readystatechangearray[2] = function () { xml.readystatechange (2); };
readystatechangearray[3] = function () { xml.readystatechange (3); };
readystatechangearray[4] = function () { xml.readystatechange (4); };
readystatechangearray[5] = function () { xml.readystatechange (5); };
function XML ()
{
var xmlhttp;
var sequencenumber = 0;
this.init = function ()
{
var i;
xmlhttp = new Array();
for (i = 0; i < 6; i++) xmlhttp[i] = false;
}
this.request = function (url)
{
var i;
for (i = 0; i < 6; i++) {
if (xmlhttp[i] == false) {
xmlhttp[i] = true;
wait.start (0);
xmlhttp[i] = new XMLRequest ();
xmlhttp[i].comp.open ('GET', url, true);
xmlhttp[i].comp.onreadystatechange = readystatechangearray[i];
xmlhttp[i].comp.send (null);
break;
}
}
if (i >= 6) {
alert ('xml.request (' + url + '): ERROR: Out of XMLHTTP objects. i=' + i);
}
}
this.readystatechange = function (id)
{
var attribute;
var attributes;
var button;
var e;
var elem;
var element;
var elements;
var err;
var head;
var height, width;
var html;
var i;
var icon;
var k;
var l, r, b;
var m;
var n;
var pic;
var prvws;
var s;
var src;
var status;
var statusText;
var target;
var targetvalue;
var xmlresponse;
if (xmlhttp[id].comp.readyState == 4) {
try {
wait.stop (0);
err = true;
status = '000';
statusText = '???';
if (xmlhttp[id].comp) {
try {
status = xmlhttp[id].comp.status;
statusText = xmlhttp[id].comp.statusText;
} catch (exception) {
}
}
if (((status >= 200) && (status < 300)) || (status == 304)) {
xmlresponse = xmlhttp[id].comp.responseXML;
if ((xmlresponse) && (xmlresponse.getElementsByTagName ('parsererror').length == 0)) {
err = false;
element = xmlresponse.getElementsByTagName ('title').item (0);
if (element != null) {
document.title = 'difo.org » ' + element.text;
}
element = xmlresponse.getElementsByTagName ('box').item (0);
if (element != null) {
elem = element.getElementsByTagName ('right').item (0);
if (elem != null) r = +elem.text; else r = null;
elem = element.getElementsByTagName ('left').item (0);
if (elem != null) l = +elem.text; else l = null;
elem = element.getElementsByTagName ('bottom').item (0);
if (elem != null) b = +elem.text; else b = null;
sidebars.resize (r, b, l);
}
element = xmlresponse.getElementsByTagName ('user').item (0);
if (element != null) {
toolbar.user (element.text);
}
element = xmlresponse.getElementsByTagName ('toolbar').item (0);
if (element != null) {
toolbar.clear ();
elements = element.childNodes;
n = elements.length;
for (i = 0; i < n; i++) {
element = elements.item (i);
if (element.tagName != undefined) {
toolbar.button (
element.tagName,
element.text,
(attribute = element.attributes.getNamedItem ('icon')) ? attribute.value : '',
(attribute = element.attributes.getNamedItem ('text')) ? attribute.value : '',
(attribute = element.attributes.getNamedItem ('hint')) ? attribute.value : ''
);
}
}
}
element = xmlresponse.getElementsByTagName ('pictures').item (0);
if (element != null) {
elements = xmlresponse.getElementsByTagName ('picture');
n = elements.length;
pictures = new Array (n);
for (i = 0; i < n; i++) {
attributes = elements.item (i).attributes;
pictures[i] = new Array (attributes.getNamedItem ('id').value, attributes.getNamedItem ('w').value, attributes.getNamedItem ('h').value, attributes.getNamedItem ('v').value);
}
}
element = xmlresponse.getElementsByTagName ('albums').item (0);
if (element != null) {
elements = element.getElementsByTagName ('album');
n = elements.length;
albums = new Array (n);
for (i = 0; i < n; i++) {
e = elements.item (i).getElementsByTagName ('preview');
m = e.length;
prvws = new Array (m);
for (j = 0; j < m; j++) {
attributes = e.item (j).attributes;
prvws[j] = attributes.getNamedItem ('id').value + '-' + attributes.getNamedItem ('version').value;
}
attributes = elements.item (i).attributes;
albums[i] = new Array (attributes.getNamedItem ('id').value, attributes.getNamedItem ('name').value, attributes.getNamedItem ('count').value, attributes.getNamedItem ('time1').value, attributes.getNamedItem ('time2').value, attributes.getNamedItem ('permissions').value, attributes.getNamedItem ('visible').value, prvws);
}
}
elements = xmlresponse.getElementsByTagName ('content');
n = elements.length;
for (i = 0; i < n; i++) {
element = elements.item (i);
target = element.attributes.getNamedItem ('target');
if (!target) targetvalue = 'boxcentercontent'; else targetvalue = target.value;
s = getInnerCdata (element);
elem = document.getElementById (targetvalue);
if (elem) elem.innerHTML = s;
}
element = xmlresponse.getElementsByTagName ('dialog').item (0);
if (element != null) {
elem = element.attributes.getNamedItem ('width');
if (elem) width = +elem.value; else width = 300;
elem = element.attributes.getNamedItem ('height');
if (elem) height = +elem.value; else height = 0;
dialog.init (width, height);
s = getInnerCdata (element);
dialog.setcontent (s, ((elem = element.attributes.getNamedItem ('title')) ? elem.value : ''));
}
element = xmlresponse.getElementsByTagName ('script').item (0);
if (element != null) {
head = document.getElementsByTagName ('head').item (0);
e = document.getElementById ('newscript');
if (e) head.removeChild (e);
e = document.createElement ('script');
e.id = 'newscript';
e.type = 'text/javascript';
e.text = getInnerCdata (element);
head.appendChild (e);
}
element = xmlresponse.getElementsByTagName ('focus').item (0);
if (element != null) {
setTimeout ("setfocus ('" + element.text + "', 0);", 25);
}
element = xmlresponse.getElementsByTagName ('refresh').item (0);
if (element != null) {
xml.request (element.text);
}
}
}
if (err) {
if (xmlresponse && xmlresponse.parseError.reason) reason = xmlresponse.parseError.reason; else reason = '';
document.title = 'Error [http ' + status + ' ' + statusText + '] ' + reason;
boxcentercontent.innerText = 'FEHLER: ' + xmlhttp[id].comp.responseText;
}
}	catch (exception) {
}
xmlhttp[id].comp = false;
xmlhttp[id] = false;
}
}
var getInnerCdata = function (node)
{
var i;
var n;
var t;
var nd;
t = '';
n = node.childNodes.length;
for (i = 0; i < n; i++) {
nd = node.childNodes.item (i);
if (nd.nodeType == 4) {
t = nd.nodeValue;
break;
}
}
return t;
}
}
var xml = new XML ();
function Jsform()
{
var submitbutton = null;
this.setsubmitbutton = function (asubmitbutton)
{
submitbutton = asubmitbutton;
}
this.submit = function (formelem)
{
var s;
var v;
var i;
var n;
var elem;
n = formelem.elements.length;
s = '';
for (i = 0; i < n; i++) {
elem = formelem.elements.item(i);
if (((elem.tagName == 'INPUT') && ((elem.type == 'text') || (elem.type == 'password') || (elem.type == 'hidden'))) || (elem.tagName == 'SELECT') || (elem.tagName == 'TEXTAREA')) {
v = elem.value;
} else if ((elem.tagName == 'INPUT') && ((elem.type == 'checkbox') || (elem.type == 'radio'))) {
if (elem.checked) v = elem.value; else v = null;
} else if ((elem.tagName == 'INPUT') && ((elem.type == 'submit'))) {
if (elem == submitbutton) v = elem.value; else v = null;
} else {
v = '?';
}
if (v !== null) {
if (i > 0) s = s + '&';
s = s + elem.name + '=' + encodeURIComponent(v);
}
}
s = s.replace (/\'/g, "%27");
s = formelem.action.replace ('%s', s);
eval (s);
}
}
var jsform = new Jsform();
//| eof