/**
*   @version $Id$
*	@package frontend
*	@author piotrj
*/

/**--------------------------------------------------------------------
*	tu funkcje dla obrazkow glownie z wysiwyg
*	DO NOT REMOVE UNDER ANY CIRCUMSTANCES !!!
*---------------------------------------------------------------------*/

	/**global object that contains popup image data */
	var popupImageObj;
	var isIE = navigator.userAgent.indexOf( "MSIE" );
	var isIE7 = navigator.userAgent.indexOf( "MSIE 7" );
	var isIE8 = navigator.userAgent.indexOf( "MSIE 8" );
	var isOpera = navigator.userAgent.indexOf( "Opera" );
	var isGecko = navigator.userAgent.indexOf( "Gecko" );
	var compareProductVis = 0;
	var slimboxVis = 0;

	/**
	* Function is used to show image popup window.
	* Window is created after complete image loading
	* @param popupImageObj global variable - image to show object
	*/
	function showImagePopupWindow()
	{
		if( popupImageObj.complete == true )
		{
			windowWidth = popupImageObj.width + 20;
			windowHeight = popupImageObj.height + 30;
			verticalPosition = ( document.body.clientWidth - windowWidth ) / 2;
			if( verticalPosition < 0 )
			{
				verticalPosition = 0;
			}
			horizontalPosition = ( document.body.clientHeight - windowHeight ) / 2;
			if( horizontalPosition < 0 )
			{
				horizontalPosition = 0;
			}
			popupWindowObj = window.open(   popupImageObj.src, 
							"image_window", 
							"channelmode=no, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, titlebar=no, \
							width="+ windowWidth +", height="+ windowHeight +", \
							left="+ verticalPosition +", top="+ horizontalPosition +"" );
			popupWindowObj.focus();
		}
		else
		{
			setTimeout( "showImagePopupWindow()", 10 );
		}
	}

	/**
	*	Opis: pokazuje obrazek w nowym dopasowanym oknie
	*/
	function showImage( pathToImage )
	{
		popupImageObj = new Image();
		popupImageObj.src = pathToImage;
		showImagePopupWindow( popupImageObj );
	}

	/**
	*	Opis: funkcja zalatwia nam obsluge PNG w IE // correctly handle PNG transparency in Win IE 5.5 & 6.
	*/
	/**
	function correctPNG()
	{
		var arVersion = navigator.appVersion.split( "MSIE" );
		var version = parseFloat( arVersion[1] );
		if( ( version >= 5.5 ) && ( document.body.filters ) ) 
		{
			for( var i = 0 ; i < document.images.length; i++ )
			{
				var img = document.images[i];
				var imgName = img.src.toUpperCase();
				if( imgName.substring( imgName.length-3, imgName.length ) == "PNG" )
				{
					var imgID = ( img.id ) ? "id='" + img.id + "' " : ""
					var imgClass = ( img.className ) ? "class='" + img.className + "' " : "";
					var imgTitle = ( img.title ) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
					var imgStyle = "display: inline-block;" + img.style.cssText;
					if( img.align == "left" )
					{
						imgStyle = "float: left;" + imgStyle;
					}
					if( img.align == "right" )
					{
						imgStyle = "float: right;" + imgStyle;
					}
					if( img.parentElement.href )
					{
						imgStyle = "cursor: hand;" + imgStyle;
					}
					var strNewHTML = "<span " + imgID + imgClass + imgTitle
							+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
							+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
							+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
					img.outerHTML = strNewHTML;
					i = i-1;
				}
			}
		}    
	}
	window.attachEvent( "onload", correctPNG );
	*/

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	tu funkcje rozne, czasem przydatne, czasem nie
*---------------------------------------------------------------------*/

	/**
	*	Opis: funkcja usowa taby z textarea
	*/
	function clearTabulators()
	{
		var oTar;
		if( oTar = document.getElementsByTagName("TEXTAREA") )
		{
			for( var i = 0; i < oTar.length; i++ )
			{
				re = /[\t]+/g;
				vTxt = oTar[i].value;
				oTar[i].value = vTxt.replace( re, "" );
				re = /[\f\n\r]+$/g;
				vTxt = oTar[i].value;
				oTar[i].value = vTxt.replace( re, "" );
			}
		}
	}

	/**
	*	Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
	*/
	function docPrinter( a_url )
	{
		a_text = ""+$( "pagecontent" ).value+"";
		winObj = window.open( a_url, "_blank", "channelmode=no, toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, titlebar=yes, fullscreen=yes" );
		winObj.document.open();
		winObj.document.write( a_text );
		winObj.document.close();
	}

	/**
	*	Opis: funkcja odkrywa jeden element ukrywajac pozostale
	*/
	function showChosen( a_name, a_nr )
	{
		docid = a_name+"0";
		i = 0;
		while( oObj = $( docid ) )
		{
			if( i != a_nr )
			{
				oObj.style.display = 'none';
			}
			i++;
			docid = a_name+""+i+"";
		}
		docid = a_name+""+a_nr+"";
		oObj = $( docid );
		oObj.style.display = 'block';
	}

	/**
	*	Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
	*/
	function showHideAll( a_name, a_nr, a_ilosc )
	{
		for( i = 0; i < a_ilosc; i++ )
		{
			if( i != a_nr )
			{
				docid = a_name+""+i+"";
				$( docid ).style.display = 'none';
			}
		}
		docid = a_name+""+a_nr+"";
		obj = $( docid );
		if( obj.style.display == 'none' )
		{
			obj.style.display = 'block';
		}
		else
		{
			obj.style.display = 'none';
		}
	}

	/**
	*	Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
	*/
	function showHideAll2( a_name, a_nr )
	{
		var i = 0;
		while( oObj = $( ''+a_name+''+i+'' ) )
		{
			if( i != a_nr )
			{
				oObj.style.display = 'none';
			}
			i++;
		}
		oObj = $( ''+a_name+''+a_nr+'' );
		if( oObj.style.display == 'none' )
		{
			oObj.style.display = 'block';
		}
		else
		{
			oObj.style.display = 'none';
		}
	}

	/**
	*	Opis: funkcja chowa lub pokazuje to co ukryte/odkryte
	*/
	function showHide( a_docid )
	{
		obj = $( a_docid );
		if( obj.style.display == 'none' )
		{
			obj.style.display = 'block';
		}
		else
		{
			obj.style.display = 'none';
		}
	}

	/**
	*	Opis: zmienia rozmiar okna
	*/
	function resizeImageWindow( imageObj, winObj )
	{
		if( imageObj.complete == true )
		{
			l_width = imageObj.width+30;
			l_height = imageObj.height+90;
			winObj.resizeTo( l_width, l_height );
		}
		else
		{
			setTimeout( "resizeImageWindow( imageObj, winObj )", 10 );
		}
	}

	/**
	*	Opis: zmienia lokacje na podany adres
	*/
	function go_to_location( a_location )
	{
		window.location = a_location;
	}

	/**
	*	Opis: przycina tekst do wskazanej dlugosci
	*/
	function checkNumChars( id, num )
	{
		oTxt = $( id );
		vTxt = oTxt.value;
		if( vTxt.length > num )
		{
			vTxt = vTxt.substr( 0, num );
			oTxt.value = vTxt;
		}
	}

	/**
	*	Opis: funkcja sprawdza, czy grafika jest aktywna, czy nie
	*/
	function checkIsOn( a_id )
	{
		oButton = $( a_id );
		sSrc = oButton.src;
		iLen = sSrc.length;
		sRoz = sSrc.substr( iLen-6, 2 );
		if( sRoz == "_a" )
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}

	/**
	*	Opis: funkcja podmienia obrazki bez tekstu przy wywolaniu
	*/
	function changeImage2( a_name, on_off ) 
	{
		old_img = $( a_name );
		old_src = old_img.src;
		len = old_src.length;
		roz = old_src.substr( len-4, len );
		new_src = old_src;
		if( on_off == 1 )
		{
			if( checkIsOn( a_name ) == 0 )
			{
				new_src = old_src.substr( 0, len-4 ) + "_a" + roz;
			}
		}
		else
		{
			if( checkIsOn( a_name ) == 1 )
			{
				new_src = old_src.substr( 0, len-6 ) + roz;
			}
		}
		old_img.src = new_src;
	} 

	/**
	*	Opis: zmienia lokacje strony na podany adres
	*/
	function LocationFromMenu( adres )
	{
		window.location = adres;
	}

	/**
	*	Opis: usuwa nadmiarowe spacje ze stringa i zamienia je na plusy
	*/
	function erase_space( str, type )
	{
		re = /(^\s*)|(\s*$)/g
		str = str.replace( re, "" );
		re = /\s+/g
		if( type == 0 )
		{
			newstr = str.replace( re, "+" );
		}
		else
		{
			newstr = str.replace( re, " " );
		}
		return newstr;
	}

	/**
	*	Opis: funkcja otwiera nowe okno z zawartoscia do wydruku
	*/
	function openMinimized( a_url )
	{
		winObj = window.open( a_url, "_blank", "channelmode=no, toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes, scrollbars=no, resizable=yes, titlebar=yes, fullscreen=no, modal=no" );
		//winObj.moveTo( 0, 0 );
	}

	/**
	*	Opis: funkcja sprawdza, czy ciag jest liczba calkowita o okreslonej ilosci znakow
	*/
	function myIsInt( v, i, j )
	{
		len = v.length;
		if( !isNaN( v ) && ( len >= i ) && ( len <= j ) )
		{
			return 1;
		}
		return 0;
	}

	/**
	*	Opis: funkcja sprawdza, czy ciag jest poprawnym adresem e-mail
	*/
	function isEMail( email )
	{
		re = /^[-a-z0-9!#$%&\'*+\/=?^_`{|}~]+(\.[-a-z0-9!#$%&\'*+\/=?^_`{|}~]+)*@(([a-z]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+([a-z]([-a-z0-9]*[a-z0-9]+)?){2,63}$/g;
		check = email.replace( re, "" );
		if( check == '' )
		{
			return 1;
		}
		return 0;
	}

	/**
	*	Opis: funkcja sprawdza, czy ciag jest poprawna data
	*/
	function isDate( vDate )
	{
		re = /\./g;
		vDate = vDate.replace( re, "-" );
		re = /^(1|2)[0-9]{3}-(0{0,1}[1-9]|(1[0-2]))-(0{0,1}[1-9]|([1-3][0-9]))$/g;
		if( vDate.match( re, "" ) )
		{
			sDate = vDate.split( "-" );
			y = ( sDate[0] * 1 );
			m = ( sDate[1] * 1 ) - 1;
			d = ( sDate[2] * 1 );
			oldDate = y+"-"+m+"-"+d;
			if( oD = new Date( y, m, d ) )
			{
				newDate = oD.getFullYear()+"-"+oD.getMonth()+"-"+oD.getDate();
				if( oldDate == newDate )
				{
					return 1;
				}
			}
		}
		return 0;
	}

	/**
	*	Opis: odsyla do wyszukiwania ze stronicowania
	*/
	function sendPaging( formName, adress )
	{
		docFormSM = $( formName );
		docFormSM.action = adress;
		docFormSM.submit();
	}
	
	/**
	*	Opis: odsyla do wyszukiwania ze stronicowania
	*/
	function sendModuleSearch( a_adres )
	{
		iHost = a_adres.split( '/slowa/' );
		iPage = iHost[1].split( '/page/' );
		words = iPage[0].toLocaleLowerCase();
		re = /(\+)/g;
		words = words.replace( re, "d7d18cfb3a0d8293e2f5d94ea30e04d2" );
		words = encodeURI(words);
		re = /(\%25+)/g;
		words2 = words.replace( re, "e1e4faf650b9178c832fd6ce887e11d4" );
		re = /(\/)/g;
		words2 = words2.replace( re, "9fbbaa4cc515bc46e0c12e82a31df736" );
		re = /#/g;
		words2 = words2.replace( re, "c515bc4650b9178c3a0d8293bbe4d1" );
		adres = iHost[0]+"/slowa/"+words2+"/page/"+iPage[1];
		$( "moduleSearch1" ).value = 0;
		docFormSM = $( "searchmod" );
		docFormSM.action = adres;
		docFormSM.submit();
	}

	/**
	*	Opis: formatuje cene
	*/
	function formatPrice( id )
	{
		oPrice = $( id );
		price = oPrice.value;
		re = /,/g;
		price = price.replace( re, "." );
		pF = parseFloat( price );
		price = "" + pF + "";
		if( isNaN( pF ) || ( pF < 0 ) )
		{
			oPrice.value = "0.00";
		}
		else
		{
			price = numberToPrecision( price, 2 );
			if( parseFloat( price ) > 999999999999.99 )
			{
				price = "999999999999.99";
			}
			oPrice.value = price;
		}
	}

	/**
	*	Opis: ustawia liczbe calkowita na wartosc od 0 do 9999
	*/
	function formatNumber( id )
	{
		oNum = $( id );
		num = oNum.value;
		pI = parseInt( num );
		if( isNaN( pI ) || ( pI < 0 ) )
		{
			oNum.value = "0";
		}
		else if( pI > 9999 )
		{
			oNum.value = "9999";
		}
	}

	/**
	*	Opis: formatuje liczbe do podanej precyzji
	*/
	function numberToPrecision( num, prec )
	{
		num = ""+num+"";
		var re = /,/g;
		num = num.replace( re, "." );
		var posDot = num.indexOf( "." );
		var addPrec = "";
		var addZero = prec;
		if( posDot >= 0 )
		{
			if( posDot == 0 )
			{
				num = "0"+num+"";
			}
			var numTab = num.split( "." );
			num = numTab[0];
			addPrec = numTab[1];
			if( numTab[1].length > prec )
			{
				for( i = 0; i < ( numTab[1].length-prec ); i++ )
				{
					addPrec *= 0.1;
				}
				addPrec = ""+Math.round( addPrec )+"";
				numTab[1] = addPrec;
			}
			addZero = ( prec-numTab[1].length );
		}
		for( var i = 0; i < addZero; i++ )
		{
			addPrec += "0";
		}
		if( addPrec != "" )
		{
			num = ""+num+"."+addPrec+"";
		}
		return num;
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	newsletter
*---------------------------------------------------------------------*/

	/**
	*	Opis: przypisuje akcje do wykonania i robi submita
	*/
	function sendReferenceMail( a_text )
	{
		l_adresat = $( "adresat" );
		l_nadawca = $( "nadawca" );
		cCode = $( "captchaCode" );
		if( ( l_adresat.value == "" ) || ( l_nadawca.value == "" ) || ( cCode.value == "" ) )
		{
			alert( a_text );
		}
		else
		{
			getWysiwyg( 0 );
			$( "polec_nas" ).submit();
		}
	}

	/**
	*	Opis: przypisuje akcje do wykonania i robi submita
	*/
	function subscriptAction( a_akcja, a_default, txt )
	{
		vInp = $( "newsEmail" ).value;
		if( ( vInp != a_default ) && ( vInp != '' ) && isEMail( vInp ) )
		{
			$( "e_mail" ).value = vInp;
			l_hidden_action = $( "akcja" );
			l_hidden_action.value = a_akcja;
			$( "subskrypt_form" ).submit();
		}
		else
		{
			alert( txt );
		}
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	wyszukiwarka
*---------------------------------------------------------------------*/

	/**
	*	Opis: sprawdza dlugosc wszystkich podanych slow
	*/
	function checkWordsLength( str, type )
	{
		ok = 1;
		if( type == 0 )
		{
			str = str.split( "+" );
		}
		else
		{
			str = str.split( " " );
		}
		num = 0;
		while( ( num < str.length ) && ( ok == 1 ) )
		{
			if( str[num].length < 2 )
			{
				ok = 0;
			}
			num++;
		}
		return ok;
	}

	/**
	*	Opis: odsyla do wyszukiwania, jesli wpisano slowa
	*/
	function SendWords( a_host, a_id, text_to_alert1, text_to_alert2, a_type, plainTxt )
	{
		//check_forbidden_chars( a_id, text_to_alert );
		word_container = $( a_id );
		words = word_container.value;
		if( ( words != "" ) && ( words != plainTxt ) )
		{
			words = words.toLocaleLowerCase();
			re = /(\+)/g;
			words = words.replace( re, "d7d18cfb3a0d8293e2f5d94ea30e04d2" );
			words = erase_space( words, 0 );
			is_ok = checkWordsLength( words, 0 );
			if( is_ok == 1 )
			{
				words = encodeURI(words);
				re = /(\%25+)/g;
				words2 = words.replace( re, "e1e4faf650b9178c832fd6ce887e11d4" );
				re = /(\/)/g;
				words2 = words2.replace( re, "9fbbaa4cc515bc46e0c12e82a31df736" );
				re = /#/g;
				words2 = words2.replace( re, "c515bc4650b9178c3a0d8293bbe4d1" );
				adres = a_host + "/wyszukiwanie/slowa/" + words2;
				if( a_type == 1 )
				{
					docFormSM = $( "searchmod" );
					docFormSM.action = adres;
					docFormSM.submit();
				}
				else if( a_type == 2 )
				{
					docFormST = $( "searchtop" );
					docFormST.action = adres;
					docFormST.submit();
				}
				else
				{
					window.location = adres;
				}
			}
			else
			{
				alert( text_to_alert1 );
			}
		}
		else
		{
			alert( text_to_alert2 );
		}
	}

	/**
	*	Opis: odsyla do wyszukiwania w dystrybutorach, jesli wpisano slowa
	*/
	function distributorSearch( id, txt, txt2, plainTxt )
	{
		wordContainer = $( ""+id+"2" );
		words = erase_space( wordContainer.value, 1 );
		if( ( words != "" ) && ( words != plainTxt ) )
		{
			ok = checkWordsLength( words, 1 );
			if( ok == 1 )
			{
				$( id ).value = words;
				$( "moduleSearchForm" ).submit();
			}
			else
			{
				alert( txt2 );
			}
		}
		else
		{
			alert( txt );
		}
	}

	/**
	*	Opis: sprawdza, czy w stringu nie ma zabronionych znakow
	*/
	function check_forbidden_chars( element_id, send, text_to_alert )
	{
		send_text_el = $( element_id );
		send_text = send_text_el.value;
		pos = send_text.indexOf( "%" );
		pos2 = send_text.indexOf( "_" );
		if( ( pos >= 0 ) || ( pos2 >= 0 ) )
		{
			send_text_el.value = "";
			alert( text_to_alert );
		}
		if( send == 1 )
		{
			if( send_text_el.value != "" )
			{
				$( "product_search" ).submit();
			}
		}
	}

/**-------------------------------------------------------------------*/

var addDivsHeight = 0;
var addElementId = '';

	/**
	*	Opis: ustawia wysokosc divow o atrubucie name zaczynajacym sie od sameHeight na wysokosc najwiekszego z nich
	*/
	function setDivHeight()
	{
		var tDivH = Array();
		var tDivId = Array();
		var tDivNum = Array();
		var num = 0;
		var pos, vName, oDivs;
		if( oDivs = document.getElementsByTagName( "DIV" ) )
		{
			for( var i = 0; i < oDivs.length; i++ )
			{
				if( vName = oDivs[i].getAttribute( "id" ) )
				{
					pos = vName.indexOf( "sameHeight" );
					if( pos == 0 )
					{
						vHeight = new Number( new String( oDivs[i].offsetHeight ).replace( /px/g, "" ) );
						tId = vName.split( "_" );
						if( eDiv = tDivH[tId[1]] )
						{
							if( vHeight > tDivH[tId[1]] )
							{
								tDivH[tId[1]] = vHeight;
							}
							tDivId[num] = tId[1];
							tDivNum[num] = tId[2];
						}
						else
						{
							tDivH[tId[1]] = vHeight;
							tDivId[num] = tId[1];
							tDivNum[num] = tId[2];
						}
						num++;
					}
				}
			}
		}
		for( var j = 0; j < num; j++ )
		{
			if( objDivName = $( "sameHeight_"+tDivId[j]+"_"+tDivNum[j] ) )
			{
				if( objDivName == addElementId )
				{
					objDivName.style.height = ''+( tDivH[tDivId[j]] + addDivsHeight )+'px';
				}
				else
				{
					objDivName.style.height = ''+tDivH[tDivId[j]]+'px';
				}
			}
		}
	}

	/**
	*	Opis: ustawia wysokosc divow o takim samym atrubucie name na wysokosc najwiekszego z nich
	*/
	function setDivHeight_Old()
	{
		tDiv = Array();
		if( oDivs = document.getElementsByTagName( "DIV" ) )
		{
			for( i = 0; i < oDivs.length; i++ )
			{
				if( vName = oDivs[i].getAttribute( "name" ) )
				{
					vHeight = new Number( new String( oDivs[i].offsetHeight ).replace( /px/g, "" ) );
					if( eDiv = tDiv[vName] )
					{
						if( vHeight > tDiv[vName] )
						{
							tDiv[vName] = vHeight;
						}
					}
					else
					{
						tDiv[vName] = vHeight;
					}
				}
			}
		}
		for( key in tDiv )
		{
			objDivNames = document.getElementsByName( ""+key+"" );
			for( j = 0; j < objDivNames.length; j++ )
			{
				if( objDivNames[j].id == addElementId )
				{
					objDivNames[j].style.height = ''+( tDiv[key] + addDivsHeight )+'px';
				}
				else
				{
					objDivNames[j].style.height = ''+tDiv[key]+'px';
				}
			}
		}
	}

	/**
	*	Opis: zamienia polskie literki na niepolskie
	*/
	function changeLetters()
	{
		letterOrig = Array( "ę", "ó", "ą", "ś", "ł", "ż", "ź", "ć", "ń", "Ę", "Ó", "Ą", "Ś", "Ł", "Ż", "Ź", "Ć", "Ń" );
		letterChange = Array( "e", "o", "a", "s", "l", "z", "z", "c", "n", "E", "O", "A", "S", "L", "Z", "Z", "C", "N" );
		oInp = $( 'letterPl' );
		iVal = oInp.value;
		re = /(^\s*)|(\s*$)/g;
		iVal = iVal.replace( re, "" );
		iVal = iVal.replace( /\s+/g, "_" );
		for( i = 0; i < letterOrig.length; i++ )
		{
			iVal = iVal.replace( letterOrig[i], letterChange[i] );
		}
		oInp.value = iVal;
	}

	/**
	*	Opis: przeladowuje formularz ankiety
	*/
	function submitQsForm( qsCount, submitType )
	{
		$( "qs"+qsCount+"type" ).value = submitType;
		$( "qsform"+qsCount+"" ).submit();
	}

	/**
	*	Opis: funkcja zamienia ikonki w menu ( :. -> :: i na odwrot )
	*/
	function changeDots( idShow, idHide )
	{
		$( ""+idHide+"" ).style.display = "none";
		$( ""+idShow+"" ).style.display = "block";
	}

	var scroll = new Fx.Scroll( window );

	/**
	* Opis: funkcja odsylajaca do gory strony
	*/
	function topOfSite()
	{
		var tOSD;
		if( tOSD = $( 'topOfSiteDiv' ) )
		{
			tOSD.addEvent( 'click',
				function( event )
				{
					scroll.toTop();
				} );
		}
	}

/**-------------------------------------------------------------------*/

	var lastOpenedTab = 0;

	/**
	* Opis: funkcja przelacza taby na stronie glownej
	*/
	function switchTabs( nr, clName )
	{
		if( nr != lastOpenedTab )
		{
			//$( 'mainImgContainer' ).style.backgroundImage = 'url( '+tabImg[nr]+' )';
			$( 'tab'+lastOpenedTab+'' ).style.display = 'none';
			$( 'tab'+nr+'' ).style.display = 'block';
			$( 'tabSwitcher'+lastOpenedTab+'' ).className = ''+clName+'Off';
			$( 'tabSwitcher'+nr+'' ).className = ''+clName+'On';
			lastOpenedTab = nr;
		}
	}

	/**
	* Opis: funkcja podswietla taby na stronie glownej
	*/
	function lightTabs( id, on, clName )
	{
		var oDiv = $( id );
		if( oDiv.className != ''+clName+'On' )
		{
			if( on == 1 )
			{
				oDiv.className = ''+clName+'OffOver';
			}
			else
			{
				oDiv.className = ''+clName+'Off';
			}
		}
	}

/**-------------------------------------------------------------------*/

	/**
	* Opis: funkcja odkodowuje zakodowany email i otwiera okno z mailto
	*/
	function writeMessageE( t )
	{
		adr = getReverseEmail( t );
		window.location = 'mailto:'+adr+'';
	}

	/**
	* Opis: funkcja odkodowuje zakodowany email i wyswietla go na stronie
	*/
	function decryptE( t )
	{
		adr = getReverseEmail( t );
		document.write( adr );
	}

	/**
	*	Opis: funkcja odkodowuje zakodowany email
	*	@author		piotrj
	*	@param		String		t		zakodowany e-mail
	*	@return		String		odkodowany e-mail
	*/
	function getReverseEmail( t )
	{
		if( t.indexOf( "e14f36d95a0ad776f778ebff6f1f7c2b" ) > -1 )
		{
			p = t.split( "e14f36d95a0ad776f778ebff6f1f7c2b" );
			t = getReverseDot( p[1] )+'@'+getReverseDot( p[0] );
		}
		return t;
	}
	
	/**
	*	Opis: odwraca kolejnosc elementow oddzielonych "_"
	*	@author		piotrj
	*	@param		String		t		tekst do odwrocenia
	*	@return		String		odwrocony tekst oddzielony "."
	*/
	function getReverseDot( t )
	{
		if( t.indexOf( "d7d18cfb3a0d8293e2f5d94ea30e04d2" ) > -1 )
		{
			t = t.split( "d7d18cfb3a0d8293e2f5d94ea30e04d2" );
			n = '';
			for( i = ( t.length-1 ); i >= 0; i-- )
			{
				if( n != '' )
				{
					n += '.';
				}
				n += t[i];
			}
			t = n;
		}
		return t;
	}

/**-------------------------------------------------------------------*/

	/**
	*	Opis: funkcja sprawdza, czy klasa aktywna, czy nie
	*	@param	String		txt			nazwa klasy
	*/
	function checkIsClassOn( txt )
	{
		re = /_on$/g;
		if( txt.match( re ) )
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}

	/** okresla, czy sa w danej chwili uruchomione funkcje odpowiedzialne za zmiane rozmiaru mapy google */
	var gMapResize = 0;

	/**
	*	Opis: funkcja uruchamia funkcje odpowiedzialne za zmiane rozmiaru google maps
	*	@param	Integer		w			docelowa szerokosc mapy
	*	@param	Integer		h			docelowa wysokosc mapy
	*	@param	Integer		mL			przesuniecie w lewo (wartosc ujemna dla marginesu)
	*	@param	Integer		mT			przesuniecie do gory (wartosc ujemna dla marginesu)
	*	@param	Integer		isOn		czy mapa jest powiekszana (1), czy pomniejszana (0)
	*/
	function resizeToWithMargins( w, h, mL, mT, isOn )
	{
		if( isOn == 1 )
		{
			clearTimeout( gMapResize );
			resizeToWithMarginsTime( w, h, mL, mT, isOn );
		}
		else
		{
			gMapResize = setTimeout( "resizeToWithMarginsTime( "+w+", "+h+", "+mL+", "+mT+", "+isOn+" )", 500 );
		}
	}

	/**
	*	Opis: funkcja zmienia rozmiar mapy google
	*	@param	Integer		w			docelowa szerokosc mapy
	*	@param	Integer		h			docelowa wysokosc mapy
	*	@param	Integer		mL			przesuniecie w lewo (wartosc ujemna dla marginesu)
	*	@param	Integer		mT			przesuniecie do gory (wartosc ujemna dla marginesu)
	*	@param	Integer		isOn		czy mapa jest powiekszana (1), czy pomniejszana (0)
	*/
	function resizeToWithMarginsTime( w, h, mL, mT, isOn )
	{
		var box = $( 'map' );
		var gMapFx = box.effects( { duration: 500, transition: Fx.Transitions.Quart.easeOut } );
		gMapFx.start( { 'width': w, 'height': h, 'margin-left': mL, 'margin-top': mT } );
		if( isOn == 1 )
		{
			manageFlash( 0 );
			manageSelects2( 0 );
		}
		else
		{
			setTimeout( "manageFlash( 1 )", 500 );
			setTimeout( "manageSelects2( 1 )", 500 );
			//centerMap();
		}
		//setTimeout( "centerMap()", 500 );
	}

	var timeOutSelect2 = 0;

	/**
	*	Opis: funkcja ukrywa/odkrywa listy rozwijane
	*	@param	Integer		onOff		czy listy maja byc widoczne (1), czy nie (0)
	*/
	function manageSelects2( onOff )
	{
		clearTimeout( timeOutSelect2 );
		if( onOff == 1 )
		{
			var vis = "visible";
		}
		else
		{
			var vis = "hidden";
		}
		//alert( vis );
		if( oSel = document.getElementsByTagName( "SELECT" ) )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				if( ( oSel[i].id != 'tbSelMonth' ) && ( oSel[i].id != 'tbSelYear' ) )
				{
					oSel[i].style.visibility = vis;
				}
			}
		}
	}

/**-------------------------------------------------------------------*/

	/**
	*	Opis: funkcja sprawdza, czy klasa aktywna, czy nie
	*	@param	Integer		sortField		numer pola po ktorym sortujemy
	*	@param	Integer		sortType		typ sortowania ASC/DESC
	*/
	function submitCategoryForNewsletterForm( txt )
	{
		if( $( 'anCategoryForNewsletter' ).value != '' )
		{
			$( 'addCategoryToNewsletterForm' ).submit();
		}
		else
		{
			alert( txt );
		}
	}

/**-------------------------------------------------------------------*/

var lastOpenedList = '';
var lastOpenedListTime = 0;
var isListMouseOver = 0;

/**
*	Opis: chowa/odkrywa liste rozwijana na linkach
*	@param	String		divId		id diva z opcjami listy
*/
function setInpSelVis( divId )
{
	clearTimeout( lastOpenedListTime );
	oDiv = $( divId );
	if( oDiv.style.visibility == 'visible' )
	{
		oDiv.style.visibility = 'hidden';
	}
	else
	{
		if( lastOpenedList != '' )
		{
			$( lastOpenedList ).style.visibility = 'hidden';
		}
		oDiv.style.visibility = 'visible';
		lastOpenedList = divId;
	}
}

/**
*	Opis: ustawia czas ukrycia listy z opcjami na okreslony czas
*	@param	String		divId		id diva z opcjami listy
*/
function setInpSelVisCloseTime( divId )
{
	lastOpenedListTime = setTimeout( "setInpSelVisClose( '"+divId+"' )", 250 );
}

/**
*	Opis: ukrywa liste z opcjami
*	@param	String		divId		id diva z opcjami listy
*/
function setInpSelVisClose( divId )
{
	if( ( isListMouseOver == 0 ) || ( lastOpenedList != divId ) )
	{
		$( divId ).style.visibility = 'hidden';
	}
	else
	{
		lastOpenedListTime = setTimeout( "setInpSelVisClose( '"+divId+"' )", 500 );
	}
}

/**
*	Opis: ustawia wybrana opcje
*	@param	String		inpTitle		wartosc, jaka ma sie pojawic w widocznym inpucie z wybrana opcja
*	@param	String		inpValue		wartosc, jaka ma sie pojawic w ukrytym inpucie z wybrana opcja
*	@param	String		inpId			id inputa z wybrana opcja listy
*	@param	String		divId			id diva z opcjami listy
*	@param	String		beforeTitle		wartosc, jaka ma sie pojawic przed wybrana opcja w widocznym inpucie
*	@param	String		afterTitle		wartosc, jaka ma sie pojawic za wybrana opcja w widocznym inpucie
*/
function setInpSelVal( inpTitle, inpValue, inpId, divId, beforeTitle, afterTitle )
{
	$( inpId ).value = inpValue;
	$( inpId+"ISV" ).value = beforeTitle+inpTitle+afterTitle;
	$( divId ).style.visibility = 'hidden';
}

/**
 *	Ponizsze ukrywa listy rozwijane w IE
 */

	var timeOutSelectAll = 0;

	/**
	*	Opis: funkcja ukrywa/odkrywa listy rozwijane
	*/
	function manageSelectsAll( vis )
	{
		clearTimeout( timeOutSelectAll );
		if( ( vis == 'hidden' ) || ( ( compareProductVis == 0 ) && ( slimboxVis == 0 ) ) )
		{
			if( ( isIE > -1 ) && ( isIE7 == -1 ) && ( isIE8 == -1 ) )
			{
				if( oSel = document.getElementsByTagName("SELECT") )
				{
					for( i = 0; i < oSel.length; i++ )
					{
						if( ( oSel[i].id != 'tbSelMonth' ) && ( oSel[i].id != 'tbSelYear' ) )
						{
							oSel[i].style.visibility = vis;
						}
					}
				}
			}
		}
	}

	var flashesAreManaged = 0;

	/**
	*	Opis: funkcja ukrywa/odkrywa listy rozwijane
	*/
	function manageFlash( onOff )
	{
		clearTimeout( flashesAreManaged );
		if( onOff == 1 )
		{
			var vis = "visible";
		}
		else
		{
			var vis = "hidden";
		}
		var oSel, i;
		if( oSel = document.getElementsByTagName("EMBED") )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				oSel[i].style.visibility = vis;
			}
		}
		if( oSel = document.getElementsByTagName("OBJECT") )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				oSel[i].style.visibility = vis;
			}
		}
		/*if( oSel = $$( document.getElementsByTagName("EMBED"), document.getElementsByTagName("OBJECT") ) )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				oSel[i].style.visibility = vis;
			}
		}*/
	}

	/**
	*	Opis: przypisuje akcje do wykonania i robi submita
	*/
	function setCatalogSearch( txt )
	{
		oInp = $( "catalogWords" );
		vInp = oInp.value;
		vInp = vInp.replace( /[\s\n\r\t]+/, ' ' );
		vInp = vInp.replace( /^\s+/, '' );
		vInp = vInp.replace( /\s+$/, '' );
		//if( vInp != '' )
		//{
			$( "catSearchForm" ).submit();
		//}
		//else
		//{
		//	alert( txt );
		//}
	}

	/**
	*	Opis: funkcja ukrywa/odkrywa listy rozwijane
	*	@param	Integer		onOff		czy listy maja byc widoczne (1), czy nie (0)
	*/
	function setVisiblePersonalAdress( num )
	{
		var disp = '';
		for( i = 1; i <= 3; i++ )
		{
			if( i == num )
			{
				disp = 'block';
			}
			else
			{
				disp = 'none';
			}
			$( 'visiblePersonalAdress'+i+'' ).style.display = disp;
		}
	}
	
	function changeNews( id )
	{
		for( i=0; i<3; i++ )
		{
			if( $( 'box_'+i ) )
			{
				$( 'box_'+i ).style.display = 'none';
			}
			if( $( 'title_'+i ) )
			{
				$( 'title_'+i ).className = 'newsTitle_'+i;
			}
		}
		$( 'box_'+id ).style.display = 'block';
		$( 'title_'+id ).className = 'newsTitleOn_'+id;
	}
	
	
	window.addEvent("load",function(){
		var dymki = new Tips($$("acronym"), {
			onShow: function(toolTip) {this.efekt.start(0,1);},
			onHide: function(toolTip) {this.efekt.start(1,0);}
		});
		
		dymki.efekt = new Fx.Style(dymki.toolTip,"opacity",{wait: true});
	});

	
	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function checkMainLogin( a_text1, a_text2, a_text3 )
	{
		var ok = 1;
		var fieldsToCheck = Array( 'exemail', 'exhaslo' );
		var fieldsMinLenght = Array( 0, 0 );
		var textToAlert = Array( '', '', '' );
		var alertText = '';
		for( i = 0; i <= 1; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text1+"\n";
			}
			else if( ( fieldsMinLenght[i] > 0 ) && ( oVal.length < fieldsMinLenght[i] ) )
			{
				oObj.className = 'textLF1';
				ok = 2;
				textToAlert[1] = a_text2+"\n";
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		/*if( isEMail( $( 'exemail' ).value ) == 0 )
		{
			ok = 0;
			$( 'exemail' ).className = 'textLF1';
			textToAlert[2] = a_text3+"\n";
		}*/
		for( var i = 0; i <= 2; i++ )
		{
			alertText += textToAlert[i];
		}
		if( ok == 1 )
		{
			$( "exmainlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}
	
	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function sendMainPassword( a_text1, a_text2, a_adr )
	{
		oObj = $( 'exemail' );
		oVal = oObj.value;
		re = /[\s\t\r\n]+/g;
		oVal = oVal.replace( re, '' )
		if( oVal != '' )
		{
			//if( isEMail( oVal ) == 1 )
			//{
				$( 'sendpass' ).value = 1;
				docFormExL = $( "exmainlogin" );
				docFormExL.action = a_adr;
				docFormExL.submit();
			/*}
			else
			{
				oObj.className = 'textLF1';
				alert( a_text2 );
			}*/
			//docFormExL.action = a_adr;
		}
		else
		{
			oObj.className = 'textLF1';
			alert( a_text1 );
		}
	}

