function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

if(document.title == "Willkommen im Dingholzer Hofkiosk"){
pfad = "";
} else {
	pfad = "../";
	}

myhuhn = 0;
closetime = 0;
opentime = 0;
reseteye = 0;
closetime2 = 0;
opentime2 = 0;
reseteye2 = 0;

if(top!=self)
  top.location=self.location;
  
function huhn(){
	myhuhn = window.setTimeout("MM_swapImage('m0','','"+pfad+"img/img32_off.gif',1)",500);
}
function clearhuhn(){
	window.clearTimeout(myhuhn);
}
function closeyes(){
window.clearTimeout(reseteye);
closetime = Math.random()*10000;
cleyetimer = window.setTimeout("MM_swapImage('eye1','','"+pfad+"img/img17_ov.gif',1)",closetime);
opeyetimer = window.setTimeout("openeyes()",closetime);
}
function openeyes(){
window.clearTimeout(cleyetimer);
window.clearTimeout(opeyetimer);
opentime = Math.random()*1000;
new_opeyetimer = window.setTimeout("MM_swapImage('eye1','','"+pfad+"img/img17_off.gif',1)",opentime);
resetin = window.setTimeout("restarteyes()",opentime);
}
function restarteyes(){
window.clearTimeout(new_opeyetimer);
window.clearTimeout(resetin);
resettime = Math.random()*10000;
reseteye = window.setTimeout("closeyes()",resettime);
}
function closeyes2(){
window.clearTimeout(reseteye2);
closetime2 = Math.random()*20000;
cleyetimer2 = window.setTimeout("MM_swapImage('eye2','','"+pfad+"img/img07_ov.gif',1)",closetime2);
opeyetimer2 = window.setTimeout("openeyes2()",closetime2);
}
function openeyes2(){
window.clearTimeout(cleyetimer2);
window.clearTimeout(opeyetimer2);
opentime2 = Math.random()*15000;
new_opeyetimer2 = window.setTimeout("MM_swapImage('eye2','','"+pfad+"img/img07_off.gif',1)",opentime2);
resetin2 = window.setTimeout("restarteyes2()",opentime2);
}
function restarteyes2(){
window.clearTimeout(new_opeyetimer2);
window.clearTimeout(resetin2);
resettime2 = Math.random()*10000;
reseteye2 = window.setTimeout("closeyes2()",resettime2);
}

mainVert = 0;
mainHori = 0;
layerID = "";

function getPosition(element){
  var elem=element,tagname="",x=0,y=0;
  while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")){
    y+=elem.offsetTop;
    x+=elem.offsetLeft;
    tagname=elem.tagName.toUpperCase();
    if (tagname=="BODY")
      elem=0;
    if (typeof(elem)=="object")
      if (typeof(elem.offsetParent)=="object")
        elem=elem.offsetParent;
  }
  position=new Object();
  position.x=x;
  position.y=y;
  return position;
}

function pos_sub(elementId,layID){
  var a,element;
  element=document.getElementById(elementId);
  a=getPosition(element);
  mainVert = a.y;
  mainHori = a.x;
  topPos = mainVert;
  leftPos = mainHori;
		eval('document.getElementById("'+ layID +'").style.left=leftPos;');
    	eval('document.getElementById("'+ layID +'").style.top=topPos;');
    	eval('document.getElementById("'+ layID +'").style.visibility="visible";');
  }

function pos_pano(elementId,layID){
  var a,element;
  element=document.getElementById(elementId);
  a=getPosition(element);
  mainVert = a.y;
  mainHori = a.x;
  topPos = mainVert;
  leftPos = mainHori;
		eval('document.getElementById("'+ layID +'").style.left=leftPos-231;');
    	eval('document.getElementById("'+ layID +'").style.top=topPos;');
		eval('document.getElementById("'+ layID +'").style.visibility="visible";');
  }
 
function showlay(name1,name2){
	eval('document.getElementById("'+ name2 +'").style.left=leftPos;');
    eval('document.getElementById("'+ name2 +'").style.top=topPos;');
    eval('document.getElementById("'+ name1 +'").style.visibility="hidden";');
	eval('document.getElementById("'+ name2 +'").style.visibility="visible";');
}
	
menuautoclose = 0;
menuoutclose = 0;
mode = "";

function setmod_out(){
	mode = "out";
	}
function setmod_over(){
	mode = "over";
	window.clearTimeout(menuoutclose);
	window.clearTimeout(menuautoclose);
	}

function timer(layID){
    layerID = layID;
	if(mode == "out"){
		menuoutclose = window.setTimeout("closmen('layID')",500);
	}
}
function mentimout(layID){
	layerID = layID;
	if(mode == "out"){
	menuautoclose = window.setTimeout("closmen('layID')",8000);
	}
}
function closmen(layID){
		if(document.getElementById(layerID)){
			eval('document.getElementById("'+ layerID +'").style.visibility="hidden";');
				if(document.getElementById('postit01')){
					restimer();
					pos_sub('submen','postit01');
					rotlay();
				}
			} 
		}

function restimer(){
	window.clearTimeout(menuoutclose);
	window.clearTimeout(menuautoclose);
	window.clearTimeout(rotat0);
	window.clearTimeout(rotat1);
	window.clearTimeout(rotat2);
	}

function pagereload(){
	window.location.href = this.window.location;
	}
