// fixed/scroll Navigation
function switchPositioning() {
var h = document.viewport.getHeight();
var t = $('pageTop');
if (t != null) {
if (h < MIN_HEIGHT_FIXED_NAV) {
t.removeClassName('fixed');
}
else {
t.addClassName('fixed');
}
}
}
// scrolling
var Weiterlesen = Class.create({
initialize: function()
{
// all size values in pixels
this.MaximalTopOffsetActive = 120; // maximally tolerated top offset of active element in list
this.MinimalUpperMargin = 0; // when header not fixed
this.MinimalHeightFixedHeader = MIN_HEIGHT_FIXED_NAV; // minimal viewport height for fixed header
this.UpperSujetHeight = 0; // upper sujet height, set by MAS
this.LowerSujetHeight = 0; // lower sujet height including margin, set by MAS
this.pageTop = $('pageTop');
this.weiterLesen = $('weiterLesen');
this.weiterLesenScroll = $('weiterLesenScroll');
if (PageProperties.isEnhanced == true)
{
this.reposition();
this.showWeiterlesenActive();
this.weiterLesen.style.bottom = '43px';
}
},
reposition: function()
{
// minimal and maximal upper margin
var min = this.MinimalUpperMargin;
var max = this.pageTop.getHeight();
if (this.MinimalHeightFixedHeader <= document.viewport.getHeight())
{
min = max;
}
max += this.UpperSujetHeight;
// calculated margin
var calc = max - document.viewport.getScrollOffsets().top;
if (calc < min)
{
calc = min;
}
calc += 8;
// adjust positions via styles
this.weiterLesen.setStyle({ top: calc + 'px' });
this.weiterLesenScroll.setStyle({ bottom: this.LowerSujetHeight + 'px' });
},
setUpperSujetHeight: function(ush)
{
this.UpperSujetHeight = ush;
this.reposition();
},
setLowerSujetHeight: function(lsh)
{
this.LowerSujetHeight = lsh;
this.reposition();
},
showWeiterlesenActive: function()
{
// guarantee visibility of active element in list, if exists
var actObj = this.weiterLesenScroll.down('ul li.active');
if (actObj)
{
var actTop = actObj.positionedOffset().top;
if (actTop > this.MaximalTopOffsetActive)
{
// scroll down
this.weiterLesenScroll.scrollTop = actTop - this.MaximalTopOffsetActive;
} else if (actTop < this.weiterLesenScroll.scrollTop)
{
// scroll up
this.weiterLesenScroll.scrollTop = actTop;
}
}
}
});
// Navigation
var Navigation = Class.create({
initialize: function(elt)
{
this.element = $(elt);
this.delayID = 0;
this.resetID = 0;
this.items = {};
this.activeItems = new Array();
var homeLink = this.element.down('a');
homeLink.observe('mouseover', this.onMouseOver.bind(this));
homeLink.observe('mouseout', this.onMouseOut.bind(this));
this.element.select('div > ul > li').each(function(channel)
{
new NavChannel(channel, this);
} .bind(this));
this.activeInit = this.activeItems;
},
onMouseOver: function() { this.mouseOver(this, this.showAll.bind(this)); },
onMouseOut: function() { this.mouseOut(this) },
showAll: function()
{
this.element.select('li').each(function(e) { e.removeClassName('active'); });
},
activate: function(pathArray)
{
var activeNew = new Array();
$A(pathArray).each(function(pathEntry)
{
try
{
var entryName = pathEntry.n.toLowerCase();
var menuItem = this.items['nav_' + entryName];
if (menuItem) activeNew.push(menuItem);
} catch (e) { }
} .bind(this));
if (activeNew.size() == 0)
{
activeNew = this.activeInit;
}
this.activeItems = activeNew;
this.reset();
},
reset: function()
{
this.showAll();
var line1 = $('navLine1');
var line2 = $('navLine2');
if (!line1.hasClassName('active')) line1.addClassName('active');
if (line2.hasClassName('active')) line2.removeClassName('active');
this.activeItems.each(function(item)
{
item.activate();
});
},
mouseOver: function(menuItem, action)
{
window.clearTimeout(this.resetID);
window.clearTimeout(this.delayID);
if (action) this.delayID = action.delay(0.333);
},
mouseOut: function(menuItem)
{
window.clearTimeout(this.delayID);
this.resetID = this.reset.bind(this).delay(1);
}
});
var NavChannel = Class.create({
initialize: function(elt, nav)
{
this.element = $(elt);
this.nav = nav;
this.id = this.element.id.toLowerCase();
nav.items[this.id] = this;
if (this.isActive()) nav.activeItems.push(this);
var channelLink = this.element.down('a');
if (channelLink) {
channelLink.observe('mouseover', this.onMouseOver.bind(this));
channelLink.observe('mouseout', this.onMouseOut.bind(this));
}
var ressortUL = this.element.down('ul');
if (ressortUL) ressortUL.childElements().each(function(ressort) {
new NavRessort(ressort, nav);
});
},
activate: function()
{
var line = this.element.up('div');
line.siblings().each(function(e) { e.removeClassName('active'); });
line.addClassName('active');
this.highlight();
this.element.select('li').each(function(e) { e.removeClassName('active'); });
},
highlight: function()
{
this.element.siblings().each(function(e) { e.removeClassName('active'); });
this.element.addClassName('active');
},
isActive: function()
{
return this.element.hasClassName('active');
},
isLineActive: function()
{
return this.element.up('div').hasClassName('active');
},
onMouseOver: function()
{
this.nav.mouseOver(this, (this.isLineActive()) ? this.highlight.bind(this) : null);
},
onMouseOut: function()
{
this.nav.mouseOut(this);
}
});
var NavRessort = Class.create({
initialize: function(elt, nav)
{
this.element = $(elt);
if (this.element.hasClassName('nav_empty')) return;
this.nav = nav;
this.id = this.element.id.toLowerCase();
nav.items[this.id] = this;
if (this.isActive()) nav.activeItems.push(this);
this.element.down('a').observe('mouseover', this.onMouseOver.bind(this));
this.element.down('a').observe('mouseout', this.onMouseOut.bind(this));
},
activate: function()
{
this.element.siblings().each(function(e) { e.removeClassName('active'); });
this.element.addClassName('active');
},
isActive: function()
{
return this.element.hasClassName('active');
},
onMouseOver: function()
{
this.nav.mouseOver(this);
},
onMouseOut: function()
{
this.nav.mouseOut(this);
}
});
// Pfad zum aktuellen Kontext
var BreadCrumbs = Class.create({
initialize: function(element, maxWidth) {
this.element = element;
this.maxWidth = maxWidth;
},
adjust: function() {
var crumbs = this.element.select('.breadCrumb').slice(0, -2);
while (this.element.getWidth() > this.maxWidth && crumbs.length > 0) {
crumbs.pop().hide();
}
}
});
// gathering the username and communityname by forcing the backend to get it from the database not from the cookie.
function refreshUserInfo()
{
if (!$('toolbarProfile')) return;
getUserInfo(['refreshUserInfo=1']);
}
// gathering the weather-data by forcing the backend to get it from the database not from the cookie.
function refreshWeatherInfo()
{
if (!$('toolbarProfile')) return;
getUserInfo(['refreshWeatherInfo=1']);
}
// gathering the username and communityname.
function updateUserInfo()
{
if (!$('toolbarProfile')) return;
getUserInfo();
}
// requesting the userinformation from the backend; from cookie or from database.
function getUserInfo()
{
var params = arguments[0] || [];
if ($('TBLogin'))
{
$('TBUser').hide();
new Ajax.Request('/ajax/bottomnavinfo.ashx',
{ method: 'get'
, parameters: params.join('&')
, onComplete: writeUserInfo
});
}
}
// writes the username and communityname in the toolbar if the user is logged in.
function writeUserInfo(transport)
{
var data = transport.responseJSON;
if (data && data.UserName) {
$('TBLoginName').innerHTML = data.UserName;
$('TBCommunityName').innerHTML = (data.CommunityName) ? data.CommunityName : "";
$('toolbarProfile').removeClassName('anonymous');
}
$('TBUser').show();
if (data && data.WeatherImgName) {
var wetter = $('wetterWidget');
if (wetter) {
wetter.down('.bild').update('');
wetter.down('.stadt').update(data.WeatherCity);
wetter.down('.temp').update(data.WeatherTemp + '°');
wetter.show();
if (wetter.cumulativeOffset().left < (breadCrumbs.element.getWidth() + breadCrumbs.element.cumulativeOffset().left + 17))
wetter.hide();
}
}
}
Event.observe(document, 'dom:loaded', updateUserInfo);
function logout()
{
if (confirm("Wollen Sie sich abmelden?"))
{
var url = "/ajax/bottomnavinfo.ashx?type=logout";
var cb = new Ajax.Request(url, { method: 'get',
onComplete: function(transport)
{
var status = transport.responseJSON;
if (status && status.Status && status.Status == "ok")
{
//User hat sich erfolgreich ausgeloggt
$('toolbarProfile').addClassName('anonymous');
}
}
});
}
}
// Spezial-Funktionen
function hasGuidCookie() {
return document.cookie.indexOf('UGUID') != -1;
}
// FlashWrite (ist auch in MAS.js definiert!)
/*
Schreibt Flash-Object- und Embed-Tags so, dass trotz MS-ActiveX-Lizenz nur ein Klick nötig ist
oParentElement DOM-Objekt, in das die Flash-Einbettung geschrieben wird
iWidth Breite
iHeight Höhe
sBanner URL der Flash-Animation
sFlash Flash-Parameter (Liste von Name-Wert-Paaren)
sClickTag Name des Flash-Parameters zur Übergabe der Ziel-URL
sURLclick Ziel-URL
sCounterURL Optionale URL des Zählpixels; kann den symbolischen Wert %%RAND%% enthalten, der dann durch einen Zeitstempel ersetzt wird
*/
function FlashWrite(oParentElement, iWidth, iHeight, sBanner, sFlash, sClickTag, sURLclick, sCounterURL) {
var i;
var sClickAppend = '';
if (sClickTag && sURLclick) { if (sBanner.indexOf('?') > -1) { sClickAppend = '&' } else { sClickAppend = '?' } sClickAppend += sClickTag + '=' + escape(sURLclick); }
var sRet = '