/**
 * 判断字符串是否为空
 *
 * @param {}
 *            str 需要判断的字符串
 * @param {true/false}
 *            isAllowBlank 是否允许空格：默认为false
 * @author Jay Wu
 */
function isBlank(str, isAllowBlank){
    if (str == null || str == "") {
        return true;
    }
    
    if (isAllowBlank == null || !isAllowBlank) {
        if (str.length > 0) {
            if ($.trim(str) == "") {
                return true;
            }
        }
    }
    
    return false;
}


function resizeContent(){
    var oldHeight = $("#LeftBar").height();
    if (oldHeight < 400) {
        oldHeight = 400;
    }
    
    $("#LeftBar").height(oldHeight);
    //    var contentHeight = $("#MainText").height() + 40;
    //    if (contentHeight > oldHeight) {
    //        $("#LeftBar").height(contentHeight);
    //    }
    //    else {
    //        $(".MainText").height(oldHeight - 115)
    //    }
}

/**
 * 获取指定参数及其对应的值
 * @param {Object} paraStr
 * @param {Object} url
 */
function getParameter(paraStr, url){
    if (url == null) {
        url = window.location.href;
    }
    
    var result = "";
    //获取URL中全部参数列表数据  
    var str = "&" + url.split("?")[1];
    var paraName = paraStr + "=";
    //判断要获取的参数是否存在  
    if (str.indexOf("&" + paraName) != -1) {
        //如果要获取的参数到结尾是否还包含“&”  
        if (str.substring(str.indexOf(paraName), str.length).indexOf("&") != -1) {
            //得到要获取的参数到结尾的字符串  
            var TmpStr = str.substring(str.indexOf(paraName), str.length);
            //截取从参数开始到最近的“&”出现位置间的字符  
            result = TmpStr.substr(TmpStr.indexOf(paraName), TmpStr.indexOf("&") - TmpStr.indexOf(paraName));
        }
        else {
            result = str.substring(str.indexOf(paraName), str.length);
        }
    }
    else {
        result = "";
    }
    
    result = result.replace("&", "");
    var value = result.split("=");
    if (value.length == 2) {
        return value[1];
    }
    else {
        return "";
    }
}


/**
 * 封装tooltip+字符截取功能，只需在需要截取字符的地方加上属性：limit = number 即可。
 *
 * @author Jay Wu
 */
function limit(){
    $("*[limit]").each(function(){
        var objString = $.trim($(this).text());
        var objLength = $(this).text().length;
        var num = $(this).attr("limit");
        if (objLength > num) {
            $(this).attr("title", objString);
            $(this).addClass("tooltip");
            objString = $(this).text(objString.substring(0, num) + "...");
        }
    });
}

function aLinks(source, target){
    var t = $(target);
    $(source).each(function(){
        if (!isBlank($(this).text())) {
            t.append(this);
        }
    });
}

