var oc = 0;
var time = 7; 
var steps = 2;
var maxopacity = 70;
var on;
var off;
var full = 0;

var menuItemDelay = 200;

Bild01 = new Image();
Bild01.src = "../images/menu/menu_hover_hb.png";

Bild02 = new Image();
Bild02.src = "../images/menu/menu.png";


var MHBoc = 0;
var MHBocMax = 100;
var MHBtimerIn;
var MHBtimerOut;

function MenuFade() {
	if (!full) {
		full = 1;
		document.getElementById('menu').style.display = '';
		document.getElementById('menu2').style.display = '';
		on = window.setTimeout('oc=oc + 1;MenuFadeIn()',1);	
	} else {
		full = 0;
		off = window.setTimeout('oc=oc - 1;MenuFadeOut()',1);
	}
}

function MenuFadeIn() {
	window.clearTimeout(off);
	document.getElementById('menu').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menu').style.opacity 	= oc / 100;
	document.getElementById('menu2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menu2').style.opacity 	= oc / 100 - 0.1;
    if(oc <= maxopacity) {
		on = window.setTimeout('oc=oc + steps;MenuFadeIn()', time);	
	}
}

function MenuFadeOut() {
	window.clearTimeout(on);
	document.getElementById('menu').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menu').style.opacity 	= oc / 100;
	document.getElementById('menu2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menu2').style.opacity 	= oc / 100 - 0.1;
	if (oc >= 0) {
		off = window.setTimeout('oc=oc - steps;MenuFadeOut()', time);
	} else {
		document.getElementById('menu').style.display = 'none';
		document.getElementById('menu2').style.display = 'none';
	}
}

function MenuHeartBeat() {
  
  window.setTimeout('MenuHeartBeatFadeIn();', 1000);
  window.setTimeout('MenuHeartBeatFadeOut();', 1300);
  
  window.setTimeout('MenuHeartBeatFadeIn();', 1530);
  window.setTimeout('MenuHeartBeatFadeOut();', 1830);
  
  window.setTimeout('MenuHeartBeat();', 2500);
}

function MenuHeartBeatFadeIn() {
  
  if (MHBoc >= 100) return;
  
  window.clearTimeout(MHBtimerIn);
  window.clearTimeout(MHBtimerOut);
  
  var menu = document.getElementById('menubuttonhover');
  
  MHBoc = MHBoc + 12;
  
  //menu.style.filter   = "Alpha(opacity=100)";
  menu.style.opacity  = MHBoc / 100;
  
  MHBtimerIn = window.setTimeout('MenuHeartBeatFadeIn();', 10);
  
  if (MHBoc >= 100) {
    MHBoc = 100;
    window.clearTimeout(MHBtimerIn);
  }
    
  //document.getElementById('debug').innerHTML = MHBoc;
}

function MenuHeartBeatFadeOut() {
  
  if (MHBoc <= 0) return;
  
  window.clearTimeout(MHBtimerIn);
  window.clearTimeout(MHBtimerOut);
  
  var menu = document.getElementById('menubuttonhover');
  
  MHBoc = MHBoc - 4;
  
  //menu.style.filter   = "Alpha(opacity=100)";
  menu.style.opacity  = MHBoc / 100;
  
  MHBtimerOut = window.setTimeout('MenuHeartBeatFadeOut();', 10);
  
  if (MHBoc <= 0) {
    MHBoc = 0;
    window.clearTimeout(MHBtimerOut);
  }
    
  //document.getElementById('debug').innerHTML = MHBoc;
}


function MenuFadeV2() {

	if (!full) {
		full = 1;
		
    ArrowFadeAllOut(); 
    
    document.getElementById('menutextv2').style.display = '';
		document.getElementById('menuboxv2').style.display = '';
		on = window.setTimeout('oc=oc + 1;MenuFadeInV2()',1);
    
    window.setTimeout('MenuItemFadeIn(\'item1\');', menuItemDelay);
    window.setTimeout('MenuItemFadeIn(\'item2\');', menuItemDelay * 2);
    window.setTimeout('MenuItemFadeIn(\'item3\');', menuItemDelay * 3);
    window.setTimeout('MenuItemFadeIn(\'item4\');', menuItemDelay * 4);
    window.setTimeout('MenuItemFadeIn(\'item5\');', menuItemDelay * 5);
	} else {
		full = 0;
		off = window.setTimeout('oc=oc - 1;MenuFadeOutV2()',1);
	}
}

