$(window).load(function () {
	$('#tabs_menu').tabs('#tabs > .tabs_content', {
		event:'click', 
		effect: "fade", 
		fadeInSpeed: "100"
	}).history();	
	var api = $("#tabs_menu").tabs();
	
	if (api.onBeforeClick) {
	
		api.onBeforeClick(function(index) {
			this.getCurrentTab().parent().removeClass('current');
			
		});	
			
		api.onClick(function(index) {
			var color = this.getCurrentTab().css("border-top-color");
			//alert(index);
			//alert(this.getCurrentTab().parent().parent().html());
			//alert(this.getTabs().eq(index));
			/*
			var string = "";
			$.each(index.target, function(i, val) {
			      if (typeof(val) != 'function') {
				  	string += (" - " + i + "." + val + "\r\n");
				  }
			});
			*/
			this.getCurrentTab().parent().parent().css("border-bottom-color", color);
			this.getCurrentTab().parent().addClass('current');
			
		});
		
	}
	
	
	$('#col_main.details .offer_options li .content').hide();
	$('#col_main.details .offer_options.digital li .content').show();
	$('#col_main.details .offer_options li .toggle').css('display', 'block');
	
	$('.promoSubscription.gift').hide();
	$('.promoSubscription.chooseGift').click(function () {
		$('.promoSubscription.gift').slideToggle('slow');
	});
	
	$('.toggle').click(function() {
		if ($(this).hasClass('selected')) {
			$(this).text('rozwiń ofertę');
		} else {
			$(this).text('zwiń ofertę');
		}
		$(this).next().next().slideToggle('slow');
		$(this).toggleClass('selected');
		return false;
	});
	
	$('.toggle').eq(0).click();
	$('.firstDigitalSubscription').click();
	
	$('.toggle_gift').click(function() {
		if ($(this).hasClass('selected')) {
			$(this).text('szczegóły');
		} else {
			$(this).text('ukryj szczegóły');
		}
		$(this).parent().next().slideToggle('slow');
		$(this).toggleClass('selected');
		return false;
	});	
		
	$('#extra_articles').pajinate({
		items_per_page : 5,
		item_container_id : '.filelist',
		nav_label_last : '&raquo;',
		nav_label_first : '&laquo;',
		nav_label_next : '&gt;',
		nav_label_prev : '&lt;',
		num_page_links_to_display: 20
	});
	

	$('#extra_files').pajinate({
		items_per_page : 5,
		item_container_id : '.filelist',
		nav_label_last : '&raquo;',
		nav_label_first : '&laquo;',
		nav_label_next : '&gt;',
		nav_label_prev : '&lt;',
		num_page_links_to_display: 20	
	});
	
	$('.full_offer').click(function () {
		$.scrollTo(500, {axis: 'y', easing:'elasout'});
		//scrollTo(0, 500);
	});
	
	$("#dialog-message").dialog({
		resizable: false,
		modal: true,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});

});