/**
*   @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 );
	*/

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	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 )
	{
		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];
		//alert( adres );
		docFormSM = $( "searchmod" );
		docFormSM.action = adres;
		docFormSM.submit();
	}
	
	function sendPaging2( 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];
		window.location = adres;
	}

	function sendPaging3( a_adres )
	{
		$( 'anSetSearch' ).value = 1;
		//$( 'anAdvancedSearch' ).value = advanced;
		$( 'searchAnForm' ).action = a_adres;
		$( 'searchAnForm' ).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+"";
		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 == "" ) )
		if( ( l_adresat.value == "" ) || ( l_nadawca.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()
	{
		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;
	}
	
	/**
	*	Opis: funkcja odkodowuje zakodowany email
	*	@author		piotrj
	*	@param		String		t		zakodowany e-mail
	*	@return		String		odkodowany e-mail
	*/
	function semRowsHider( num )
	{
		var i = 0;
		while( oDiv = $( 'semRow'+i+'' ) )
		{
			if( i != num )
			{
				oDiv.style.display = 'none';
			}
			i++;
		}
		$( 'semRow'+num+'' ).style.display = 'block';
	}

	/**
	*	Opis: funkcja odkodowuje zakodowany email
	*	@author		piotrj
	*	@param		String		t		zakodowany e-mail
	*	@return		String		odkodowany e-mail
	*/
	function semRowsHider2( num )
	{
		var i = 0;
		while( oDiv = $( 'semRow'+i+'' ) )
		{
			if( i != num )
			{
				oDiv.style.display = 'none';
				$( 'semLink'+i+'' ).className = 'l24';
			}
			i++;
		}
		$( 'semRow'+num+'' ).style.display = 'block';
		$( 'semLink'+num+'' ).className = 'l25';
	}

/**-------------------------------------------------------------------*/

	var szNormal = 100, szSmall = 29, szFull = 280;
	var kwicks = null;
	var fxk = null;

	/**
	*	Opis: funkcja odkodowuje zakodowany email
	*	@author		piotrj
	*	@param		String		t		zakodowany e-mail
	*	@return		String		odkodowany e-mail
	*/
	function setKwicks()
	{
		kwicks = $$(".seminaryRow");
		fxk = new Fx.Elements( kwicks, { wait: false, duration: 1000, transition: Fx.Transitions.Back.easeOut } );
		kwicks.each( function( kwick, i )
					{
						kwick.addEvent( "mouseenter", function( event )
														{
															var o = {};
															o[i] = { height: [kwick.getStyle( "height" ).toInt(), szFull] };
															kwicks.each( function( other, j )
																			{
																				if( i != j )
																				{
																					var w = other.getStyle( "height" ).toInt();
																					if( w != szSmall ) o[j] = { height: [w, szSmall] };
																				}
																			}
																		);
															fxk.start( o );
														}
										);
					}
				);
	}
