var dragobjekt = null;
var dragx = 0;
var dragy = 0;
var posx = 0;
var posy = 0;

document.onmousemove = drag;
document.onmouseup = dragstop;

function dragstart(element) {                                               
   //Wird aufgerufen, wenn ein Objekt bewegt werden soll.

  dragobjekt = element;
  if(!dragobjekt.style) dragobjekt = document.getElementById(element);
  dragx = posx - dragobjekt.offsetLeft;
  dragy = posy - dragobjekt.offsetTop;
}


function dragstop() {
  //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
  dragobjekt=null;
}


function drag(ereignis) {
  //Wird aufgerufen, wenn die Maus bewegt wird und bewegt bei Bedarf das Objekt.

  posx = document.all ? window.event.clientX : ereignis.pageX;
  posy = document.all ? window.event.clientY : ereignis.pageY;
  if(dragobjekt != null) {
    dragobjekt.style.left = (posx - dragx) + "px";
    dragobjekt.style.top = (posy - dragy) + "px";
  }
}

function getPosition(GlossarID, x, y, yy) {
    document.getElementById('Help').style.left = x + 'px';
    document.getElementById('Help').style.top = y + yy + 8 + 'px';
    ajaxload('GET','ajax.php','?id=' + GlossarID,'contan',true);
    setTimeout("showWindow()",500);
}

function showWindow() {
    Effect.toggle('Help','blind'); return false;
}

function opacity(obj, o) {
  if(typeof obj.style.filter != 'undefined') {
    if(o==0) {
      obj.style.visibility='hidden';
      obj.style.filter = 'alpha(opacity=0)';
    } else {
      if(o!=100) {
        obj.style.visibility='visible';
        obj.style.filter = 'alpha(opacity=' + o + ')';
      } else {
        obj.style.filter = 'alpha(opacity=100)';
      }
    }
  } else {
    if(o!=0) {
      if(o==100) {
        obj.style.opacity = '100';
        obj.style.KHTMLOpacity = '100';
        obj.style.MozOpacity = '100';
      } else {
        obj.style.visibility='visible';
        obj.style.opacity = o / 100;
        obj.style.KHTMLOpacity = o / 100;
        obj.style.MozOpacity = o / 100;
      }
    } else {
      obj.style.visibility='hidden';
      obj.style.opactiy = 0;
      obj.style.KTMLOpactiy = 0;
      obj.style.MozOpactiy = 0;
    }
  }
}

function ajaxload(methode,datei,daten,output,syncFlag) {
    if( ajax && ajax.readyState ) {
        ajax.abort();
        ajax = false;
    }

    if (window.XMLHttpRequest) {
        var ajax= new XMLHttpRequest;
    } else if (window.ActiveXObject) {
        var ajax=new ActiveXObject('Microsoft.XMLHTTP');
    }
    if (methode == "POST") {	
        ajax.open(methode, datei, syncFlag);
        ajax.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
        ajax.setRequestHeader( 'Content-length', daten.length );		
        ajax.setRequestHeader( 'Cache-Control', 'no-cache, must-revalidate');
    } else {
        ajax.open(methode, datei + daten, syncFlag);
        ajax.setRequestHeader( 'Cache-Control', 'no-cache, must-revalidate');
    }
    ajax.onreadystatechange=function() {
        if (ajax.readyState == 4){
            window.document.getElementById(output).innerHTML= ajax.responseText;
        } 
    }
    
    if (methode == "POST") {	
        ajax.send(daten);
    } else {
        ajax.send(null);	
    }
}
