﻿/* ------------------------------------------------------------------------------------------------------------
	jquery functions
------------------------------------------------------------------------------------------------------------ */

var vc_lightbox = new function(){
	this.open = function(objectID, objectWidth, objectLanguage, closingMethod){
		object = jQuery(objectID)
		
		/* --- abort if lightbox already opened --- */
		if(object.prev("div#vc_jq_lightbox_overlay").length > 0) {
			return false;
		}	
		
		/* --- initial values --- */
		
		// set in em - use same values as set in css		
		maxWidth = 89.8;
		minWidth = 30;

		// set in px
		minWidthLeft = 30;


		/* --- content --- */
		
		/* set width */		
		// calculate real em values from given percentage

		width = ( maxWidth/100 ) * objectWidth;

		if(width > maxWidth) { width = maxWidth; }
		if(width < minWidth) { width = minWidth; }

		object.css("width", width+"em");		


		/* set initial position */				
		object.css("position", "fixed");
		
		var positionLeft = (document.documentElement.clientWidth / 2) - (object.outerWidth() / 2);
		if (positionLeft <= minWidthLeft) {
			positionLeft = minWidthLeft;
		}
		object.css("left", positionLeft);

		var positionTop = (document.documentElement.clientHeight / 2) - (object.outerHeight() / 2);
		if (positionTop <= 0) {
			positionTop = 0;
		}
		object.css("top", positionTop);
		
		// set position absolute if box is to big and must be scrollable	
		if ( object.outerHeight() > document.documentElement.clientHeight || object.outerWidth() > document.documentElement.clientWidth || jQuery.browser.msie && /6.0/.test(navigator.userAgent)) {
			object.css("position", "absolute");
			
			var positionTop = (document.documentElement.clientHeight / 2) + jQuery(window).scrollTop() - (object.outerHeight() / 2);
			if (positionTop <= jQuery(window).scrollTop()) {
				positionTop = jQuery(window).scrollTop();
			}
			object.css("top", positionTop);
			var positionLeft = (document.documentElement.clientWidth / 2) + jQuery(window).scrollLeft() - (object.outerWidth() / 2);
			if (positionLeft <= minWidthLeft) {
				positionLeft = minWidthLeft;
			}
			object.css("left", positionLeft);
		}
		
		/* handle resize */
		jQuery(window).resize(function(){
			object.css("position", "fixed");
			
			// position left
			var positionLeft = (document.documentElement.clientWidth / 2) - (object.outerWidth() / 2);
			if (positionLeft <= minWidthLeft) {
				positionLeft = minWidthLeft;
			}
			object.css("left", positionLeft + "px");
			
			// postion top
			var positionTop = (document.documentElement.clientHeight / 2) - (object.outerHeight() / 2);
			if (positionTop <= 0) {
				positionTop = 0;
			}
			object.css("top", positionTop);
			
			// set position absolute if box is to big and must be scrollable	
			if ( object.outerHeight() > document.documentElement.clientHeight || object.outerWidth() > document.documentElement.clientWidth || jQuery.browser.msie && /6.0/.test(navigator.userAgent)) {
				object.css("position", "absolute");
				
				var positionTop = (document.documentElement.clientHeight / 2) + jQuery(window).scrollTop() - (object.outerHeight() / 2);
				if (positionTop <= jQuery(window).scrollTop()) {
					positionTop = jQuery(window).scrollTop();
				}
				object.css("top", positionTop);
				
				var positionLeft = (document.documentElement.clientWidth / 2) + jQuery(window).scrollLeft() - (object.outerWidth() / 2);
				if (positionLeft <= minWidthLeft) {
					positionLeft = minWidthLeft;
				}
				object.css("left", positionLeft);
			}		
		});
		
		/* handle scroll */
		jQuery(window).scroll(function(){
			object.css("position", "fixed");				
			
			// set position absolute if box is to big and must be scrollable
			
			// box too heigh	
			if (object.outerHeight() > document.documentElement.clientHeight && object.outerWidth() <= document.documentElement.clientWidth) {
				object.css("position", "absolute");
				
				// position left
				var positionLeft = (document.documentElement.clientWidth / 2) + jQuery(window).scrollLeft() - (object.outerWidth() / 2);
				if (positionLeft <= minWidthLeft) {
					positionLeft = minWidthLeft;
				}
				object.css("left", positionLeft);
			}
			
			// box to wide
			if (object.outerWidth() > document.documentElement.clientWidth && object.outerHeight() <= document.documentElement.clientHeight) {
				object.css("position", "absolute");
				
					positionLeft = minWidthLeft;
					object.css("left", positionLeft);
				
				
					var positionTop = (document.documentElement.clientHeight / 2) + jQuery(window).scrollTop() - (object.outerHeight() / 2);
					if (positionTop <= jQuery(window).scrollTop()) {
						positionTop = jQuery(window).scrollTop();
					}
					object.css("top", positionTop);
			}
			
			//box to wide and to heigh
			if (object.outerHeight() > document.documentElement.clientHeight && object.outerWidth() > document.documentElement.clientWidth) {
				object.css("position", "absolute");
			}
		});
		
		
		// add lightbox header
		if (closingMethod == 'all' || closingMethod == 'closelink') {
			if (objectLanguage == 'auto') {
				if (vc_getBrowserLanguage() == 'de') {
					title = 'Fenster schlie&szlig;en';
					text = 'Fenster schlie&szlig;en';
				} else {
					title = 'close window';
					text = 'close window';
				}
			} else if (objectLanguage == 'de') {
				title = 'Fenster schlie&szlig;en';
				text = 'Fenster schlie&szlig;en';
			} else {
				title = 'close window';
				text = 'close window';
			}
			
			object.prepend('<div class="vc_jq_lightbox_header"><a href="#" onclick="vc_lightbox.close(\'#\' + jQuery(this).parent().parent().attr(\'id\'));return false;" title="' + title + '" class="vc_link_close">' + text + '</a></div>');
		} else {
			object.prepend('<div class="vc_jq_lightbox_header vc_jq_lightbox_header_empty"></div>');
		}
		
		// show content
		object.show();
		
		
		/* --- overlay --- */
		
		// generate overlay
		object.before('<div id="vc_jq_lightbox_overlay"></div>');
		
		overlay = jQuery("#vc_jq_lightbox_overlay");
		
		// set size and position
		if (jQuery.browser.msie && /6.0/.test(navigator.userAgent)) {
			overlay.width(document.documentElement.clientWidth);
			overlay.height(jQuery(document).height());
			
			positionLeft = jQuery(window).scrollLeft();
			overlay.css("left", positionLeft);
		} else {
			overlay.css("position", "fixed");
		}
		
		// hide alle elments which can't be overlaid, but not in lightbox
		jQuery("embed, object, select, iframe").css("visibility", "hidden");
		
		object.find("embed").css("visibility", "visible");
		object.find("object").css("visibility", "visible");
		object.find("select").css("visibility", "visible");
		object.find("iframe").css("visibility", "visible");
		
		// show overlay
		overlay.show();		
		
		// handle resize
		jQuery(window).resize(function(){
			if (jQuery.browser.msie && /6.0/.test(navigator.userAgent)) {
				overlay.width(document.documentElement.clientWidth);
				overlay.height(jQuery(document).height());
			} else {
				overlay.hide().show();
			}
		});
		// handle scroll
		if (jQuery.browser.msie && /6.0/.test(navigator.userAgent)) {	
			jQuery(window).scroll(function(){
				positionLeft = jQuery(window).scrollLeft();
				overlay.css("left", positionLeft);
			});
		}		
		
		/* --- events --- */
		
		// close lightbox by clicking into the overlay
		if (closingMethod == 'all') {
			overlay.click(function(){
				vc_lightbox.close(object);
				return false;
			});
		}
		
		//Esc should close lightbox
		if (closingMethod == 'all' || closingMethod == 'closelink') {
			jQuery(document).keyup(function(event){
				if (event.keyCode == 27) {
					event.preventDefault();
					vc_lightbox.close(object);
					return false;
				}
			});
			jQuery(document).keydown(function(event){
				if (event.keyCode == 27) {
					event.preventDefault();
				}
			});
		} else {
			jQuery(document).unbind('keyup');
		}
	}
	
	this.close = function(objectID){
		object = jQuery(objectID);
		
		// hide content
		object.hide();
		
		// remove lightbox header
		object.find(".vc_jq_lightbox_header").remove();
		
		// unbind events
		jQuery(window).unbind('resize');
		jQuery(window).unbind('scroll');
		
		// remove overlay
		if(jQuery.browser.opera){
			//object.prev("#vc_jq_lightbox_overlay").remove();
			//object.prev("body").hide();
			object.prev("#vc_jq_lightbox_overlay").remove();
			window.scrollBy(0, 1);
			window.scrollBy(0, -1);
			//jQuery.scrollTo(jQuery(window).scrollTop()+1);
			//jQuery.scrollTo(jQuery(window).scrollTop()-1);
		} else {
			object.prev("#vc_jq_lightbox_overlay").remove();
		}
		
		// show hidden element
		jQuery("embed, object, select, iframe").css("visibility", "visible");
				
		return false;
	}
}

