﻿var TTIPS = [  ];
function ieCoordinatesDTD4(event) {
   return [ event.clientX + document.documentElement.scrollLeft, event.clientY + document.documentElement.scrollTop ]
}
function ie5Coordinates(event) {
   return [ event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop ]
}
function notIeCoordinates(event) {
   return [ event.pageX, event.pageY ]
}
function operaCoordinates(event) {
   if (event.pageX) 
         return [ event.pageX, event.pageY ];
   else
         return [ event.clientX, event.clientY ];
}
function getWindowSize() {
   if (window.innerHeight != null) 
         return [ innerWidth, innerHeight ];
   else
         return [ document.body.clientWidth, document.body.clientHeight ];
}
function getWindowScroll() {
   if (window.innerHeight != null) 
         return [ pageXOffset, pageYOffset ];
   else
         return [ document.body.scrollLeft, document.body.scrollTop ];
}
function getElemSize(elem) {
   if (elem.offsetWidth) 
         return [ elem.offsetWidth, elem.offsetHeight ];
   else
         return [ elem.style.pixelWidth, elem.style.pixelHeight ];
}
var getCoordinates;
/*
function showNote(ttipId, event) {
	var ttip = document.getElementById(ttipId)
   if (event) {
      var wX = getWindowScroll()[0];
      var wY = getWindowScroll()[1];
      var wWidth = getWindowSize()[0];
      var wHeight = getWindowSize()[1];
      var width = getElemSize(ttip)[0];
      var height = getElemSize(ttip)[1];
      var eX = getCoordinates(event)[0];
      var eY = getCoordinates(event)[1];
      var right = Math.min((wX + wWidth) - 10, width + eX);
      var bottom = Math.min((wY + wHeight) - 20, height + eY);
      var left = Math.max(wX, right - width);
      var top = Math.max(wY, bottom - height);
      ttip.style.top = 10 + top - 175 ;
      ttip.style.left = 10 + left - 175 ;
      ttip.style.visibility = "visible";
   }
}*/

// Moves note to current mouse ref
function moveNote(noteID, event) {
	var ttip = document.getElementById(noteID)
   if (event) {
      var wX = getWindowScroll()[0];
      var wY = getWindowScroll()[1];
      var wWidth = getWindowSize()[0];
      var wHeight = getWindowSize()[1];
      var width = getElemSize(ttip)[0];
      var height = getElemSize(ttip)[1];
      var eX = getCoordinates(event)[0];
      var eY = getCoordinates(event)[1];
      var right = Math.min((wX + wWidth) - 10, width + eX);
      var bottom = Math.min((wY + wHeight) - 20, height + eY);
      var left = Math.max(wX, right - width);
      var top = Math.max(wY, bottom - height);
      ttip.style.top = 10 + top - 250;
      ttip.style.left = 10 + left - 250;
   }
}

function showNote(ttipId, x, y, event) {
	var ttip = document.getElementById(ttipId)
   if (event) {
      var wX = getWindowScroll()[0];
      var wY = getWindowScroll()[1];
      var wWidth = getWindowSize()[0];
      var wHeight = getWindowSize()[1];
      var width = getElemSize(ttip)[0];
      var height = getElemSize(ttip)[1];
      var eX = getCoordinates(event)[0];
      var eY = getCoordinates(event)[1];
      var right = Math.min((wX + wWidth) - 10, width + eX);
      var bottom = Math.min((wY + wHeight) - 20, height + eY);
      var left = Math.max(wX, right - width);
      var top = Math.max(wY, bottom - height);
      ttip.style.top = 10 + top - 175 + y + "px"; //
      ttip.style.left = 10 + left - 175  + x + "px"; //
      ttip.style.visibility = "visible";
   }
}
function hideNote(ttipId) {
var ttip = document.getElementById(ttipId)
   ttip.style.visibility = "hidden";
}
if (window.opera) 
   getCoordinates = operaCoordinates;
else {
if (navigator.appVersion.indexOf("MSIE")!=-1) 
      getCoordinates = ieCoordinatesDTD4;
else
      getCoordinates = notIeCoordinates;
}
