$(function (){





    function Show_Hidden1(obj) {
        if(obj.style.display=="block")
        {
            obj.style.display='none';
        }
        else
        {
            obj.style.display='block';
        }
    }

    draw.initCanvas();

    // 绑定绘画板工具
    $(".pencil").on("click", function () {
        draw.draw_graph('pencil', this);
    });
    $(".rescind").on("click", function () {

        client.sendGotoPrev();
    });

    $(".handwriting").on("click", function () {
        draw.draw_graph('handwriting', this);
    });

    $(".rubber").on("click", function () {
        draw.draw_graph('rubber', this);
    });
    $(".drawLine").on("click", function () {
        draw.draw_graph('line', this);
    });
    $(".square").on("click", function () {
        draw.draw_graph('square', this);
    });
    $(".circle").on("click", function () {
        draw.draw_graph('circle', this);
    });

    $(".clearContext").on("click", function () {
        client.sendDeleteAllAnnotation();
        // draw.clearContext('1');
    });




    // 初始化铅笔工具
    $(".draw_controller li:first").click();

    // 选择线条大小
    $(".line_size button").click(function () {
        $(".line_size button").removeClass('current');
        $(this).addClass('current');
        size = $(this).data("value");
        $("#line_size").hide();
    });


    //表情

    var face=document.getElementById("face");
    var faceList=document.getElementById("facelist");
    face.onclick=function()
    {
        console.log("click事件---------------------");
        Show_Hidden1(faceList);
        return false;
    }



    //表情功能实现
    var step = 0, count = 4;
    var $inner = $("#inner-slide"),
        $tip = $("#tiplist"),
        $tipList = $tip.children("li");

    function changeTip() {
        var temp = step;
        temp >= count ? temp = 0 : null;
        $tipList.each(function (index, item) {
            index === temp ? $(this).addClass("bg") : $(this).removeClass("bg");
        });
    }



    $tipList.bind("click", function () {
        step = $(this).index();
        if (document.documentElement.clientWidth > 1366) {
            $inner.stop().animate({left: -step * 360}, 500);
        } else if (document.documentElement.clientWidth <= 1366 && document.documentElement.clientWidth > 1280) {
            $inner.stop().animate({left: -step * 256}, 500);
        } else if (document.documentElement.clientWidth <= 1280) {
            $inner.stop().animate({left: -step * 238}, 500);
        }
        changeTip();
    });


    $(".inner-slide").on("click", "li", function (e) {
        $("#txt_message").val($("#txt_message").val() + "[img:" + $(this).find("img").attr("data-type") + "]");
        faceList.style.display="none";
    });





});