/*
	MAP MARKERS add events
*/
markerAddEvents = function(){
	$('.entries li a:has(img)').lightBox(lightboxParams);
	/*
		ROUTE EDIT marker
	*/
	$('.route-edit-marker').click(function(){
		__modalShow();
		href = $(this).attr('href');
		$('.modal-box').load(href, function(){
			$(this).attr('id',  'route-edit-marker').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('textarea').text($('#route-map .description').text()).focus().end()
			.find('#modal-box-close').click(function(){
				__modalHide();
				return false;
			});
		});
		return false;
	});
	/*
		ROUTE EDIT foto adding
	*/
	$('.marker-gallery-add').click(function(){
		__modalShow();
		href = $(this).attr('href');
		$('.modal-box').load(href, function(){
			$(this).attr('id', 'marker-gallery-add').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close').click(function(){
				__modalHide();
				return false;
			});
		});
		return false;
	});
	/*
		ROUTE EDIT marker delete
	*/
	$('.route-remove-marker').click(function(){
		href = $(this).attr('mid');
		if (($('#route-map .description').text() != '') || ($('#route-map .entries li').text() != '')) {
			__modalShow();
			$('.modal-box').load(HOST + '/ajax-content/route-marker-delete-confirm.php', function(){
				$(this).attr('id', 'delete-confirm').fadeIn('fast')
				.find('.content h2').after(modalBoxClose).end()
				.find('#modal-box-close, .no').click(function(){
					__modalHide();
					return false;
				}).end().find('.yes').click(function(){
					removeMarker(href);
					__modalHide();
					return false;
				});
			});
		}
		else {
			removeMarker(href);
		}
		return false;
	});
}
function whenReady(id, callback){
	var interval = setInterval(function(){
		if ($(id).size()) {
			clearInterval(interval);
			callback();
		}
	}, 10);
}
/*
	DOCUMENT READY
*/
$(function(){
	/*
		CONFIG and globals
	*/
	HOST = $('#header h1:first a').attr('href');
	lightboxParams = {overlayOpacity:0.7, imageLoading: HOST + '/pub/uploadimages/lightbox-ico-loading.gif', imageBtnPrev: HOST + '/pub/uploadimages/lightbox-btn-prev.png', imageBtnNext: HOST + '/pub/uploadimages/lightbox-btn-next.png', imageBtnClose: HOST + '/pub/uploadimages/lightbox-btn-close.png', imageBlank: HOST + '/pub/uploadimages/lightbox-blank.gif', txtImage: 'Zdjęcie', txtOf: 'z'}
	modalBoxClose = '<a id="modal-box-close" href="#">Zamknij</a>';
	/*
		:FOCUS HACK FOR IE
	*/
	$('input:text, textarea, button').focus(function(){$(this).addClass('active');}).blur(function(){$(this).removeClass('active');});
	$('button').mouseover(function(){$(this).addClass('active');}).mouseout(function(){$(this).removeClass('active');});
	/*
		TABLE ROWS mouseover highlight
	*/
	$('table.routes tbody tr').hover(
		function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')}
	);
	/*
		INVITE TO FREINDS message preview
	*/
	if ($('#message-preview').size()) {
		$('#comment').keyup(function(){
			$('#message-preview #example_comment').text($(this).val());
		}).keyup();
	}
	/*
		TUTORIALS' movies
	*/
	$.getScript(HOST + '/pub/js/jquery.lightbox.js', function(){
		$('.tutorials ol li')
			.find('p').hide().end()
			.find('h4 a').click(function(){
				$(this).parents('h4').siblings('p').toggle();
				return false;
			}).end()
			.find('p.movie a').lightBox(lightboxParams);
	});
	/*
		ROUTE rating
	*/
	if ($('#route-info .rating-graph ul').size()){
		resultStyles = {'background-position': '0 -44px', width: $('#route-info .rating-graph ul').get(0).className.replace('average-', '').replace(' novote', '') + '%'};
		if ($('#route-info .rating-graph ul').css(resultStyles).is('.novote')){
			$('#route-info .rating-graph a').remove();
		}
		else {
			$('#route-info .rating-graph')
				.mouseover(function(){$('ul', this).css({'background-position': '0 0', width: '100%'})})
				.mouseout(function(){$('ul', this).css(resultStyles)})
				.find('ul a').mouseover(function(){
					$this = $(this);
					$this.parents('ul').find('a').removeClass('active').filter(':lt(' + $this.text() + ')').addClass('active');
				});
		}
	}
	/*
		TEXT INPUTS value show/hide
	*/
	$('#left input:text[value], #aside .box input:text[value], #map-edit .section-nav input:text[value]').each(function(){
		var $this = $(this);
		var startVal = $this.val();
		if (document.location.search.indexOf('=') < 0 || (document.location.search.indexOf($this.attr('id') + '=&') > -1 || document.location.search.indexOf($this.attr('id')) < 0)){
			$this.focus(function(){
				if (this.value == startVal)
					$this.val('');
			})
			.blur(function(){
				if (!this.value)
					$this.val(startVal);
			});
		}
	});
	$('form').submit(function(){
		$('input:text[value]').each(function(){
			val = $(this).val();
			if (val == "Autor trasy" || val == "Nazwa trasy / hasło w opisie" || val == "Miejscowość" || val == "Nick / imię / nazwisko" || val == "Nazwa teamu / uczestnik teamu" || val == "Województwo / miasto / ulica")
				$(this).val('');
		});
	});
	/*
		MODAL BOXES
	*/
	__modalBoxHide = function(){
		$('.modal-box').remove();
	};
	__modalShow = function(){
		$('<div id="modal-layer"></div>').appendTo('body').css({height: $().height(), opacity: '0.7'}).prepend('<div class="ajax-loader"></div>').click(function(){
			__modalHide();
		}).after('<div class="modal-box"></div>');
		$('embed, object, select').addClass('modal-hidden').css({'visibility': 'hidden'});
	};
	__modalHide = function(){
		$('#modal-layer').fadeOut('fast').remove();
		__modalBoxHide();
		$('.modal-hidden').removeClass('modal-hidden').css({'visibility': 'visible'});
	};
	/*
		BLOG ENTRY deleting
	*/
	$('#blog .entries .edit').find('a:last').click(function(){
		__modalShow();
		deleteLink = $(this).attr('href');
		$('.modal-box').load(HOST + '/ajax-content/entry-delete-confirm.php', function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				$.get(deleteLink, function(){
					window.location.reload();
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		ROUTE GALLERY & USER GALLERY foto adding
	*/
	$('#route-info + #gallery .section-nav a:first, #your-favorites + #gallery .section-nav a:first').click(function(){
		__modalShow();
		href = new String($(this).attr('href'));
		if (href.search(/user-gallery-add-photo/ig)>-1) href = href + '?js=1'; else href = href + '&js=1';
		$('.modal-box').load(href, function(){
			$modalbox = $(this);
			$modalbox.attr('id', 'gallery-add-photo').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close').click(function(){
				__modalHide();
				return false;
			}).end().find('button').click(function(){
				$modalbox.hide();
			});
		});
		return false;
	});
	/*
		INVITE friend
	*/
	$('#aside .latest-friends .more a:contains("zapro")').click(function(){
		__modalShow();
		$('.modal-box').load(HOST + '/ajax-content/recommend-site.php', function(){
			$(this).attr('id', 'recommend-site').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close').click(function(){
				__modalHide();
				return false;
			});
			$('#comment').keyup(function(){
				$('#message-preview #example_comment').text($(this).val());
			});
		});
		return false;
	});
	/*
		FAVORITES add & remove
	*/
	$('#route-info .section-nav li a:contains("dodaj trasę do ulubionych"), #route-info .section-nav li a:contains("usuń trasę z ulubionych")').click(function(){
		__modalShow();
		href = $(this).attr('href') + '&js=1';
		$('.modal-box').load(href, function(){
			$(this).attr('id', 'add-remove-favorites').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .buttons a', this).click(function(){
				window.location.reload();
				__modalHide();
				return false;
			});
		});
		return false;
	});
	/*
		INVITATIONS & APPLIES
	*/
	$('#profile-nav li a:contains("znajomych"), .profiles .invite a:contains("znajomych"), #profile-nav li a:contains("zaproś do teamu"), .profiles .invite a:contains("zaproś do teamu"), #profile-nav li a:contains("zgłoś"), .profiles .invite a:contains("zgłoś"), .section-nav a:contains("wyślij zgłoszenie"), .section-nav a:contains("anuluj wysłane"), #invitations-sent a:contains("Anuluj"), #invitations-recieved a:contains("Akceptuj"), #invitations-recieved a:contains("Odrzuć"), .route-attached .more a:contains("Dołącz")').click(function(){
		__modalShow();
		if ($(this).attr('href').indexOf('?') > 0)
			href = $(this).attr('href') + '&js=1';
		else
			href = $(this).attr('href') + '?js=1';
		$('.modal-box').load(href, function(){
			$(this).attr('id', 'invitation').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .buttons a', this).click(function(){
				window.location.reload();
				__modalHide();
				return false;
			});
		});
		return false;
	});
	/*
		INVITATIONS & APPLIES 2
	*/
	$('#profile-nav li a[href*="need-to-be-logged-in"]:contains("załóż swój team")').click(function(){
		__modalShow();
		if ($(this).attr('href').indexOf('?') > 0)
			href = $(this).attr('href') + '&js=1';
		else
			href = $(this).attr('href') + '?js=1';
		$('.modal-box').load(href, function(){
			$(this).attr('id', 'invitation').show()
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .buttons a', this).click(function(){
				__modalHide();
				return false;
			});
		});
		return false;
	});
	/*
		DELETE user
	*/
	$('#profile-nav li a:contains("usuń profil")').click(function(){
		__modalShow();
		confirmLink = $(this).attr('href') + '&js=1';
		$('.modal-box').load(confirmLink, function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				deleteLink = $(this).attr('href');
				$.get(deleteLink, function(){
					window.location = HOST;
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		DELETE team
	*/
	$('#profile-nav li a:contains("usuń swój team")').click(function(){
		__modalShow();
		deleteLink = $(this).attr('href');
		$('.modal-box').load(HOST + '/ajax-content/team-delete-confirm.php', function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				$.get(deleteLink, function(){
					window.location = HOST + '/twoj-profil.html';
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		DELETE route
	*/
	$('.section-nav a:contains("usuń trasę")').not(':contains("usuń trasę z ulubionych")').click(function(){
		__modalShow();
		confirmLink = $(this).attr('href') + '&js=1';
		$('.modal-box').load(confirmLink, function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				deleteLink = $(this).attr('href');
				$.get(deleteLink, function(){
					window.location = HOST + '/twoj-profil.html';
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		DELETE user from team
	*/
	$('.section .profiles a:contains("usuń z teamu")').click(function(){
		__modalShow();
		deleteLink = $(this).attr('href');
		$('.modal-box').load(HOST + '/ajax-content/team-member-delete-confirm.php', function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				$.get(deleteLink, function(){
					window.location.reload();
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		DELETE me from team
	*/
	$('#profile-nav a:contains("wypisz się z teamu")').click(function(){
		__modalShow();
		deleteLink = $(this).attr('href');
		$('.modal-box').load(HOST + '/ajax-content/team-me-delete-confirm.php', function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				$.get(deleteLink, function(){
					window.location.reload();
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		SEND MAIL to team
	*/
	$('#profile-nav a:contains("mail do teamu")').click(function(){
		__modalShow();
		if ($(this).attr('href').indexOf('?') > 0)
			sendLink = $(this).attr('href') + '&js=1';
		else
			sendLink = $(this).attr('href') + '?js=1';
		$('.modal-box').load(sendLink, function(){
			$(this).attr('id', 'send-mail').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no, .buttons a').click(function(){
				__modalHide();
				return false;
			}).end().find('form').submit(function(){
				formAction = $(this).attr('action') + '?js=1';
				$('.modal-box').css({visibility: 'hidden'});
				$.post(formAction, $('#send-mail input, #send-mail textarea').serialize(), function(msg){
					$('.modal-box').html(msg).css({visibility: 'visible'}).find('.buttons a').click(function(){
						__modalHide();
						return false;
					});
				});
				return false;
			});
		});
		return false;
	});
	/*
		CANCEL invitation
	*/
	$('#invitations-sent a:contains("anuluj")').click(function(){
		__modalShow();
		deleteLink = $(this).attr('href');
		$('.modal-box').load(HOST + '/ajax-content/team-invitation-delete-confirm.php', function(){
			$(this).attr('id', 'delete-confirm').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#modal-box-close, .no').click(function(){
				__modalHide();
				return false;
			}).end().find('.yes').click(function(){
				$.get(deleteLink, function(){
					window.location.reload();
				});
				__modalBoxHide();
				return false;
			});
		});
		return false;
	});
	/*
		SEND a report
	*/
	$('#profile-nav a:contains("wyślij uwagę"), #footer .report a').click(function(){
		__modalShow();
		sendlink = $(this).attr('href');
		$('.modal-box').load(sendlink + '?js=1', function(){
			$(this).attr('id', 'report-send').fadeIn('fast')
			.find('.content h2').after(modalBoxClose).end()
			.find('#unique_id').val((Math.random()) * 10).end()
			.find('#opener_callback').val(HOST + '/sugestie-i-uwagi.html').end()
			.find('#modal-box-close').click(function(){
				__modalHide();
				return false;
			}).end().find('form').submit(function(){
				if ($.trim($('#report-send textarea').val()) != '') {
					$('.modal-box').css({visibility: 'hidden'});
					$.post(HOST + '/admin/forms/form_submit.php', $('#report-send input, #report-send textarea').serialize(), function(msg){
						$('.modal-box').css({visibility: 'visible'}).find('form').before(msg + '<div class="buttons"><a href="#">OK</a></div>').remove();
						$('.modal-box .buttons a').click(function(){
							__modalHide();
							return false;
						});
					});
				} else {
					alert('Wpisz uwagi i sugestie dotyczące serwisu.');
					$('textarea:first', this).focus();
					return false;
				}
				return false;
			});
		});
		return false;
	});
	/*
		ROUTE MAP toolbar
	*/
	if ($('#route-map').size()){
		$.getScript(HOST + '/pub/js/jquery.tooltip.min.js', function(){
			$.getScript(HOST + '/pub/js/jquery.dimensions.min.js', function(){
				if (typeof initialize == 'function'){initialize();}
				if (typeof setMapMode == 'function'){
					$('<ul class="map-toolbar"><li id="move" class="active"><a href="#">Nawigacja</a></li><li id="route-points-draw"><a title="Rysuj trasę" href="#">Edycja trasy</a></li><li id="markers-draw"><a title="Dodaj punkt" href="#">Edycja punktów</a></li><li id="clear-map"><a title="Wyczyść mapę" href="#">Wyczyść mapę</a></li></ul>').appendTo('#route-map').find('a').click(function(event){
						$(this).parent('li').addClass('active').siblings('li').removeClass('active');
							event.preventDefault();
					});
					$('.map-toolbar #move a').click(function(){
						setMapMode('move');
					});
					$('.map-toolbar #route-points-draw a').click(function(){
						setMapMode('draw');
					});
					$('.map-toolbar #markers-draw a').click(function(){
						setMapMode('set');
					});
					$('.map-toolbar #clear-map a').click(function(){
						__modalShow();
						deleteLink = $(this).attr('href');
						$('.modal-box').load(HOST + '/ajax-content/route-edit-clear-map-confirm.php', function(){
							$(this).attr('id', 'delete-confirm').fadeIn('fast')
							.find('.content h2').after(modalBoxClose).end()
							.find('#modal-box-close, .no').click(function(){
								__modalHide();
								return false;
							}).end().find('.yes').click(function(){
								clearMap();
								__modalHide();
								return false;
							});
							$('.map-toolbar #move').addClass('active').siblings('li').removeClass('active');
							setMapMode('move');
						});
						return false;
					});
					$('.map-toolbar #route-points-draw a, .map-toolbar #markers-draw a, .map-toolbar #clear-map a').tooltip({track: true, delay: 0, showURL: false, showBody: " - ", extraClass: "map-toolbar-tooltip"});
				}
			});
		});
	}
	else {
		/*
			GOOGLE MAPS initializing
		*/
		if (typeof initialize == 'function'){initialize();}
	}	
	/*
		GALLERY carousel
	*/
	if ($('#mycarousel').size()){
		$('#mycarousel').append('<ul></ul>');
		var bindCarouselClick = function(carousel){
			$.getScript(HOST + '/pub/js/jquery.lightbox.js', function(){
				$('#mycarousel li a:not(".delete-entry")').lightBox(lightboxParams);
			});
			$('#mycarousel li a.delete-entry').each(function(){
				/*
					GALLERY ENTRY deleting
				*/
				$(this).click(function(){
					__modalShow();
					deleteLink = $(this).attr('href');
					$('.modal-box').load(HOST + '/ajax-content/photo-delete-confirm.php', function(){
						$(this).attr('id', 'delete-confirm').fadeIn('fast')
						.find('.content h2').after(modalBoxClose).end()
						.find('#modal-box-close, .no').click(function(){
							__modalHide();
							return false;
						}).end().find('.yes').click(function(){
							$.get(deleteLink, function(){
								__modalBoxHide();
								window.location.reload();
							});
							return false;
						});
					});
					return false;
				});
			});
			return false;
		};
		if ($('#your-favorites').size()){
			var xmlGalleryId = $('#gallery .entries').get(0).className.replace('entries user-', '');
			var xmlFilePath = HOST + '/include/plugins/structure/kross.all/controllers/KrossUserGalleryXmlGenerator.php';
		}
		else {
			var xmlGalleryId = $('#gallery .entries').get(0).className.replace('entries route-', '');
			var xmlFilePath = HOST + '/include/plugins/structure/kross.all/controllers/KrossRouteGalleryXmlGenerator.php';
		}
		$.getScript(HOST + '/pub/js/jquery.jcarousel.js', function(){
			function mycarousel_itemLoadCallback(carousel, state){
				if (carousel.has(carousel.first, carousel.last)) {return;}
				$.get(xmlFilePath, {first: carousel.first, last: carousel.last, uid: xmlGalleryId, rid: xmlGalleryId}, function(xml){
					mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
				}, 'xml');
			};
			function mycarousel_itemAddCallback(carousel, first, last, xml){
				carousel.size(parseInt($('total', xml).text()));
				$('image', xml).each(function(i){
					carousel.add(first + i, mycarousel_getItemHTML($('thumb', this).text(), $('full', this).text(), $('remove', this).text()));
				});
				bindCarouselClick(carousel);
			};
			function mycarousel_getItemHTML(thumb, full, remove){
				var item = '<a href="' + full + '"><img src="' + thumb + '" alt="" /></a>';
				if (isAuthorizedUser) {
					item += '<a class="delete-entry" href="' + remove + '">usuń</a>';
					$('.jcarousel-item').css({height: '97px'});
				}
				return item;
			};
			var isAuthorizedUser;
			$.get(xmlFilePath, {first: 1, last: 1, uid: xmlGalleryId, rid: xmlGalleryId}, function(xml){
				if (parseInt($('total', xml).text()) > 0){
					$('#mycarousel').jcarousel({itemLoadCallback: mycarousel_itemLoadCallback});
					isAuthorizedUser = ($('remove', xml).text() != '') ? true : false;
				}
				else {
					$('#mycarousel').html('<p>Brak zdjęć w galerii.</p>');
				}
			}, 'xml');
		});
	}
	/*
		ROUTE COMMENT validator
	*/
	$('#route-comments form').submit(function(){
		if ($('textarea', this).val() == '') {
			alert('Wprowadź treść opinii o trasie.');
			return false;
		}
	});
	/*
		TOOLTIP with username
	*/
	if ($('#promo #latest-users').size()){
		$.getScript(HOST + '/pub/js/jquery.tooltip.min.js', function(){
			$.getScript(HOST + '/pub/js/jquery.dimensions.min.js', function(){
				$('#promo #latest-users a').tooltip({track: true, delay: 0, showURL: false, showBody: " - "});
			});
		});
	}
	/*
		TOOLTIP with route-info
	*/
	if ($('#aside #route-data').size()){
		$.getScript(HOST + '/pub/js/jquery.tooltip.min.js', function(){
			$.getScript(HOST + '/pub/js/jquery.dimensions.min.js', function(){
				$('a.help').tooltip({track: true, delay: 0, showURL: false, showBody: " - ", extraClass: "help-tooltip"}).click(function(event){
					return false;
				});
			});
		});
	}
	/*
		SEARCH FOR ROUTE FORM state change
	*/
	var getURLparam = function(name){
		var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
		var results = regex.exec(window.location.href);
		results = (results == null) ? '' : results[1];
		return results;
	}
	if ($('#search-for-route form').size()){
		var pChange = function(regionId, selectedId){
			$('#search-for-route form #p').html('<option val="">Wczytywanie...</option>');
			$.get(HOST + '/include/plugins/structure/kross.all/controllers/KrossRouteRegionsAndStates.php?type=2&id=' + selectedId + '&sid=' + regionId, function(htmlOptions){
				if (htmlOptions != '')
					$('#search-for-route form #p').html(htmlOptions);
				else
					$('#search-for-route form #p').html('<option val="">Powiat</option>');
			});
		}
		$('#search-for-route form #w').change(function(){
			pChange($('option:selected', this).val(), '-1');
		});
		pChange($('#search-for-route form #w option:selected').val(), getURLparam('p'));
	}
	/*
		SEARCH FOR ROUTE FORM state change
	*/
	$('#state').change(function(){
		$('#region').load(HOST + '/include/plugins/structure/kross.all/controllers/KrossRegions.php?id='+$('option:selected', this).val());
	}); 
	/*
		AKCJA map flash inserting
	*/
	if ($('#flash-sklepy').size()){
		var so = new SWFObject(HOST + "/pub/uploadflash/kross_map_2.swf", "kross-map", "249", "239", "8", "");
		so.addParam("wmode", "transparent");
		so.addVariable('targetURL', HOST + '/skrossuj/lista-sklepow');
		so.write("flash-sklepy");
	}
	/*
		AKCJA flash mp3 player inserting
	*/
	$('.player').each(function(){
		$this = $(this);
		var so = new SWFObject(HOST + "/pub/uploadflash/mp3player.swf", "mp3player", "139", "44", "8", "");
		so.addVariable('mp3', $this.find('a').attr('href'));
		so.addVariable('playtrack', 'no');
		so.write($this.attr('id'));
	});
});
/*
	AKCJA kody sprzedawców
*/
function trim(text){return text.replace(/^\s*(.*?)\s*$/,"$1");}
function redirect(url){setTimeout('window.location.assign(\''+url+'\')',3000);}
var tablicaKod=new Array('200043','200008','201058','203349','200243','200132','203048','202428','203346','200009','200127','200020','200057','202557','201158','200033','200333','202600','200391','200206','200739','200306','200321','200379','200387','200287','200122','201030','200156','213528','202355','200310','200278','201003','201090','203031','200022','200220','200340','200003','203296','200507','200290','200247','200034','200308','202432','200014','201572','200117','200741','200152','201621','201706','200128','200913','200509','200085','201143','200193','200347','200889','201266','200388','201768','200257','202799','200036','201214','200080','200925','200274','200235','200018','200124','202356','200360','200070','200345','203029','200248','200180','202368','203102','200231','200138','200422','203792','202034','200445','202784','202019','200770','201271','200266','200250','200434','200181','200787','201120','200442','203790','200743','201757','200356','200337','201153','201593','200094','201584','200383','200366','200076','200452','200239','200165','200204','200431','200113','202029','200604','200393','200351','202822','200053','200255','200015','200039','200147','200108','200332','200024','200588','200935','200501','200972','201336','201161','201068','201623','202354','200170','203023','203683','200357','200157','200067','200568','201282','200041','200078','202780','200288','203210','200510','201569','201804','200238','200875','202225','200816','200782','201707','200436','201798','201276','201756','200603','203341','200947','200063','201280','200083','200219','200075','202348','200059','203098','200370','200148','200784','200225','200312','200593','200056','200866','203684','200411','200563','200062','200350','203047','200390','202972','200074','202018','202082','200808','201504','200023','200877','201227','200182','200572','200896','200914','202357','202560','200598','201456','201002','200251','201295','201590','200574','200564','203798','201249','200348','200105','200045','201714','201360','200448','202039','200174','202628','200508','203801','200776','200046','203830','202853','200042','201379','201806','200245','203823','201274','203821','200843','200123','201602','200342','200295','200322','203820','213524','203686','203825','200395','201563','200514','202436','200372','203400','200264','203835','203841','201454','203610','201367','202403','201626','201340','201755');