
    /**
     * 分页用到的方法
     */
    $.page = {
        init:function(formId) {
            if (!$.util.isEmpty(formId)) {
                $.page.setting.thisFormId = formId;
            }
            
            if (arguments.length > 1 && !$.util.isEmpty(arguments[1])) {
                $.page.setting.submitCB = arguments[1];
            }
        },
        changeSize:function(target,form){
        	var value = $(target).val();
        	
        	//$("#page_pageSize").val(value);
        	$("#" + $.page.setting.currentPageId).val("0");
        	$("#" + $.page.setting.pageSizeId).val(value);
        	//form.submit();
        	page_submit({thisForm:form});
        },
        formSubmit : function (form, currentPage) {
            var form1 = form || document.getElementById($.page.setting.thisFormId);
            if (form1 == null) {
                alert("请设置FORM表单的ID为" + $.page.setting.thisFormId);
                return false;
            }
            //用户选择或输入的页码
            var currentPageNum = parseInt(currentPage);
            currentPageNum--;
            var maxPageNum = parseInt($("#" + $.page.setting.pageNumId).val());
            //当前页码
            var currentPageObj = $("#" + $.page.setting.currentPageId);
            var pageSize = $("#page_size").val()||"";
            if(pageSize!=""){
            	$("#" + $.page.setting.pageSizeId).val(pageSize);
            }
            var oddCurrentPage = parseInt(currentPageObj.val());
            try {
                if (currentPageNum > maxPageNum) {
                    return false;
                }
                if (currentPageNum == oddCurrentPage) {
                    return false;
                }
                currentPageObj.val(currentPageNum);
                $('#current_pg').val(currentPageNum+1);
                //form1.submit();
                page_submit({thisForm:form1});
            } catch(e) {
            }
            return false;
        },
        enterPageNum : function (form, value, e, totle) {
            //var ev = e || window.event;
            //var code = ev.keyCode;
            var vInt = /^\+?[\d]*$/;
            if (vInt.test(value) && parseInt(value) > 0 && parseInt(value) <= parseInt(totle)) {
                //if (code == 13) {
                		$("#current_pg").attr("oa-pre-value", value);
                    return   $.page.formSubmit(form, value);
                //}
            } else {
            		$("#current_pg").val($("#current_pg").attr("oa-pre-value"));
                return false;
            }
        },
        orderSortParm : function (form, value,sort) {
        	$("#" + $.page.setting.currentPageId).val("0");
        	$("#orderParm").val(value);
        	if(sort=="1"){
        		$("#sortType").val("asc");
        	}else{
        		$("#sortType").val("desc");
        	}
        	//form.submit();
        	page_submit({thisForm:form});
        }
    };
    $.page.setting = {
        currentPageId:"page_currentPage",
        pageNumId:"page_pageCount",
        pageSizeId:"page_pageSize",
        totalId:"page_recordCount",
        thisFormId:"thisFormId",
        orderParm:"orderParm",
        sortType:"sortType",
        submitCB:null
    };
    
    var page_submit = function(param_json) {
    	if (!param_json) {
    		return false;
    	}
    	
    	if ($.page.setting.submitCB) {
    		/* 异步提交 */
   			$.page.setting.submitCB();
    	} else {
    		/* 同步提交(default) */
    		if (param_json.thisForm) {
    			param_json.thisForm.submit();
    		}
    	}
    };

//(jQuery)
