// Menu:hover with delay
// ---------------------

// This script will enable the :hover for the submenu's within
// the menu's. Besides enabling the :hover it will also set
// a delay on the submenu.

// Credits: Tino Zijdel (crisp), crisp(at)tweakers.net


var menu = null;

function init_menu() {
	menu = document.getElementById('menu');
	var li = menu.getElementsByTagName('li'), i = li.length;
	while (i--) li[i].onmouseover = showMenu;
	menu.onmouseout = timeout;
	menu.onmouseover = cleartimer;
}

var timer = null;
function timeout() {
	timer = setTimeout('hideMenus(menu, null)', 1000);
}

function cleartimer() {
	if (timer) {
		clearTimeout(timer);
		timer = null;
	}
}

function showMenu()	{
	var ul = this.parentNode;
	while (ul) {
		if (ul.tagName.toLowerCase() == 'ul') {
			hideMenus(ul, this);
			break;
		}

		ul = ul.parentNode;
	}

	ul = this.firstChild;
	while (ul) {
		if (ul.nodeType == 1 && ul.tagName.toLowerCase() == 'ul') {
			ul.style.display = 'block';
			ul.style.visibility = ''; // necessary for IE
			break;
		}

		ul = ul.nextSibling;
	}
}

function hideMenus(level, skipli) {
	var stack = [level], i = 0, li, j, el, tag;
	do {
		li = stack[i].childNodes, j = li.length;
		while (j--) {
			el = li[j];
			if (el.nodeType == 1 && el != skipli) {
				tag = el.tagName.toLowerCase();
				if (tag == 'li') {
					stack[i++] = el;
				}
				else if (tag == 'ul' && el.style.display == 'block') {
					stack[i++] = el;
					el.style.display = 'none';
					el.style.visibility = 'hidden'; // necessary for IE
				}
			}
		}
	}
	while (i--);
}


// Weltkarte:hover divs
// --------------------


tooltip = null;  
   document.onmousemove = updateTooltip;  
   
   function updateTooltip(e) {  
     try {  
       x = (document.all) ? window.event.x + document.documentElement.scrollLeft: e.pageX;  
       y = (document.all) ? window.event.y + document.documentElement.scrollTop: e.pageY;  
       if (tooltip != null) {  
         tooltip.style.left = (x + 20) + "px";  
         tooltip.style.top = (y + 20) + "px";  
       }  
     } catch (error) { error=null; }  
   }  
   
   function showTooltip(id) {  
     try {  
       tooltip = document.getElementById(id);  
       tooltip.style.display = "block"  
     } catch (error) { error=null; }  
   }  
   
   function hideTooltip() {  
     try {  
       tooltip.style.display = "none";  
     } catch (error) { error=null; }  
   }  


