$(function() {
    $(".report_this").click(function() {
        var link = $(this);
        var comment_id = $(this).attr("object_id");
        $.ajax({
            type: 'get',
            url: '/report/comment/' + comment_id + '/',
            dataType: 'json',
            success: function(json) {
                //alert(json.success);
                if(json.success) {
                    link.remove();
                }
            }    
        });
        return false;
    });
});



$(function() {
        $("input, tr").each(function() {
                if($(this).attr("href")) {
                        var href = $(this).attr("href")
                        $(this).click(function() {
                                location.href = href;
                        });
                }
		if($(this).attr("start_here")) {
			$(this).focus();
		}
        });
	

		$("#lang_select").change(function() {
			alert('wtf is going on here?');
			$("#lang_form").submit();
			/*
			if($(this).val()) {
			});
			*/
		});


        // Feedback form popup
        $("#feedback_open").click(function() {
            $("#feedback_form_wrapper").toggle();
        });

        $("#feedback_close").click(function() {
            $("#feedback_form_wrapper").hide();
        });

        $("#feedback_form").submit(function() {
            var data_str = $(this).serialize();
            $.ajax({
                type: "POST",
                url: $(this).attr("action"),
                data: data_str,
                dataType: "json",
                success: function(json) {
                    if(json.success)
                        $("#feedback_form_wrapper").hide();
                    else if(json.message)
                        alert(json.message);
                }
            });
            return false;
        });

        // Help form popup
        $("#help_open").click(function() {
            $("#help_form_wrapper").toggle();
        });

        $("#help_close").click(function() {
            $("#help_form_wrapper").hide();
        });

        $("#help_form").submit(function() {
            var data_str = $(this).serialize();
            $.ajax({
                type: "POST",
                url: $(this).attr("action"),
                data: data_str,
                dataType: "json",
                success: function(json) {
                    if(json.success)
                        $("#help_form_wrapper").hide();
                    else if(json.message)
                        alert(json.message);
                        
                }

            });
            return false;
        });

});

