﻿$(function(){
	$('body').removeClass('no-js').addClass('js');

	$('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});

	$('a.email[rel]').each(function() {
		e = this.rel.replace('/','@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});

	// v 2.0
	$('form:has(input[type=submit])').each(function(){
		var thisForm = $(this);
		var submitButton = thisForm.find('input[type=submit]');
		var link = $('<a href="#" class="submitReplacement" title="' + submitButton.attr('value') +'">' + submitButton.attr('value') + '</a>');
		link.insertAfter(submitButton).click(function(){
			thisForm.submit();
			return false;
		});
		submitButton.remove();
	});

	// Cufon
    Cufon.replace("#home .newsBox .news .header h1, #home .newsBox .events .header h2, #home .colAnnouncements h2, #home .colScores h2", { fontFamily: "DaxlinePro" });
    Cufon.replace("#sub #header h1, #sub .default h2", { fontFamily: "DaxlinePro" });
    Cufon.replace("#footer p .cufon", { fontFamily: "HelveLB" });

    // Animacja newsów - kolor
	$('#home .newsBox .news .otherNews li').hoverIntent( {
		over : function() {
			$(this).find('p a').animate( {
				color : '#ffffff'
			}, 500);
			$(this).find('h3 a').animate( {
				color : '#ffffff'
			}, 500);
		},
		out : function() {
			$(this).find('p a').animate( {
				color : '#8e8e8e'
			}, 500);
			$(this).find('h3 a').animate( {
				color : '#cccccc'
			}, 500);
		},
		timeout : 1,
		interval : 20
	});

    //Taby newsów
	$("#newsBoxContent .category").hide();
	$("#newsBoxTabs li:first").addClass("active").show();
	$('#newsBoxContent .category:first').show();
	$("#newsBoxTabs li").click(function() {
		$("#newsBoxTabs li").removeClass("active");
		$(this).addClass("active");
        var activeTab = $(this).find("a").attr("href");
		$("#newsBoxContent .category").hide();
		$(activeTab).fadeIn(300);

        $(activeTab).find('.bigNewsImg').animate({ opacity: 0.25 }, 150,
				function() {$(this).animate({ opacity: 1 }, 150);});

        $(activeTab).find('.bigNews p').animate( {
			color : '#ffffff'
			}, 150, function(){
                $(this).animate( { color: '#999999' }, 150)
        });
		return false;
	});

    //Taby komunikatów
	$("#announcementsContent .category").hide();
	$("#announcementsTabs li:first").addClass("active").show();
	$('#announcementsContent .category:first').show();
	$("#announcementsTabs li").click(function() {
		$("#announcementsTabs li").removeClass("active");
		$(this).addClass("active");
        var activeTab = $(this).find("a").attr("href");
		$("#announcementsContent .category").hide();
		$(activeTab).fadeIn();
		return false;
	});

    //Główna - galeria obrazki
    $('#home .colGallery .photos').cycle({});

    //Szukajka
    $("#searchPhrase").placeholder({
        message: "Szukaj..."
    });
});
