Site = {
	MainMenu: function() {
		$('#header .tab-center:not(.active-tab-center)').bind('mouseenter', function() {
			$(this).addClass('active-tab-center')
				.prev()
				.addClass('active-tab-left')
				.end()
				.next()
				.addClass('active-tab-right');
		})
		
		.bind('mouseleave', function() { 
			$(this).removeClass('active-tab-center')
				.prev()
				.removeClass('active-tab-left')
				.end()
				.next()
				.removeClass('active-tab-right');
		});
	},

	SideMenu: function() {
		$('#content-left h3 a').click(function() {
			if (!$(this).parent().hasClass('active')) {
				$('#content-left h3.active')
					.siblings('a')
					.hide('normal')
					.removeClass('active')
					.end()
					.removeClass('active')
					.find('img')
					.attr('src', 'common/img/small_arrow_collapsed.gif');
					
				$(this).parent()
					.addClass('active')
					.find('img')
					.attr('src', 'common/img/small_arrow_expanded.gif')
					.parents('.menu-category')
					.children('a')
					.show('normal')
					.addClass('active');
			}
			
			return false;
		});
		
		$('#content-left .menu-category a').click(function() {
			$(this).next('.menu-inner').find('a').toggleClass('active');
			return false;
		});
	},
	
	InfoBox: function() {
		var links = $('#info-top a');
		var pictures = $('#info-content img');
		var contents = $('#box-content > div');
	
		links.click(function() {
			pictures.removeClass('active');
			
			contents.removeClass('box-content-active');
			contents.addClass('box-content-inactive');
			
			$('#' + this.id + '-picture').addClass('active');
			$('#' + this.id + '-box').removeClass('box-content-inactive');
			$('#' + this.id + '-box').addClass('box-content-active');
			return false;
		});
	},
	
	Buttons: function() {
		$('.button').hover(function() {
			var src = $(this).attr('src');
			$(this).attr('src', src.replace('.gif', '_active.gif'));
		},
		
		function() {
			var src = $(this).attr('src');
			$(this).attr('src', src.replace('_active.gif', '.gif'));
		});
	},
	
	Footer: function() {
		$('a.more').toggle(
			function() {	
				$(this).parents('#footer-box')
					.css('background-position', '0 -43px')
					.height('142px')
					.find('#footer-separator, #footer-links')
					.show();
				
				return false;
			},
			
			function() {
				$(this).parents('#footer-box')
					.css('background-position', '0 0')
					.height('32px')
					.find('#footer-separator, #footer-links')
					.hide();
				
				return false;
			}
		);
	},
	
	FancyBox: function() {
		$('a.fancy-box').fancybox({
			hideOnContentClick: true
		});
	},
	
	Checkboxes: function() {
		$("#content-right input.input-radio").CheckImg('checkbox_inactive.gif', 'checkbox_active.gif', 'common/img/');
		$("#news input.input-radio").CheckImg('checkbox_inactive.gif', 'checkbox_active.gif', 'common/img/');
	},
	
	SliderNews: function() {
		$("#nowosci").jCarouselLite({
		btnNext: "#news-left",
		btnPrev: "#news-right",
		mouseWheel: false,
		auto: 3000,
		speed: 500,
		//easing: "linear",
		//easing: "easein",
		easing: "easeout",
		//easing: "easeinout",
		//easing: "expoin",
		//easing: "expoout",
		//easing: "expoinout",
		//easing: "bounceout",
		//easing: "bouncein",
		//easing: "bounceinout",
		//easing: "elasin",
		//easing: "elasout",
		//easing: "elasinout",
		//easing: "backin",
		//easing: "backout",
		//easing: "backinout",
		visible: 5,
		vertical: false,
		circular: true,
		start: 0,
		scroll: 1,
		beforeStart: function(a) {
			//alert("Before animation starts:" + a);
		},
		afterEnd: function(a) {
			//alert("After animation ends:" + a);
	   	}
		});
	},
		
	SliderPromo1: function() {
		$("#promocje").jCarouselLite({
		btnNext: "#promo-left",
		btnPrev: "#promo-right",
		mouseWheel: false,
		/*autoneg: 7000,*/
		speed: 500,
		//easing: "linear",
		//easing: "easein",
		//easing: "easeout",
		//easing: "easeinout",
		//easing: "expoin",
		//easing: "expoout",
		//easing: "expoinout",
		//easing: "bounceout",
		//easing: "bouncein",
		//easing: "bounceinout",
		//easing: "elasin",
		//easing: "elasout",
		//easing: "elasinout",
		easing: "backin",
		//easing: "backout",
		//easing: "backinout",
		visible: 2,
		vertical: false,
		circular: true,
		start: 0,
		scroll: 1,
		beforeStart: function(a) {
			//alert("Before animation starts:" + a);
		},
		afterEnd: function(a) {
			//alert("After animation ends:" + a);
	   	}
		});
	},
		
	SliderPromo2: function() {
		$("#promocje2").jCarouselLite({
		btnNext: "#promo-left",
		btnPrev: "#promo-right",
		mouseWheel: false,
		/*autoneg: 7000,*/
		speed: 500,
		//easing: "linear",
		//easing: "easein",
		//easing: "easeout",
		//easing: "easeinout",
		//easing: "expoin",
		//easing: "expoout",
		//easing: "expoinout",
		//easing: "bounceout",
		//easing: "bouncein",
		//easing: "bounceinout",
		//easing: "elasin",
		//easing: "elasout",
		//easing: "elasinout",
		easing: "backin",
		//easing: "backout",
		//easing: "backinout",
		visible: 2,
		vertical: false,
		circular: true,
		start: 0,
		scroll: 1,
		beforeStart: function(a) {
			//alert("Before animation starts:" + a);
		},
		afterEnd: function(a) {
			//alert("After animation ends:" + a);
		}
		});
	},
	
	SliderTop10: function(count) {
		$("#top10_slide").jCarouselLite({
		btnNext: "#top10-up",
		btnPrev: "#top10-down",
		mouseWheel: false,
		speed: 500,
		easing: "easeout",
		visible: count,
		vertical: true,
		circular: true,
		start: 0,
		scroll: 1
		});
	},

	run: function() {
		this.MainMenu();
		//this.SideMenu();
		this.InfoBox();
		this.Buttons();
		this.Footer();
		this.FancyBox();
		this.Checkboxes();
		this.SliderNews();
		this.SliderPromo1();
		this.SliderPromo2();
		
		var useragent = navigator.userAgent;
		var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
		var pos = useragent.indexOf('MSIE');
		if (pos > -1) {
		bVer = useragent.substring(pos + 5);
		var pos = bVer.indexOf(';');
		var bVer = bVer.substring(0,pos);
		}
		var pos = useragent.indexOf('Opera');
		if (pos > -1)	{
		bVer = useragent.substring(pos + 6);
		var pos = bVer.indexOf(' ');
		var bVer = bVer.substring(0, pos);
		}
		if (bName == "Netscape") {
		var bVer = useragent.substring(8);
		var pos = bVer.indexOf(' ');
		var bVer = bVer.substring(0, pos);
		}
		if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
		var pos = useragent.lastIndexOf('/');
		var bVer = useragent.substring(pos + 1);
		}
		
		if(bVer == "6.0")
		{
			cnt = 5;
		}
		else if(bVer == "7.0")
		{
			cnt = 6;
		}
		else
		{
			cnt = 6;
		}
		
		this.SliderTop10(cnt);
	}
}

$(function() {
	Site.run();
	
	
});