$(document).ready(function() {
	if($('#stockreg_info')[0]){
	    $('#stockreg_info').click(function(){
	        showAddStockReg();
	    });
	}
});

//弹出层并绑定事件
function showAddStockReg(){
    $('#ShowStockReg').popup({
        width:300,
        height:200,
        isFixed:true,
        popupHead:'StockRegHead',
        btnClose:'closeStockRegpop'
    });
    //点击添加缺货登记
    $('#btnAddStockReg').unbind().click(function(){
        var email = $.trim($('#txtEmail').val());
        if(email == ''){alert('请先填写邮箱地址');return false;};
        var reg = new RegExp("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$");
        if(!reg.test(email)){alert('请您输入正确邮箱');return false;};
        $.ajax({
            url:baseUrl + 'ajax.aspx?NoCopyRight=1&type=AddStockReg&PID='+productID+'&email='+escape(email) + '&GID=' + $('#GID').val() + '&specdesc=' + $('#specdesc').val(),
            cache:false,
            success:function(data){
                if(data == 'NOLOGIN' && confirm('请先登录后再继续操作,是否现在登录?')){
                    window.location.href = baseUrl + 'Login.aspx?ReturnUrl='+window.location.href;
                }else if(data > 0){
                    alert('操作成功');
                    disablePopup($('#ShowStockReg'));
                };
            },
            error:function(){alert('error');}
        });
    });
};