/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$(function () {
    $('input[type=text],textarea').keyup(function () {
    	if(/[`~!@#\$%\^\&\*\(\)_\+<>\?:"\{\},\\\/;'\[\]]/im.test($(this).val())){
    		var value = $(this).val().replace(/[`~!@#\$%\^\&\*\(\)_\+<>\?:"\{\},\\\/;'\[\]]/im, "");
    		$(this).val(value);	
    	}
    });
    if (typeof ($.fn.lazyload) === 'function') {
			$('img').lazyload({
			  effect:'fadeIn'
			});
    }
    
    $.ajaxSetup({
                beforeSend: function () {
                    layer.msg('加载中...', {time: false,shade: 0.3,icon:6});
                },
                complete: function () {
                     //ajax请求完成，不管成功失败
                 },
                error: function () {
                   layer.alert('出现错误');
                }
            });
	
});
var com ={
        /**
     * ===================================================================================
     * 
     * AJAX鎻愪氦
     * */
    sub_ajax: function (url, data, layinfo) {
	var json = null;
	if (layinfo) {
	    layer.closeAll();
	    console.log(layer);
	    layer.msg(layinfo, {time: 0});
	}
	$.ajax({
	    type: 'POST',
	    url: url,
	    data: data,
	    async: false,
//            beforeSend:function(XMLHttpRequest){ 
//              //alert('远程调用开始...'); 
//              layer.msg('加载中...', {time: 0,shade: 0.3});
//            }, 
//            error:function(XMLHttpRequest,textStatus,errorThrown){ 
//              layer.msg('加载失败', {time: 3000,shade: 0.3});
//            },
	    success: function (vo) {
                json = vo;
                /*
		if (vo.status) {
		    success_callback;
		    layer.msg(vo.info, {icon: 5, time: 3000}, function () {
			location.reload();
		    });
		} else {
		    layer.msg(vo.info, {icon: 2, time: 3000});
		}*/
	    },
            
	});
	if (layinfo) {
	    layer.closeAll();
	}
        return json;
    },
    
    }