﻿var reklama_page = 0;
var posty_page = 0;
var galeria_page = 0;
jQuery(document).ready(function(){
	jQuery('.reklama-nav .arrow_up').click(function(){
		if(reklama_page > 0){
			load_buttons(reklama_page-1);	
		}
	});
	jQuery('.reklama-nav .arrow_down').click(function(){
		load_buttons(reklama_page+1);	
	});
	jQuery('.T-panel2 .arrow_b_up').click(function(){
		if(galeria_page > 0){
			load_photos(galeria_page-1);	
		}
	});
	jQuery('.T-panel2 .arrow_b_down').click(function(){
		load_photos(galeria_page+1);	
	});
	jQuery('.T-panel3 .arrow_s_up').click(function(){
		if(posty_page > 0){
			load_posts(posty_page-1);	
		}
	});
	jQuery('.T-panel3 .arrow_s_down').click(function(){
		load_posts(posty_page+1);	
	});
	jQuery('.a-shoutbox-inp input').focus(function(){
		var sb_val_o = jQuery(this).val();
		if(sb_val_o == "Musisz zalogować się, aby móc dodać wiadomość." || sb_val_o == "Wpisz wiadomość."){
			jQuery(this).val('');
		}
	});
	jQuery('.T-info-log input').focus(function(){
		var log_val_o = jQuery(this).val();
		if(log_val_o == "Login" || log_val_o == "Hasło"){
			jQuery(this).val('');
		}
	});
	set_buttons_css();
});

function set_buttons_css(){
	jQuery('.reklama-btn img').css('opacity', 0.2).hover(function(){
		jQuery(this).css('opacity', 1);
	}, function(){
		jQuery(this).css('opacity', 0.2);
	});
};

function load_buttons(id){
	jQuery.post(BASE + "infusions/reklama_panel/reklama_panel_data.php", { page: id },
  	function(data, status){
		if(status == "success" && data != ""){
			jQuery('.reklama-btn').animate({opacity: 0}, "normal", function(){
			   jQuery(this).html(data);
			   set_buttons_css();
			   jQuery(this).animate({opacity: 1}, "normal");
			});
			reklama_page = id;
		}
  	}, "html");
};

function load_posts(id){
	jQuery.post(BASE + "themes/berserkfan/panels/ostatnie_posty_data.php", { page: id },
  	function(data, status){
		if(status == "success" && data != ""){
			jQuery('.T-panel3 .T-panel-m').animate({opacity: 0}, "normal", function(){
			   jQuery(this).html(data);
			   jQuery(this).animate({opacity: 1}, "normal");
			});
			posty_page = id;
		}
  	}, "html");
};

function load_photos(id){
	jQuery.post(BASE + "themes/berserkfan/panels/losowe_fan_arty_data.php", { page: id },
  	function(data, status){
		if(status == "success" && data != ""){
			jQuery('.T-panel2 .fan-img').animate({opacity: 0}, "normal", function(){
			   jQuery(this).html(data);
			   jQuery(this).animate({opacity: 1}, "normal");
			});
			galeria_page = id;
		}
  	}, "html");
};