$(document).ready(function(){

	$(".n2 li:last").addClass("noborder");

	
	 
	 $(".car").jCarouselLite({
    btnNext: ".lc-next",
    btnPrev: ".lc-prev",
	auto: 6000,
    speed: 500,
	visible: 1,
    afterEnd: function(data){
        var id_raw = $(data).attr('id'),
        id = id_raw.split("--")[1]
        $("#last_comment").attr("href", "/" + id + "/comment/")
    }
});

$(".br1, .br2, .br3, .br6, .br7, .br8, .cmp1, .cmp2, .br-logo").wrapInner($("<div class='ietc'></div>"));


$(".show span").toggle (function(){
$(this).parent(".show").addClass("show2");
$(this).html("Скрыть");
$(this).parents(".brocker").addClass("br-show");
$(this).parents(".brocker").find(".br-dop").slideDown("fast");
}, function(){
$(this).parent(".show").removeClass("show2");
$(this).html("Подробнее");
$(this).parents(".brocker").removeClass("br-show");
$(this).parents(".brocker").find(".br-dop").slideUp("fast");
	
});


$(".close").click(function(){
$(this).parent(".comp").fadeOut(300);
});

$("#clo").click(function(){
$('.drop2').fadeOut(300);
});


$(".close2").click(function(){
$(this).parent(".drop").fadeOut(300);
});


$(".ost-com").click(function(){

    $("#comment_popup").fadeIn(300, function(){
        $("#head_comment").html('Отзыв');
        $("#er_comment").html('Отзыв');
        $("#add_comment").html('Добавить отзыв');
        $("#id_name").focus()
    });

});

$(".ost-com3").click(function(){

    if (this.id == "login_form") {
        login_form();
    } else {

        $("#rev_popup").show();
    }
});


var he = parseInt($(".drop").height()/2);
$(".drop").css("margin-top", -he+"px");


var he2 = parseInt($(".drop2").height()/2);
$(".drop2").css("margin-top", -he2-120+"px");

var wi2 = parseInt($(".drop2").width()/2);

$(".drop2").css("margin-left", -wi2+"px");

    
$(".pod-com span").click(function(){
    var id = this.parentNode.id.split("-")

    $("#comment_popup").fadeIn(300, function(){
        $("#head_comment").html('Комментарий');
        $("#er_comment").html('Комментарий');
        $("#add_comment").html('Добавить комментарий');
        $("#id_name").focus();
        $("#parent_comment_id").val(id[1]);
    });
});

$(".otz-l .otz-x:nth-child(odd), .otz-r .otz-x:nth-child(odd)").addClass("otz-col");



		
	 
	 
});

function close_comment_popup(el) {
var el = el

    $(el).parent(".drop2").fadeOut(300);
}
