').addClass('pgn');
cnt.find('img').each(function(i) {
i += 1;
jQuery(this)
.attr('id', 'gl-' +i)
.addClass('gl-' +i)
.next('p')
.addClass('gl-' +i)
;
controlPanel
.append(jQuery('')
.append(jQuery('')
.attr({
title: jQuery(this).attr('alt'),
href: '#' +jQuery(this).attr('id')
})
.text(i)
)
)
;
if (i === 1) {
jQuery('a', controlPanel).addClass('active');
}
});
if (controlPanel.find('li').length > 1) {
cnt.append(controlPanel);
}
},
article: function() {
jQuery('div.rtcl-gl ul.pgn li a').click(function(ev) {
ev.preventDefault();
try {
if (jQuery(this).hasClass('active') === false) {
var currentId = jQuery('div.rtcl-gl>img').attr('id'),
currentSrc = jQuery('div.rtcl-gl>img').attr('src'),
currentAlt = jQuery('div.rtcl-gl>img').attr('alt'),
currentText = jQuery('div.rtcl-gl>p').html(),
changeLink = jQuery(this).attr('href'),
changeId = changeLink.substring(changeLink.indexOf('#')+1, changeLink.length),
changeSrc = jQuery('div.rtcl-gl img.' +changeId).attr('src'),
changeAlt = jQuery('div.rtcl-gl img.' +changeId).attr('alt'),
changeText = jQuery('div.rtcl-gl p.' +changeId).html();
jQuery('div.rtcl-gl')
.find('>img')
.attr({'src':changeSrc, 'alt':changeAlt, 'id':changeId, 'class':changeId})
.end()
.find('>p')
.html(changeText)
.removeClass(currentId)
.addClass(changeId)
.end()
.find('ul.pgn a')
.removeClass('active')
;
jQuery('div.rtcl-gl div.strg')
.find('img.' +changeId)
.attr({'src':currentSrc, 'id':currentId, 'class':currentId})
.end()
.find('p.' +changeId)
.removeClass(changeId)
.addClass(currentId)
.html(currentText)
;
jQuery(this).addClass('active');
}
} catch(e) {}
});
}
};
zo.peDropDown = {
init: function(navJSON) {
this.getNav('div#level1Navi ul', {file:navJSON, delay:500}, function() { zo.peDropDown.navi.slideDown(); });
},
getNav: function(navId, optMap, callback) {
// load the JSON data
jQuery.getJSON(optMap.file, function(data, textStatus) {
if (textStatus === 'success') {
// wait till the dom is ready
jQuery(document).ready(function() {
// get the active navigation items
var actNav = jQuery(navId+ ' a.active'),
// render the whole navigation tree with the JSON data
fullNav = zo.peDropDown.buildNav(data);
// walk through the active nav items and mark the equivalent item in the whole nav tree
actNav.each(function(i) {
fullNav
.find('a[id="' +jQuery(actNav[i]).attr('id')+ '"]')
.addClass('active')
.closest('li')
.addClass('activeLi')
;
});
// replace the static navigation with the rendered nav
jQuery(navId).replaceWith(fullNav);
// dispatch the dropdown ability
callback();
});
}
});
},
/**
* render the navigation from a json structure
*
* @attribute (Object) data the navigation array
* @attribute (String) depth navigation level, default "1"
* @attribute (Number) z numerical navigation level, default 0
*/
buildNav: function(data, depth, z) {
var tmpUl, tmpLi,
depth = depth || "1",
z = z || 0,
rdDepth = 2; // render depth
$.each(data, function(i) {
if(typeof data[i].id !== "undefined") {
// create the list container
if (i === 0) {
tmpUl = jQuery('
').addClass('level' +depth);
}
// create the list item
tmpLi = jQuery('')
.addClass(data[i].li_class)
.append(jQuery('')
.attr({
href: data[i].href,
id: data[i].id
})
.html(data[i].headline)
.attr('title', function() { return jQuery(this).text(); })
)
;
// got children?
if (typeof data[i].nav === 'object' && data[i].nav.length > 0 && z < rdDepth) {
// raise depth
depth += "_1";
z++;
// recursive call
tmpLi.append(zo.peDropDown.buildNav(data[i].nav, depth, z));
// change depth back
depth = depth.substring(0, depth.length-2);
z--;
}
// mount list items
tmpUl.append(tmpLi);
}
});
return tmpUl;
},
/**
* drop down ability
*
*/
elem: "",
zindex: 100,
increaseZIndex: function() {
zo.peDropDown.zindex++;
return zo.peDropDown.zindex;
},
decreaseZIndex: function() {
zo.peDropDown.zindex--;
return zo.peDropDown.zindex;
},
navi: {
slideDown: function() {
var focused;
jQuery('*').bind('focus', function(ev) {
focused = ev.target;
});
// handle the navigation with the keyboard
jQuery('div#level1Navi ul a')
.bind('focus', function(ev) {
if (jQuery(this).closest('ul').hasClass('level1_1')) {
var posLeft = parseInt(jQuery(this).closest('li').offset().left - jQuery('div#level1Navi ul').offset().left - 10, 10);
jQuery(this)
.closest('li')
.find('>ul')
.css({
left:posLeft,
'z-index':100
})
.show()
;
} else {
jQuery(this)
.closest('li')
.find('>ul')
.css({'z-index':100})
.show()
;
}
})
.bind('blur', function(ev) {
// start new thread through setTimeout call
setTimeout(function() {
// from third level to second level
if ((jQuery(focused).closest('ul').attr('class') == "level1_1"
&& jQuery(ev.target).closest('ul').attr('class') == "level1_1_1")
&& jQuery.inArray(ev.target, jQuery(focused).closest('li').find('ul').find('a')) == -1)
{
jQuery(ev.target)
.closest('ul')
.closest('li')
.find('>ul')
.hide()
;
}
// jump back from second level to second level or from second level to first level
else if ((jQuery(focused).closest('ul').attr('class') == "level1_1"
&& jQuery(ev.target).closest('ul').attr('class') == "level1_1")
|| (jQuery(focused).closest('ul').attr('class') == "level1"
&& jQuery(ev.target).closest('ul').attr('class') == "level1_1"))
{
jQuery(ev.target)
.closest('li')
.find('>ul')
.hide()
;
}
// jump from last third level to next first level
else if (jQuery(focused).closest('ul').attr('class') == "level1"
&& jQuery(ev.target).closest('ul').attr('class') == "level1_1_1")
{
jQuery(ev.target)
.parents('ul.level1_1')
.find('li>ul')
.hide()
;
jQuery(focused)
.closest('li')
.prev()
.find('>ul')
.hide()
;
}
// jump back from first level to first level
else if (jQuery(focused).closest('ul').attr('class') == "level1"
&& jQuery(ev.target).closest('ul').attr('class') == "level1")
{
jQuery(focused)
.find('li>ul')
.show()
.end()
.closest('li')
.next()
.find('>ul')
.hide()
;
}
// jumping out the navigation box
else if (jQuery.inArray(focused, jQuery('div#level1Navi ul').find('a')) == -1) {
jQuery('div#level1Navi ul li>ul')
.hide()
;
}
}, 0);
})
;
// handle the navigation with the mouse
var duration = {slideDown:500, slideDownTimeout:500, slideUp:500, slideUpTimeout:500};
jQuery('div#level1Navi li').hover(
// mouseover action
function() {
// save the event target (this) to a variable to use it in another scope (in this case inside the setTimeout method)
var self = jQuery(this),
zindex, posLeft;
// proceed if the event target is not the current active element or lays not in the third navigation level
if (self.hasClass('activeLi') === false || self.parent().hasClass('level1_1')) {
// increase z-index
zindex = zo.peDropDown.increaseZIndex();
// first navigation level
if (self.closest('ul').hasClass('level1'))
{
jQuery(document).bind('mouseover', function(ev) {
zo.peDropDown.elem = ev.target;
});
// use a delay to avoid direct changes in the second level
setTimeout(function() {
// change the navigation only if the mouse is still over the same navigation element
if (jQuery(zo.peDropDown.elem).closest('li')[0] === self[0]) {
self
.find('>ul')
.css({'z-index':zindex})
.slideDown(duration.slideDown);
}
jQuery(document).unbind('mouseover');
},duration.slideDownTimeout);
}
// second navigation level
// show the third navigation level (drop down) without any delay
else
{
var posLeft = parseInt(self.offset().left - jQuery('div#level1Navi ul').offset().left - 10, 10);
self
.find('>ul')
.css({
left:posLeft,
'z-index':zindex
})
.slideDown(0)
;
}
}
},
// mouseout action
function() {
// save the event target (this) to a variable to use it in another scope (in this case inside the setTimeout method)
var self = jQuery(this);
if (self.hasClass('activeLi') === false || self.parent().hasClass('level1_1')) {
// first navigation level
if (self.closest('ul').hasClass('level1')) {
jQuery(document).bind('mouseover', function(ev) {
zo.peDropDown.elem = ev.target;
});
// use a delay to avoid direct changes in the second level
setTimeout(function() {
// hide the second navigation layer in case of not equal and in first level or if the mouse position is not inside the navigation element
if ((jQuery(zo.peDropDown.elem).closest('li')[0] !== self[0] && jQuery(zo.peDropDown.elem).closest('ul').hasClass('level1'))
|| (jQuery(zo.peDropDown.elem).parents('div#level1Navi').length < 1))
{
self
.find('>ul')
.animate({opacity:1.0},duration.slideUp)
.slideUp(duration.slideUp)
.animate({opacity:1.0},0);
}
jQuery(document).unbind('mouseover');
},duration.slideUpTimeout);
}
// second navigation level
else
{
self
.find('>ul')
.slideUp(0);
}
}
}
);
}
}
};
/**
* toggle the visibility of the meta navigation
*
*/
zo.toggleMeta = {
slideUp: function() {
var pTop = jQuery('#vzbv-logo').offset().top - jQuery('div#metaNavi').offset().top,
pLeft = jQuery('#vzbv-logo').offset().left - jQuery('div#metaNavi').offset().left
;
jQuery('#vzbv-logo')
.find('img')
.clone()
.attr({
'alt': '',
'id': 'vzbv-logo-clone'
})
.css({
'position': 'absolute',
'top': pTop,
'left': pLeft
})
.appendTo('div#headerArea')
;
jQuery('div#metaNavi').slideUp(1000);
},
slideDown: function() {
jQuery('div#metaNavi').slideDown(1000, function() {
jQuery('img#vzbv-logo-clone').remove();
});
}
};
/**
* visual rating tool
* this method creates the hover effect for the rating line
*
*/
jQuery.fn.rating = function() {
jQuery(this)
.find('a')
.hover(
// over
function() {
// activate this and all previous items
jQuery(this)
.find('img')
.attr('src', '')
.parent()
.prevAll('a')
.find('img')
.attr('src', '')
;
},
// out
function() {
// deactivate all
jQuery(this)
.parent()
.siblings('a')
.andSelf()
.find('img')
.attr('src', '')
;
}
)
;
return this;
};
/**
* zebra stripes
* this method extends jQuery to make chaining possible
*
* @attribute (Object) even map with the css properties for all even elements
* @attribute (Object) odd map with the css properties for all odd elements
*/
jQuery.fn.zebraStripes = function(even, odd) {
jQuery(this)
.filter(':even')
.css(even)
.end()
.filter(':odd')
.css(odd)
;
return this;
};
jQuery.fn.markLinksInRnText = function() {
if (navigator.userAgent.indexOf('MSIE') > -1) {
jQuery(this).each(function(i) {
var anchor = jQuery(this),
aText = anchor.text().split(' '),
aClass = anchor.attr('class'),
aFirstWord = aText.shift(),
aOffcut = aText.join(' '),
aTarget = jQuery.trim(aClass.replace(/rntxt/, ''));
anchor
.removeClass('rntxt')
.html(jQuery('')
.addClass(aTarget)
.text(aFirstWord)
)
.append(' ' +aOffcut)
;
});
}
return this;
};
/** init level1 navigation */
zo.peDropDown.init('/cps/rde/xchg/projektklima/hs.xsl/naviJSON_V2.js');
/** include extra stylesheet */
zo.css.include('/cps/rde/xchg/projektklima/hs.xsl/behavior.css');
/** things to do when the dom is ready */
jQuery(document).ready(function()
{
/** include extra stylesheet for meta pages */
if (jQuery('div#level1Navi ul li.activeLi').length === 0) {
jQuery('div#breadcrumbNavi').css('margin', '0.5em 0 1em');
}
zo.target.tab('a.extern, a.extrn, a.pdf, div#vzbv-foot a');
zo.target.popup('a.popup');
zo.toggle();
// klimalexikon
if (jQuery('div#dct').length) zo.lexicon.init();
// widget: artikel fotostrecke
if (jQuery('div.rtcl-gl').length) zo.gallery.init();
// widget: fotostrecke
if (jQuery('div#sldshw').length) zo.slideshow.init();
jQuery('a[href=#taf]').click(function(ev) {
ev.preventDefault();
var lbContent = zo.target.buildTal();
zo.target.openLightBox(lbContent);
});
if (jQuery('div#taf p.error').length) {
jQuery('a[href=#taf]').trigger('click');
}
if (jQuery('li[id=print]').length) {
zo.toolbar.print();
}
// widget: klimatipps
if (jQuery('div#cl-tps').length) zo.snippets.clTips(700);
// widget: image map
if (jQuery('div#map').length) {
zo.imageMap.toggleItems('map#img-map');
zo.imageMap.toggleItems('ul#stt');
}
// rating tool
jQuery('div.rtng-tl').rating();
zo.toggleRating();
// clearing the search fields default value
if (jQuery('input#search_textfield').length) {
jQuery('input#search_textfield').focus(function(ev) {
zo.form.clearFieldDef(jQuery(this), zo.form.defSearch);
});
}
// hack for background-images in inline elemtens
jQuery('a.rntxt').markLinksInRnText();
// form validation
// comments
if (jQuery('form#wrtCmt').length) zo.form.validate.cmtForm();
jQuery('div.rd div.cmt')
.css({padding:'10px'})
.zebraStripes({'background-color':'#f9f9f9'}, {'background-color':'#f1f1f1'})
;
});