
function ylPageHeight()
	{  return document.body.scrollHeight;  }

function ylScrollX()
	{
	var de = document.documentElement;

	return self.pageXOffset ||
			 ( de && de.scrollLeft ) ||
			 document.body.scrollLeft;
	}

function ylScrollY()
	{
	var de = document.documentElement;

	return self.pageYOffset ||
			 ( de && de.scrollTop ) ||
			 document.body.scrollTop;
	}

function ylWindowWidth()
	{
	var de = document.documentElement;

	return self.innerWidth ||
			 ( de && de.clientWidth ) ||
			 document.body.clientWidth;
	}

function ylWindowHeight()
	{
	var de = document.documentElement;

	return self.innerHeight ||
			 ( de && de.clientHeight ) ||
			 document.body.clientHeight;
	}

var CURR = null;

var UNBLUR = false;

var ARROW = 0;

function unblur_all()
	{
	var e = document.getElementById( "putbl" );
	if( ! e )e = document.getElementById( "bvt" );

	if( e )
		{
		var a = e.getElementsByTagName( "td" );

		for( var i = 0; i < a.length; ++i )
			{
			a[i].style.opacity    = 1.0;
			a[i].style.MozOpacity = 1.0;

			if( ISIE )
				{
				if( a[i].filters && 0 == a[i].filters.length )
					a[i].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100);";
				else
					a[i].filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
				}
			}

		UNBLUR = false;
		}
	}

function blur_others()
	{
	var e = document.getElementById( "putbl" );
	if( ! e )e = document.getElementById( "bvt" );

	if( e )
		{
		var a  = e.getElementsByTagName( "td" );
		var id = CURR + "td";

		for( var i = 0; i < a.length; ++i )
			if( a[i].id != id && a[i].parentNode.className != "nb" )
				{
				a[i].style.opacity    = 0.4;
				a[i].style.MozOpacity = 0.4;

				if( ISIE )
					{
					if( a[i].filters && 0 == a[i].filters.length )
						a[i].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=40);";
					else
						a[i].filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 40;
					}
				}

		UNBLUR = true;
		}
	}

function puh( id )
	{
	var e = document.getElementById( id );

	if( e.timer )
		{
		clearTimeout( e.timer );
		e.timer = null;
		}

	e.style.display = "none";

	if( ARROW )
		{
		var a = document.getElementById( "puar" + ARROW );
		a.style.display = "none";

		ARROW = 0;
		}

	if( ISIE && VERSION < 7 )
		document.getElementById( "pufrm" ).style.display = "none";

	if( UNBLUR )
		unblur_all();
	}

function dopus( e, x, y, rp )
	{
	var bottom = ylScrollY() + ylWindowHeight();

	e.style.zIndex = 10000;

	ARROW = 1;
	var a = document.getElementById( "puar1" );

	a.style.zIndex  = 10001;

	e.style.left       = 0;
	e.style.top        = 0;
	e.style.visibility = "hidden";
	e.style.display    = "block";

	var height = e.clientHeight || e.style.height;

	var f;

	if( ISIE && VERSION < 7 )
		{
		var width = e.clientWidth || e.style.width;

		f = document.getElementById( "pufrm" );

		f.style.zIndex          = 9999;
		f.style.width           = width + "px";
		f.style.height          = height + "px";
		f.style.left            = 0;
		f.style.top             = 0;
		f.style.visibility      = "hidden";
		f.style.display         = "block";
		f.style.backgroundColor = "transparent";
		}

	a.style.left       = 0;
	a.style.top        = 0;
	a.style.visibility = "hidden";
	a.style.display    = "block";

	var el = x + 176;
	var et = ( y + 62 ) - height / 2;

	var al = x + 124;
	var at = ( y + 62 ) - 38;

	if( et + height > bottom )
		{
		var delta = ( et + height ) - bottom;

		et -= delta;
		at -= delta;
		}

	if( at + 38 < y )
		{
		a.style.display = "none";
		ARROW = 2;
		a     = document.getElementById( "puar2" );

		a.style.zIndex     = 10001;
		a.style.left       = 0;
		a.style.top        = 0;
		a.style.visibility = "hidden";
		a.style.display    = "block";

		at = y - 80;

		if( at < et + 24 )
			at = et + 24;

		if( at + 80 > bottom )
			at = bottom - 80;
		}

	var right = ylScrollX() + ylWindowWidth();

	if( ! rp /*el + 274 > right*/ )
		{
		el = x - 318;
		al = x - 60;

		if( 1 == ARROW )
			{
			a.style.display = "none";
			ARROW = 3;
			a     = document.getElementById( "puar3" );

			a.style.zIndex     = 10001;
			a.style.left       = 0;
			a.style.top        = 0;
			a.style.visibility = "hidden";
			a.style.display    = "block";
			}
		else if( 2 == ARROW )
			{
			a.style.display = "none";
			ARROW = 4;
			a     = document.getElementById( "puar4" );

			a.style.zIndex     = 10001;
			a.style.left       = 0;
			a.style.top        = 0;
			a.style.visibility = "hidden";
			a.style.display    = "block";
			}
		}

	e.style.left = el + "px";
	e.style.top  = et + "px";

	a.style.left = al + "px";
	a.style.top  = at + "px";

	blur_others();

	if( ISIE && VERSION < 7 )
		{
		f.style.left       = el + "px";
		f.style.top        = et + "px";
		f.style.visibility = "visible";
		}

	e.style.visibility = "visible";
	a.style.visibility = "visible";
	}

