
var ____acz_text = "";
var ____acz_curr = null;

function acznoidx()
	{
	if( ____acz_curr )
		____acz_curr.className = "";

	____acz_curr = null;
	}

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

	if( e.is_open )
		{
		e.is_open = false;
		document.getElementById( "ylaczo" ).style.display = "none";
		}
	
	acznoidx();
	}

function aczfade( e )
	{  setTimeout( function(){ aczhide( e ); }, 500 );  }

function aczhover( e )
	{
	acznoidx();

	____acz_curr = e;
	e.className  = "ylaczs";
	}

var ____acz_digits = new Array('0','1','2','3','4','5','6','7','8','9');
function is_digit( d )
	{
	for( var i = 0; i < ____acz_digits.length; ++i )
		if( d == ____acz_digits[i] )
			return true;

	return false;
	}

function aczselect( e )
	{
	var digits = "0123456789";
	var i;
	var h;
	var t;
	var z;


	h = e.innerHTML;
	t = "";

	for( i = 0; i < h.length; ++i )
		if( is_digit( h.charAt(i) ) )
			{
			t += ( "" + h.charAt(i) );

			if( 5 == t.length )
				break;
			}

	z = document.getElementById( "puzc" );

	z.value = t;

	aczhide( z );

	z.focus();
	}

function aczpop( o, x, y, h, t )
	{
	____acz_text = t;

	o.style.left    = x + "px";
	o.style.top     = ( y + h ) + "px";

	if( ISIE && VERSION < 7 )
		o.style.width = "250px";

	o.style.display = "block";
	o.style.zIndex  = 10200;
	}

function aczget( e, x, y, h )
	{
	var zip    = e.value;
	var digits = "0123456789";
	var i;
	var o;


	e.timer = null;

	if( zip.length < 3 || 5 < zip.length )	
		return aczhide( e );

	for( i = 0; i < zip.length; ++i )
		if( ! is_digit( zip.charAt(i) ) )
			return aczhide( e );

	e.is_open = true;

	____acz_curr = null;

	o = document.getElementById( "ylaczo" );

	if( ____acz_text !== zip )
		ajax({
			url: "popzips?" + serialize( { z:zip } ),
			onSuccess: function( data )
				{
				o.innerHTML = data;

				var arr = o.getElementsByTagName( "li" );

				for( var l = 0; l < arr.length; ++l )
					{
					arr[l].onmouseover = function(){ aczhover( this ); };
					arr[l].onclick     = function(){ aczselect( this ); };		
					}

				aczpop( o, x, y, h, zip );
				}
			});
	else
		aczpop( o, x, y, h, zip );
	}

function aczshow( e )
	{
	if( e.timer )
		return;

	var x = ylPageX( e );
	var y = ylPageY( e );
	var h = e.offsetHeight || e.style.height;

	e.timer = setTimeout( function(){ aczget( e, x, y, h ); }, 500 );
	}

