/*
* 显示省略号部分的详细信息
* @jqueryObject: jquery object
---------------------------------------*/
function showDetail(jqueryObject) {
    jqueryObject.mouseover(function(e) {
        var target = $(e.target);
        if (target.is("td") && target.index() != 0 && target.children().length == 0) {
            target.attr("title", target.html());
        }
    });
}
function endEdit(jqueryObject) {
    jqueryObject.children().find('input[type!="button"]').each(function() {
        $(this).parent().html($(this).val());
    });
    jqueryObject.children().find("select").each(function() {
        $(this).parent().html($(this).find("option:selected").text());
    });
}
function limit() {
    $("body").children().find("[limit]").focus(function() {
        $(this).blur();
    });
}
function ChangeCss(jqueryObject, errorMsg) {
    jqueryObject.addClass("pt-error-tip");
    if (jqueryObject.is("select")) {
        jqueryObject.css('height', '22').css('line-height', '22');
    }
    jqueryObject.focus(); //焦点
    if ($("#errortip").attr("id") == undefined) {
        $('body').append('<span id="errortip" class="pt-error"></span>');
    }
    var X = jqueryObject.offset().top;
    var Y = jqueryObject.offset().left;
    $('#errortip').css({ left: Y + 90, top: X });
    $('#errortip').show();
    $('#errortip').html(errorMsg);
    jqueryObject.change(function() {
        if (jqueryObject.val()) {
            jqueryObject.removeClass("pt-error-tip");
            $('#errortip').hide();
        }
    });
}
function JudgeValidate() {
    var isVaidate = true;
    var errorMsg;
    $("body").children().find("[checkexpression]").each(function() {
        var expression = $(this).attr("checkexpression"), error = $(this).attr("error");
        switch (expression.toLowerCase()) {
            case "notnull":
                if (!$(this).val()) {
                    errorMsg = error + "不能为空！\n";
                    isVaidate = false;
                    ChangeCss($(this), errorMsg); return false;
                }
                break;
            default:
                break;
        }
    });
    return isVaidate;
}
function JudgeValidate1() {
    var isVaidate = true;
    var errorMsg;
    $("body").children().find("[checkexpression]").each(function() {
        var expression = $(this).attr("checkexpression"), error = $(this).attr("error");
        switch (expression.toLowerCase()) {
            case "notnull":
                if (!$(this).val()) {
                    errorMsg = error + "不能为空！\n";
                    isVaidate = false;
                    /*showTipsMsg(errorMsg, 2);*/
                    var self = this;
                    top.showConfirmMsg(errorMsg, function(r) {
                        if (r) {
                            $(self).focus();
                        }
                    });
                    return false;
                }
                break;
            default:
                break;
        }
    });
    return isVaidate;
}
/*
* 获取style中的值
* e.g. style="width:500px;text-align:center;"
---------------------------------------*/
function getStyle(styleStr, key) {
    var arr = styleStr && styleStr.toLowerCase().match(new RegExp("(^| )" + key + ":([^;]*)(;|$)"));
    if (arr != null) return arr[2]; return 0;
}
function FixedTableHeader(id, scrollHeight, scrollWidth) {
    var fixedId = id + "-Fixed",headerId=id+"-Header"
    if ($(fixedId).attr("id") == undefined) {
        id = "#" + id;
        var gvn = $(id).clone(true).removeAttr("id").attr("id",headerId);
        $(gvn).find("tbody").remove();
        $(id).before(gvn);
        $(id).find("thead").remove();
        $(id).wrap($("<div id='" + fixedId + "' class='pt-fixTable' ></div>").css({ width: scrollWidth, height: scrollHeight }));
    }
}

/**
获取选中复选框值
值：1,2,3,4
**/
function CheckboxValue() {
    var reVal = '';


    $('[type = checkbox]').each(function() {
        if ($(this).attr("checked")) {

            reVal += $(this).val() + ",";
        }
    });
    reVal = reVal.substr(0, reVal.length - 1);
    return reVal;
}