function vc_getBrowserLanguage(){
	var language = navigator.browserLanguage;
	if(!language) {
		var language = navigator.language;
	}
	
	if(language == 'de' || language == 'de-de'){
		language = 'de';
	} else {
		language = 'en';
	}
	
	return language;
}


/* ------------------------------------------------------------------------------------------------------------
	scriptacolous functions
------------------------------------------------------------------------------------------------------------ */

function initScripts(){
	commonInits();
}

function initScriptsStartseite(){
	//init onmouseout-EventHandler for Portalnavigation
	$('portaldirektlinks-oekb-aufklappwrap').observe('mouseleave',mouseOutPortalNavigationOeKB);
	$('portalnavigation-startseite-wrap').observe('mouseleave',resetPortalstartseiteNavigation);
	commonInits();
}


function commonInits(){
	//preload Images
	ImagePreloaderWrap();
	//init onmouseout-EventHandler for Portalnavigation
	$('portaldirektlinks-aufklappwrap').observe('mouseleave',mouseOutPortalNavigation);	
	$('merkliste').observe('mouseleave',mouseLeaveEventFunction);
	$('merkliste').observe('mouseenter',clearMerklisteTimer);
	disableAllAnchors();
	initMerklisteMitLang();
	
	
	try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
	
}


function sitemapInits(){
	//preload Images
	ImagePreloaderWrap();
	disableAllAnchors();	
}



