function checkForm()
{
	var send = true;
	$('.cw3 .w6 table').each(function(){
			

		var len = $(this).find('tbody tr',this).length;
		var v1 = $('.vote-1', this).is(':checked');
		var v2 = $('.vote-2', this).is(':checked');
		var v3 = $('.vote-3', this).is(':checked');
		var v = $('.vote-none', this).is(':checked');
		
		if(len==1)
		{
			$('.error', this).hide();
			if(v || v1)
			{
				$('.error', this).hide();
				//$(this).parents('dd').prev('dt').removeClass('selected');
				//$(this).parents('dd').animate({'opacity':'0'}).hide();
			}
			else
			{
				$('tfoot tr.error', this).show();
				$(this).parents('dd').prev('dt').addClass('selected');
				$(this).parents('dd').animate({'opacity':'1'}).show();
				send = false;
			}
		}
		
		if(len==2)
		{
			$('.error', this).hide();
			if(v || (v1 && v2))
			{
				$('.error', this).hide();
				//$(this).parents('dd').prev('dt').removeClass('selected');
				//$(this).parents('dd').animate({'opacity':'0'}).hide();
			}
			else
			{
				$('tfoot tr.error', this).show();
				$(this).parents('dd').prev('dt').addClass('selected');
				$(this).parents('dd').animate({'opacity':'1'}).show();
				
				send = false;
			}
		}
		else if(len>2)
		{
			
			$('.error', this).hide();
			if(v || (v1 && v2 && v3))
			{
				$('.error', this).hide();
				//$(this).parents('dd').prev('dt').removeClass('selected');
				//$(this).parents('dd').animate({'opacity':'0'}).hide();
			}
			else
			{
				$('tfoot tr.error', this).show();
				$(this).parents('dd').prev('dt').addClass('selected');
				$(this).parents('dd').animate({'opacity':'1'}).show();
				send = false;
			}
		}
			
	});
	
	return send;
};



$(document).ready(function(){

	$('a[rel=external]').click(function(){
		window.open(this.href);
		
		return false;
	});
	
	$('.facebook img').hover(
		function(){$(this).attr('src', 'img/l-facebook-active.gif');}, 
		function(){$(this).attr('src', 'img/l-facebook.gif');}
	);
	$('.flickr img').hover(
		function(){$(this).attr('src', 'img/l-flickr-active.gif');}, 
		function(){$(this).attr('src', 'img/l-flickr.gif');}
	);
	$('.youtube img').hover(
		function(){$(this).attr('src', 'img/l-youtube-active.gif');}, 
		function(){$(this).attr('src', 'img/l-youtube.gif');}
	);

	Cufon.replace('#top .c4 legend span, #top .c5 legend span, #menu li li a, #menu .date, .hw2 .w1 h2, .ch, .cw5 .nav a, .cw8 .nav a', {'font-family':'trajanpro', hover:true});
	
	
	
	
	$('#top .c4 .input:first label').click(function(){
		$(this).hide();
	});
	
	$('#top .c4 .input:last label').click(function(){
		$(this).hide();
	});
	
$('#top .c5 .input').click(function(){
		$('#NewsletterEmailError').hide();
	});
	
$('#top .c4 .input').click(function(){
		$('#UserUsernameError').hide();
	});	
	
	
	$('.cw1 hr').wrap('<div class="hr"></div>');
	
	if(!($('.cw1 img.imgrns').length)) {
		$('.cw1 img').not('.imgnoborder').wrap('<span class="img"></span>');
	};
	
	$('.cw1 h2, .cw1 h3').before('<div class="clear" style="height:0;">.</div>');
	
	if(!($('.cw1 img').is('.imgrns'))) {
		$('.cw1 img').parents('h2,h3,h4,h5,h6,p').before('<div class="clear">.</div>');
	}
	
});	



	
$(document).ready(function(){	
	
	$('.cw1 .toggle p.more').html('<img src="img/b-szczegoly.gif" alt="" />');
	$('.cw1 .toggle p.more').nextAll().wrap('<div class="hide"></div>');
	$('.cw1 .toggle p.more').nextAll().animate({'opacity': '0'}).hide();	

	
	$('.cw1 .toggle p.more img').click(function(){	
	
		$(this).parents('p.more').hide();
		
		$(this).parents('.toggle').find('.hide').animate({'height': 'toggle'}).animate({'opacity': '1'});
		
		$(this).parents('.toggle').append('<p class="less"><img src="img/b-zwin.gif" alt="" onclick="$(this).parents(\'.toggle\').find(\'.hide\').animate({\'opacity\': \'0\'}, 500).animate({\'height\': \'toggle\'}, 500);$(this).parents(\'.toggle\').find(\'.less\').hide();$(this).parents(\'.toggle\').find(\'.more\').fadeIn(2000);" /></p>');
		
	});
	
});




