﻿var debug = false;
var root_path="/portal/";

if (debug) alert(root_path);

window.onerror = Fehlerbehandlung;

function Fehlerbehandlung (Nachricht, Datei, Zeile) {
  Fehler = "Fehlermeldung:\n" + Nachricht + "\n" + Datei + "\n" + Zeile;
  zeigeFehler();
  return true;
}

function zeigeFehler () {
  alert(Fehler);
}

function menubutton (name) {
   var t=this;
   t.name = name;
   t.img_out = new Image();
   t.img_over = new Image();
   t.img_down = new Image();
   return t;
 }

function menuitem (name, imgOut, imgOver, imgDown) { 
   t = this;
   t.constructor(name);
   
   if (imgOut&&imgOver&&imgDown){
   //alert("Images");
     t.img_out.src = imgOut;
     t.img_over.src = imgOver;
     t.img_down.src = imgDown;}
   
   t.loadImages = function (imgOut, imgOver, imgDown){
     alert("function t.loadImages");
     t.img_out.src = imgOut;
     t.img_over.src = imgOver;
     t.img_down.src = imgDown;
   };
     
   t.showProperties = function (){
     var outTxt = '';
	 var t = this;
	 outTxt = 'Name=' + t.name + '\r';
	 outTxt = outTxt + 'img_out.src=' + t.img_out.src + '\r';
	 outTxt = outTxt + 'img_over.src=' + t.img_over.src + '\r';
	 outTxt = outTxt + 'img_down.src=' + t.img_down.src + '\r';
	 alert(outTxt);
	 return t;
   };  


    t.mouseAction = function (name, action, target, link){
      var t = this;
      if (action == "up"){
        document.getElementById(name).src = t.img_down.src;
        document.getElementById(target).src = link;
        /*document.getElementById(name).src = (document.getElementById(name).src != t.img_down.src)?
             document.getElementById(name).src = t.img_down.src:
             document.getElementById(name).src = t.img_over.src;
             document.getElementById(target).src = link;*/
      }

      if (action == "over"){
       if (document.getElementById(name).src != t.img_down.src){
             //alert(document.getElementById(name).src);
             document.getElementById(name).src = t.img_over.src;}
      }
  
      if (action == "out"){
       if (document.getElementById(name).src == t.img_over.src){
             //alert(document.getElementById(name).src);
             document.getElementById(name).src = t.img_out.src;}
      }
    };
    
    return this;
 
}

function resetButtons (btnName, numButtons){
   
      for (var i = 1; i <= numButtons; i++){
       curBtn = eval('btn' + i);      
       if (btnName != 'button' + i)document.getElementById('button' + i).src = curBtn.img_out.src;
      }
}

menuitem.prototype = new menubutton();

var btn1 = new  menuitem ('button1', root_path + 'images/stage/button1_off.jpg', root_path + 'images/stage/button1_over.jpg', root_path + 'images/stage/button1_on.jpg');
var btn2 = new  menuitem ('button2', root_path + 'images/stage/button2_off.jpg', root_path + 'images/stage/button2_over.jpg', root_path + 'images/stage/button2_on.jpg');
var btn3 = new  menuitem ('button3', root_path + 'images/stage/button3_off.jpg', root_path + 'images/stage/button3_over.jpg', root_path + 'images/stage/button3_on.jpg');
var btn4 = new  menuitem ('button4', root_path + 'images/stage/button4_off.jpg', root_path + 'images/stage/button4_over.jpg', root_path + 'images/stage/button4_on.jpg');
var btn5 = new  menuitem ('button5', root_path + 'images/stage/button5_off.jpg', root_path + 'images/stage/button5_over.jpg', root_path + 'images/stage/button5_on.jpg');
var btn6 = new  menuitem ('button6', root_path + 'images/stage/button6_off.jpg', root_path + 'images/stage/button6_over.jpg', root_path + 'images/stage/button6_on.jpg');
var btn7 = new  menuitem ('button7', root_path + 'images/stage/button7_off.jpg', root_path + 'images/stage/button7_over.jpg', root_path + 'images/stage/button7_on.jpg');
var btn8 = new  menuitem ('button8', root_path + 'images/stage/button8_off.jpg', root_path + 'images/stage/button8_over.jpg', root_path + 'images/stage/button8_on.jpg');
var btn9 = new  menuitem ('button9', root_path + 'images/stage/button9_off.jpg', root_path + 'images/stage/button9_over.jpg', root_path + 'images/stage/button9_on.jpg');
var btn10 = new  menuitem ('button10', root_path + 'images/stage/button10_off.jpg', root_path + 'images/stage/button10_over.jpg', root_path + 'images/stage/button10_on.jpg');
var btn11 = new  menuitem ('button11', root_path + 'images/stage/button_info_off.jpg', root_path + 'images/stage/button_info_over.jpg', root_path + 'images/stage/button_info_on.jpg');


       curBtn = eval('btn' + 2);
       if (debug)alert(curBtn.img_out.src);

if (debug)btn1.showProperties();
