    var pictureView = function()
    {

        // покупка
        $("#buyPicture").click(function( e ) {
            e.preventDefault();
            $("#pictureInfo").hide();
            $("#orderInfo").toggle();
            if ( parseInt(document.body.clientHeight) > 700 )
                {
                $("#orderInfo").get(0).style.height = (parseInt(document.body.clientHeight)) + "px";
                }
            else {
                $("#orderInfo").get(0).style.height = "671px";
            };
            $("#commentBoard").hide();
        });
        
        $("#close2").click(function( e ) {
            e.preventDefault();
            $("#orderInfo").hide();            
        });

        // о картине
        if ( $("#aboutPicture") ) {
            $("#aboutPicture").click(function( e ) {
                e.preventDefault();
                $("#pictureInfo").toggle();
                if ( parseInt(document.body.clientHeight) > 700 )
                    {
                    $("#pictureInfo").get(0).style.height = (parseInt(document.body.clientHeight)) + "px";
                    }
                else {
                    $("#pictureInfo").get(0).style.height = "671px";
                };

                $('#divAddComment').hide();
                $("#orderInfo").hide();
                $("#commentBoard").hide();
                $('#div_about_container').jScrollPaneRemove();
                if ( parseInt(document.body.clientHeight) > 700 )
                    {
                    $("#div_about_container").get(0).style.height = (parseInt(document.body.clientHeight -29)) + "px";
                    }
                else {
                    $("#div_about_container").get(0).style.height = "671px";
                };
	        	$('#div_about_container').jScrollPane();
            });
            $("#close").click(function( e ) {
            	fsShadowBox.hide();
                e.preventDefault();
                $("#pictureInfo").hide();
                $("#divAddComment").hide();
            });
        }
        if ( $("#commentPicture") ) {
            $("#commentPicture").click(function( e ) {
                e.preventDefault();

                if ( parseInt(document.body.clientHeight) > 700 )
                    {
                    $("#commentBoard").get(0).style.height = (parseInt(document.body.clientHeight)) + "px";
                    }
                else {
                    $("#commentBoard").get(0).style.height = "671px";
                };

                $("#orderInfo").hide();
                $("#pictureInfo").hide();
            });
            $("#close").click(function( e ) {
            	fsShadowBox.hide();
                e.preventDefault();
                $("#commentBoard").hide();
                $("#divAddComment").hide();
            });
        }

        $("#commentPicture").click(function( e ) {
            e.preventDefault();
            $("#commentBoard").toggle();
            $('#commentListScrollContainer').jScrollPaneRemove();

            if ( parseInt(document.body.clientHeight) > 700 )
                {
                $("#commentListScrollContainer").get(0).style.height = (parseInt(document.body.clientHeight)) + "px";
                }
            else {
                $("#commentListScrollContainer").get(0).style.height = "671px";
            };

            $('#commentListScrollContainer').jScrollPane();
        });

        $("#close3").click(function( e ) {
            e.preventDefault();
            $("#commentBoard").hide();
            $("#divAddComment").hide();
        });

        // добавить в избранное
        $("#toFavorites").live("click", function(e) {
            e.preventDefault();

            var url = $(this).attr("href");

            var $this = this;
            $.get($($this).attr("href"), {},
                function(data) {
                    if (data == "add") {
                        $("#linkAddToFavorites").hide();
                        $("#linkRemoveFromFavorites").show();
                    } else if (data == "del") {
                        $("#linkRemoveFromFavorites").hide();
                        $("#linkAddToFavorites").show();
                    }
                }
            );
        });

        // проголосовать
        $("#favoritePicture").live("click", function( e ) {
        	var sendUrl = $("#ilike_link").val();
        	if( ! sendUrl ) {
        		return;
        	}
            e.preventDefault();
        	$.ajax({
    		  url: sendUrl,
    		  data: {},
    		  success: function(data) {
                  $("#voteCount").html("&nbsp;" + data.voteCount);
                  $("#voteText").html( $("#ilike_text").val() );
                  Cufon.replace( $("#voteText") );
                  $("#ilike_link").remove();
                  $("#ilike_text").remove();
              },
    		  dataType: 'json'
    		});
        });

        // вешаем listener на нажатие кнопок влева/вправо
        $(document).ready(function() {

            // ставим фокус в невидимое текстовое поле
            $("#hack_set_focus_input").focus();

            $(document.body).keyup(function( e ) {
                //alert(e.keyCode);
                if (e.keyCode == 37) {
                    // left
                    if ($("#leftUrl").val().replace(/\s/gi, "")) {
                        doRedirect($("#leftUrl").val());
                    }
                } else if (e.keyCode == 39) {
                    // right
                    if ($("#rightUrl").val().replace(/\s/gi, "")) {
                        doRedirect($("#rightUrl").val());
                    }
                }
            });
        });
    }

    // ответ в гостевой
    var replyTo = function (commentId, userId)
    {
        $("#toUserName").html('Ответ пользователю: ' + $("#comment" + commentId).html()).show();
        $("#toUserNameDel").show();
        $("#toUserId").val(userId);
        $("#commentForm").show();
        return false;
    }

    var deleteReply = function (link)
    {
        $('#toUserName').empty().hide();
        $('#toUserId').val('');
        $(link).hide();
        return false;
    }

    // обновление списка комментариев
    var reloadPage = function (currentUrl, response)
    {
        if (response.imgUrl) {
            // загружаем комменатрии
            loadComments(response.imgUrl);

        } else if (response.authImgUrl) {
            // авторизация пользователя
            //$.post(response.authImgUrl + "?action=get_comment_form", {},
            $.post(response.authImgUrl + "?action=get_comments", {},
                function (data) {
                    tinyMCE.execCommand('mceRemoveControl', false, 'commentTextArea');
                    //$("#commentFormBox").html(data);
                    $("#scrollBoxPlace2").html(data);
                    // вешаем ajax form submit
                    bindSimpleAjaxForm ();
                    initEditorValues();
                    createAudioPlugin();
                    tinyMCE.execCommand('mceAddControl', false, 'commentTextArea');

                    // добавляем кнопку "добавить в избранное"
                    if ($("#toFavorites").get(0)) {
                        $("#toFavorites").insertBefore($("#commentPicture")).show();
                    }
                }
            );
        } else if (response.requestOn) {
            // обработка отправленного запроса
            $("#requestForm").hide();
            $("#messageSent").show();
        } else if (response.commentEdit && response.afterEditUrl) {
            // после редактирования комментария
            loadComments(response.afterEditUrl);
        }
    }

    // загрузка статей
    var loadArticle = function (url)
    {
        var concat = (url.indexOf("?") != -1) ? "&" : "?"
        $.post(url + concat + "action=get_article_list", {},
            function (data) {
                $("#article_list").html(data);
            }
        );
        return false;
    }

    // загрузка списка комментариев
    var loadComments = function (url)
    {
        var concat = (url.indexOf("?") != -1) ? "&" : "?"
        $.post(url + concat + "action=get_comments", {},
            function (data) {
                tinyMCE.execCommand('mceRemoveControl', false, 'commentTextArea');
                $("#scrollBoxPlace2").html(data);
                // вешаем ajax form submit
                bindSimpleAjaxForm ();
                initEditorValues();
                createAudioPlugin();
                tinyMCE.execCommand('mceAddControl', false, 'commentTextArea');
                // инициализируем mp3-плеер
                initMp3Player();
                // обновляем количество комментариев
                $("#comments").html($("#commentCount").val());
            }
        );
    }


    // удалить комментарий
    var delComment = function (imgUrl, commentId)
    {
        if (confirm('Удалить комментарий?')) {
            $.post(imgUrl + "?section=delcomment&commentId=" + commentId, {}, function(data) {
            	window.location.reload();
            });
        }
        return false;
    }