$(document).ready(function(){
	
	$('.cw3 > dl > dd.roll').animate({'opacity':'0'}).hide();
	
	$('.cw3 > dl > dt').toggle(function(){
		$(this).addClass('selected');
		$(this).next('dd').animate({'opacity':'1'}, 700).show();
	}, function(){
		$(this).removeClass();
		$(this).next('dd').animate({'opacity':'0'}).hide();
	});	
	
	
	
	$('.cw3 .w6 table').each(function(){
	
		$('tbody tr:even th, tbody tr:even td', this).css({'background-color': '#f4f4f4'});
		$('tbody tr:odd th, tbody tr:odd td', this).css({'background-color': '#fafafa'});
		
		
		if($('tbody tr', this).length % 2 == 0) {
			$('tfoot tr th, tfoot tr td', this).css({'background-color': '#f4f4f4'});
		} else {
			$('tfoot tr th, tfoot tr td', this).css({'background-color': '#fafafa'});
		};
	
	});
	
	
	
	$('.cw5 .w2 .c2 .az').click(function(){
		$('.cw5 .w2 .c2 .il').removeClass('selected');
		$(this).addClass('selected');
		
		$('.cw3 .w5 table').each(function(){
			$('thead th:eq(0)', this).click();
		});
		
		return false;
	});
	
	$('.cw5 .w2 .c2 .il').click(function(){
		$('.cw5 .w2 .c2 .az').removeClass('selected');
		$(this).addClass('selected');
		
		$('.cw3 .w5 table').each(function(){
			$('thead th:eq(1)', this).click();
		});
		
		return false;
	});
	
	
	$('#search-hof').keyup(function(){
		var szuk = $(this).val();
		
		$('.cw3 > dl > dt').removeClass('selected');
		$('.cw3 > dl > dd').animate({'opacity':'1'}).hide();
		$('.cw3 .w5 tbody tr').show();
		
		if(szuk) {
			$('.cw3 .w5 tbody th').each(function(){
				if($(this).html().toLowerCase().indexOf(szuk.toLowerCase()) != -1){		
					$(this).parent('tr').show();
					$(this).parents('dd').show();
					$(this).parents('dd').prev('dt').addClass('selected');
				} else {
					$(this).parent('tr').hide();					
				}
			})
		}	
	});
	
});




$(document).ready(function() {

  $('.cw3 .w5 table').each(function() {
    var $table = $(this);
    $('th', $table).each(function(column) {
      var $header = $(this);
      var findSortKey;
      if ($header.is('.sort-alpha')) {
        findSortKey = function($cell) {
          return $cell.find('.sort-key').text().toUpperCase()
            + ' ' + $cell.text().toUpperCase();
        };
      }
      else if ($header.is('.sort-numeric')) {
        findSortKey = function($cell) {
          var key = $cell.find('img').attr('alt').replace(/^[^\d.]*/, '');
          key = parseFloat(key);
          return isNaN(key) ? 0 : key;
        };
      }
			
      if (findSortKey) {
        $header.addClass('clickable').hover(function() {
          $header.addClass('hover');
        }, function() {
          $header.removeClass('hover');
        }).click(function() {
          var sortDirection = 1;
          if ($header.is('.sorted-asc')) {
            sortDirection = -1;
          }
          var rows = $table.find('tbody > tr').get();
          $.each(rows, function(index, row) {
            var $cell = $(row).children('th,td').eq(column);
            row.sortKey = findSortKey($cell);
          });
          rows.sort(function(a, b) {
            if (a.sortKey < b.sortKey) return -sortDirection;
            if (a.sortKey > b.sortKey) return sortDirection;
            return 0;
          });
          $.each(rows, function(index, row) {
            $table.children('tbody').append(row);
            row.sortKey = null;
          });
          $table.find('th').removeClass('sorted-asc')
            .removeClass('sorted-desc');
          if (sortDirection == 1) {
            $header.addClass('sorted-asc');
          }
          else {
            $header.addClass('sorted-desc');
          }
          $table.find('td').removeClass('sorted')
            .filter(':nth-child(' + (column + 1) + ')')
            .addClass('sorted');

        });
      }
    });
  });
	
	
	$('.cw3 .w5 table').each(function(){
		$('thead th:eq(0)', this).click();
	});
	
});




