﻿ 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') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    
    function go()
    {
        v = document.getElementById("txtval").value;
        gdd(v, x, y);
    }
    
    function gdd(v, x, y)
    {
        ld("http://www.hairy-spider.com/dt/df.ashx?"+v, x, y);
    }
    function f(m, x, y)
    {
        var _pre=null;
        if (!document._pre)
        {
            var d=document.createElement("div");
            d.innerHTML = m.documentElement.attributes.getNamedItem("footer").value;
            d.className="dx";
            _pre=document.createElement("pre");
            d.insertBefore(_pre, d.firstChild);
            document._pre = _pre;
            document.body.appendChild(d);
            
        }
        else
            _pre = document._pre;
        
        while (_pre.childNodes.length>0)
            _pre.removeChild(_pre.childNodes[0]);
            
        var z = m.documentElement.firstChild;
        if (window.ActiveXObject)
            _pre.innerText = z.nodeValue;
        else
            _pre.innerHTML = z.nodeValue;
       
        _pre.parentNode.style.left=x + "px";
        _pre.parentNode.style.top=y + "px";
        _pre.parentNode.style.display="block";
        
        document.body.onclick = function ()
        {
            _pre.parentNode.style.display = "none";
        }
        
    }
    function ld(w, x, y)
    {
        if (xmlhttp)
        {
        xmlhttp.open("GET", w, true);
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4)  
                if(xmlhttp.status == 200)
			{
			    var doc = xmlhttp.responseXml;
			    if (!doc)
			    {
			        var p = new DOMParser();
                    doc = p.parseFromString(xmlhttp.responseText, "text/xml");
			    }
			   	f(doc, x, y);
			}
			else
			{
				alert("Error sending data\n" + xmlhttp.status + "\n" + xmlhttp.responseText);
			}
		};
		
        xmlhttp.send(null);
        }
        else
        {
            alert("unable to create the XmlHttp object");
        }
    }
    
    function flap(e)
    {
        if (!e)
            e=event;
            
        var x, y;
        
        if (e.keyCode==100 || e.which==100)
        {
            var selection = null;
	    var el = null;

            if (window.getSelection)
            {
                selection = window.getSelection();
                selection.text = selection.toString();
		el = selection.anchorNode;
		if(el.nodeType!=3) //3 is a text element.
			return;
            }
            else
            {
		selection = document.selection.createRange();
		el=selection.parentElement(); 
		switch (el.tagName)
		    {
			case "INPUT":
			case "SELECT":
			case "TEXTAREA":
			case "BUTTON":
				return;
		    }
	    }
            

            x = selection.offsetLeft;
            //check that the dictionary pane won't drop off the page.
            y = get_ScrollPos().y;
            if (get_windowHeight()<selection.offsetTop + selection.boundingHeight+180)
                y += selection.offsetTop - 180;
            else
                y += selection.offsetTop + selection.boundingHeight;
                
            gdd(selection.text, x, y);
        }
          
          
    }
    function get_ScrollPos(el)
    {
        var x,y;
        if (self.pageYOffset) // all except Explorer
        {
	        x = self.pageXOffset;
	        y = self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)
	        // Explorer 6 Strict
        {
	        x = document.documentElement.scrollLeft;
	        y = document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
	        x = document.body.scrollLeft;
	        y = document.body.scrollTop;
        }
        var o=new Object();
        o.x=x;
        o.y=y
        return o;
    }
    function get_windowHeight()
    {
        var myWidth = 0, myHeight = 0;
        if (window.innerWidth)
            myHeight = window.innerHeight;
        else
        {
            if ( document.documentElement && ( document.documentElement.clientWidth ||    document.documentElement.clientHeight ) )
              myHeight = document.documentElement.clientHeight;
            else
              if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
                 myHeight = document.body.clientHeight;
        }
        return myHeight;
    }
  
  
   