//**************************************************************************************
/*
winop(url)
showbox(xid)
hidebox(xid)
activatebox(xid)
minimizebox(xid)
closebox(xid);
movestart(xid)
movestop(xid)
movebox()
showstartbox()
chimg(xid)
addtask(xid, onoff)
chtask(xid, onoff)
deltask(xid, onoff)
*/
//-----------------------------------------------------------
var winvar;
var mb_x, mb_y;
var movedbox, b_pfad;
var allboxes;
var upindex, downindex, startboxindex;
var startboxwidth, startboxheight;
//----------
allboxes = new Array(
  "b_about",
  "b_links",
  "b_test"
);

mb_x           = 0;
mb_y           = 0;
b_pfad         = "boxes/";
movedbox       = "";
upindex        = 5;
downindex      = 1;
startboxindex  = 9;
startboxwidth  = 200;
startboxheight = 400;
//-----------------------------------------------------------
function initial()
{
  for (i=0; i<allboxes.length; i++)
  {
    document.getElementById(allboxes[i]).style.left = i*10;
    document.getElementById(allboxes[i]).style.top  = i*10;
  }
}
//-----------------------------------------------------------
function winop(url)
{
  //url = "";
  //WW = 400;
  //HH = 200;

  //winXX = screen.availWidth;
  //winYY = screen.availHeight;

  //XX = (winXX/2) - (WW/2);
  //YY = (winYY/2) - (HH/2);

  win2stats = "fullscreen";

  winvar = window.open(url, "htmldesk", win2stats);
  //win2.resizeTo(WW,HH);
  //win2.moveTo(XX,YY);
  winvar.focus();
}
//-----------------------------------------------------------
function showbox(xid)
{
  activatebox(xid);
  addtask(xid, "on");
  xid.style.visibility = "visible";
}
//-----------------------------------------------------------
function hidebox(xid)
{
  xid.style.visibility = "hidden";
}
//-----------------------------------------------------------
function activatebox(xid)
{
  var i;

  hidebox(startbox);

  for (i=0; i<allboxes.length; i++)
    document.getElementById(allboxes[i]).style.zIndex = downindex;

  xid.style.zIndex = upindex;
}
//-----------------------------------------------------------
function minimizebox(xid)
{
  chtask(xid, "off");
  hidebox(xid);
}
//-----------------------------------------------------------
function closebox(xid)
{
  hidebox(xid);
  deltask(xid);
}
//-----------------------------------------------------------
function movestart(xid)
{
  movedbox = xid.id;
  activatebox(xid);

  mb_x = window.event.x;
  mb_y = window.event.y;
}
//-----------------------------------------------------------
function movestop(xid)
{
  movedbox = "";
}
//-----------------------------------------------------------
function movebox()
{
  if (movedbox == "")
    return 0;

  xid = document.getElementById(movedbox);
  mx = window.event.x;
  my = window.event.y;

  bx = xid.style.left;
  by = xid.style.top;

  bx = bx.substring(0, (bx.length-2));
  by = by.substring(0, (by.length-2));

  bx *= 1;
  by *= 1;

  xid.style.left = (bx + (mx - mb_x)) + "px";
  xid.style.top  = (by + (my - mb_y)) + "px";

  mb_x = mx;
  mb_y = my;
}
//-----------------------------------------------------------
function showstartbox()
{
  my = window.event.y;

  startbox.style.visibility = "visible";
  startbox.style.zIndex = startboxindex;
  //startbox.style.left = 5;
  //startbox.style.top = my - 10 - startboxheight;
}
//-----------------------------------------------------------
function chimg(xid)
{
  pfad_o = xid.src;
  pos    = pfad_o.lastIndexOf("_");
  pos++;
  num    = pfad_o.substring(pos,pos+1);
  pfad_n = pfad_o.substring(0,pos);

  if(num == 1)
    num = 2;
  else
    num = 1;

  pfad_n += num + ".gif";

  xid.src = pfad_n;
}
//-----------------------------------------------------------
function addtask(xid, onoff)
{
  task_str = taskbar.innerHTML;
  path = b_pfad + xid.id.slice(2) + "/";

  str1 = "<!-- " +xid.id+ " begin -->";
  str2 = "<!-- " +xid.id+ " end -->";

  if (task_str.indexOf(str1) == -1)
  {
    pic_str = '<img onclick="showbox(' +xid.id+ ');" src="' +path+ 'taskbar_' +onoff+ '.jpg">';
    task_str += str1 + pic_str + str2;

    taskbar.innerHTML = task_str;
  }
  else
    chtask(xid, "on");
}
//-----------------------------------------------------------
function chtask(xid, onoff)
{
  task_str = taskbar.innerHTML;
  path = b_pfad + xid.id.slice(2) + "/";

  str1 = "<!-- " +xid.id+ " begin -->";
  str2 = "<!-- " +xid.id+ " end -->";
  pos1 = task_str.indexOf(str1);
  pos2 = task_str.indexOf(str2);
  pos2 += str2.length;

  vor  = task_str.substring(0,pos1);
  extr = task_str.substring(pos1,pos2);
  nach = task_str.slice(pos2);

  pic_str = '<img onclick="showbox(' +xid.id+ ');" src="' +path+ 'taskbar_' +onoff+ '.jpg">';
  new_str = '<!-- ' +xid.id+ ' begin -->' +pic_str+ '&nbsp;<!-- ' +xid.id+ ' end -->';

  task_str = vor + new_str + nach;

  taskbar.innerHTML = task_str;

  //alert(vor + "\n\n" + extr + "\n\n" + nach);
}
//-----------------------------------------------------------
function deltask(xid)
{
  task_str = taskbar.innerHTML;

  str1 = "<!-- " +xid.id+ " begin -->";
  str2 = "<!-- " +xid.id+ " end -->";
  pos1 = task_str.indexOf(str1);
  pos2 = task_str.indexOf(str2);
  pos2 += str2.length;

  vor  = task_str.substring(0,pos1);
  nach = task_str.slice(pos2);

  task_str = vor + nach;

  taskbar.innerHTML = task_str;
}
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------