$(document).ready(function(){

		$('.cw3 .w6 table').each(function(){
			
			
			$('.vote-1').click(function(){
				$(this).parents('table').find('.vote-none').attr('checked', false);
			});
			
			$('.vote-2').click(function(){
				$(this).parents('table').find('.vote-none').attr('checked', false);
			});
			
			$('.vote-3').click(function(){
				$(this).parents('table').find('.vote-none').attr('checked', false);
			});
			
			$('.vote-none').click(function(){
				$(this).parents('table').find('.vote-1').attr('checked', false);
				$(this).parents('table').find('.vote-2').attr('checked', false);
				$(this).parents('table').find('.vote-3').attr('checked', false);
			});
			
			
			/*$('.vrow-1',this).click(function(){
				$('.vrow-1:checked').attr('checked',false);
				$(this).attr('checked',true);
			});*/
			
			$('.vote-1, .vote-2, .vote-3').click(function(){
				$(this).parents('td').siblings('td').find('input').attr('checked', false);
			});
			
			
			var len = $(this).find('tbody tr',this).length;	
			if(len==1)
			{
				$('.vote-2,.vote-3', this).attr('disabled','disabled');
			}
			else if(len==2)
			{
				$('.vote-3', this).attr('disabled','disabled');
			}	
			
			$(this).find('.vote-none,.vote-1,.vote-2,.vote-3').click(function()
			{
				checkForm();
			});
		
		});
		
		
		
		
		$('.cw3 .w6 tr.error').hide();

		$('#validate-form').submit(function(){
		
			return checkForm();
			
		});
			
		
});





$(document).ready(function(){
	
	function mycarousel_initCallback(carousel){

		

		
		carousel.clip.hover(function(){
				carousel.stopAuto();
		}, function(){
				carousel.startAuto();
		});
	};

	$('#buttons ul').jcarousel({
		scroll: 1,
		auto: 3,
		wrap: 'last',
		
		initCallback: mycarousel_initCallback
	});

});


$(document).ready(function(){
	
	function mycarousel_initCallback(carousel){
		carousel.buttonNext.bind('click', function(){
				carousel.startAuto(0);
		});
		
		carousel.buttonPrev.bind('click', function(){
				carousel.startAuto(0);
		});
		
		carousel.clip.hover(function(){
				carousel.stopAuto();
		}, function(){
				carousel.startAuto();
		});
	};

	$('.cw6 ul').jcarousel({
		scroll: 6,
		auto: 5,
		wrap: 'last',
		
		initCallback: mycarousel_initCallback
	});

});

// zakładki kategorie

$(document).ready(
	function(){
		$("#fade #category0").fadeIn("slow");
		$(".category0").parent().addClass("selected");
		$("#fade a").click(function(){
			$("#fade li").removeClass("selected");
			$(this).parent().addClass("selected");
			class2 = $(this).attr("class");
			$("#fade dl").not("#" + class2).hide();
			$("#fade dl#" + class2).fadeIn(1500);
			Cufon.replace('#fade .nav a', {
				'font-family': 'trajanpro',
				hover: true
			});
			return false;
		});
	}
);

function form_changeSelect()
{
	if($('#form-option') && $('#form-option').val()!='0')
		document.location = base + 'pages/formular/' + $('#form-option').val();
}
