////////////
// [ubertooltip.js] v1.6
// 2002-07-23
// Author: chrisken
// URL: http://www.cs.utexas.edu/users/chrisken/ubertooltip.html
// Supports: alphaAPI.js
////

// wrapper to automate the tooltip install
function installTip() {
	if( document.layers ) return; // ns4 = bad
	function mouseMove(e)
	{
		//alert('jo');
		if( window.tip ) tip.mouseMove( e );
	} // update tooltip coordinates if the object exists
	document.onmousemove = mouseMove; // capture mouse movement in IE/Opera
	if( document.addEventListener )
	{
	 	document.addEventListener( "mousemove", mouseMove, true ); // capture in Mozilla/NS6
	}
	//writeTip( 'tipDiv' );


	// Create abstract functions until the page has loaded and a full ubertooltip can be created
	tip = new Object();
	tip.show = function( x ) { };
	tip.hide = function( x ) { };
	tip.mouseMove = function( x ) { };
	tip.loaded = false;
}

// outputs the tooltip <div> with the minimum amount of css
function writeTip( divName ) {
	document.write( '<div id="' + divName + '" style="position: absolute; visibility: hidden; top: 0px; left: 0px; ' );
	document.write( 'z-index: 37;"></div>' );
//	document.write( 'filter: alpha(opacity=100); -moz-opacity: 0; z-index: 37;"></div>' );
}

function uberToolTip( id, delay, xrelative, yrelative) {
	// orientation = left | right
	this.id = id || "tipDiv";
	this.mouseX = 0;
	this.mouseY = 0;
	this.updateToolTip = false;
	this.obj = null;
	this.fader = null;
	this.delay = delay || 40;
	this.selects=document.getElementsByTagName('select');

	this.getMouseX = function() { return this.mouseX+xrelative; }
	this.getMouseY = function() { return this.mouseY+yrelative; }

	// display (fade in, if supported) the tooltip and update coords when the mouse moves
	this.show = function( html ) {
		if( document.layers) return;
		this.updateToolTip = true;
		if( this.fader ) { // alphaAPI was included and the browser supports fading
			this.fader.setTrans( 0 );
			this.fader.fadeIn();
		}
		this.update();
		writeLayerObj( this.obj, html );
		showLayerObj( this.obj );

		if(document.all)//ie
		{
			//var selects = document.getElementsByTagName('select');
			for(i=0; i<this.selects.length; i++)
			{
				if(this.selects[i].name!='page[items][form_sub_members][items][active_sub_member]')
				{
					this.selects[i].style.visibility = 'hidden';
				}
			}
		}

	}

	// update coordinates of the layer based on mouse coords;
	this.update = function() {
    if (document.all) { // pokud se jedna o IE
      if (document.documentElement && document.documentElement.scrollTop) {
        var x = event.clientX + document.documentElement.scrollLeft;
        var y = event.clientY + document.documentElement.scrollTop;
      }
      else if (document.body) {
        var x = event.clientX + document.body.scrollLeft;
        var y = event.clientY + document.body.scrollTop;
      } 
      this.obj.style.left = x+xrelative;
		  this.obj.style.top = (y+yrelative);
		} else { // jiny prohlizec
      this.obj.style.left = this.getMouseX() + 13+'px';
		  this.obj.style.top = this.getMouseY() + ( document.all? 20: 15 )+'px';
		}

		if(document.all)//ie
		{
			//var selects = document.getElementsByTagName('select');
			for(i=0; i<this.selects.length; i++)
			{
				if(this.selects[i].name!='page[items][form_sub_members][items][active_sub_member]')
				{
					this.selects[i].style.visibility = 'hidden';
				}

			}
		}
	}

	// hide layer and stop updating with mouse
	this.hide = function() {
		if( document.layers) return;
		hideLayerObj( this.obj );
		this.updateToolTip = false;
		if( this.fader ) this.fader.setTrans( 0 );
		this.obj.style.left = this.obj.style.top = 0;
		writeLayerObj( this.obj, "" );

		if(document.all)//ie
		{
			//var selects = document.getElementsByTagName('select');
			for(i=0; i<this.selects.length; i++)
			{
				this.selects[i].style.visibility = 'visible';
			}
		}
	}

	// grab a reference to the <div> and initialize the fader
	this.init = function() {
		if( document.layers) return;
		this.obj = document.getLayer( this.id );
		if( !this.obj ) {
			//alert( 'Error: tooltip layer initialized to "' + this.id + '",\nbut a <div> with that id does not exist.' );
			return;
		}
		this.loaded = true;
		if( this.delay != -1 && window.alphaAPI && !document.layers && ( document.all || ( document.getElementById && document.addEventListener ) ) ) {
			// only allow IE and Mozilla
			this.fader = new alphaAPI( this.id, this.delay, null, 100, 0, null, 10 );
			this.fader.setTrans( 0 );
			this.fader.norepeat( );
		}
	}

	this.mouseMove = function( e ) {
		var mouseX, mouseY;
		if( window.event && !document.layers ) {
			// Internet Explorer & Opera mouse detection
			mouseX = event.clientX;
			mouseX +=  document.body.scrollLeft;
			mouseY = event.clientY;
			mouseY += document.body.scrollTop;
		} else {
			// Netscape and Mozilla
			//alert('fd');
			mouseX = e.pageX;
			mouseY = e.pageY + 10;
		}
		this.mouseX = mouseX;
		this.mouseY = mouseY;
		if( this.obj && this.updateToolTip ) this.update();
	}

	return this;
}

///////
// Mini-dhtml library with NS4 support removed
////

// Use getLayer so that IE 4 works the same as IE 5+ & Mozilla
if( document.getElementById ) document.getLayer = document.getElementById;
else if( document.all ) document.getLayer = function( id ){ return document.all[ id ]; }

// wrapper to showLayerObj
function showLayer( id ) { showLayerObj( document.getLayer( id ) ); }

// show a layer object
function showLayerObj( layer ) { layer.style.visibility = "visible"; }

// wrapper to hideLayerObj
function hideLayer( id ) { hideLayerObj( document.getLayer( id ) ); }

// hide a layer object
function hideLayerObj( layer ) { layer.style.visibility = "hidden"; }

// wrapper to writeLayerObj
function writeLayer( id, html ) { writeLayerObj( document.getLayer( id ), html ); }

// write html to a layer
function writeLayerObj( layer, html ) { // pass in the layer object
	if( typeof( layer.innerHTML ) == "undefined" ) {
		
	} else { // IE and Mozilla are cool
		html = html.replace(/&/,"&amp;");

		layer.innerHTML = html;
	}
}

// --------------- vsufka ----------------
function showHelp()
{
	if(document.all) //test IE
		showhideSelects(false);
}

function hideHelp()
{
	if(document.all) //test IE
		showhideSelects(true);
}

function showhideSelects(show)
{
	var prop = (show ? "visible" : "hidden");
//	var selects = document.getElementsByTagName('select');
	var selects = document.getElementsByTagName('select');
	for(i=0; i<selects.length; i++)
	{
		if(selects[i].id == 'hider')
	{
			selects[i].style.visibility = prop;
		}
	}
}

// ---------------------------------------


// set autoInstall to false if you want to customize your uberTooltip installation
function LoadTip()
{
	//writeTip( 'tipDiv' );
	tip = new uberToolTip(null, -1, -440, -20);
	tip.init();
}
if( !window.autoInstall && window.autoInstall != true)
{
 installTip();
 window.onload=LoadTip;
}
