
if (document.all) $(document.body).addClass('women');

/**
 * HBV Women navigation...
 * @author Lennart Pegel <lennart@neofonie.de>
 */
function initWomanNavi () {
	var MIN_ADD_OV_WIDTH = 40,	// overlay's width will be at least parentItem's width plus this value
		jNavi1 = $('#navigation'),
		jNavi2 = $('#navi2'),
		offs1 = jNavi1.offset(),
		offs2 = jNavi2.offset() || {left:0,top:0},
		h1 = jNavi1.height(),
		h2 = jNavi2.outerHeight(),
		jDiv = $('<div id="naviOV"><div class="novMinWidth"></div></div>'),
		offsY1 = offs1.top + h1 - 2,
		offsY2 = offs2.top + h2 - 2,
		leftSubOffs = 0,
		jMinWidth = $(jDiv[0].childNodes[0]),
		currHElem = 0, // currently hovered element
		
		hide = function() {
			jDiv.hide().find('ul').hide()
			$(document.body).unbind('mouseover', hide);
			if (currHElem && currHElem.hoverClass) {
				currHElem.parentNode.className = (currHElem.parentNode.className||'').replace(currHElem.hoverClass,'');
				currHElem = 0;
			}
		},
		jDivHover = function() {
			if (currHElem && currHElem.hoverClass)
				$(currHElem.parentNode).addClass(currHElem.hoverClass);
			return false;
		},

		hoverHandler = function(e) {
			hide();
			if (this.hoverClass) $(this.parentNode).addClass(this.hoverClass);
			
			if (!this.sub) return false;
			currHElem = this;

			this.sub.ul.style.display = 'block';
			jDiv.css({
				left: this.sub.left + 'px',
				top: this.sub.top +2 + 'px',
				display: 'block'
			});

			// min with of the overlay depending on level1/2 item..
			jMinWidth.css('width', this.sub.minW + MIN_ADD_OV_WIDTH + 'px');

			$(document.body).bind('mouseover', hide);
			return false;
		},
		mouseout = function(e) {
			if (this.hoverClass) $(this.parentNode).removeClass(this.hoverClass);
			return false;
		},
		
		prepareSub = function(i,li) {
			var subUL = $('ul',this.parentNode)[0] || 0,
				isLevel1 = this.parentNode.parentNode.parentNode.parentNode.id=='navtabs',
				isActive = this.parentNode.className.indexOf('active')<0;

			// make navi-links clickable on full area in IE6..
			if ($.browser.msie) {
				var span = document.createElement('span');
				this.appendChild(span);
			}
			
			this.hoverClass = (subUL)? 'hover2' : 'hover';
			$(this).bind('mouseover', hoverHandler).bind('mouseout', mouseout);

			if (!subUL) return;

			jDiv.append(subUL);
	
			var offs = $(this.parentNode).offset();
			this.sub = {
				ul: subUL,
				left: offs.left + ((isLevel1)? 0 : 1),
				top: (isLevel1)? offsY1 : offsY2,
				minW: $(this).outerWidth() + 30
			};

			if ($.browser.msie) this.sub.top--;

			$('li:last', subUL).addClass('last').each(function(o) {
				// ie6 fix (pseudo text node)
				if ($.browser.msie && this.childNodes.length>1) this.removeChild( this.childNodes[ (this.childNodes[0].nodeType==1)? 1 : 0] );
			});
			
		};

	$(document.body).append(jDiv);
	jDiv.bind('mouseover', jDivHover);

	// iterate level1+2 tabs..
	$('#navtabs td > a').each(prepareSub);
	leftSubOffs++;
	$('#navtabs2 td > a').each(prepareSub);
	jDiv.append(jMinWidth);
}



/**
 * Places the skyscraper vertically aligned with the header
 * To be called inline directly after the hbv_skyscraper-DIV element.
 */
function fixSkyScrPosition() {
	var offs = $('#header').offset() || {top:-1};
	$('#hbv_skyscraper').css('top', offs.top+1 );
}


/**
 * Places the body-background image just below the top navigation on maxi pages.
 */
function adjustMaxiBackground() {
	var jN = $('#navigation'),
		h = jN.height(),
		o = jN.offset().top,
		jN2 = $('#navi2'),
		h2 = jN2.height() || 0,
		bgOffs = o + h + (h2?h2+1:0) - 400;
	if ($.browser.msie) bgOffs -= 1;
	$(document.body).css('background','#E0E5E7 url(img/maxi/bg_white400.gif) 0 '+ bgOffs +'px repeat-x');

}