/*################################*/
/*### SPRACHSPEZIFISCHE INHALTE ##*/
/*#################################*/


/* COOKIE F�R DIE SPRACHE. WIRD NICHT BENUTZT. STATTDESSEN WIRD IM METHODENAUFRUF DIE SPRACHE MITGEGEBEN
/*
langcookiejar = new CookieJar({  
			expires: 31536000,   // 1 year 
			path: '/'  
		}); 

langcookiejar.put("oekblang", "de");
currentlang = langcookiejar.get("oekblang");

*/

/* ARRAYS MIT DEN LOCALIZATIONS */

var lang = new Array("de","en");
lang["de"] = new Array("sitemap", "suche", "downloadcenter", "kontakt", "merkliste");
lang["en"] = new Array("sitemap", "suche", "downloadcenter", "kontakt", "merkliste");


lang["de"]["sitemap"] = new Array("EINBLENDEN", "AUSBLENDEN");
lang["en"]["sitemap"] = new Array("SHOW", "HIDE");

lang["de"]["suche"] = new Array("ERWEITERTE SUCHE EINBLENDEN", "ERWEITERTE SUCHE AUSBLENDEN");
lang["en"]["suche"] = new Array("SHOW ADVANCED SEARCH", "HIDE ADVANCED SEARCH");

lang["de"]["downloadcenter"] = new Array("ERWEITERTEN FILTER EINBLENDEN", "ERWEITERTEN FILTER AUSBLENDEN");
lang["en"]["downloadcenter"] = new Array("SHOW ADVANCED FILTER", "HIDE ADVANCED FILTER");

lang["de"]["kontakt"] = new Array("Erweiterte Kontaktdaten einblenden", "Erweiterte Kontaktdaten ausblenden");
lang["en"]["kontakt"] = new Array("Show contact details", "Hide contact details");

