function DL_GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy

      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent is not a table or the body, then...
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent a table cell, then...
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}

function visObject(obj,o, vis,dLeft,dTop) {
//Viser/gemmer objektet obj, dLeft & dTop fra objektet o's top & left
//	var x = (d.layers)?d[imgId].x:d[imgId].offsetLeft;
//	var y = (d.layers)?d[imgId].y:d[imgId].offsetTop;
 if (vis){
		obj.style.posLeft=DL_GetElementLeft(o)+dLeft;
		obj.style.posTop=DL_GetElementTop(o)+dTop;
		//vistext.innerText=o.xalt;
		obj.style.visibility='visible';
	}else{
		obj.style.visibility='hidden';
	}


}


function soeg(tekst,vt)
{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}
	 xmlhttp.open("GET", "vare5.php?tekst="+escape(tekst),true);
	 xmlhttp.onreadystatechange=function() {
	  if (xmlhttp.readyState==4) {
		var v= ""+xmlhttp.responseText;
		/* doo stuff here */
		vt.innerHTML=v;
		valgte=0;

	  }
	 }
	 xmlhttp.send(null)
}



var sidste=""
var valgte=0;

function tast(obj,e)
{
	if (e.keyCode==40 || e.keyCode==38) //40,down,38up
	{
		if (valgte!=0 && (linie = document.getElementById("line"+valgte)))
		{
			linie.style.backgroundColor="#FFFFFF";
			linie.style.color="#000000";
		}
		ny_valgte = valgte+(e.keyCode==40 ? 1 : -1 );
		if (ny_valgte==0 || document.getElementById("line"+ny_valgte)) valgte=ny_valgte;
		if (valgte!=0 && (linie = document.getElementById("line"+valgte)))
		{
//		if (valgte<0) valgte=0;
//		if (valgte>maxvalgte) valgte=maxvalgte;
//			linie = document.getElementById("line"+valgte);
			linie.style.backgroundColor="#0000FF";
			linie.style.color="#FFFFFF";
		}
	} else if (e.keycode==13) //enter skulle aldrig ske
	{
		document.getElementById('vistext').style.visibility='hidden';
	} else
	{
		if (obj.value==sidste) return true;
		if (obj.value.length<3) return true;
		vt = document.getElementById('vistext');
		visObject(vt,obj,true,0,17);	
		sidste=obj.value;
		soeg(sidste,vt);
		return true;
	}
}

function tastenter(obj,e)
{
	if (e.keyCode!=13) return true;
	document.getElementById('vistext').style.visibility='hidden';
	if (valgte==0) return true;
	vare = document.getElementById("varenr"+valgte);
	obj.value=vare.value;
	sidste=vare.value;
	valgte=0;
	return true;
}

function mushover(nummer,over)
{
		if (valgte!=0)
		{
			linie = document.getElementById("line"+valgte);
			linie.style.backgroundColor="#FFFFFF";
			linie.style.color="#000000";
		}
		valgte=nummer;
//		if (valgte<0) valgte=0;
//		if (valgte>10) valgte=10;
		if (valgte!=0 && (linie = document.getElementById("line"+valgte)))
		{
			
			linie.style.backgroundColor="#0000FF";
			linie.style.color="#FFFFFF";
		}
}

function musvalg(nummer)
{
	document.getElementById('vistext').style.visibility='hidden';
	vare = document.getElementById("varenr"+nummer);
	document.getElementById("varenr").value=vare.value;
	sidste=vare.value;
	valgte=0;
	document.forms[0].submit();
	return true;
}

