/*
  Copyright (c) 2006-2007 Xorentec GbR Stefan Ehrhardt, Fabian Blaicher. All rights reserved.
*/

TLA = new Image();
TLA.src = "images/gui/tableft.gif";
TL = new Image();
TL.src = "images/gui/tableftinactive.gif";
TLTA = new Image();
TLTA.src = "images/gui/tableftactive.gif";

TRA = new Image();
TRA.src = "images/gui/tabright.gif";
TR = new Image();
TR.src = "images/gui/tabrightinactive.gif";
TRTA = new Image();
TRTA.src = "images/gui/tabrightactive.gif";

TSA = new Image();
TSA.src = "images/gui/tableftactive.gif";
TS = new Image();
TS.src = "images/gui/tabmiddleactive.gif";
TSTA = new Image();
TSTA.src = "images/gui/tabrightactive.gif";

function tover(group, idnum) {

  for (i=0; i<TabGrps.length; i++)
    if (group == TabGrps[i]["name"]) break;
  acttab = TabGrps[i]["acttab"];
  if (!TabGrps[i]["enabled"][idnum]) return;

  if (idnum == acttab) return;

  if (document.getElementById) {
    document.getElementById("TL" + group + idnum).src = TLA.src;
    document.getElementById("TR" + group + idnum).src = TRA.src;
    document.getElementById("TM" + group + idnum).className = "tabia";
    document.getElementById("TA" + group + idnum).className = "menu";
  }
}

function tout(group, idnum) {
  for (i=0; i<TabGrps.length; i++)
    if (group == TabGrps[i]["name"]) break;
  acttab = TabGrps[i]["acttab"];
  if (!TabGrps[i]["enabled"][idnum]) return;

  if (idnum == acttab) return;

  if (document.getElementById) {
    document.getElementById("TL" + group + idnum).src = TL.src;
    document.getElementById("TR" + group + idnum).src = TR.src;
    document.getElementById("TM" + group + idnum).className = "tab";
    document.getElementById("TA" + group + idnum).className = "menu";
  }
}

function tselect(group, idnum) {
  for (i=0; i<TabGrps.length; i++)
    if (group == TabGrps[i]["name"]) break;
  acttab = TabGrps[i]["acttab"];
  if (!TabGrps[i]["enabled"][idnum]) return;

  if (document.getElementById) {
    document.getElementById("TL" + group + idnum).src = TSA.src;
    document.getElementById("TR" + group + idnum).src = TSTA.src;
    document.getElementById("TM" + group + idnum).className = "tabta";
    document.getElementById("TA" + group + idnum).className = "menus";
  }
}

var wcanmove = false, wposx = 0, wposy = 0, widname = "";

function wmovestart(mEvent, idname) {
  if (!wcanmove) {
  wposx = mEvent.screenX - document.getElementById(idname).offsetLeft;
  wposy = mEvent.screenY - document.getElementById(idname).offsetTop;
  widname = idname;
  wcanmove = true;
  }
}

function wmoveend(mEvent) {
  if (!wcanmove) return;
  wcanmove = false;
  document.getElementById(widname).style.left = + mEvent.screenX - wposx;
  document.getElementById(widname).style.top = + mEvent.screenY - wposy;
}

function wmove(mEvent) {
  if (!wcanmove) return false;
  document.getElementById(widname).style.left = + mEvent.screenX - wposx;
  document.getElementById(widname).style.top = + mEvent.screenY - wposy;
}

function wshow(idname) {
  document.getElementById(idname).style.display = 'inline';
}

function wclose(idname) {
  document.getElementById(idname).style.display = 'none';
}

function winlclose(idname) {
  showElement('show' + idname);
  hideElement(idname);
}

function winlshow(idname) {
  showElement(idname);
  hideElement('show' + idname);
}

function oshow(idname) {
  document.getElementById(idname).style.display = '';
}

function ohide(idname) {
  document.getElementById(idname).style.display = 'none';
}

wcls = new Image();
wcls.src = "images/gui/butclose.gif";
wclsa = new Image();
wclsa.src = "images/gui/butclosea.gif";
wup = new Image();
wup.src = "images/gui/butup.gif";
wupa = new Image();
wupa.src = "images/gui/butupa.gif";

function wchimg(idname, img, state) {
  if (state == 1)
    chimg(idname, wclsa);
  else if (state == 0)
    chimg(idname, wcls);
  else if (state == 2)
    chimg(idname, wupa);
  else if (state == 3)
    chimg(idname, wup);}

function chimg(idname, imgObj) {
    document.getElementById(idname).src = imgObj.src;
}

function obgcolor(idname, color) {
  document.getElementById(idname).style.backgroundColor = color;
}
