Object.extend = function(target, source) {
for (n in source) {
target[n] = source[n];
}
return target;
}
Object.extend(Array, {
from: function(obj) {
var result = [];
for (var n = 0; n < obj.length; n++) {
result.push(obj[n]);
}
return result;
}
});
Object.extend(Function.prototype, {
bind: function(bind) {
if (!bind) { return; }
var target = this;
return function() { return target.apply(bind, arguments); };
}
});
var fastLink = {
contents: {},
lines: {},
timeouts: {},
visible: null,
closeIcon: null,
attempt: function() {
var result, args = Array.from(arguments);
do {
try {
result = args.shift()();
break;
} catch (e) { }
} while (args.length);
return result;
},
initialize: function() {
var container = document.getElementById('fastLink');
var lnks = container.getElementsByTagName('a');
for (var i = 0; i < lnks.length; i++) {
lnks[i].onmouseover = function(e) {
fastLink.showContent(this);
}
lnks[i].onmouseout = function(e) {
if (fastLink.timeouts[this]) {
clearTimeout(fastLink.timeouts[this]);
fastLink.timeouts[this] = null;
}
fastLink.timeouts[this] = setTimeout(
function() {
fastLink.hideContent(this)
}.bind(this),
300
);
}
lnks[i].parentNode.onmouseover = lnks[i].onmouseover.bind(lnks[i]);
lnks[i].parentNode.onmouseout = lnks[i].onmouseout.bind(lnks[i]);
}
},
showContent: function(obj) {
if (this.timeouts[obj]) {
clearTimeout(this.timeouts[obj]);
this.timeouts[obj] = null;
}
if (this.visible) {
this.hideContent(this.visible);
}
this.visible = obj;
window.document.getElementById('newsMessenEvents').style.visibility = 'visible';
if (!this.contents[obj]) {
this.contents[obj] = window.document.createElement('div');
this.contents[obj].className = 'fastLinkContent';
this.contents[obj].innerHTML = '
' + FastLinkStrings["inhaltWirdGeladen"] + '
';
this.contents[obj].onmouseover = obj.onmouseover.bind(obj);
this.contents[obj].onmouseout = obj.onmouseout.bind(obj);
window.document.getElementById('contentBox').appendChild(this.contents[obj]);
var loader = new AJAX();
loader.oncomplete = function(r) {
fastLink.contents[obj].innerHTML = r.responseText;
}
loader.initialize(obj.href + "&framework=3s-2007-fastLink&disableAutocreateFramework=1");
}
if (!this.closeIcon) {
this.closeIcon = window.document.createElement('div');
this.closeIcon.className = 'fastLinkClose';
this.closeIcon.innerHTML = FastLinkStrings["schliessen"] + ' X
';
window.document.getElementById('contentBox').appendChild(this.closeIcon);
}
this.closeIcon.onmouseover = obj.onmouseover.bind(obj);
this.closeIcon.onmouseout = obj.onmouseout.bind(obj);
this.closeIcon.onclick = obj.onmouseout.bind(obj);
this.closeIcon.style.display = 'block';
this.contents[obj].style.display = 'block';
obj.className = obj.className.replace(/\s*active/, '') + ' active';
if (!this.lines[obj]) {
this.lines[obj] = window.document.createElement('div');
this.lines[obj].className = "line";
this.lines[obj].onmouseover = obj.onmouseover.bind(obj);
this.lines[obj].onmouseout = obj.onmouseout.bind(obj);
obj.parentNode.appendChild(this.lines[obj]);
}
// Alles hat geklappt -> onClick alternative ausschalten
obj.onclick = function(e) {
return false;
}
},
hideContent: function(obj) {
if (this.visible == obj) {
this.visible = null;
if (this.lines[obj]) {
this.lines[obj].parentNode.removeChild(this.lines[obj]);
this.lines[obj] = null;
}
obj.className = obj.className.replace(/\s*active/, '');
this.contents[obj].style.display = 'none';
this.closeIcon.style.display = 'none';
window.document.getElementById('newsMessenEvents').style.visibility = 'hidden';
}
}
}
var AJAX = function() {};
Object.extend(AJAX.prototype, {
request: null,
initialize: function(url, method) {
this.url = url;
method = method ? method.toUpperCase() : "GET";
this.request = fastLink.attempt(
function() { return new XMLHttpRequest(); },
function() { return ActiveXObject('Msxml2.XMLHTTP'); },
function() { return new ActiveXObject('Microsoft.XMLHTTP'); }
);
this.request.onreadystatechange = function() {
this.response();
}.bind(this);
this.request.open(method, url, true);
this.request.send(null);
this.onrequest(this.request);
},
response: function() {
if (this.request.readyState == 4) {
if (this.request.status == 200) {
this.oncomplete(this.request);
} else {
this.onerror(this.request);
}
}
this.onresponse(this.request);
},
onrequest: function(e) {},
onresponse: function(e) {},
oncomplete: function(e) {},
onerror: function(e) {}
});
fastLink.initialize();