lang["de"]["merkliste"] = new Array("Ihre pers&ouml;nliche Merkliste ist leer. Klicken Sie auf das Plus vor dem Seitentitel um eine Seite auf die Merkliste zu setzen.", "alle Eintr&auml;ge entfernen", "Eintrag entfernen", "HILFE ZUR MERKLISTE EINBLENDEN", "HILFE ZUR MERKLISTE AUSBLENDEN");
lang["en"]["merkliste"] = new Array("Your Quicklink list is empty. You can add items by clicking on the plus icon next to the page link", "remove all entries", "remove entry", "SHOW QUICKLINK LIST HELP", "HIDE QUICKLINK LIST HELP");





/*print function*/
function printPage(){
	window.print();
}

/*dummy function*/
function doSomething(){
	
}

//## Portalnavigation ##
function togglePortalNavigation(node){
	var displaynode = node;
	new Effect.toggle(displaynode, 'blind', {duration:0.3} );
}

function openPortalNavigation(node){
	//portalNavigationNode = getNodeByClass(getNextSibling(node), 'portaldirektlinks-aufklappwrap');
	portalNavigationNode = document.getElementById('portaldirektlinks-aufklappwrap');
	togglePortalNavigation(portalNavigationNode);
}

function openPortalNavigationOeKB(node){
	//portalNavigationNode = getNodeByClass(getNextSibling(node), 'portaldirektlinks-aufklappwrap');
	portalNavigationNode = document.getElementById('portaldirektlinks-oekb-aufklappwrap');
	togglePortalNavigation(portalNavigationNode);
}

function mouseOutPortalNavigation(){
	//$('sharepoint-element-top').innerHTML = '<b>Leaving</b><br>' + $('sharepoint-element-top').innerHTML;
	if ( document.getElementById('portaldirektlinks-aufklappwrap').style.display != "none"){
		togglePortalNavigation( document.getElementById('portaldirektlinks-aufklappwrap') );
	}	
}

function mouseOutPortalNavigationOeKB(){
	//$('sharepoint-element-top').innerHTML = '<b>Leaving</b><br>' + $('sharepoint-element-top').innerHTML;
	if ( document.getElementById('portaldirektlinks-oekb-aufklappwrap').style.display != "none"){
		togglePortalNavigation( document.getElementById('portaldirektlinks-oekb-aufklappwrap') );
	}	
}



//## Image Preloading ##
function ImagePreloaderWrap(){
	//MM_preloadImages('fileadmin/img/linkbox-top-closed.gif');
}

/*Disable ToTopAnchor to avoid a Jump without scrolling - if Javascript is deactivated the Anchor remains in the Dom Tree and toTop is  still functional*/
function disableAllAnchors(){
	$('topAnchorId').remove();
}

//## Back to Top Button ##
function backToTop(thisElement){
	scrollToElement("page_margins");
}







/*Sitefeature Scripts*/
function showSitefeatureTitle(node, targetnodeID){
	displaynode = document.getElementById(targetnodeID);
	if (displaynode.style.display == "none"){
		displaynode.style.display = "block";
	}else{
		displaynode.style.display = "none";
	}
}






/*Portalnavigation Startseite*/
function openSecondLevel(node){
 	var obj=getElementsByClassNameOeKB('portalnavigation-startseite-level1-link');
  	for(i=0;i<obj.length;i++)
	  {
			var knoten = obj[i].firstChild;
			obj[i].style.backgroundImage = 'none';
			obj[i].style.backgroundColor = 'transparent';
			obj[i].style.color = '#585855';
	  }
	node.style.backgroundImage = 'url(/oekbstyles/oekbimg/portalnavigationstartseite/icon.gif)';
	node.style.backgroundColor = '#E9E9E4';
	node.style.color = '#333231';
	document.getElementById('portalnavigation-startseite-wrap').style.width = '395px';
}


