/**
 * Created by Administrator on 2016/7/27.
 */
(function(){
    $('#introducer_tel').focus(function(){
        if($('#submit').attr('disabled')){
            $('#submit').attr('disabled',false);
            $('#submit').css('background','#ff4a4b');
        }
    });
    $('#project_description').focus(function(){
        if($('#submit').attr('disabled')){
            $('#submit').attr('disabled',false);
            $('#submit').css('background','#ff4a4b');
        }
    });
    $('#introducer_tel').keyup(function(){
        valiTel(this);
    });
    $('#project_description').keyup(function(){
        valiDescription(this);
    })
    $('#submit').click(function(){
        var introducer_tel=$('#introducer_tel')[0];
        var project_description=$('#project_description')[0];
        var valiT=valiTel(introducer_tel);
        var valiD=valiDescription(project_description);
        if( !valiT ){
            $(introducer_tel).focus();
        }else{
            if( !valiD ){
                $(project_description).focus();
            }else{
                $('#introducer')[0].submit;
            }
        }
    })

    function valiTel(obj){
        var reg=/^[0-9]{11}$/;
        var tel=obj.value.trim();
        if( !reg.test(tel) ){
            $('.error_phone').html('电话号码有误，请再次输入！');
            return false;
        }else{
            $('.error_phone').html('');
            return true;
        }
    }
    function valiDescription(obj){
        var text=obj.value.trim();
        if( !text){
            $('.error_description').html('项目描述不能为空！');
            return false;
        }else{
            $('.error_description').html('');
            return true;
        }
    }
    
    $('.project_one').click(function(e){
        e.preventDefault();
        $('.modal_box').css('display','block');
    })
    $('#modal_box_hidden').click(function(){
        $('.modal_box').css('display','none');
    });

   
        
})();