function MenuFadeInV2() {
	window.clearTimeout(off);
	document.getElementById('menutextv2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menutextv2').style.opacity 	= oc / 100;
	document.getElementById('menuboxv2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menuboxv2').style.opacity 	= oc / 100 - 0.1;
    if(oc <= maxopacity) {
		on = window.setTimeout('oc=oc + steps;MenuFadeInV2()', time);	
	}
}

function MenuItemFadeIn(item) {
  
  document.getElementById(item).style.opacity = parseFloat(document.getElementById(item).style.opacity) + 0.03;
  
  //document.getElementById('debug').innerHTML = document.getElementById('debug').innerHTML + document.getElementById(item).style.opacity+'<br />';
  
  if (document.getElementById(item).style.opacity < 1) { 
    window.setTimeout('MenuItemFadeIn(\''+item+'\');', 3);
  }
}

function MenuFadeOutV2() {
	window.clearTimeout(on);
	document.getElementById('menutextv2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menutextv2').style.opacity 	= oc / 100;
	document.getElementById('menuboxv2').style.filter	= "Alpha(opacity="+oc+")";
	document.getElementById('menuboxv2').style.opacity 	= oc / 100 - 0.1;
	if (oc >= 0) {
		off = window.setTimeout('oc=oc - steps;MenuFadeOutV2()', time);
	} else {
		document.getElementById('menutextv2').style.display = 'none';
		document.getElementById('menuboxv2').style.display = 'none';
    
    document.getElementById('item1').style.opacity = 0;
    document.getElementById('item2').style.opacity = 0;
    document.getElementById('item3').style.opacity = 0;
    document.getElementById('item4').style.opacity = 0;
    document.getElementById('item5').style.opacity = 0;
	}
}

function ResizeMenu() {
  document.getElementById('menuboxv2').style.width  = getWindowWidth() - 100 +"px";
  document.getElementById('menutextv2').style.width = getWindowWidth() - 100 +"px";
}

var ArrowDelay  = 100;
var ArrowFade   = 5;
var ArrowStep   = 0.02;

function MenuArrowBeat() {
  
  window.setTimeout('MenuArrowFadeIn(\'arrow1\')', ArrowDelay * 5 * 2);
  window.setTimeout('MenuArrowFadeIn(\'arrow2\')', ArrowDelay * 4 * 2);
  window.setTimeout('MenuArrowFadeIn(\'arrow3\')', ArrowDelay * 3 * 2);
  window.setTimeout('MenuArrowFadeIn(\'arrow4\')', ArrowDelay * 2 * 2);
  window.setTimeout('MenuArrowFadeIn(\'arrow5\')', ArrowDelay * 1 * 2);
  
  window.setTimeout('MenuArrowBeat()', ArrowDelay * 30);
}

function MenuArrowFadeOut(arrow) {

  document.getElementById(arrow).style.opacity = document.getElementById(arrow).style.opacity - ArrowStep;
  
  if (document.getElementById(arrow).style.opacity <= 0) {
    document.getElementById(arrow).style.opacity = 0;
  } else {
    window.setTimeout('MenuArrowFadeOut(\''+arrow+'\')', ArrowFade);
  }
}

function MenuArrowFadeIn(arrow) {

  document.getElementById(arrow).style.opacity = parseFloat(document.getElementById(arrow).style.opacity) + parseFloat(ArrowStep);
  
  if (document.getElementById(arrow).style.opacity <= 1) {
    window.setTimeout('MenuArrowFadeIn(\''+arrow+'\')', ArrowFade * 1);
  } else {
    document.getElementById(arrow).style.opacity = 1;
    window.setTimeout('MenuArrowFadeOut(\''+arrow+'\')', ArrowFade);
  }
}

function ArrowFadeAllOut() {
  document.getElementById('menuarrows').style.opacity = document.getElementById('menuarrows').style.opacity - 0.15;
  
  if (document.getElementById('menuarrows').style.opacity > 0) {
    window.setTimeout('ArrowFadeAllOut()', 20);
  } else
    document.getElementById('menuarrows').style.display = 'none';
}






