﻿jQuery.noConflict();
jQuery(document).ready(
function() {
if (jQuery('.summaryValidator').css('display') == 'block') {
    jQuery('.newCommentContainer').show();
    jQuery('.addNewComment').text('Schowaj');
}
    jQuery('.addNewComment').toggle(
    function() {
        jQuery('.newCommentContainer').slideDown();
        jQuery('.addNewComment').text('Schowaj');
    },
   function() {
       jQuery('.newCommentContainer').slideUp();
       jQuery('.addNewComment').text('Dodaj nowy komentarz');
   });
});

function validateFields()
{
	jQuery('.autographStar').hide();
	jQuery('.textStar').hide();
	jQuery('.captchaStar').hide();
	jQuery('.errorContainer').children('ul').empty();
	var captchaText = jQuery('.inputTextCaptcha').val();
	if (jQuery('.txtAutographClass').val().length > 0 && jQuery('.txtTextClass').val().length >0 && captchaText.length > 0)
	{
		return true;
	}
	else
	{
		if (jQuery('.txtAutographClass').val().length == 0)
		{
		    jQuery('.newCommentContainer').slideDown();
			jQuery('.addNewComment').text('Schowaj');
			jQuery('.errorContainer').children('ul').append('<li>Podpis nie może być pusty!</li>');
			jQuery('.autographStar').show();
		}
		if (jQuery('.txtTextClass').val().length == 0)
		{
		    jQuery('.newCommentContainer').slideDown();
			jQuery('.addNewComment').text('Schowaj');
			jQuery('.errorContainer').children('ul').append('<li>Treść nie może być pusta!</li>');
			jQuery('.textStar').show();
		}
		if (captchaText.length == 0)
		{
		    jQuery('.newCommentContainer').slideDown();
		    jQuery('.addNewComment').text('Schowaj');
			jQuery('.errorContainer').children('ul').append('<li>Wpisz kod z obrazka!</li>');
			jQuery('.captchaStar').show();
		}
		return false;
	}
}

function wrongCaptcha()
{
	if (window.location.href.indexOf('#comments') == -1)
	{
		window.location.href = window.location.href + "#comments"
	}
    jQuery('.newCommentContainer').slideDown();
    jQuery('.addNewComment').text('Schowaj');
	jQuery('.errorContainer').children('ul').append('<li>Zły kod z obrazka!</li>');
	jQuery('.captchaStar').show();

}


function goToAnchor()
{
	if (window.location.href.indexOf('#comments') == -1)
	{
		window.location.href = window.location.href + "#comments"
	}
}