﻿var request = {
    QueryString: function (val) {
        var uri = window.location.search;
        var re = new RegExp("" + val + "\=([^\&\?]*)", "ig");
        return ((uri.match(re)) ? (uri.match(re)[0].substr(val.length + 1)) : null);
    },
    QueryStrings: function () {
        var uri = window.location.search;
        var re = /\w*\=([^\&\?]*)/ig;
        var retval = [];
        while ((arr = re.exec(uri)) != null)
            retval.push(arr[0]);
        return retval;
    },
    setQuery: function (val1, val2) {
        var a = this.QueryStrings();
        var retval = "";
        var seted = false;
        var re = new RegExp("^" + val1 + "\=([^\&\?]*)$", "ig");
        for (var i = 0; i < a.length; i++) {
            if (re.test(a[i])) {
                seted = true;
                a[i] = val1 + "=" + val2;
            }
        }
        retval = a.join("&");
        return "?" + retval + (seted ? "" : (retval ? "&" : "") + val1 + "=" + val2);
    }
}
//一级菜单  设置 底色为白色 样式
function SetMenuStyle(setDivID) {
    $(".Menu").each(function () {
        if ($(this).attr("id") == setDivID) {
            $(this).removeClass("Menu");
            $(this).addClass("MenuCur");
        } else {
            $(this).removeClass("MenuCur");
            $(this).addClass("Menu");
        }
    });
}
// 子菜单隐藏或显示
function menuClick(menuId) {

    $(".LeftSubMenu div").each(function () {
        var childMenu = $("#" + $(this).attr("id") + "Child"); //获取 子菜单
        if ($(this).attr("id") == menuId) {
            $(this).removeClass("Menuf");
            $(this).addClass("MenufCur");
            if (childMenu != null && childMenu != "undefined") {
                childMenu.show();
            }
        } else {
            $(this).removeClass("MenufCur");
            $(this).addClass("Menuf");
            if (childMenu != null && childMenu != "undefined") {
                childMenu.hide();
            }
        }
    });
}

//返回当前页面高度
function pageHeight() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    } else {
        return self.innerHeight;
    }
}
//返回当前页面宽度 
function pageWidth() {
    if ($.browser.msie) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    } else {
        return self.innerWidth;
    }
}
function closeWindow() {
    document.getElementById('NavFrameProject').src = 'about:blank';
    $('#projectWindow').window('close');
}
function showProjectWindow(title, url) {
    var html = "<div id=\"projectWindow\" class=\"easyui-panel\" closed=\"true\">" +
                " <img src=\"/Images/Hydrangeas.jpg\" /></div>";
    $(html).appendTo("body");
    $('#projectWindow').window({
        title: title,
        width: pageWidth(),
        height: pageHeight(),
        modal: true,
        shadow: false,
        closed: false,
        minimizable: false,
        maximizable: false,
        onClose: function () {
            $('#projectWindow').remove();
        }
    });
}

function initTree(wbs) {
    $.ajax({
        type: "post",
        async: false,
        url: '/Ashx/GetTree.ashx?wbs=' + wbs,
        success: function (data) {
            document.getElementById('treeDiv').innerHTML = data;
        }
    });

}

function qualificationOnmouseover(img, ev) {
    var point = getMousePoint(ev);
    //alert(a.x+"----"+a.y);
    $("#detailsDiv").css("left", point.x + 20 + "px");
    $("#detailsDiv").css("top", point.y + 20 + "px");
    $("#detailsImg").attr("src", img);
    $("#detailsDiv").show();
}
function qualificationOnmouseout() {
    $("#detailsDiv").hide();
}
function getMousePoint(ev) {
    // 定义鼠标在视窗中的位置
    var point = {
        x: 0,
        y: 0
    };

    // 如果浏览器支持 pageYOffset, 通过 pageXOffset 和 pageYOffset 获取页面和视窗之间的距离
    if (typeof window.pageYOffset != 'undefined') {
        point.x = window.pageXOffset;
        point.y = window.pageYOffset;
    }
    // 如果浏览器支持 compatMode, 并且指定了 DOCTYPE, 通过 documentElement 获取滚动距离作为页面和视窗间的距离
    // IE 中, 当页面指定 DOCTYPE, compatMode 的值是 CSS1Compat, 否则 compatMode 的值是 BackCompat
    else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
        point.x = document.documentElement.scrollLeft;
        point.y = document.documentElement.scrollTop;
    }
    // 如果浏览器支持 document.body, 可以通过 document.body 来获取滚动高度
    else if (typeof document.body != 'undefined') {
        point.x = document.body.scrollLeft;
        point.y = document.body.scrollTop;
    }

    // 加上鼠标在视窗中的位置
    point.x += ev.clientX;
    point.y += ev.clientY;

    // 返回鼠标在视窗中的位置
    return point;
}
function isExists() {
    if (isV == "True") {
        alert("请您登录后进行下载！");
    }
}

