function maxHeight (selector) {
	var maxHeight = null;
	
	$(selector).each(function() {
		if(null==maxHeight) {
			maxHeight = $(this).innerHeight();
		} else {
			if($(this).innerHeight() > maxHeight) {
				maxHeight = $(this).innerHeight();
			}
		}
	});
	
	return maxHeight;
}


$(document).ready(function() {
	
	if(Theme == 1) {
		
		Cufon.replace('#menu > ul > li > a, #header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #b96413',
			hover: true
		});
		
		$("html").css('background','#c7591c url("_tematy/domyslny/images/bg/bg.jpg") no-repeat top center');
		
		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #000000',
			hover: true
		}); 
		
	} else if(Theme == 2) {
		
		Cufon.replace('#menu > ul > li > a', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #fff',
			hover: true
		}); 
		
		Cufon.replace('#header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #34591b',
			hover: true
		}); 
		
		$("html").css('background','#b5d6df url("_tematy/domyslny/images/bg/bg_theme_2.jpg") no-repeat top center');
		
		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #1d618a',
			hover: true
		}); 
		
	} else if(Theme == 3) {
		
		Cufon.replace('#menu > ul > li > a, #header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #b96413',
			hover: true
		});
		
		$("html").css('background','#2a0f08 url("_tematy/domyslny/images/bg/bg_theme_3.jpg") no-repeat top center');
		
		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #000000',
			hover: true
		}); 
		
	} else if(Theme == 4) {
		
		Cufon.replace('#menu > ul > li > a, #header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #57290f',
			hover: true
		});
		
		$("html").css('background','#2d1a0b url("_tematy/domyslny/images/bg/bg_theme_4.jpg") no-repeat top center');

		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #000000',
			hover: true
		}); 
		
	} else if(Theme == 5) {
		
		Cufon.replace('#menu > ul > li > a', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #fff',
			hover: true
		}); 
		
		Cufon.replace('#header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-0px 0px 0px #000',
			hover: true
		}); 
		
		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #fff',
			hover: true
		}); 
		
	} else {
		
		Cufon.replace('#menu > ul > li > a, #header #menu ul li.offer > div .item h5', { 
			fontFamily: 'Verdana Bold',
			textShadow: '-1px 1px 0px #b96413',
			hover: true
		}); 
		
		Cufon.replace('h2', { 
			fontFamily: 'Verdana Bold',
			textShadow: '1px 1px 0 #000000',
			hover: true
		}); 
		
	}

	Cufon.replace('.SiecSprzedazyWyszukiwarka h3', { 
		fontFamily: 'Verdana Bold',
		textShadow: '1px 1px 0 #000000',
		hover: true
	}); 
	
	Cufon.replace('#shops_list h3, #shops_list h4, #promo_shops h3, #promo_shops h4', { 
		fontFamily: 'Verdana Bold',
		textShadow: '1px 1px 0 #fff',
		hover: true
	}); 

	Cufon.replace('.Subpage_header ul.categories li a', {
		fontFamily: 'Georgia Bold Italic',
		hover: true
	});

	Cufon.replace('.Subpage_header ul.tabs li a', {
		fontFamily: 'Georgia Regular Italic',
		hover: true
	});
	
	Cufon.replace('.products .item .price', { 
		fontFamily: 'Arial Bold',
		hover: true
	});
	
	Cufon.replace('#Banners .Wrapper ul li div .caption h4', { 
		fontFamily: 'Verdana Bold',
		hover: true
	});
	


	$("#menu ul").jessmenu({
		delay: 200,
		hoverClass: 'hover',
		arrows: false,
		animation: 'fade'
	});
	
	// dodaj sugestie
	$("a#Dodaj_sugestie, a#Zglos_blad").fancybox({
		'hideOnContentClick': false,
		'autoDimensions'	: false,
		'width'         	: 330,
		'height'			: 290,
		'padding'			: 0,
		'type'				: 'ajax'

	});
	
	// Tabs
	//$("#Top_videos_tabs").tabs();

	// Banners
	$("#Banners .Wrapper ul li:odd").addClass("odd");
	
	// Footer
	$("footer .Wrapper .infobox .links ul:first-child").addClass("first");
	$("footer .Wrapper .infobox .links ul:last-child").addClass("last");

	
	$('#Featured_products .inside > ul').bxSlider({
		displaySlideQty: 3,
		moveSlideQty: 1,
		controls: true,
        pager: false
	});
	
	$('#Partners_offer .inside > ul').bxSlider({
		displaySlideQty: 4,
		moveSlideQty: 1,
		controls: true,
        pager: false
	});

	
	$("#Banners .Wrapper ul li").hover( function() {
		$("div.banner", this).addClass("hover");
		$(".caption", this).animate({ top: '0px' }, { queue: false, duration: 100 });
		$(".caption h4", this).animate({ top: '15px' }, { queue: false, duration: 300 });
		$(".caption p", this).animate({ top: '40px' }, { queue: false, duration: 200 });
		$(".caption a.more", this).fadeIn(1000);
	}, function() {
		$("div.banner", this).removeClass("hover");
		$(".caption", this).animate({ top: '-129px' }, { queue: false, duration: 100 });
		$(".caption h4", this).animate({ top: '-129px' }, { queue: false, duration: 300 });
		$(".caption p", this).animate({ top: '-129px' }, { queue: false, duration: 300 });
		$(".caption a.more", this).fadeOut(300);
	});
	
	
    $('#Facebook_box').hover(function(){
    	$('#Facebook_box').stop(true,false).animate({marginRight: 270}, 500);
	},function(){
		$('#Facebook_box').stop(true,false).animate({marginRight: 0}, 500);
	});
	
    $("table tr:odd").addClass("odd");
    
    $('a.fancybox').fancybox();

});