function resetPortalstartseiteNavigation(){
	 var obj=getElementsByClassNameOeKB('portalnavigation-startseite-level1-link');
	  for(i=0;i<obj.length;i++)
	  {
			var knoten = obj[i].firstChild;
			obj[i].style.backgroundImage = 'url(/oekbstyles/oekbimg/portalnavigationstartseite/icon.gif)';
			obj[i].style.backgroundColor = 'transparent';
			obj[i].style.color = '#585855';
	  }
	  document.getElementById('portalnavigation-startseite-wrap').style.width = '205px';
}




/* ####################### */
/* SITEMAP Toggle Function */
/* ####################### */

function toggleSitemapBox(node, section, currentlang){
	
	var ausblendenLink = $(node).down(1).down();  // div class => .sitemap_toggler a 
	var title = $(node).down(0);  //div class =>  .sitemap_section_title
	var header = node;	    //div class =>  .sitemap_header
	
	
	/*
	var ausblendenLink = node;  // div class => .sitemap_toggler a 
	var title = $(node).up().previous();  //div class =>  .sitemap_section_title
	var header = $(title).up();	    //div class =>  .sitemap_header
	
	*/
	
		//alert($(sitemapSection).next());	
	myEffect = new Effect.toggle( $(header).next(), 'slide', {duration:0.3, beforeStart:updateDataBefore, afterFinish: updateDataAfter} );
	

	
	
	function updateDataBefore()
	{ 
	
		if (ausblendenLink.innerHTML == lang[currentlang]["sitemap"][0]) {
				
					$(ausblendenLink).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/toggle_up.gif)'
				  
				});
					
					
					
					
			 if(section == 'unternehmen')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#7F7D7C',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/unternehmen/bg-stretch-current.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
			 else if(section == 'anleihen')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#990000',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/anleihen/bg-stretch-current.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
			 else if(section == 'exportservice')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#CC0000',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/exportservice/bg-stretch-current.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
			 else if(section == 'kapitalmarkt')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#006600',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/kapitalmarkt/bg-stretch-current.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
			 else if(section == 'informationservices')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#003366',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/informationservices/bg-stretch-current.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
			 else if(section == 'energiemarkt')
			 {
					
				$(header).setStyle({
				
				 borderLeftColor: '#669900',
					borderLeftStyle: 'solid',
					borderLeftWidth: '1px',
					
					borderBottom: 'none'
					
					});
				
				
				
				$(title).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/energiemarkt/bg-stretch-current_green.gif)',
				  paddingLeft: '9px'
				  
				  });
				
			 }
		
		
}
		
	
	
	}
	
	
	
	
	function updateDataAfter()
	{ 
	 
	 
		 if (ausblendenLink.innerHTML == lang[currentlang]["sitemap"][0]) {
				
				
				ausblendenLink.innerHTML = lang[currentlang]["sitemap"][1];
				/*$(sitemapSection).setStyle ({display:block});*/
			
				
				
			}else{
				
				$(ausblendenLink).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/sitemap/toggle_down.gif)'
				  
				});
				
				
				$(title).setStyle({
				  backgroundImage: 'none',
				  paddingLeft: '10px'
				  
				
				});
				
				
				
				
				
		
				
					$(header).setStyle({
					
					 borderLeft: 'none',
					 
					 borderBottomColor: '#DFDFDA',
						borderBottomStyle: 'solid',
						borderBottomWidth: '5px'
						});
					
	
					
					
				ausblendenLink.innerHTML = lang[currentlang]["sitemap"][0];
			
					
			}
													  
	
	}
		
	
	 
}

/*  SUCHE TOGGLER F�R DIE ERWEITERTE SUCHE */

function toggleSucheBox(currentlang) {
	
	myEffect = new Effect.toggle( $$('.suche_erweitert_wrapper')[0], 'blind', {duration:0.3} );
	
	
	
	var icon = $$('.suche_toggler')[0].down();
	
	if ( $$('.suche_erweitert_wrapper')[0].style.display != "none"){
				
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/suche/toggler_down.gif)'
				  
				});
				
				$(icon).innerHTML = lang[currentlang]["suche"][0];
				
			}else{
				
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/suche/toggler_up.gif)'
				});
				
				$(icon).innerHTML =  lang[currentlang]["suche"][1];
				
			}	
}


/* TOGGLE FUNCTION F�R DIE FAQ SEITEN */

