$(document).ready(function() {
    $("input[name='submit'][type='image']").not("#send_comment").hide();

    $(".qa_li").live("click", function() {
        $(this).addClass("qa_li_s");
        $(this).removeClass("qa_li");
        $(this).children("p").not(".author").show();
        return false;
    });
    $(".qa_li_s").live("click", function() {
        $(this).removeClass("qa_li_s");
        $(this).addClass("qa_li");
        $(this).children("p").not(".author").hide();
        return false;
    });

    $(".answers_list_ul li").click(function() {
        $("input[name='submit'][type='image']").show();
    });

    $("#not_recomended").click(function() {
        var popupLeft = Math.floor(($("body").innerWidth() - 675) / 2);
        var popupTop = Math.floor(($(window).height() - 625) / 2);
        if($(this).attr("href") != '#') {
            $(".popup_content").load($(this).attr("href") + "?" + Math.round((Math.random()*9)+1));
            $(".big_popup").hide().css({opacity: "0.0", display: "block", left: popupLeft + "px", top: popupTop + "px"}).animate({opacity: "1.0"}, 500);
        }
        return false;
    });

//    $(".one_photo_smile a").click(function() {
//        var popupLeft = Math.floor(($("body").innerWidth() - 675) / 2);
//        var popupTop = Math.floor(($(window).height() - 475) / 2);
//        $(".popup_content").html('<p style="text-align: center;"><a href="#" id="close_btn"><img src="/graphics/close_popup.jpg" alt="" style="width:15px; height:16px; position:absolute; top:0px; right: 10px;" /></a><img src="' + $(this).attr("href") + '" width="500" /><br /><br /><strong>' + $(this).siblings("img").attr("alt") + '</strong></p>');
//        $(".big_popup").hide().css({opacity: "0.0", display: "block", left: popupLeft + "px", top: popupTop + "px"}).animate({opacity: "1.0"}, 500);
//        return false;
//    });

    $("#close_btn").live("click", function() {
       $(".big_popup").show().animate({opacity: "0.0"}, 500);
       setTimeout('$(".big_popup").css({display: "none"})', 500);
       return false;
    });

    $("#register").submit(function () {
       if($("#agree").attr("checked") == true) {
           return true;
       } else {
           alert("Для принятия участия в конкурсе вам необходимо принять условия конкурса.");
           return false;
       }
    });

    $("ul.star-rating li a").one('click', function () {
		var rating = $(this).attr("id");
		var entry_id = window.location.href;
		var pattern = /\d{1,10}/;
		var url = window.location.href
		entry_id = url.match(pattern);

		$('ul.star-rating li a').each(function () { $(this).unbind('click'); $(this).click(function () { return false; }); });

		$.ajax({
		url: "/rate.php?entry_id=" + entry_id + "&mark=" + rating,
		cache: false,
		success: function(html){
			$("div#vote_result").slideDown();
			$("div#vote_result").append(html);
			setTimeout('$("div#vote_result").animate({opacity: "0.0"}, 1000)', 1500);
			setTimeout('$("div#vote_result").text("")', 2500);
		}
	});

		return false;
	});
})


