/**
*   @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 isOpera = navigator.userAgent.indexOf( "Opera" );
	var isGecko = navigator.userAgent.indexOf( "Gecko" );

	/**
	* 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 );
	*/

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	to nam zalatwia poprawne wyswietlanie flashy w Internet Exploderze
*---------------------------------------------------------------------*/

	/**
	 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
	 *
	 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 *
	 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
	 *   legal reasons.
	 */
	if( typeof deconcept == "undefined" )
	{
		var deconcept = new Object();
	}
	if( typeof deconcept.util == "undefined" )
	{
		deconcept.util = new Object();
	}
	if( typeof deconcept.SWFObjectUtil == "undefined" )
	{
		deconcept.SWFObjectUtil = new Object();
	}
	deconcept.SWFObject = function( _1, id, w, h, _5, c, _7, _8, _9, _a, _b )
	{
		if( !document.createElement || !document.getElementById )
		{
			return;
		}
		this.DETECT_KEY = _b ? _b : "detectflash";
		this.skipDetect = deconcept.util.getRequestParameter( this.DETECT_KEY );
		this.params = new Object();
		this.variables = new Object();
		this.attributes = new Array();
		if( _1 )
		{
			this.setAttribute( "swf", _1 );
		}
		if( id )
		{
			this.setAttribute( "id", id );
		}
		if( w )
		{
			this.setAttribute( "width", w );
		}
		if( h )
		{
			this.setAttribute( "height", h);
		}
		if( _5 )
		{
			this.setAttribute( "version", new deconcept.PlayerVersion( _5.toString().split( "." ) ) );
		}
		this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion( this.getAttribute( "version" ), _7 );
		if( c )
		{
			this.addParam( "bgcolor", c );
		}
		var q = _8 ? _8 : "high";
		this.addParam( "quality", q );
		this.setAttribute( "useExpressInstall", _7 );
		this.setAttribute( "doExpressInstall", false );
		var _d = ( _9 ) ? _9 : window.location;
		this.setAttribute( "xiRedirectUrl", _d );
		this.setAttribute( "redirectUrl", "" );
		if( _a )
		{
			this.setAttribute( "redirectUrl", _a );
		}
	};
	deconcept.SWFObject.prototype = { 
		setAttribute:function( _e, _f )
		{
			this.attributes[_e] = _f;
		}
		, getAttribute:function( _10 )
		{
			return this.attributes[_10];
		}
		, addParam:function( _11, _12)
		{
			this.params[_11]=_12;
		}
		, getParams:function()
		{
			return this.params;
		}
		, addVariable:function( _13, _14 )
		{
			this.variables[_13] = _14;
		}
		, getVariable:function( _15 )
		{
			return this.variables[_15];
		}
		, getVariables:function()
		{
			return this.variables;
		}
		, getVariablePairs:function()
		{
			var _16 = new Array();
			var key;
			var _18 = this.getVariables();
			for( key in _18 )
			{
				_16.push( key + "=" + _18[key] );
			}
			return _16;
		}
		, getSWFHTML:function()
		{
			var _19 = '';
			if( navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length )
			{
				if( this.getAttribute( "doExpressInstall" ) )
				{
					this.addVariable( "MMplayerType", "PlugIn" );
				}
				_19 = '<embed type="application/x-shockwave-flash" src="'+this.getAttribute( "swf" )+'" width="'+this.getAttribute( "width" )+'" height="'+this.getAttribute( "height" )+'"';
				_19 += ' id="'+this.getAttribute( "id" )+'" name="'+this.getAttribute( "id" )+'" ';
				var _1a = this.getParams();
				for( var key in _1a )
				{
					_19 += [key] + '="'+_1a[key]+'" ';
				}
				var _1c = this.getVariablePairs().join( "&" );
				if( _1c.length > 0 )
				{
					_19 += 'flashvars="'+_1c+'"';
				}
				_19 += '/>';
			}
			else
			{
				if( this.getAttribute( "doExpressInstall" ) )
				{
					this.addVariable( "MMplayerType", "ActiveX" );
				}
				_19 = '<object id="'+this.getAttribute( "id" )+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute( "width" )+'" height="'+this.getAttribute( "height" )+'">';
				_19 += '<param name="movie" value="'+this.getAttribute( "swf" )+'" />';
				var _1d = this.getParams();
				for( var key in _1d )
				{
					_19 += '<param name="'+key+'" value="'+_1d[key]+'" />';
				}
				var _1f = this.getVariablePairs().join( "&" );
				if( _1f.length > 0 )
				{
					_19 += '<param name="flashvars" value="'+_1f+'" />';
				}
				_19 += '</object>';
			}
			return _19;
		}
		, write:function( _20 )
		{
			if( this.getAttribute( "useExpressInstall" ) )
			{
				var _21 = new deconcept.PlayerVersion( [6, 0, 65] );
				if( this.installedVer.versionIsValid( _21 ) && !this.installedVer.versionIsValid( this.getAttribute( "version" ) ) )
				{
					this.setAttribute( "doExpressInstall", true );
					this.addVariable( "MMredirectURL", escape( this.getAttribute( "xiRedirectUrl" ) ) );
					document.title = document.title.slice( 0, 47 ) + " - Flash Player Installation";
					this.addVariable( "MMdoctitle", document.title );
				}
			}
			if( this.skipDetect || this.getAttribute( "doExpressInstall" ) || this.installedVer.versionIsValid( this.getAttribute( "version" ) ) )
			{
				var n = ( typeof( _20 ) == "string" ) ? $( _20 ) : _20;
				//n.innerHTML = this.getSWFHTML();
				var newDiv = new Element('div').setProperty( 'id', _20 );
				newDiv.innerHTML = this.getSWFHTML();
				$( _20 ).replaceWith( newDiv );
				return true;
			}
			else
			{
				if( this.getAttribute( "redirectUrl" ) != "" )
				{
					document.location.replace( this.getAttribute( "redirectUrl" ) );
				}
			}
			return false;
		}
	};
	deconcept.SWFObjectUtil.getPlayerVersion = function( _23, _24 )
	{
		var _25 = new deconcept.PlayerVersion( [0, 0, 0] );
		if( navigator.plugins && navigator.mimeTypes.length )
		{
			var x = navigator.plugins[ "Shockwave Flash" ];
			if( x && x.description )
			{
				_25 = new deconcept.PlayerVersion( x.description.replace( /([a-z]|[A-Z]|\s)+/, "" ).replace( /(\s+r|\s+b[0-9]+)/, "." ).split( "." ) );
			}
		}
		else
		{
			try
			{
				var axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
				for( var i = 3; axo != null; i++ )
				{
					axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
					_25 = new deconcept.PlayerVersion( [i, 0, 0] );
				}
			}
			catch( e ){}
			if( _23 && _25.major > _23.major )
			{
				return _25;
			}
			if( !_23 || ( ( _23.minor != 0 || _23.rev != 0 ) && _25.major == _23.major ) || _25.major != 6 || _24 )
			{
				try
				{
					_25 = new deconcept.PlayerVersion( axo.GetVariable( "$version" ).split( " " )[1].split( "," ) );
				}
				catch( e ){}
			}
		}
		return _25;
	};
	deconcept.PlayerVersion = function( _29 )
	{
		this.major = parseInt( _29[0] ) != null ? parseInt( _29[0] ) : 0;
		this.minor = parseInt( _29[1] ) || 0;
		this.rev = parseInt( _29[2] ) || 0;
	};
	deconcept.PlayerVersion.prototype.versionIsValid = function( fv )
	{
		if( this.major < fv.major )
		{
			return false;
		}
		if( this.major > fv.major )
		{
			return true;
		}
		if( this.minor < fv.minor )
		{
			return false;
		}
		if( this.minor > fv.minor )
		{
			return true;
		}
		if( this.rev < fv.rev )
		{
			return false;
		}
		return true;
	};
	deconcept.util = {
		getRequestParameter:function( _2b )
		{
			var q = document.location.search || document.location.hash;
			if( q )
			{
				var _2d = q.indexOf( _2b + "=" );
				var _2e = ( q.indexOf( "&", _2d ) >- 1 ) ? q.indexOf( "&", _2d ) : q.length;
				if( q.length > 1 && _2d >- 1 )
				{
					return q.substring( q.indexOf( "=", _2d ) + 1, _2e );
				}
			}
			return "";
		}
	};
	if( Array.prototype.push == null )
	{
		Array.prototype.push = function( _2f )
		{
			this[this.length] = _2f;
			return this.length;
		};
	}
	var getQueryParamValue = deconcept.util.getRequestParameter;
	var FlashObject = deconcept.SWFObject; // for backwards compatibility
	var SWFObject = deconcept.SWFObject;

	/**
	*	Opis: funkcja zalatwia problem z wstawianiem flashy do IE
	*/
	function drawFlash( path, param, quality, bgcolor, width, height, name, flashDiv )
	{
		var so = new SWFObject( path, name, width, height, "8", bgcolor );
		so.addParam( "quality", quality );
		var par = param.split( "&" );
		for( var i = 0; i < par.length; i++ )
		{
			var p = par[i].split( "=" );
			so.addVariable( p[0], p[1] );
		}
		//so.addParam( "wmode", "transparent" );
		so.write( flashDiv );
	}

	/**
	*	Opis: funkcja zalatwia problem z wstawianiem flashy do IE
	*/
	function drawFlashOld( path, param, quality, bgcolor, width, height, name )
	{
		with( document )
		{
			write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="mainElem" align="middle">' );
			write( '<param name="allowScriptAccess" value="sameDomain" />' );
			write( '<param name="movie" value="'+path+'" />' );
			write( '<param name="quality" value="'+quality+'" />' );
			write( '<param name="bgcolor" value="'+bgcolor+'" />' );
			write( '<param name="wmode" value="transparent" >' );
			write( '<param name="FlashVars" value="'+param+'" >' );
			write( '<embed src="'+path+'?'+param+'" quality="'+quality+'" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' );
			write( '</object>' );
		}
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	tu funkcje rozne, czasem przydatne, czasem nie
*---------------------------------------------------------------------*/

	/**
	*	Opis: funkcja usowa taby z textarea
	*/
	function clearTabulators()
	{
		if( oTar = document.getElementsByTagName("TEXTAREA") )
		{
			for( 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 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( a_adres )
	{
		docFormSM = $( "searchmod" );
		docFormSM.action = a_adres;
		docFormSM.submit();
	}

	/**
	*	Opis: odsyla do wyszukiwania ze stronicowania
	*/
	function sendModuleSearch( a_adres )
	{
		$( "moduleSearch1" ).value = 0;
		docFormSM = $( "searchmod" );
		docFormSM.action = a_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+"";
		re = /,/g;
		num = num.replace( re, "." );
		posDot = num.indexOf( "." );
		addPrec = "";
		addZero = prec;
		if( posDot >= 0 )
		{
			if( posDot == 0 )
			{
				num = "0"+num+"";
			}
			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( 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" );
				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()
	{
		tDivH = Array();
		tDivId = Array();
		tDivNum = Array();
		num = 0;
		if( oDivs = document.getElementsByTagName( "DIV" ) )
		{
			for( 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( 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()
	{
		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 )
	{
		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;
	}
	