function toggleFAQBox(node){
	
	var antwortBox = $(node).next();
	
	myEffect = new Effect.toggle( antwortBox, 'slide', {duration:0.3} );
	
	var icon = $(node);
	if ( antwortBox.style.display != "none"){
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_down.gif)'
				});
				//alert("DOWN");
			}else{
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_up.gif)'
				});
				//	alert("UP");	
			}
}


/*  DOWNLOADCENTER TOGGLER F�R DIE ERWEITERTE FILTERUNG */



function toggleDownloadBox(node){
	
	var antwortBox = $(node).up('div').next();
	
	myEffect = new Effect.toggle( antwortBox, 'slide', {duration:0.3} );
	
	var icon = $(node);
	if ( antwortBox.style.display != "none"){
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_down.gif)'
				  
				});
				//alert("DOWN");
			}else{
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_up.gif)'
				});
				//	alert("UP");
				
			}

}


function toggleDownloadCenterBox(currentlang) {
	
	myEffect = new Effect.toggle( $('downloadcenter_erweitert_wrapper'), 'blind', {duration:0.3} );
	
	
	
	var icon = $('downloadcenter_toggler').down();
	
	if ( $('downloadcenter_erweitert_wrapper').style.display != "none"){
				
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/suche/toggler_down.gif)'
				  
				});
				
				$(icon).innerHTML =  lang[currentlang]["downloadcenter"][0];
				
			}else{
				
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/suche/toggler_up.gif)'
				});
				
				$(icon).innerHTML = lang[currentlang]["downloadcenter"][1];
				
			}
	
}

/* TOGGLE FUNCTION F�R DIE GLOSSAR SEITEN */

function toggleGlossarBox(node){
	
	var antwortBox = $(node).next();
	
	myEffect = new Effect.toggle( antwortBox, 'slide', {duration:0.3} );
	
	var icon = $(node);
	if ( antwortBox.style.display != "none"){
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_down.gif)'
				});
				//alert("DOWN");
			}else{
				$(icon).setStyle({
				  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_up.gif)'
				});
				//	alert("UP");	
			}
}


/* TOGGLE FUNCTION F�R DIE Kontakt SEITEN */

function toggleKontaktBox(node, currentlang){
	
	var antwortBox = $(node).previous().previous().down();
	
	myEffect = new Effect.toggle( antwortBox, 'blind', {duration:0.3, afterFinish:toggleIconAndFont} );
	
	
	
	function toggleIconAndFont(){
		var icon = $(node);
		if ( antwortBox.style.display == "none"){
			$(icon).setStyle({
			  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_down.gif)'
			  
			});
			$(icon).innerHTML = lang[currentlang]["kontakt"][0];
			//alert("DOWN");
		}else{
			$(icon).setStyle({
			  backgroundImage: 'url(/oekbstyles/oekbimg/faq/arrow_up.gif)'
			});
			//	alert("UP");
			$(icon).innerHTML = lang[currentlang]["kontakt"][1];
		}
		
	}
	
	

}



/*MERKLISTE DEVELOPMENT*/




/*init the objects necessary for the merkliste*/
function initMerkliste(currentlang){
	jar = new CookieJar();
	
	GLOBAL_PATHLANG = currentlang;
	
	jar.initialize("oekb_merkliste_cookiejar", {  
			expires: 31536000,   // 1 year 
			path: '/'
		})	
		
		
		
	updateMerklisteView(getCurrentLang());
}

function getCurrentLang(){
	return GLOBAL_PATHLANG;
}


