﻿// JScript File

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
var tipobj

function doDicResult(id,action,pos)
{
    if(action == 1)
	{	
	    document.getElementById("dicText").innerText = "מידת הרלוונטיות של מסמך למילות החיפוש";
	    tipobj = document.getElementById("dicText");
		enabletip=true;
		document.getElementById("dicText").style.position = 'absolute';
		document.getElementById("dicText").className = 'dicbox';
		tipobjid="dicText";
	}
	else
	{
	    document.getElementById("dicText").className = 'Shidden';
		enabletip=false;
	}
}
function doDic(id,action,pos)
{	
	//debugger;
	var xmlres;
	if(action == 1)
	{	
		try{
			xmlres=getxmlhttp(id);
		}catch(e){xmlres=''}
		if (xmlres != '')
		{
			//alert ("2")
			document.getElementById("dicText").innerText=xmlres;
		}
		tipobj = document.getElementById("dicText");
		enabletip=true;
		document.getElementById("dicText").style.position = 'absolute';
		document.getElementById("dicText").className = 'dicbox';
		tipobjid="dicText";
	}
	else
	{
		document.getElementById("dicText").className = 'Shidden';
		enabletip=false;
	}
}

function getxmlhttp(stridd)
{
	var objHTTP=getXMLHttpObject();
	var parser=new ActiveXObject("microsoft.xmldom");
	var intidd;
	var strPath;
	objHTTP.Open ('GET','dicxml.ashx?idd='+stridd,false);
	objHTTP.Send();
	parser.async=false;
	//alert (objHTTP.responseText)
	parser.loadXML (objHTTP.responseText)
	strPath = "xml/row";
	var objNodeList = parser.selectNodes(strPath);
	//alert (objNodeList.length)
	if (objNodeList.length>0)
	{
		//alert (objNodeList(0).selectSingleNode('divVal').text)
		return objNodeList(0).selectSingleNode('DictionaryBody').text;
	}
	else
	{
		return '';
	}
}

function getXMLHttpObject()
{
	var A=null;
	try
	{
		A=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e)
	{
		try
		{
			A=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(oc){A=null}
	}
	if(!A&&typeof XMLHttpRequest!="undefined")
	{
		A = new	XMLHttpRequest()
	}
	return A;
}


function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function positiontip(e)
{
	//debugger;
	if (enabletip)
	{
		var nondefaultpos=false;
		var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;
		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;
		if (rightedge<tipobj.offsetWidth)
		{
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true;
		}
		else if (curX<leftedge)
		{
			tipobj.style.left="5px";
			alert(0)
		}
		else
		{
			tipobj.style.left=curX+offsetfromcursorX+"px";
		}
		tipobj.style.top=curY+offsetfromcursorY+"px";
		if (bottomedge<tipobj.offsetHeight)
		{
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
			nondefaultpos=true;
		}
		else
		{
			tipobj.style.top=curY+offsetfromcursorY+"px";
		}
	}
}
document.onmousemove=positiontip