var I=0;

function onpus( id, x, y, user, ty, rp )
	{
	var e = document.getElementById( id );

	e.timer = null;

	if( ! e.innerHTML || e.innerHTML == "" )
		{
		var prog, zip = "";

		switch( ty )
			{
			case 0:
				prog = "popmini";
				zip  = document.getElementById( "puzc" ).value;
				break;

			case 1:
				prog = "popprof";
				break;

			default: prog = "";
			}

		ajax({
			url: prog + "?" + serialize( { i:I, pid:user, z:zip } ),
			onSuccess: function( data )
				{
				e.innerHTML = data;
				dopus( e, x, y, rp );
				}
			});
		}
	else
		dopus( e, x, y, rp );
	}

function pus( lnk, id, user, ty, rp )
	{
	var e = document.getElementById( id );
	var x = ylPageX( lnk.firstChild );
	var y = ylPageY( lnk.firstChild );

	if( id == CURR )
		{
		if( e.timer )
			return;
		}
	else
		{
		if( CURR )
			puh( CURR );
		}

	CURR = id;

	e.timer = setTimeout( function(){ onpus( id, x, y, user, ty, rp ); }, 1000 );
	}

function xdopus( e, x, y, w, h )
	{
	var bottom = ylScrollY() + ylWindowHeight();

	e.style.zIndex = 10000;

	ARROW = 1;
	var a = document.getElementById( "puar1" );

	a.style.zIndex  = 10001;

	e.style.left       = 0;
	e.style.top        = 0;
	e.style.visibility = "hidden";
	e.style.display    = "block";

	var height = e.clientHeight || e.style.height;

	var f;

	if( ISIE && VERSION < 7 )
		{
		var width = e.clientWidth || e.style.width;

		f = document.getElementById( "pufrm" );

		f.style.zIndex          = 9999;
		f.style.width           = width + "px";
		f.style.height          = height + "px";
		f.style.left            = 0;
		f.style.top             = 0;
		f.style.visibility      = "hidden";
		f.style.display         = "block";
		f.style.backgroundColor = "transparent";
		}

	a.style.left       = 0;
	a.style.top        = 0;
	a.style.visibility = "hidden";
	a.style.display    = "block";

	var el = x + w + 52;
	var et = ( y + h / 2 ) - height / 2;

	var al = x + w;
	var at = ( y + h / 2 ) - 38;

	if( et + height > bottom )
		{
		var delta = ( et + height ) - bottom;
		et -= delta;
		}

	if( ( at < et + 12 || at + 76 > et + height - 12 )
			&&
		 at - 80 >= et )
		{
		a.style.display = "none";
		ARROW = 2;
		a     = document.getElementById( "puar2" );

		a.style.zIndex     = 10001;
		a.style.left       = 0;
		a.style.top        = 0;
		a.style.visibility = "hidden";
		a.style.display    = "block";

		at = ( y + h / 2 ) - 80;

		if( at + 80 > bottom )
			at = bottom - 80;
		}

	e.style.left = el + "px";
	e.style.top  = et + "px";

	a.style.left = al + "px";
	a.style.top  = at + "px";

	if( ISIE && VERSION < 7 )
		{
		f.style.left       = el + "px";
		f.style.top        = et + "px";
		f.style.visibility = "visible";
		}

	e.style.visibility = "visible";
	a.style.visibility = "visible";
	}

function xonpus( id, x, y, w, h, val, ty )
	{
	var e = document.getElementById( id );

	e.timer = null;

	if( ! e.innerHTML || e.innerHTML == "" )
		{
		var prog;

		switch( ty )
			{
			case 0: prog = "popprof"; I = 4; break;
			case 1: prog = "popmsg"; I = 5; break;
			default: prog = "";
			}

		ajax({
			url: prog + "?" + serialize( { i:I, pid:val, th:1 } ),
			onSuccess: function( data )
				{
				e.innerHTML = data;
				xdopus( e, x, y, w, h );
				}
			});
		}
	else
		xdopus( e, x, y, w, h );
	}

function xpuh( id )
	{
	var e = document.getElementById( id );

	if( e.timer )
		{
		clearTimeout( e.timer );
		e.timer = null;
		}

	e.style.display = "none";

	if( ARROW )
		{
		var a = document.getElementById( "puar" + ARROW );
		a.style.display = "none";

		ARROW = 0;
		}

	if( ISIE && VERSION < 7 )
		document.getElementById( "pufrm" ).style.display = "none";
	}

function xpus( lnk, id, val, ty )
	{
	var e = document.getElementById( id );
	var x = ylPageX( lnk );
	var y = ylPageY( lnk );
	var w = lnk.offsetWidth || lnk.style.width;
	var h = lnk.offsetHeight || lnk.style.height;

	if( id == CURR )
		{
		if( e.timer )
			return;
		}
	else
		{
		if( CURR )
			xpuh( CURR );
		}

	CURR = id;

	e.timer = setTimeout( function(){ xonpus( id, x, y, w, h, val, ty ); }, 1000 );
	}


function gstmt( e, user )
	{
	ajax({
		url: "getstmt?" + serialize( { pid:user } ),
		onSuccess: function( data ){ e.innerHTML = data; }
		});
	}

