$(document).ready(function()
{

    $('a[rel=external]').click(function(){
		window.open(this.href);
		
		return false;
	});

	$("a[rel='colorbox']").colorbox({
        current: "{current} ({total})",
		maxWidth: '90%',
		maxHeight: '90%'
	});

	
	$('a[href^=#]').each(function(i){
		$(this).attr('href', location.href+$(this).attr('href'));
	});

	
	Cufon.now();
	Cufon.replace('.cw1 .winner_nick, .cw1 .winner_title, .cw1 .w2 div, .cw1 .w4, .cw1 .w3 label, .cw5 #flashMessage, .mw1 .footer li, .content .footer li', {fontFamily: 'cooper', hover: true});	
		
	if($('.cw1 .w2').length)
		$('.cw1 .w2').jScrollPane();
	

	
	
//##############################################################
//soczyste ciekawostki

	Cufon.replace('.cw3 dt .t', {fontFamily: 'cooper', hover: true});
	
	if($('.cw3 .w').length)
		$('.cw3 .w').jScrollPane();

	
	$('.cw3 dt').live('click', function()
	{
		if(!($(this).is('.active')))
		{
			$('.arrowdown', this).addClass('arrowup');
		
			$(this).parents('dl').siblings('dl').hide();
			$(this).next('dd').fadeIn();
			
			$('.cw3 .w').jScrollPane();
			
			$('.cw3').after('<div class="cw3back"><a href="#" onclick="return false"></a></div>');
		}
	
		$(this).addClass('active');		
	});
	
	
	$('.cw3back, .cw3 dt.active').live('click', function() 
	{
		$('.cw3 dl').show();
		$('.cw3 dt').removeClass('active').find('.arrowdown').removeClass('arrowup');
		$('.cw3 dd').hide();
		$('.cw3back').remove();
				
		$('.cw3 .w').jScrollPane();		
		
		if (typeof event!='undefined')
		event.returnValue=false;
	});
	
	
//##############################################################
//popup

	
	$('.footer .recommend').click(function()
	{
		$('.content, .mw1').append('<div class="cw5bg"><div class="cw5main"><iframe src="'+$(this).attr('href')+'" width="357" height="457" scrolling="no" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0"></iframe><div class="closebox"></div></div></div>')
		
		return false;
	});
	
	$('.cw5bg .closebox').live('click', function()
	{
		$('.cw5bg').remove();
	});
	
	$('.cw5 .w1 label').bind('click', function()
	{
		$(this).hide().siblings('input').focus();
	});
	
	$('.cw5 .w1 input').bind('focus', function()
	{
		$(this).siblings('label').hide();
	});

});
