﻿changeTab = function(tab, idContent, classPrefix)
{
	$('.'+classPrefix+'-tab').removeClass('selected');
	$(tab).addClass('selected');
	
	$('.'+classPrefix+'-content').hide();
	$('#'+idContent).show();
	
	tab.blur();
	return false;
}

$(document).ready(function() {

	author = $('input#author');
    if (author.length) {
        author.focus(function() {
            if (this.value == 'Imię (wymagane)') this.value = '';
        });
        author.blur(function() {
            if (this.value == '') this.value = 'Imię (wymagane)';
        });
    }
	email = $('input#email');
    if (email.length) {
        email.focus(function() {
            if (this.value == 'E-mail (wymagany)') this.value = '';
        });
        email.blur(function() {
            if (this.value == '') this.value = 'E-mail (wymagany)';
        });
    }
	url = $('input#url');
    if (url.length) {
        url.focus(function() {
            if (this.value == 'Strona www') this.value = '';
        });
        url.blur(function() {
            if (this.value == '') this.value = 'Strona www';
        });
    }
	comment = $('textarea#comment');
    if (comment.length) {
		comment.focus(function() {
			if ($(this).val() == 'Treść komentarza') $(this).val('');
        });
        comment.blur(function() {
            if ($(this).val() == '') $(this).val('Treść komentarza');
        });
    }
	search = $('form#searchform input#s');
    if (search.length) {
        search.focus(function() {
            if (this.value == 'Szukaj w serwisie') this.value = '';
        });
        search.blur(function() {
            if (this.value == '') this.value = 'Szukaj w serwisie';
        });
    }
	
	// remember author comment
	if ($('.recaptcha-error').length) {
		$('textarea#comment').val($.cookie('last_post_comment'));
	}
	if ($('#commentform').length) {
		$('#commentform').submit(function() {
			$.cookie('last_post_comment', $('textarea#comment').val(), {expires: 30, path: "/"});
		});
	}

});