/************************************************************************************************************
Ajax dynamic content
Copyright (C) November, 2005  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 3000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed = 10;	// Speed of fading	(Lower value = faster)


var slideshow2_stats = new Array();

var slideshow2_slideIndex = new Array();	// Index of current image shown
var slideshow2_slideIndexNext = new Array();	// Index of next image shown
var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity = new Array();	// Initial opacity
var slideshow2_imagesInGallery = new Array();	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs(imageIndex,divId)
{
	if(imageIndex==slideshow2_imagesInGallery[divId]){	
		showGallery(divId);
	}else{
		var imgObj = document.getElementById(divId + '_' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		if(!slideshow2_imageDivs[divId])slideshow2_imageDivs[divId] = new Array();
		slideshow2_imageDivs[divId][slideshow2_imageDivs[divId].length] =  imgObj;

		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs(imageIndex,divId);	
	}		
}

function showGallery(divId)
{
	if(slideshow2_slideIndex[divId]==-1)slideshow2_slideIndex[divId]=0; else slideshow2_slideIndex[divId]++;	// Index of next image to show
	if(slideshow2_slideIndex[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndex[divId]=0;
	slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]+1;	// Index of the next next image
	if(slideshow2_slideIndexNext[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndexNext[divId] = 0;

	
	slideshow2_currentOpacity[divId]=100;	// Reset current opacity

	// Displaying image divs
	slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity=1)';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = 0.01;
	}		
	

	setTimeout('revealImage("' + divId + '")',slideshow2_timeBetweenSlides);		
}

function revealImage(divId)
{

	if(slideshow2_noFading){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';
		showGallery(divId);
		return;
	}
	slideshow2_currentOpacity[divId]--;
	if(document.all){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity[divId]+')';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity[divId])+')';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity[divId]/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity[divId]/100)));
	}
	if(slideshow2_currentOpacity[divId]>0){
		setTimeout('revealImage("' + divId + '")',slideshow2_fadingSpeed);
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';		
		showGallery(divId);
	}
}

function initImageGallery(divId)
{
	var slideshow2_galleryContainer = document.getElementById(divId);
	
	
	slideshow2_slideIndex[divId] = -1;
	slideshow2_slideIndexNext[divId] = false;
	
	var galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
	for(var no=0;no<galleryImgArray.length;no++){
		galleryImgArray[no].id = divId + '_' + no;
	}
	
	slideshow2_imagesInGallery[divId] = galleryImgArray.length;
	createParentDivs(0,divId);		
	
}
var activeNavi='';

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

var layers = new Array('layer_b');
function show(id){
	for(i = 0; i < layers.length; i++){
		var obj;
		if(obj = document.getElementById(layers[i])){
			if(obj.style){
				if(layers[i] == id){	
					obj.style.visibility = 'visible';
				}
				else{
					obj.style.visibility = 'hidden';
				}
			}
		}
	}
}



function hide_bild(imageId)
{
 var div;
 var hide_link;
 var show_link;

 div= document.getElementById(imageId);
 div.style.display = 'none';
 
 hide_link= document.getElementById('hide_link');
 hide_link.style.display = 'none';

 show_link= document.getElementById('show_link');
 show_link.style.display = '';
return false;
}

function hide_bilder(imageId)
{
 var div;
 var hide_link;
 var show_link;
 var alle_link;
 var ein_link;

 div= document.getElementById(imageId);
 div.style.display = 'none';
 
 ein_link= document.getElementById('ein_link');
 ein_link.style.display = 'none';

 alle_link= document.getElementById('alle_link');
 alle_link.style.display = '';
 
return false;
}

function show_bild(imageId)
{
 var div;
 var hide_link;
 var show_link;
 div= document.getElementById(imageId);
 div.style.display = '';

 hide_link= document.getElementById('hide_link');
 hide_link.style.display = '';

 show_link= document.getElementById('show_link');
 show_link.style.display = 'none';
return false;
}

function show_bilder(imageId)
{
 var div;
 var hide_link;
 var show_link;
 var alle_link;
 var ein_link;
 div= document.getElementById(imageId);
 div.style.display = '';

 ein_link= document.getElementById('ein_link');
 ein_link.style.display = '';

 alle_link= document.getElementById('alle_link');
 alle_link.style.display = 'none';

 hide_link= document.getElementById('hide_link');
 hide_link.style.display = '';
 
 show_link= document.getElementById('show_link');
 show_link.style.display = 'none';

return false;
}



function hide(id){
	for(i = 0; i < layers.length; i++){
		var obj;
		if(obj = document.getElementById(layers[i])){
			if(obj.style){
				obj.style.visibility = 'hidden';
			}
		}
	}
}

function entsub(event,ourform,formaction) {
if (event.keyCode == 13)
  { 
  ourform.action=formaction;
  ourform.submit();
  }
  else
    return true;
}

function swap_image(id, newImg){
	document.getElementById(id).src = newImg;
}


function PopUp(name, url, width, height){
    var options = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0";
    window.open(url, name, options + ',width=' + width + ',height=' + height);
}

function active_navi(elem) {
  document.getElementById(elem).style.backgroundColor='#8C8A8C';
}

function active_navi_kabyte(elem_div,elem_link) {
  document.getElementById(elem_div).style.backgroundColor='#8C8A8C';
  document.getElementById(elem_link).style.color='white';
  /*document.getElementById('mouse_out').style.visibility='hidden';*/
}

function inactive_navi(elem) { 
  document.getElementById(elem).style.backgroundColor='#163853'; 
}

function inactive_navi_kabyte(elem_div,elem_link) { 
  document.getElementById(elem_div).style.backgroundColor='white'; 
  document.getElementById(elem_link).style.color='#424542'; 
  /*document.getElementById('mouse_out').style.visibility='visible';*/
  
}

function kabyte_layer_mouse_in(elem) {
  if(activeNavi=='mouse_over_layer') {
    document.getElementById(elem).style.visibility = 'visible'; 
  }
}

function inactive_navi3(elem1,elem2,elem3,activeElem) {
  if (elem1!=activeElem) document.getElementById(elem1).style.backgroundColor='#163853';
  if (elem2!=activeElem) document.getElementById(elem2).style.backgroundColor='#163853';
  if (elem3!=activeElem) document.getElementById(elem3).style.backgroundColor='#163853';
}

function inactive_navi4(elem1,elem2,elem3,elem4,activeElem) {
  if (elem1!=activeElem) document.getElementById(elem1).style.backgroundColor='#980003';
  if (elem2!=activeElem) document.getElementById(elem2).style.backgroundColor='#980003';
  if (elem3!=activeElem) document.getElementById(elem3).style.backgroundColor='#980003';
  if (elem4!=activeElem) document.getElementById(elem4).style.backgroundColor='#980003';
}

function inactive_navi_not_active(elem,activeElem) {
  if (elem!=activeElem) document.getElementById(elem).style.backgroundColor='#980003'; 
}

function setMainLink(id,link) {
  document.getElementById(id).href=link;
  return false;
}

function delMainLink(id1,id2,id3) {
  document.getElementById(id1).href='#';
  document.getElementById(id2).href='#';
  document.getElementById(id3).href='#';
}

function delMainLinkYachten(id1,id2,id3,id4) {
  document.getElementById(id1).href='#';
  document.getElementById(id2).href='#';
  document.getElementById(id3).href='#';
  document.getElementById(id4).href='#';

   }

function createLanguageCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readLanguageCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraselanguageCookie(name) {
	createCookie(name,"",-1);
    return true;
}

function goLanguage(selected_lang,start_path,start_language)
{
	createLanguageCookie('ev_prefered_language',selected_lang);
	if(start_language == selected_lang)
	{
		window.location.href = start_path+'/';
	}
	else
	{
		window.location.href=window.location.href = start_path+'/'+selected_lang;
	}
}
