		var active = 2;
		var activ = 1;
		var animateTimer = 0;
		var img = 0;
		var nav = 0;
		var title = new Array();
		var desc = new Array();
		var banner = 0;
		var play = 1;
		var image = new Array();
		var points = new Array();
		var blockPoints = false;
		var czyPrzewijac = true;
		
		function rebuild(what) {
			if(what == 'banner') {
			nav = $('.navigator li').each( function (i) {
					this.index = i;
				});
			
			img = $('#images img').each( function (i) {
					this.index = i;
				});
				
			banner = $('.banner').each( function (i) {
					this.index = i;
				});
				
			cat_nav = $('header nav ul li').each(function (i) {
					this.index = i;
					this.subcat = $(this).children('div').children('div');
				});
				
			}
			
			else if(what == 'point') {
				
			point = $('.point').each( function (i) {
					this.index = i;
					$(this).mouseenter( function () {
						if(!blockPoints) {
						$(this).children('.figure').css('display','block');
						$(this).children('.figcaption').css('display','block');	
						$(this).css("zIndex","1000");
						$(this).animate({width:166,height:200},200, function() {
							$(this).css("zIndex","1000");
							$(this).css('width','166px');
							$(this).css('height','200px');
							$(this).children('figure').fadeIn('fast',function() {
								$(this).css("zIndex","1000");
								$(this).css('display','block');
								blockPoints = true;
								});
							});
						
						}
						else {
							$(point).children('figure').fadeOut('fast', function() {
								$(point).children('figure').css("zIndex","999");
								$(point).css('width','0px');
								$(point).css('height','0px');
								$(point).children('figure').css('display','none');
								$(point).css("zIndex","999");
								blockPoints = false;
							});
							$(this).css("zIndex","1000");
							$(this).children('.figure').css('display','block');
							$(this).children('.figcaption').css('display','block');
							$(this).animate({width:166,height:200},200, function() {
								$(this).css("zIndex","1000");
								$(this).css('width','166px');
								$(this).css('height','200px');
								$(this).children('figure').fadeIn('fast',function() {
									$(this).css("zIndex","1000");
									$(this).css('display','block');
									blockPoints = true;
									});
								});
							
						}
					}).mouseleave( function () {
						if(blockPoints) {
						//$(this).delay(200).queue( function() {
							$(this).children('figure').fadeOut('fast', function() {
								$(this).css('display','none');
								$(this).css("zIndex","999");
								$(this).parent('div').animate({width:0,height:0},200, function() {
									$(this).css('width','0px');
									$(this).css('height','0px');
									$(this).children('figure').css('display','none');
									$(this).children('.figure').css('display','none');
									$(this).children('.figcaption').css('display','none');
									$(this).css("zIndex","999");
									blockPoints = false;
								});
							});
						//});
						
						}
						else {

							/*
							$(this).delay(200).queue( function() {
							$(this).children('figure').fadeOut('fast', function() {
								$(this).css('display','none');
								$(this).css("zIndex","999");
								$(this).parent('div').animate({width:0,height:0},200, function() {
									$(this).css('width','0px');
									$(this).css('height','0px');
									$(this).children('figure').css('display','none');
									$(this).css("zIndex","999");
									blockPoints = false;
									});
								});
							});
							*/
							
							}
					});
				});
			}
			
		}
		
		function activeImage(active, size, activ) {
					$('#images').html('');
									
					$('#images').append($(img[0]));
					$('#images').append($(img[size-active]));
					$('#images').append($(img[size-activ]));
					
					$(img).css('display','none');
					$(img[0]).css('display','block');
					$(img).css('opacity','1');
					$(nav).attr('class','');
					$(nav[size-1]).attr('class','no_border');
					
					for(var i=0; i!=points.length; i++)
						{
							var point = points[i];
							if(point[0] == active) {
								var qweqweqwe = '<a href="'+ point[5] +'"><div class="point" style="top:'+(point[1]-5)+'px;left:'+(point[2]-5)+'px"><img src="'+BASEURL+'pub/gfx/default/point.png" /><figure style="display:none"><img class="figure" style="max-width: 151px; max-height: 151px;" src="'+point[3]+'" /><figcaption><div class="figcaption">'+point[4]+'</div></figcaption></figure></div></a>';
								$('#images').append(qweqweqwe);
							}
						}
					
					if(active-1 == size-1) $(nav[active-1]).attr('class','active no_border');
					else $(nav[active-1]).attr('class','active');
					
					$('.slogan').html(title[(active-1)] + '<div class="color">' + desc[(active-1)] + '</div>');
					
					$(img[size-activ]).css('display','block');
				    $(img[size-active]).css('display','block');
					
					$(img[size-activ]).animate({opacity:0},1000, function() {
					$(img[size-activ]).css('display','none');
					});
					rebuild('point');
					//activePoints();
					return active;
					
				}
				
		function aTimer(time) { 
					if(play) {
					animateTimer++;
	  				if(!(animateTimer%10)) activ = activeImage(active++, img.length, activ);
	  				if(active > img.length) {
	  					active = 1;
	  				}
	  				}
	  				setTimeout("aTimer(500)",time); 
	  	}
		
		
		
		
		$(document).ready(function() {
				
				
				for(var i = 0; i != image.length; i++) {
				
					if(!i) $('.navigator').append('<li class="active"></li>');
					else if(i == image.length-1) $('.navigator').append('<li class="no_border"></li>');
					else $('.navigator').append('<li></li>');
					/* Default ( width="986" height="453" ) */
					if(!i) $('#images').prepend('<img width="640" height="480" src="' + image[i] + '" />');
					else $('#images').prepend('<img style="display:none" width="640" height="480" src="' + image[i] + '" />');
					
					}
				
				$('.slogan').html(title[0] + '<div class="color">' + desc[0] + '</div>');
				
				rebuild('banner');
				activeImage(1,image.length,0);
				if(czyPrzewijac) aTimer();
				
				$(banner).mouseenter( function () {
					play = 0;
				}).mouseleave( function () {
					//play = 1;
				});
				
				$(nav).click( function () {
					activ = activeImage((this.index+1), img.length, activ);
					active = this.index+2;
				});
				
				$(cat_nav).mouseenter( function () {
					this.subcat.show('fast');
				}).mouseleave( function () {
					this.subcat.hide('fast');
				});
			
		});
		
		function login_reminder() {
			var offset = $('.user').offset();
			var body_w = $('body').width();
			var body_h = $('body').height();
			var user_w = $('.user').width();
			var html_h = $('html').height();
			
			if(html_h) shadow_h = html_h;
			else shadow_h = body_h;
			
			var left_pos = ( body_w / 2 ) - ( user_w / 2 );
			
			$(window).scrollTop(0);
			
			$('body').append('<div id="shadow" style="opacity: 0; z-index: 9998; display: block; position: absolute; top: 0px; left: 0px; width: 100%; height: '+shadow_h+'px; background: url('+ BASEURL +'pub/gfx/default/shadow.png) repeat;">');
			
			$('#shadow').animate({opacity: '1'}, 'slow');
			
			$('.user').css('top',offset.top);
			$('.user').css('left',offset.left);
			$('.user').css('position','fixed');
			$('.user').css('zIndex','9999');
			$('.user').animate({
				top: '200px',
				left: left_pos + 'px'
					},'slow');
			
			$(window).scroll( function () {
				scrollUp(true);
			});
			
			$('#shadow').click( function () {
				$(window).scrollTop(0);
				$('#shadow').animate({opacity: '0'}, 'slow', function() { $('#shadow').remove();});
				$('.user').animate(
					{top: offset.top + 'px',
					left: offset.left + 'px'},
				'slow',function(){ $('.user').css('position','static'); $('.user').css('zIndex','auto'); } );
				$(window).scroll( function () {
					scrollUp(false);
				});
			});
		}
		
		function scrollUp(block) {
			//if(block) $(window).scrollTop(0);
			
		}
		
	 
