	var focusField = '';

	/**
	*	Opis: dodaje polska czcionke
	*/
	function crossUndisable( id, e )
	{
		setTimeout( 'unDisable2()', 50 );
		if( ( e.keyCode < 37 ) || ( e.keyCode > 40 ) )
		{
			if( e.keyCode == 13 )
			{
				searchInDictCross( 1 );
			}
			else if( e.keyCode == 8 )
			{
				setTimeout( 'goPrev( '+id+' )', 50 );
			}
			else
			{
				setTimeout( 'goNext( '+id+' )', 50 );
			}
		}
	}

	/**
	*	Opis: dodaje polska czcionke
	*/
	function addPlChar( plChar )
	{
		oInp = $( "dictSearch2" );
		oInp.value = oInp.value + plChar;
		oInp.focus();
	}

	/**
	*	Opis: dodaje polska czcionke
	*/
	function addPlChar2( plChar )
	{
		if( oInp = $( focusField ) )
		{
			oInp.value = oInp.value + plChar;
			oInp.focus();
		}
	}

	/**
	*	Opis: dodaje polska czcionke
	*/
	function addPlChar3( plChar )
	{
		if( focusField == "withExpression2" )
		{
			addPlChar2( plChar );
		}
		else
		{
			if( oInp = $( focusField ) )
			{
				//if( oInp.value == '' )
				//{
					//oInp.value = oInp.value + plChar;
					oInp.value = plChar;
					oInp.focus();
					re = /^letter/g;
					num = ( focusField.replace( re, "" ) * 1 );
					goNext( num );
				//}
			}
		}
	}

	/**
	*	Opis: przechodzi do nastepnego pola
	*/
	function unDisable()
	{
		words = getWords( "dictSearch2" );
		withEx = getWords( "withExpression2" );
		withStr = getWords( "withString2" );
		oObj = $( "withoutWords2" );
		if( ( ( words != "" ) && ( words != WPISZ_SLOWA ) ) || ( ( withEx != "" ) && ( withEx != WPISZ_SLOWA ) ) || ( ( withStr != "" ) && ( withStr != WPISZ_CIAG_ZNAKOW ) ) )
		{
			oObj.disabled = false;
			oObj.style.color = '#000000';
			if( oObj2 = $( "wiWo" ) )
			{
				oObj2.style.color = '#000000';
			}
			//oObj.style.borderTop = '1px solid #000000';
			//oObj.style.borderLeft = '1px solid #000000';
		}
		else
		{
			oObj.disabled = true;
			oObj.style.color = '#999999';
			if( oObj2 = $( "wiWo" ) )
			{
				oObj2.style.color = '#999999';
			}
			//oObj.style.borderTop = '1px solid #cccccc';
			//oObj.style.borderLeft = '1px solid #cccccc';
		}
	}

	/**
	*	Opis: przechodzi do nastepnego pola
	*/
	function unDisable2()
	{
		words = "";
		for( var i = 1; i <= $( "crossCount2" ).value; i++ )
		{
			if( oInp = $( "letter"+i+"" ) )
			{
				//if( oInp.style.display == 'inline' )
				//{
					words += ""+oInp.value+"";
				//}
			}
		}
		oObj = $( "withExpression2" );
		if( words != "" )
		{
			oObj.disabled = false;
			oObj.style.color = '#000000';
			if( oObj2 = $( "wiEx" ) )
			{
				oObj2.style.color = '#000000';
			}
			//oObj.style.borderTop = '1px solid #000000';
			//oObj.style.borderLeft = '1px solid #000000';
		}
		else
		{
			oObj.disabled = true;
			oObj.style.color = '#999999';
			if( oObj2 = $( "wiEx" ) )
			{
				oObj2.style.color = '#999999';
			}
			//oObj.style.borderTop = '1px solid #cccccc';
			//oObj.style.borderLeft = '1px solid #cccccc';
		}
	}

	/**
	*	Opis: przechodzi do nastepnego pola
	*/
	function goNext( num )
	{
		oObj = $( "letter"+num+"" );
		if( oObj.value != '' )
		{
			nextObj = num+1;
			if( oObj2 = $( "letter"+nextObj+"" ) )
			{
				if( oObj2.style.display != 'none' )
				{
					oObj2.focus();
					oObj2.select();
				}
			}
		}
	}

	/**
	*	Opis: przechodzi do nastepnego pola
	*/
	function goPrev( num )
	{
		oObj = $( "letter"+num+"" );
		if( oObj.value == '' )
		{
			nextObj = num-1;
			if( oObj2 = $( "letter"+nextObj+"" ) )
			{
				oObj2.focus();
				oObj2.select();
			}
		}
	}

	/**
	*	Opis: odkrywa odpowiednia ilosc pol z literami w wyszukiwarce krzyzowkowej
	*/
	function showLetters( num )
	{
		for( var i = 1; i <= 20; i++ )
		{
			//oObj = $( "letter"+i+"" );
			oObj = $( "letterDiv"+i+"" );
			if( i <= num )
			{
				oObj.style.display = 'inline';
			}
			else
			{
				oObj.style.display = 'none';
				oObj.value = '';
			}
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function searchInDict( txt1, txt2, plainTxt )
	{
		words = getWords( "dictSearch2" );
		if( ( words != "" ) && ( words != WPISZ_SLOWA ) )
		{
			isOk = checkWordsLength( words, 1 );
			if( isOk == 1 )
			{
				$( "dictSearch" ).value = words;
				$( "dictForm" ).submit();
			}
			else
			{
				alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function searchInDict2( vPage )
	{
		words2 = getWords( "dictSearch2" );
		if( $( "wSearch" ).checked )
		{
			words = words2;
			withStr = '';
		}
		else
		{
			words = '';
			withStr = words2;
		}
		if( ( words2 != "" ) && ( words2 != WPISZ_SLOWA ) )
		{
			isOk = checkWordsLength( words2, 1 );
			if( isOk == 1 )
			{
				if( $( "translation1" ).checked )
				{
					vTrans = 2;
				}
				else
				{
					vTrans = 1;
				}
				//ajaxCheck = $( 'ajaxPostCount' ).value;
				$( 'searchResultDiv' ).innerHTML = '';
				$( 'loaderDiv' ).style.display = 'block';
				//"ajaxPostCount" : ajaxCheck
				/*advAJAX.post( 
					{
						url: serverHost+'/frontend/dictionary/AjaxDictionary.php5',
						parameters : 
							{
								"dictSearch" : words,
								"translation" : vTrans,
								"page" : vPage,
								"advanced" : 0
							},
						onSuccess : function( obj )
							{
								$( 'searchResultDiv' ).innerHTML = obj.responseText;
								$( 'loaderDiv' ).style.display = 'none';
								resizeFont( "fontResizeDiv", -1 );
								setDivWidth();
							},
						onError : function( obj )
							{*/
								$( "dictSearch" ).value = words;
								$( "withString" ).value = withStr;
								$( "page" ).value = vPage;
								$( "translation" ).value = vTrans;
								//document.forms.dictForm.submit();
								$( "dictForm" ).submit();
							/*}
					}
				);*/
			}
			else
			{
				alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function searchInDictAdv( vPage )
	{
		words = getWords( "dictSearch2" );
		withStr = getWords( "withString2" );
		withEx = getWords( "withExpression2" );
		oObj = $( "withoutWords2" );
		if( !oObj.disabled )
		{
			withoutW = getWords( "withoutWords2" );
		}
		else
		{
			withoutW = "";
		}
		if( ( ( words != "" ) && ( words != WPISZ_SLOWA ) ) || ( ( withStr != "" ) && ( withStr != WPISZ_CIAG_ZNAKOW ) ) || ( ( withEx != "" ) && ( withEx != WPISZ_SLOWA ) ) || ( ( withoutW != "" ) && ( withoutW != WPISZ_SLOWA ) ) )
		{
			if( ( withoutW != "" ) && ( withoutW != WPISZ_SLOWA ) && ( ( words == "" ) || ( words == WPISZ_SLOWA ) ) && ( ( withEx == "" ) || ( withEx == WPISZ_SLOWA ) ) && ( ( withStr == "" ) || ( withStr == WPISZ_CIAG_ZNAKOW ) ) )
			{
				alert( ABY_SKORZYSTAC_Z_OPCJI_BEZ_SLOW );
			}
			else
			{
				var isOk = Array( 1, 1, 1, 1 );
				if( ( words != "" ) && ( words != WPISZ_SLOWA ) )
				{
					isOk[0] = checkWordsLength( words, 1 );
				}
				if( ( withEx != "" ) && ( withEx != WPISZ_SLOWA ) )
				{
					isOk[1] = checkWordsLength( withEx, 2 );
				}
				if( ( withoutW != "" ) && ( withoutW != WPISZ_SLOWA ) )
				{
					isOk[2] = checkWordsLength( withoutW, 1 );
				}
				if( ( withStr != "" ) && ( withStr != WPISZ_CIAG_ZNAKOW ) )
				{
					isOk[3] = checkWordsLength( withStr, 1 );
				}
				if( ( isOk[0] == 1 ) && ( isOk[1] == 1 ) && ( isOk[2] == 1 ) && ( isOk[3] == 1 ) )
				{
					if( $( "translation1" ).checked )
					{
						vTrans = 2;
					}
					else
					{
						vTrans = 1;
					}
					if( $( "allAnyX1" ).checked )
					{
						vAa = 1;
					}
					else
					{
						vAa = 2;
					}
					if( $( "allAnyY1" ).checked )
					{
						vBb = 1;
					}
					else
					{
						vBb = 2;
					}
					//ajaxCheck = $( 'ajaxPostCount' ).value;
					$( 'searchResultDiv' ).innerHTML = '';
					$( 'loaderDiv' ).style.display = 'block';
					//"ajaxPostCount" : ajaxCheck
					/*advAJAX.post( 
						{
							url: serverHost+'/frontend/dictionary/AjaxDictionary.php5',
							parameters : 
								{
									"dictSearch" : words,
									"withExpression" : withEx,
									"allAny" : vAa,
									"withoutWords" : withoutW,
									"translation" : vTrans,
									"page" : vPage,
									"advanced" : 1
								},
							onSuccess : function( obj )
								{
									$( 'searchResultDiv' ).innerHTML = obj.responseText;
									$( 'loaderDiv' ).style.display = 'none';
									resizeFont( "fontResizeDiv", -1 );
									setDivWidth();
								},
							onError : function( obj )
								{*/
									$( "dictSearch" ).value = words;
									$( "withString" ).value = withStr;
									$( "allAnyS" ).value = vBb;
									$( "withExpression" ).value = withEx;
									$( "allAny" ).value = vAa;
									$( "withoutWords" ).value = withoutW;
									$( "page" ).value = vPage;
									$( "translation" ).value = vTrans;
									//document.forms.dictForm.submit();
									$( "dictForm" ).submit();
								/*}
						}
					);*/
				}
				else
				{
					alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
				}
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function searchInDictCross( vPage )
	{
		cSearch = "";
		isOk = 0;
		cCount = $( "crossCount2" ).value;
		for( var i = 1; i <= cCount; i++ )
		{
			oL = $( "letter"+i+"" );
			if( oL.value != '' )
			{
				isOk = 1;
				cSearch += oL.value+";";
			}
			else
			{
				cSearch += "_;";
			}
		}
		if( isOk == 1 )
		{
			if( $( "translation1" ).checked )
			{
				vTrans = 2;
			}
			else
			{
				vTrans = 1;
			}
			withEx = getWords( "withExpression2" );
			if( withEx == WPISZ_SLOWA )
			{
				withEx = '';
			}
			//ajaxCheck = $( 'ajaxPostCount' ).value;
			$( 'searchResultDiv' ).innerHTML = '';
			$( 'loaderDiv' ).style.display = 'block';
			//"ajaxPostCount" : ajaxCheck
			/*advAJAX.post( 
				{
					url: serverHost+'/frontend/dictionary/AjaxDictionary.php5',
					parameters : 
						{
							"crossSearch" : cSearch,
							"withExpression" : withEx,
							"crossCount" : cCount,
							"translation" : vTrans,
							"page" : vPage,
							"advanced" : 2
						},
					onSuccess : function( obj )
						{
							$( 'searchResultDiv' ).innerHTML = obj.responseText;
							$( 'loaderDiv' ).style.display = 'none';
							resizeFont( "fontResizeDiv", -1 );
							setDivWidth();
						},
					onError : function( obj )
						{*/
							$( "crossSearch" ).value = cSearch;
							$( "withExpression" ).value = withEx;
							$( "crossCount" ).value = cCount;
							$( "page" ).value = vPage;
							$( "translation" ).value = vTrans;
							//document.forms.dictForm.submit();
							$( "dictForm" ).submit();
						/*}
				}
			);*/
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: pobiera slowa do wyszukania
	*/
	function getWords( id )
	{
		oInp = $( id );
		vWords = oInp.value;
		re = /(\s+)|(\n+)|(\r+)|(\t+)|(\f+)/g;
		vWords = vWords.replace( re, " " );
		vWords = vWords.replace( /(^\s)|(\s$)/, "" );
		return vWords;
	}

	/**
	*	Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
	*/
	function openPopUp( isPageToPrint, vPage )
	{
		words2 = getWords( "dictSearch2" );
		if( $( "wSearch" ).checked )
		{
			words = words2;
			withStr = '';
		}
		else
		{
			words = '';
			withStr = words2;
		}
		if( ( words2 != "" ) && ( words2 != WPISZ_SLOWA ) )
		{
			isOk = checkWordsLength( words2, 1 );
			if( isOk == 1 )
			{
				if( $( "translation1" ).checked )
				{
					vTrans = 2;
				}
				else
				{
					vTrans = 1;
				}
				winObj = window.open( serverHost+'/frontend/dictionary/AjaxDictionary.php5?dictSearch='+words+'&translation='+vTrans+'&showPage=1&isPageToPrint='+isPageToPrint+'&page='+vPage+'&advanced=0&withString='+withStr+'', "_blank", "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=no, width=770, height=550" );
			}
			else
			{
				alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
	*/
	function openPopUpAdv( isPageToPrint, vPage )
	{
		words = getWords( "dictSearch2" );
		withEx = getWords( "withExpression2" );
		withStr = getWords( "withString2" );
		oObj = $( "withoutWords2" );
		if( !oObj.disabled )
		{
			withoutW = getWords( "withoutWords2" );
		}
		else
		{
			withoutW = "";
		}
		if( ( ( words != "" ) && ( words != WPISZ_SLOWA ) ) || ( ( withStr != "" ) && ( withStr != WPISZ_CIAG_ZNAKOW ) ) || ( ( withEx != "" ) && ( withEx != WPISZ_SLOWA ) ) || ( ( withoutW != "" ) && ( withoutW != WPISZ_SLOWA ) ) )
		{
			var isOk = Array( 1, 1, 1, 1 );
			if( ( words != "" ) && ( words != WPISZ_SLOWA ) )
			{
				isOk[0] = checkWordsLength( words, 1 );
			}
			if( ( withEx != "" ) && ( withEx != WPISZ_SLOWA ) )
			{
				isOk[1] = checkWordsLength( withEx, 2 );
			}
			if( ( withoutW != "" ) && ( withoutW != WPISZ_SLOWA ) )
			{
				isOk[2] = checkWordsLength( withoutW, 1 );
			}
			if( ( withStr != "" ) && ( withStr != WPISZ_CIAG_ZNAKOW ) )
			{
				isOk[3] = checkWordsLength( withStr, 1 );
			}
			if( ( isOk[0] == 1 ) && ( isOk[1] == 1 ) && ( isOk[2] == 1 ) && ( isOk[3] == 1 ) )
			{
				if( $( "translation1" ).checked )
				{
					vTrans = 2;
				}
				else
				{
					vTrans = 1;
				}
				if( $( "allAnyX1" ).checked )
				{
					vAa = 1;
				}
				else
				{
					vAa = 2;
				}
				if( $( "allAnyY1" ).checked )
				{
					vBb = 1;
				}
				else
				{
					vBb = 2;
				}
				winObj = window.open( serverHost+'/frontend/dictionary/AjaxDictionary.php5?dictSearch='+words+'&translation='+vTrans+'&showPage=1&isPageToPrint='+isPageToPrint+'&page='+vPage+'&withExpression='+withEx+'&allAny='+vAa+'&withoutWords='+withoutW+'&advanced=1&withString='+withStr+'&allAnyS='+vBb+'', "_blank", "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=no, width=770, height=550" );
			}
			else
			{
				alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function openPopUpCross( isPageToPrint, vPage )
	{
		cSearch = "";
		isOk = 0;
		cCount = $( "crossCount2" ).value;
		for( var i = 1; i <= cCount; i++ )
		{
			oL = $( "letter"+i+"" );
			if( oL.value != '' )
			{
				isOk = 1;
				cSearch += oL.value+";";
			}
			else
			{
				cSearch += "_;";
			}
		}
		if( isOk == 1 )
		{
			if( $( "translation1" ).checked )
			{
				vTrans = 2;
			}
			else
			{
				vTrans = 1;
			}
			withEx = getWords( "withExpression2" );
			if( withEx == WPISZ_SLOWA )
			{
				withEx = '';
			}
			winObj = window.open( serverHost+'/frontend/dictionary/AjaxDictionary.php5?crossSearch='+cSearch+'&translation='+vTrans+'&showPage=1&isPageToPrint='+isPageToPrint+'&page='+vPage+'&withExpression='+withEx+'&crossCount='+cCount+'&advanced=2', "_blank", "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=no, width=770, height=550" );
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	function installSearchEngine( agentType )
	{
		if( window.external && ( "AddSearchProvider" in window.external ) )
		{
			// Firefox 2 i IE 7, OpenSearch
			if( agentType == 1 )
			{
				window.external.AddSearchProvider( serverHost+"/extensions/websearch/kosciuszkowski_ff.xml" );
			}
			else
			{
				window.external.AddSearchProvider( serverHost+"/extensions/websearch/kosciuszkowski_ie.xml" );
			}
		}
		else if( window.sidebar && ( "addSearchEngine" in window.sidebar ) )
		{
			// Firefox <= 1.5, Sherlock
			window.sidebar.addSearchEngine( serverHost+"/extensions/websearch/kosciuszkowski.src", serverHost+"/images/kosciuszkowski.png", "Search Plugin", "" );
		}
		else
		{
			// Brak obsługi wyszukiwarki (IE 6, Opera, itd.).
			alert( BRAK_OBSLUGI_WYSZUKIWARKI );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function searchInDictMain( vPage )
	{
		words = getWords( "dictSearch2" );
		if( ( words != "" ) && ( words != WPISZ_SLOWA ) )
		{
			isOk = checkWordsLength( words, 1 );
			if( isOk == 1 )
			{
				if( $( "translation1" ).checked )
				{
					vTrans = 2;
				}
				else
				{
					vTrans = 1;
				}
				$( "dictSearch" ).value = words;
				$( "page" ).value = vPage;
				$( "translation" ).value = vTrans;
				$( "dictForm" ).submit();
			}
			else
			{
				alert( KAZDY_WYRAZ_MUSI_MIEC_2_ZNAKI );
			}
		}
		else
		{
			alert( MUSISZ_WPISAC_JAKIES_SLOWA );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function setLetterAndTranslation( vLetter, vTranslation )
	{
		$( "chosenLetter" ).value = vLetter;
		$( "translation" ).value = vTranslation;
		$( "dictForm" ).submit();
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function setLetterAndTranslationPaging( vPage )
	{
		$( "page" ).value = vPage;
		$( "dictForm" ).submit();
	}

	/**
	*	Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
	*/
	function openWordInPopUp( isPageToPrint, wordId )
	{
		vLetter = $( "chosenLetter" ).value;
		winObj = window.open( serverHost+'/frontend/dictionary/AjaxDictionary.php5?showPage=1&isPageToPrint='+isPageToPrint+'&advanced=4&chosenWordId='+wordId+'&chosenLetter='+vLetter+'', "_blank", "channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=no, width=770, height=550" );
	}