/*Controller Functions*/
function updateMerklisteView(currentlang){
	//get the merkliste from the cookie and render it
	var merklistefromcookie = getMerklisteFromCookie();
	//check if merkliste is empty
	if (merklistefromcookie.length == 0){
		//render empty list
		var html  = "<div id=\"merkliste-leer\" style=\"display\:none\;\">";
	    html +=  "<div id=\"merkliste-leer-text\">"+ lang[currentlang]["merkliste"][0] + "</div></div>";
		html += "<ul id=\"merkliste-liste\" style=\"display\:none\;\"> <li><a href=\"javascript:removeAllElements();\" class=\"deleteall\"  >"+ lang[currentlang]["merkliste"][1] + "</a></li></ul>";
   		html +=  "<div class=\"clearboth-cols\">&nbsp;</div>";
		$('merkliste-listenwrap').innerHTML = html;
		new Effect.toggle( $('merkliste-leer'), 'blind', {duration:0.3, afterFinish:attachMerklisteMouseLeave } );
	}else{
		//render populated list
		var html  = "<div id=\"merkliste-leer\" style=\"display\:none\;\">";
	    html +=  "<div id=\"merkliste-leer-text\">"+ lang[currentlang]["merkliste"][0] + "</div></div>";
		html += "<ul id=\"merkliste-liste\">       <li><a href=\"javascript:removeAllElements();\" class=\"deleteall\"  >"+ lang[currentlang]["merkliste"][1] + "</a></li></ul>";
		html +=  "<div class=\"clearboth-cols\">&nbsp;</div>";
		
		$('merkliste-listenwrap').innerHTML = html;
		
		//print the listitems stored in jar-cookie
		for (i=0; i<merklistefromcookie.length; i++){
			new Insertion.Bottom($('merkliste-liste'), "<li id=\""+merklistefromcookie[i].id+"\"><a class=\"seitentitel\" target=\"_blank\" title=\""+merklistefromcookie[i].uri+"\"  alt=\""+merklistefromcookie[i].uri+"\" href=\""+merklistefromcookie[i].uri+"\">"+merklistefromcookie[i].title+"</a><a class=\"eintragloeschen\" href=\"javascript:removeElement('"+merklistefromcookie[i].id+"')\;\">"+ lang[currentlang]["merkliste"][2] + "</a></li>");
		}
	}
}



/* DATA MODEL FUNCTIONS*/

//returns the merklistenarray
function getMerklisteFromCookie(){
	//get the data from the cookie
	var merkliste = jar.get('merklistencookie');
	//if the cookie is empty, create the merkliste-array
	if (merkliste == null){
		merkliste = new Array(); 	
	}		
	return merkliste;
}


function putMerklisteToCookie(merkliste){
	jar.put('merklistencookie', merkliste);  
}

function emptyMerklistenCookie(){
	jar.empty('merklistencookie');
}


function addItemToMerkliste(node, uri, title, unique_id){
	if (isIdUnique(unique_id)){
		var merkliste = getMerklisteFromCookie();
		
		var newitem = new Object();
		newitem["title"] = title;
		newitem["uri"] = uri;
		newitem["id"] = unique_id;
	
		merkliste.unshift(newitem);
		//emtpy before refill
		emptyMerklistenCookie();
		//rewrite entire cookie
		putMerklisteToCookie(merkliste);
		//update HTML
		updateMerklisteView(getCurrentLang());
	}
	//open merkliste
	showMerkListe();
	highlightMerklistenItem(unique_id);
	startCloseMerklisteTimer();
}


function isIdUnique(unique_id){
	var merklistefromcookie = getMerklisteFromCookie();
	//check if id doesn't exist - avoids that a link can be added twice
	returnflag = true;
	for (i=0; i<merklistefromcookie.length; i++){
		if (merklistefromcookie[i].id == unique_id){
			//delete the item
			returnflag = false;
		}
	}
	return returnflag;
}


function removeElement(unique_id){
	var merklistefromcookie = getMerklisteFromCookie();
	
	//find the object 
	for (i=0; i<merklistefromcookie.length; i++){
		if (merklistefromcookie[i].id == unique_id){
			//delete the item
			merklistefromcookie.splice(i, 1);
		}
	}
	//update the cookie
	putMerklisteToCookie(merklistefromcookie);

	new Effect.toggle( $(unique_id), 'slide', {duration:0.3, afterFinish:EintragLoeschen} );
	
	function EintragLoeschen(){
		//$(node).remove();	
		updateMerklisteView(getCurrentLang());
	}
}

function removeAllElements(){
	new Effect.toggle( $('merkliste-liste'), 'slide', {duration:0.5, afterFinish:removeAllElementsNode} );
	function removeAllElementsNode(){
		emptyMerklistenCookie();
		updateMerklisteView(getCurrentLang());
	}
}


