/*
Copyright Jan Winkler, 2006

Wichtiger Hinweis:
Das Kopieren, Übernehmen oder Verwenden des Skriptes ist untersagt und wird zur Anzeige gebracht!

*/






















































  function drawBar(n,w,mi,ma,fo,typ2,start,end)
  {
   if(!document.getElementById)
   {
    return false;
   }

   k1 = Math.round((start/ma)*(w-15));
   k2 = Math.round((end/ma)*(w-15));
   c = '';
c += '<div style="border:1px solid white;"><table style="border:0px solid #BFBFBF; background-color:#EFEFEF; height:21px;" width="'+w+'" cellspacing="0" cellpadding="0" border="0" height="21">';
c += '<tr height="21">';
c += '<td background="/move/move_line.gif" valign="top" align="left" height="21" width="3">';
c += '<img src="/move/move_line_l.gif" width="3" height="21" border="0" alt="">';
c += '</td>';
c += '<td background="/move/move_line.gif" width="'+(w-6)+'" height="21">';
c += '<div id="dd_'+n+'_d1" style="padding:0px; margin:0px; position:relative; height:21px; width:'+(w-6)+'px;">';
c += '<div id="dd_'+n+'_d2" style="padding:0px; margin:0px; position:absolute; left:'+k1+'px; top:0px;">';
c += '<img src="/move/move_button'+(typ2?'2':'')+'.gif" width="9" height="20" border="0" alt="Beweg mich!">';
c += '</div>';
if(typ2)
{
c += '<div id="dd_'+n+'_d3" style="padding:0px; margin:0px; position:absolute; left:'+k2+'px; top:0px;">';
c += '<img src="/move/move_button3.gif" width="9" height="20" border="0" alt="Beweg mich!">';
c += '</div>';
}
c += '</div>';
c += '</td>';
c += '<td background="/move/move_line.gif" valign="top" align="right" height="21" width="3">';
c += '<img src="/move/move_line_r.gif" width="3" height="21" border="0" alt="">';
c += '</td>';
c += '</td>';
c += '</tr>';
c += '</table>';
   document.writeln(c);
   InitiItm(n,(w-15),mi,ma,fo,typ2,start,end)
  }

  function GetEventObject(e)
  {
   if(window.event){ return window.event; }
   else{ return e; }
  }

  function GetEventTarget(e)
  {
   var obj;
   if(e.srcElement){ obj = e.srcElement; }
   else if(e.target){ obj = e.target; }
   else{ obj = null; }
   if(!obj){ return null; }
   while(true)
   {
    if(obj == null || obj.id == null){ return null; }
    if(obj.id.substring(0, 3) == 'dd_'){ return obj; }
    if(obj.parentElement != null){ obj = obj.parentElement; }
    else{ obj = obj.parentNode; }
   }
   return obj;
  }

  //drawBar('hase',50,0,1000);

  var move_obj = null;
  var move_objs = new Array();
  var tos = 0;
  var tos2 = 0;
  function move_up(e)
  {
   move_obj = null;
  }

  function move_down(e)
  {
   e = GetEventObject(e);
   o = GetEventTarget(e);
   if(o == null){return ;}
   move_obj = o;

   ex = 0;
   if(e.clientX)
   {
    ex = e.clientX;
    if(document.body){ ex = e.clientX+document.body.scrollLeft; }
   }
   if(e.pageX){ ex = e.pageX; }

   n = move_obj.id;
   n = n.substr(3,n.length).replace('_d2','').replace('_d1','').replace('_d3','');

   //objekt suchen
   z = -1;
   for(i=0; i<move_objs.length; i++)
   {
    if(move_objs[i][0] == n){z = i;}
   }
   if(z==-1){ move_obj = null; return false;}

   b = document.getElementById('dd_'+n+'_d2');
   t = move_objs[z][5];
   if(move_obj == b)
   {
    move_objs[z][6] = parseInt(o.style.left);
    move_objs[z][7] = ex;
   }
   else
   {
    move_objs[z][8] = parseInt(o.style.left);
    move_objs[z][9] = ex;
   }
   return false;
  }

  function move_move(e)
  {
   e = GetEventObject(e);
   o = GetEventTarget(e);
   if(o == null){return;}
   if(move_obj == null){return;}

   ex = 0;
   if(e.clientX)
   {
    ex = e.clientX;
    if(document.body){ ex = e.clientX+document.body.scrollLeft; }
   }
   if(e.pageX){ ex = e.pageX; }

   n = move_obj.id;
   n = n.substr(3,n.length).replace('_d2','').replace('_d1','').replace('_d3','');

   //objekt suchen
   z = -1;
   for(i=0; i<move_objs.length; i++)
   {
    if(move_objs[i][0] == n){z = i;}
   }
   if(z==-1){ move_obj = null; return false;}

   donull = false;
   p = document.getElementById('dd_'+n+'_d1');
   b = document.getElementById('dd_'+n+'_d2');
   w = (move_objs[z][1]);
   mi = (move_objs[z][2]);
   ma = (move_objs[z][3]);
   fo = move_objs[z][4];
   t = move_objs[z][5];
   lb = move_objs[z][6];
   lx = move_objs[z][7];
   lb2 = move_objs[z][8];
   lx2 = move_objs[z][9];
   k = move_objs[z][10];
   k2 = move_objs[z][11];
   if(!t && move_obj == b)
   {
    ex2 = lb+(ex-lx);
    if(ex2 < 0){ex2 = 0; donull = true; }
    if(ex2 > w){ex2 = w; donull = true; }
    k = Math.round(((ex2/w)*(ma-mi))+mi);
    if(k < mi){k = mi; }
    if(k > ma){k = ma; }
    document[fo][n].value = k;
    move_objs[z][10] = k;
   }
   else
   {
    if(move_obj == b)
    {
     ex2 = lb+(ex-lx);
     if(ex2 < 0){ex2 = 0; donull = true; }
     if(ex2 > w){ex2 = w; donull = true; }
     k = Math.round(((ex2/w)*(ma-mi))+mi);
     if(k < mi){k = mi; }
     if(k > ma){k = ma; }
     if(k > k2){k = k2-1; donull = true; }
     document[fo][n].value = k+' - '+k2;
     move_objs[z][10] = k;
    }
    else
    {
     ex2 = lb2+(ex-lx2);
     if(ex2 < 0){ex2 = 0; donull = true; }
     if(ex2 > w){ex2 = w; donull = true; }
     k2 = Math.round(((ex2/w)*(ma-mi))+mi);
     if(k2 < mi){k2 = mi; }
     if(k2 > ma){k2 = ma; }
     if(k2 < k){k2 = k+1; donull = true; }
     document[fo][n].value = k+' - '+k2;
     move_objs[z][11] = k2;
    }
   }
   move_obj.style.left = ex2+'px';
   move_obj.style.cursor = "pointer";
   if(donull){move_obj = null;}
   hideN(n);
   return false;
  }

  function hideN(n)
  {
   if(tos > 0){window.clearTimeout(tos);}
   if(tos2 > 0){window.clearTimeout(tos2);}
  }

  function InitiItm(n,w,mi,ma,fo,typ2,start,end)
  {
   document.getElementById('dd_'+n+'_d1').onmouseup = move_up;
   document.getElementById('dd_'+n+'_d1').onmousemove = move_move;
   document.getElementById('dd_'+n+'_d2').onmouseup = move_up;
   document.getElementById('dd_'+n+'_d2').onmousemove = move_move;
   document.getElementById('dd_'+n+'_d2').onmousedown = move_down;
   if(typ2)
   {
    document.getElementById('dd_'+n+'_d3').onmouseup = move_up;
    document.getElementById('dd_'+n+'_d3').onmousemove = move_move;
    document.getElementById('dd_'+n+'_d3').onmousedown = move_down;
   }
   z = move_objs.length;
   move_objs[z] = new Array();
   move_objs[z][0] = n;
   move_objs[z][1] = w;
   move_objs[z][2] = mi;
   move_objs[z][3] = ma;
   move_objs[z][4] = fo;
   move_objs[z][5] = typ2;
   move_objs[z][6] = start;
   move_objs[z][7] = parseInt(document.getElementById('dd_'+n+'_d2').style.left);
   if(typ2)
   {
    move_objs[z][8] = end;
    move_objs[z][9] = parseInt(document.getElementById('dd_'+n+'_d3').style.left);
   }
   else
   {
    move_objs[z][8] = end;
    move_objs[z][9] = w;
   }
   move_objs[z][10] = start;
   move_objs[z][11] = end;
  }

  document.onmouseup = move_up;
  document.onmousemove = move_move;