function getAJAX(element, div_id) {
	if (div_id == null)
		div_id = 'ajaxDIV';

	$.ajax({
		type: "POST",
		url: $(element).attr('href'),
		data: "ajax=true",
		async: true,
		success: function(msg) {
			$('#' + div_id).html(msg);
		}
	});
	return false;	
}
function slideAJAX(element, div_id) {
	$('#' + div_id).slideUp('slow', function() {
		getAJAX(element, div_id);
		$('#' + div_id).slideDown();
	});
	return false;
}


function toggleEditor(id) {
	if (!tinyMCE.getInstanceById(id))
		tinyMCE.execCommand('mceAddControl', false, id);
	else
		tinyMCE.execCommand('mceRemoveControl', false, id);
	return false;
}

function advertisementClick(id) {
	window.open('/advertisement/reload/' + id);
	return false;
}

  
$(document).ready(function() {
	//submenu
	$('.menubox-ins ul.subtabs li').click(function() {
		if ($(this).hasClass('active'))
		   return false;
		
		$(this).parent().find('li').removeClass('active');
		$(this).addClass('active');
		index = $(this).parents('.menubox-ins ul.subtabs').find('li').index($(this));
		$(this).parents('.menubox-ins').find('.stab').hide();
		$(this).parents('.menubox-ins').find('.stab').eq(index).show();
	});
	
	//czerwone menu
	$('.menubox-ins.tabs ul.tabs li').click(function() {
		if ($(this).hasClass('active'))
		   return false;
		$(this).parent().find('li').removeClass('active');
		$(this).addClass('active');
		index = $(this).parent().find('li').index($(this));
		$(this).parents('.menubox-ins').find('.tab').hide();
		$(this).parents('.menubox-ins').find('.tab').eq(index).show();
	});
	
	//lewe menu
	$('.ltabs ul.ltabs li').click(function() {
		if ($(this).hasClass('active'))
		   return false;
		$(this).parent().find('li').removeClass('active');
		$(this).addClass('active');
		index = $(this).parent().find('li').index($(this));
		$(this).parents('div.ltabs').find('.tab').hide();
		$(this).parents('div.ltabs').find('.tab').eq(index).show();
	});
	
	
	$('#top .baner').mousemove(function(event) {
      $('.info_cloud').css({ top: event.pageY + 2, left: event.pageX +2 });
      if (!$('.info_cloud').is(":visible"))
			$('.info_cloud').show();
	});
	$('#top .baner').mouseleave(function() {
		$('.info_cloud').hide();
	});
	
	$('#news_size .s1').click(function() {
		$('#news_content').css('font-size', '11px' );
		return false;
	});
	$('#news_size .s2').click(function() {
		$('#news_content').css('font-size', '16px' );
		return false;
	});
	$('#news_size .s3').click(function() {
		$('#news_content').css('font-size', '22px' );
		return false;
	});
	$('#a_more_buttons').click(function() {
		$('div.buttons_more').slideToggle();
		$(this).html($(this).html() == 'Pokaż wszystkie buttony' ? 'Ukryj buttony' : 'Pokaż wszystkie buttony');
		return false;
	});
	$('#top-search input.text').focus(function() {
		if ($(this).val() == 'wpisz fraze')
			$(this).val('');
	});
	$('#top-search input.text').blur(function() {
		if ($(this).val() == '')
			$(this).val('wpisz fraze');
	});
	$('#live_results').ready(function() {
		$.ajax({
			type: "POST",
			url: '/live.php',
			data: "ajax=true",
			async: true,
			success: function(msg) {
				$('#live_results').html(msg);
			}
		});
	});
	var t;
	$('.shout_nav .top').hover(function() {
		t = setInterval(function() {$('#shoutBox').scrollTop($('#shoutBox').scrollTop() - 1); }, 10);
	}, function() { clearInterval(t) });
	$('.shout_nav .bottom').hover(function() {
		t = setInterval(function() {$('#shoutBox').scrollTop($('#shoutBox').scrollTop() + 1); }, 10);
	}, function() { clearInterval(t) });
	
	
});
function usercontextmenu(id, name) {
	$('.userFriends a').attr('href', '/znajomi/' + id);
	$('.userProfile a').attr('href', '/profil/' + id + '-' + name);
	$('.userPw a').attr('href', '/pw/wyslij/' + id);
	$('.userForumProfile a').attr('href', 'http://forum.gunners.com.pl/profile.php?mode=viewprofile&u=' + id);
	return false;
}