/* VIEW Functions */
function toggleMerkListe(){
	new Effect.toggle($('merkliste'), 'blind', {duration:0.2} );
	correctSafariViewBug();
}

function showMerkListe(){
	if ($('merkliste').style.display == "none"){
		new Effect.BlindDown($('merkliste'), {duration:0.2} );
	}
	correctSafariViewBug();
}

function hideMerkListe(){
	new Effect.BlindUp($('merkliste'), {duration:0.2} );
	correctSafariViewBug();
}

function mouseLeaveEventFunction(){
	hideMerkListe();
}

function correctSafariViewBug(){
	if (BrowserDetect.browser == "Safari" && BrowserDetect.version < 500){
			$('sitefeature-titles').setStyle({
			  margin: '-18px 0px 0px 0px'
			});
			allTitles = $('sitefeature-titles').immediateDescendants();	
			for (var i = 0;i<allTitles.length;i++){
				allTitles[i].setStyle({
					margin: '-18px 0px 0px 540px'
				});
			}
		}
}

function highlightMerklistenItem(unique_id){
	new Effect.Highlight($(unique_id), {startcolor:'#ffffff', endcolor:'#E9E9E4', duration:0.7});	
}

function toggleMerklisteHilfetext(currentlang){
	new Effect.toggle( $('merkliste-hilfetext'), 'blind', {duration:0.3} );

		if ( $('merkliste-hilfetext').style.display != "none"){
			
			$('merkliste-togglelink-linktag').setStyle({
			  backgroundImage: 'url(/oekbstyles/oekbimg/sitefeatures/merkliste/merkliste-togglebutton-closed.gif)'
			});
			$('merkliste-togglelink-linktag').innerHTML = lang[currentlang]["merkliste"][3] ;
		}else{
			
			$('merkliste-togglelink-linktag').setStyle({
			  backgroundImage: 'url(/oekbstyles/oekbimg/sitefeatures/merkliste/merkliste-togglebutton-open.gif)'
			});
			$('merkliste-togglelink-linktag').innerHTML =  lang[currentlang]["merkliste"][4] ;
		} 
	correctSafariViewBug();
}

function detachMerklisteMouseLeave() {
   // $('observation').stopObserving('mouseleave',leave);
	$('merkliste').stopObserving('mouseleave',showMerkListe);	
}

function attachMerklisteMouseLeave() {
   // $('observation').stopObserving('mouseleave',leave);
	$('merkliste').observe('mouseleave',showMerkListe);	
}

function showAddToMerklisteTooltip(node){
	new Effect.Appear($(node).previous(0), {duration:0.4, from:0, to:0.8} );
} 

function hideAddToMerklisteTooltip(node){
	new Effect.Fade($(node).previous(0), {duration:0.2, from:0.8, to:0} );
}


//interval
function startCloseMerklisteTimer(){
	//clear old IntervalCalls;
	if(typeof closeMerklisteTimer != "undefined"){
		window.clearInterval(closeMerklisteTimer);
	}
	closeMerklisteTimer = window.setInterval(clearCloseMerklisteTimer, 5000);
}

function clearMerklisteTimer(){
	//clear old IntervalCalls;
	if(typeof closeMerklisteTimer != "undefined"){
		window.clearInterval(closeMerklisteTimer);
	}
}

function clearCloseMerklisteTimer(){
	window.clearInterval(closeMerklisteTimer);
	hideMerkListe();
}

function SubmitEnterOnSearch(myfield,e)
{
	
    var keycode;
    if (window.event) {
                   keycode = window.event.keyCode;
    } 
    else if (e) {
                   keycode = e.which;
    }
    else return true;
    if (keycode == 13){
       if (document.getElementById("ctl00$portalsuche$ctl00") != null)
       		document.getElementById("ctl00$portalsuche$ctl00").click();
	else if (document.getElementById("ctl00$PlaceHolderMain$oekb_erweiterte_suche$ctl00") != null)
       		document.getElementById("ctl00$PlaceHolderMain$oekb_erweiterte_suche$ctl00").click();
       	
       return false;
    }
    else
       return true;
}
