// Wywołanie Cufona
Cufon.replace('#page-header .content a.logo, .logo-txt, #page-navigation .nav ul li a', {
        fontFamily : 'AvantGarde Md BT'
});

function gup(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec(window.location.href);
  if( results == null )
    return "";
  else
    return results[1];
}

$(document).ready(function() {

    $("#commentform").validationEngine();

    $(".comment:first").addClass("last");
    $("#nav-top .nav li:last").addClass("last");
    $(".nav-footer .nav li:last").addClass("last");

    $(".add-comment-trigger").click(function() {
        $(".add-comment-form").fadeIn("slow");
    });

    $(".add-comment-submit").click(function() {
        $("#commentform").submit();
    });

    $('.search .button').click(function() {
        $("#searchform").submit();
    });


    $(".contact-form-submit").click(function() {
        $(".wpcf7-form").submit();
    });

	// Czyszczenie pól formularzy.
	$('input.clean').focusin(function() {
		$(this).attr('data-backup-value', this.value);
		this.value = '';
	});
	$('input.clean').focusout(function() {
        if ($(this).val() == '') {
            this.value = $(this).attr('data-backup-value');
        }
	});
        
        // Rozwijanie boxow w prawym menu
        $(".more").click(function() {
            if ($(this).hasClass("active")){
                    $(this).removeClass("active");
                    $(this).next(".more-txt").fadeOut();
            }
            else {
                    $(".more-txt").hide();
                    $(".more").removeClass('active');
                    $(this).next(".more-txt").fadeIn();
                    $(this).addClass('active');
            }
	});
        
        // Otwieranie linków w nowym oknie
        $('A[rel="_blank"]').each(function(){
             $(this).attr('target', '_blank');
        });
        
});
