function findPos(obj) {
   var curleft = curtop = 0;
   if (obj.offsetParent) {
      do {
	 curleft += obj.offsetLeft;
	 curtop += obj.offsetTop;
      } while (obj = obj.offsetParent);
      return [curleft,curtop];
   }
}

function getStyleObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
    } else {
	return false;
    }
}

function showDiv(count,menuID,divId,the_height)
{
  var the_timeout;
  var the_style = getStyleObject(divId);
  if(document.getElementById) { var menuObj = document.getElementById(menuID); }
  else if(document.all) { var menuObj = document.all(menuID); }
  
  the_style.left = findPos(menuObj)[0] + "px";
  
  if (the_style)
  { /*
    var start = findPos(menuObj)[1]-2;
    var newY = start - count;
    var newH = count;
   
    the_style.visibility = "visible"; 
    the_style.top = newY + "px";
    the_style.height = newH + "px";
     
    if (newH < the_height)
    {
      the_timeout = setTimeout('showDiv('+(newH+1)+',"'+menuID+'","'+divId+'",'+the_height+');',1);
    }*/
    the_style.visibility = "visible"; 
    the_style.top = findPos(menuObj)[1]-2-the_height + "px";
    the_style.height = the_height + "px";
  }
}

function hideDiv(count,menuID,divId,the_height)
{
  var the_timeout;
  var the_style = getStyleObject(divId);
  
 if(the_style.visibility=="visible") { 
  if(document.getElementById) { var menuObj = document.getElementById(menuID); }
  else if(document.all) { var menuObj = document.all(menuID); }
  
  the_style.left = findPos(menuObj)[0] + "px";
  
  if (the_style)
  { /*
    var start = findPos(menuObj)[1]-(2+the_height);
    var newY = start + count;
    var newH = the_height-count;
   
    the_style.visibility = "visible"; 
    the_style.top = newY + "px";
    the_style.height = newH + "px";
        
    if (count < the_height)
    {
      the_timeout = setTimeout('hideDiv('+(count+1)+',"'+menuID+'","'+divId+'",'+the_height+');',1);
    }
    else {*/
    	the_style.visibility = "hidden";
    //}
  }
 }
}

function resetMenus() {
   $("#menu1").css({ backgroundColor:"#5D560E" });
   $("#menu2").css({ backgroundColor:"#5D560E" });
   $("#menu3").css({ backgroundColor:"#5D560E" });
   $("#menu4").css({ backgroundColor:"#5D560E" });
   $("#menu5").css({ backgroundColor:"#5D560E" });
}
function setMenu(menuObj) {   
   menuObj.style.backgroundColor = '#97C00E';
}

function loadContent(contentUrl) {
   $("#contentTD").empty();
   $("#contentTD").load(contentUrl);
}

function loadRecipe() {
   $("#recipeTD").empty();
   var datum = new Date();
   var today = datum.getDate();
   var rest = today%2;
   if(rest==0) {
      $("#recipeTD").load("./content/rezepte/01.html");
   } else if(rest==1) {
      $("#recipeTD").load("./content/rezepte/02.html");
   }
}

function loadVideoclip() {
   $("#videoTD").empty();
   var datum = new Date();
   var today = datum.getDate();
   var rest = today%2;
   if(rest==0) {
      $("#videoTD").load("./content/videos/02.html");
   } else if(rest==1) {
      $("#videoTD").load("./content/videos/01.html");
   }
}

function showBox(nr) {
   if(nr==1) {
      $("#tableSideBox")[0].style.display = "block";
      $("#tableSideBox2")[0].style.display = "none";
   } else if(nr==2) {
      $("#tableSideBox")[0].style.display = "none";
      $("#tableSideBox2")[0].style.display = "block";
   }
}