var mode=0; // DOM/JS 1.5 (NS6, IE>5)
var actname="";

function checkbrowser() {
   if (document.layers!=null) {
      mode=1;  // NS4
   } else if (document.all!=null) {
      mode=2;  // IE
   }

   //  NS4 = (document.layers) ? 1 : 0;   // Welcher Browser (für Layer- Show/Hide);
   act_name = "";

   //	switch(mode) {
   //		case 01:
   //			document.captureEvents(Event.MOUSEMOVE);
   //			break;
   //		case 02:
   //			document.onmousemove=get_mouse;
   //			break;
   //		case 00:
   //			document.captureEvents(Event.MOUSEMOVE);
   //			break;
   //	}
   //	document.onmousemove=get_mouse;
}

function leadzero(nr) {
   if (nr<10) return "0"+nr;
   else return nr;
}

/*
function get_mouse_click(e) {
//	alert("Maustaste: " + e.which);
if (NS4) {
if (document.layers[act_name]!=null) {
if (e.which==3) alert(""); //Hier kommen spaeter sautolle rechtsklick-Menüs rein...
return false;
} else {
alert("?");
return;
}
} else {
if (document.all[act_name]!=null) {
//			if (event.button==2) alert("");
} else return false;
}
}
*/

function get_mouse(e) {
   if (act_name==null) return;
   if (mode==1) {
      if (document.layers[act_name]==null) return;
      if (e.pageX+165 > window.innerWidth) {
         document.layers[act_name].left = e.pageX-155;
      } else {
         document.layers[act_name].left = e.pageX+5;
      }
      document.layers[act_name].top = e.pageY+5;
   } else if (mode==2) {
      if (document.all[act_name]!=null) {
         if (window.event.clientX+document.body.scrollLeft+155>document.body.clientWidth) {
            document.all[act_name].style.left = window.event.clientX+document.body.scrollLeft-155;
         } else {
            document.all[act_name].style.left = window.event.clientX+document.body.scrollLeft+5;
         }
         document.all[act_name].style.top = window.event.clientY+document.body.scrollTop+5;
      }
   } else if (mode==0){
      obj=document.getElementById(act_name);
      if (!obj) return;
      if (e.pageX+165 > window.innerWidth) {
         obj.style.left = e.pageX-155;
      } else {
         obj.style.left = e.pageX+5;
      }
      obj.style.top = e.pageY+5;
   }
}

function temp(e) {
   if (act_name==null) return;
   if (mode==1) {
      if (document.layers[act_name]==null) return;
      document.layers[act_name].left = (window.innerWidth-document.layers[act_name].right)/2;
      document.layers[act_name].top = 10;
   } else if (mode==2) {
      if (document.all[act_name]!=null) {
         document.all[act_name].style.left = (document.body.clientWidth-document.all[act_name].style.right)/2;
         document.all[act_name].style.top = 10;
      }
   } else if (mode==0){
      obj=document.getElementById(act_name);
      if (!obj) return;
      obj.style.left = (window.innerWidth-obj.style.right)/2;
      obj.style.top = 10;
   }
}

function showwindow(name,on) {  // zeigt ein Layer an...
   if (mode==1) {
      //		document.layers[name].top = window.event.pageY;//+document.body.scrollTop;
      //		document.layers[name].left = window.event.pageX;//+document.body.scrollLeft;
      document.layers[name].left = (window.innerWidth-document.layers[name].clip.width)/2;
      document.layers[name].top = 60;
      //		document.layers[name].y=-1000;
      document.layers[name].y=( on ? 50 : -1000);
      document.layers[name].visibility = ( on ? "show" : "hide");
      if (on) act_name=name;
      else act_name="";
   } else if (mode==2) {
      if (document.all[name]!=null) {
         //			if (window.event.clientX+document.body.scrollLeft+155>document.body.clientWidth) {
         //				document.all[name].style.left = window.event.clientX+document.body.scrollLeft-155;
         //			} else {
         //				document.all[name].style.left = window.event.clientX+document.body.scrollLeft+5;
         //			}
         //			document.all[name].style.top = window.event.clientY+document.body.scrollTop+5;
         document.all[name].style.left = (document.body.clientWidth-document.all[name].style.right-100)/2;
         document.all[name].style.top = 60;
         document.all[name].style.visibility = ( on ? "visible" : "hidden");
         if (on) act_name=name;
         else act_name="";
      }
   } else if (mode==0) {
      obj=document.getElementById(name);
      if (on) {
         obj.style.visibility="visible";
         obj.style.left = 280;//(window.innerWidth-obj.style.width)/2;
         obj.style.top = 100;
         act_name=name;
      } else {
         obj.style.visibility="hidden";
         act_name="";
      }
   }
}
