/***************************************************************
*  Copyright notice
*
*  (c) 2007 Patrick Stoecker <mail@pksr.de>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

function show_tooltip(filename_label,filesize_label,fileformat_label,date_label,filename,filesize,fileformat,date){
  document.getElementById('tx_pksrfefilemanager_pi1_tooltip').innerHTML = '<table cellpadding="0" cellspacing="0" border="0"><tr><td>' + filename_label + ':</td><td>' + filename + '</td></tr><tr><td>' + filesize_label + ':</td><td>' + filesize + '</td></tr><td>' + fileformat_label + ':</td><td>' + fileformat + '</td></tr><td>' + date_label + ':</td><td>' + date + '</td></tr></table>';
  tx_pksrfefilemanager_pi1_getmousepos.an();
}

function hide_tooltip(){
if (tx_pksrfefilemanager_pi1_getmousepos.div) tx_pksrfefilemanager_pi1_getmousepos.aus();
}

tx_pksrfefilemanager_pi1_getmousepos = {

	// CSS-ID für das DIV-Element
	cssID : "tx_pksrfefilemanager_pi1_tooltip",
	cssID_shadow : "tx_pksrfefilemanager_pi1_tooltip_shadow",

	// Abweichungen des Verfolgers von der exakten Mausposition
	dx : 20,
	dy : -10,

	div : false, // enthält nach der Initialisierung eine Referenz auf das DIV-Element

	init : function () {
	if (!tx_pksrfefilemanager_pi1_getmousepos.div) {
	        //Tooltip
		tx_pksrfefilemanager_pi1_getmousepos.div = document.createElement("div");
		tx_pksrfefilemanager_pi1_getmousepos.div.id = tx_pksrfefilemanager_pi1_getmousepos.cssID;
		document.body.insertBefore(tx_pksrfefilemanager_pi1_getmousepos.div, document.body.firstChild);

		//Tooltip-Shadow
	        tx_pksrfefilemanager_pi1_getmousepos.div_shadow = document.createElement("div_shadow");
		tx_pksrfefilemanager_pi1_getmousepos.div_shadow.id = tx_pksrfefilemanager_pi1_getmousepos.cssID_shadow;
		document.body.insertBefore(tx_pksrfefilemanager_pi1_getmousepos.div_shadow, document.body.firstChild);
		
		tx_pksrfefilemanager_pi1_getmousepos.aus(); // vorsorglich ausschalten

		// document.onmousemove "verbiegen"
		tx_pksrfefilemanager_pi1_getmousepos.oldDocOnMouseMove = document.onmousemove;
		document.onmousemove = function (e) {
			if (typeof(tx_pksrfefilemanager_pi1_getmousepos.oldDocOnMouseMove) == "function")
				tx_pksrfefilemanager_pi1_getmousepos.oldDocOnMouseMove(e);
			tx_pksrfefilemanager_pi1_getmousepos.verfolgeKoordinaten(e);
		};
          }
	},

	verfolgeKoordinaten : function (ereignis) {
		var pos, IE;

		if (!ereignis)
			ereignis = window.event;

		pos = { left : ereignis.clientX, top : ereignis.clientY };

		IE = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
			window.document.documentElement : window.document.body || null;

		if (typeof(IE.scrollLeft) == "number") {
			pos.left += IE.scrollLeft;
			pos.top +=  IE.scrollTop;
		}

		tx_pksrfefilemanager_pi1_getmousepos.div.style.left = pos.left + tx_pksrfefilemanager_pi1_getmousepos.dx + "px";
		tx_pksrfefilemanager_pi1_getmousepos.div.style.top = pos.top + tx_pksrfefilemanager_pi1_getmousepos.dy + "px";
		
		tx_pksrfefilemanager_pi1_getmousepos.div_shadow.style.left = pos.left + tx_pksrfefilemanager_pi1_getmousepos.dx + 10 + "px";
		tx_pksrfefilemanager_pi1_getmousepos.div_shadow.style.top = pos.top + tx_pksrfefilemanager_pi1_getmousepos.dy + 10 + "px";
	},

	// Verfolger sichtbar schalten
	an : function () {
	       
		tx_pksrfefilemanager_pi1_getmousepos.div.style.display = "block";
		tx_pksrfefilemanager_pi1_getmousepos.div_shadow.style.display = "block";
		return false;
	},

	// Verfolger unsichtbar schalten
	aus : function () {
		tx_pksrfefilemanager_pi1_getmousepos.div.style.display = "none";
		tx_pksrfefilemanager_pi1_getmousepos.div_shadow.style.display = "none";
		return false;
	}
}

