// Nexus 4 Pure CSS Design
// Author : Erhan Basa ( erhanbasa.com )
// http://erhanbasa.com/blog/css-ile-nexus-4/
$(document).ready(function () {
    $(window).load(function () {
        $(".phone-pic").hide();
        $(".re-phone").hide();
        $(".over-phone").hide();
        ////$(".bo").hide();
        $(".tong").hide();
        $(".cover").hide();
        $(".yes-no").hide();
        $(".numbers").focus();


        //回车执行
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                var callNumber = $(".number-area .numbers").val();
                if (callNumber != null && callNumber != "") {
                    top.PhoneCallOut(1, callNumber);
                    $(".bo").hide();
                    $(".tong").show();

                    $(".btn-btn").css('background-position', '0 0');
                    $(".btn-people").css('background-position', '0 -49px');
                }
                else {

                    layer.msg('电话号码不能为空!', { icon: 5, time: 2000 });
                    return;


                }
            }
        };


    });

    layui.use(['jquery'], function () {

        layer = parent.layer === undefined ? layui.layer : parent.layer,

        /*	Current Tab 	*/
        $('.phone-tabs li a').click(function () {
            $('.phone-tabs li').removeClass('current');
            $(this).parent().addClass('current');
        });

        /*	Simple Tab 	*/
        var tabContents = $('.phone-tab-contents');
        $('.phone-tabs .getphone').click(function () {
            tabContents.removeClass('getpeoples');
            tabContents.removeClass('getclock');
        });

        $('.phone-tabs .getclock').click(function () {
            tabContents.removeClass('getpeoples');
            tabContents.addClass('getclock');
        });

        $('.phone-tabs .getpeoples').click(function () {
            tabContents.removeClass('getclock');
            tabContents.addClass('getpeoples');
        });

        /*	Delete */
        $('.delete-btn').click(function () {
            var numbers = $('.number-area .numbers').val();
            var numbers2 = $('.number-area .numbers').val().length;
            $('.number-area .numbers').val(numbers.substr(0, numbers2 - 1));
            $('.speaker .numbers').val(numbers.substr(0, numbers2 - 1));
            //if (numbers.substr(0, numbers2 - 1)=="") {
            //	//$(".bo").hide();
            //	//$(".circle").css('background-position', '0 -22px');
            //	//$(".btn-btn").css('background-position', '0 0');

            //}
            $(".btn-btn").css('background-position', '0 -105px');
            $(".tong").hide();
            top.button_ReleaseAnswer();
        });


        /*拨号键图片变化*/
        $(".btn-btn").click(function (event) {
            /*$(this).css('background-position', '0 -105px');*/


        });


        /*	Pusher	*/
        var pusher = {
            number: function (num) {
                $('.numbers-container .pushed' + num + '').click(function () {

                    $(".number-area .numbers").val($(".number-area .numbers").val() + num);
                    $('.speaker .numbers').append('' + num + '');
                    $(".btn-btn").css('background-position', '0 -105px');
                    $(".bo").show();
                    $(".tong").hide();
                    $(".circle").css('background-position', '0 0');
                  
                });
            }
        }
        $(".btn-btn").click(function (event) {

            var callNumber = $(".number-area .numbers").val();
            if (callNumber != null && callNumber != "") {
                top.PhoneCallOut(1, callNumber);
                $(".bo").hide();
                $(".tong").show();

                $(".btn-btn").css('background-position', '0 0');
                $(".btn-people").css('background-position', '0 -49px');
            }
            else {

                layer.msg('电话号码不能为空!', { icon: 5, time: 2000 });
                return;


            }
        });
        pusher.number(1);
        pusher.number(2);
        pusher.number(3);
        pusher.number(4);
        pusher.number(5);
        pusher.number(6);
        pusher.number(7);
        pusher.number(8);
        pusher.number(9);
        pusher.number(0);

        $('.numbers-container .pushedasterisk').click(function () {
            $('.number-area .numbers').append('*');
        });

        $('.numbers-container .pushednumber').click(function () {
            $('.number-area .numbers').append('#');
        });
    }
    );
});