﻿// JScript 文件
var obj = window.document.body.getElementsByTagName("input");
for (var i = 0; i < obj.length; i++)
{
    if (obj[i].getAttribute("NoValue") != null && obj[i].getAttribute("NoValue") != "")
    {
        if (obj[i].value == "")
        {
            obj[i].style.color = "#e0e0e0";
            obj[i].value = obj[i].getAttribute("NoValue");
            obj[i].setAttribute("IsChage", "1");
        }
        else
        {
            obj[i].setAttribute("IsChage", "0");
        }
        if (window.addEventListener)
        {
            obj[i].addEventListener('focus', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                if (obj.getAttribute("IsChage") == '1') obj.value = '';
                if (obj.getAttribute("WColor") != null && obj.getAttribute("WColor") != "")
                {
                    obj.style.color = obj.getAttribute("WColor");
                }
                else
                {
                    obj.style.color = "#000";
                }
            }, false);
            obj[i].addEventListener('keypress', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                obj.setAttribute("IsChage", '0');
            }, false);
            obj[i].addEventListener('blur', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                if (obj.value == '')
                {
                    obj.value = obj.getAttribute("NoValue");
                    obj.style.color = "#e0e0e0";
                    obj.setAttribute("IsChage", '1');
                } else
                {
                    obj.setAttribute("IsChage", '0');
                    if (obj.getAttribute("WBColor") != null && obj.getAttribute("WBColor") != "")
                    {
                        obj.style.color = obj.getAttribute("WBColor");
                    }
                    else
                    {
                        if (obj.getAttribute("WColor") != null && obj.getAttribute("WColor") != "")
                        {
                            obj.style.color = obj.getAttribute("WColor");
                        }
                        else
                        {
                            obj.style.color = "#000";
                        }
                    }
                }
            }, false);
        }
        else if (window.attachEvent)
        {
            obj[i].attachEvent('onfocus', function()
            {
                if (event.srcElement.getAttribute("IsChage") == '1') event.srcElement.value = '';
                if (event.srcElement.getAttribute("WColor") != null && event.srcElement.getAttribute("WColor") != "")
                {
                    event.srcElement.style.color = event.srcElement.getAttribute("WColor");
                }
                else
                {
                    event.srcElement.style.color = "#000";
                }
            });
            obj[i].attachEvent('onkeypress', function() { event.srcElement.setAttribute("IsChage", '0') });
            obj[i].attachEvent('onblur', function()
            {
                if (event.srcElement.value == '')
                {
                    event.srcElement.value = event.srcElement.getAttribute("NoValue");
                    event.srcElement.style.color = "#e0e0e0";
                    event.srcElement.setAttribute("IsChage", '1');
                } else
                {
                    event.srcElement.setAttribute("IsChage", '0');
                    if (event.srcElement.getAttribute("WBColor") != null && event.srcElement.getAttribute("WBColor") != "")
                    {
                        event.srcElement.style.color = event.srcElement.getAttribute("WBColor");
                    }
                    else
                    {
                        if (event.srcElement.getAttribute("WColor") != null && event.srcElement.getAttribute("WColor") != "")
                        {
                            event.srcElement.style.color = event.srcElement.getAttribute("WColor");
                        }
                        else
                        {
                            event.srcElement.style.color = "#000";
                        }
                    }
                }
            });
        }
        else
        {

            obj[i].onfocus = function()
            {
                if (this.getAttribute("IsChage") == '1') this.value = '';
                if (this.getAttribute("WColor") != null && this.getAttribute("WColor") != "")
                {
                    this.style.color = obj.getAttribute("WColor");
                }
                else
                {
                    this.style.color = "#000";
                }
            }
            obj[i].onkeypress = function() { this.setAttribute("IsChage", '0'); }
            obj[i].onblur = function()
            {
                if (this.value == '')
                {
                    this.value = this.getAttribute("NoValue");
                    this.style.color = "#e0e0e0";
                    this.setAttribute("IsChage", '1');
                } else
                {
                    this.setAttribute("IsChage", '0');
                    if (this.getAttribute("WBColor") != null && this.getAttribute("WBColor") != "")
                    {
                        this.style.color = this.getAttribute("WBColor");
                    }
                    else
                    {
                        if (this.getAttribute("WColor") != null && this.getAttribute("WColor") != "")
                        {
                            this.style.color = obj.getAttribute("WColor");
                        }
                        else
                        {
                            this.style.color = "#000";
                        }
                    }
                }
            }
        }
    }
}
obj = window.document.body.getElementsByTagName("textarea");
for (var i = 0; i < obj.length; i++)
{
    if (obj[i].getAttribute("NoValue") != null && obj[i].getAttribute("NoValue") != "")
    {
        if (obj[i].value == "")
        {
            obj[i].style.color = "#e0e0e0";
            obj[i].value = obj[i].getAttribute("NoValue");
            obj[i].setAttribute("IsChage", "1");
        }
        else
        {
            obj[i].setAttribute("IsChage", "0");
        }
        if (window.addEventListener)
        {
            obj[i].addEventListener('focus', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                if (obj.getAttribute("IsChage") == '1') obj.value = '';
                if (obj.getAttribute("WColor") != null && obj.getAttribute("WColor") != "")
                {
                    obj.style.color = obj.getAttribute("WColor");
                }
                else
                {
                    obj.style.color = "#000";
                }
            }, false);
            obj[i].addEventListener('keypress', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                obj.setAttribute("IsChage", '0');
            }, false);
            obj[i].addEventListener('blur', function(event)
            {
                var e = event ? event : window.event;
                var obj = e.srcElement ? e.srcElement : e.target;
                if (obj.value == '')
                {
                    obj.value = obj.getAttribute("NoValue");
                    obj.style.color = "#e0e0e0";
                    obj.getAttribute("IsChage") = '1';
                } else
                {
                    obj.setAttribute("IsChage", '0');
                    if (obj.getAttribute("WBColor") != null && obj.getAttribute("WBColor") != "")
                    {
                        obj.style.color = obj.getAttribute("WBColor");
                    }
                    else
                    {
                        if (obj.getAttribute("WColor") != null && obj.getAttribute("WColor") != "")
                        {
                            obj.style.color = obj.getAttribute("WColor");
                        }
                        else
                        {
                            obj.style.color = "#000";
                        }
                    }
                }
            }, false);
        }
        else if (window.attachEvent)
        {
            obj[i].attachEvent('onfocus', function()
            {
                if (event.srcElement.getAttribute("IsChage") == '1') event.srcElement.value = '';
                event.srcElement.style.color = "#000";
            });
            obj[i].attachEvent('onkeypress', function() { event.srcElement.setAttribute("IsChage", '0') });
            obj[i].attachEvent('onblur', function()
            {
                if (event.srcElement.value == '')
                {
                    event.srcElement.value = event.srcElement.getAttribute("NoValue");
                    event.srcElement.style.color = "#e0e0e0";
                    event.srcElement.setAttribute("IsChage", '1');
                } else
                {
                    event.srcElement.setAttribute("IsChage", '0');

                    if (event.srcElement.getAttribute("WBColor") != null && event.srcElement.getAttribute("WBColor") != "")
                    {
                        event.srcElement.style.color = event.srcElement.getAttribute("WBColor");
                    }
                    else
                    {
                        if (event.srcElement.getAttribute("WColor") != null && event.srcElement.getAttribute("WColor") != "")
                        {
                            event.srcElement.style.color = event.srcElement.getAttribute("WColor");
                        }
                        else
                        {
                            event.srcElement.style.color = "#000";
                        }
                    }

                }
            });
        }
        else
        {

            obj[i].onfocus = function()
            {
                if (this.getAttribute("IsChage") == '1') this.value = '';
                this.style.color = "#000";
            }
            obj[i].onkeypress = function() { this.setAttribute("IsChage", '0'); }
            obj[i].onblur = function()
            {
                if (this.value == '')
                {
                    this.value = this.getAttribute("NoValue");
                    this.style.color = "#e0e0e0";
                    this.setAttribute("IsChage", '1');
                } else
                {
                    this.setAttribute("IsChage", '0');
                    if (this.getAttribute("WBColor") != null && this.getAttribute("WBColor") != "")
                    {
                        this.style.color = this.getAttribute("WBColor");
                    }
                    else
                    {
                        if (this.getAttribute("WColor") != null && this.getAttribute("WColor") != "")
                        {
                            this.style.color = this.getAttribute("WColor");
                        }
                        else
                        {
                            this.style.color = "#000";
                        }
                    }
                }
            }
        }
    }
}



//function MaintainStatus()
//{
//    try
//    {
//        if(Page.GetLoginOfAjax().value!="OK")
//        {
//            window.location.reload();
//            //window.location.href=window.location.href;
//        }
//        else
//        {
//            setTimeout("MaintainStatus();",600000)
//        }
//    }
//    catch(e)
//    {}
//}
//setTimeout("MaintainStatus();",10000)
BaseInfoSumbit_Class = function(json)
{
    if (window.document.getElementById("BaseInfoSumbit") == null)
    {
        var v = '<div style="display:none">';
        v += '<form action="printpaypage.aspx" target="_self" id="BaseInfoSumbit" method="post">';
        v += '<input id="BaseInfo_SumbitData" name="SumbitData" value="{}" />';
        v += '</form>';
        v += '</div>';

        window.document.body.innerHTML += v;
    }
    window.document.getElementById("BaseInfo_SumbitData").value = json;
};
BaseInfoSumbit_Class.prototype.Sumbit = function(url, obj, target)
{
    window.document.getElementById("BaseInfo_SumbitData").value = JSON.stringify(obj);
    window.document.getElementById("BaseInfoSumbit").action = url;
    if (target != null)
    {
        window.document.getElementById("BaseInfoSumbit").target = target;
    }
    //window.document.forms[1].submit();
    window.document.getElementById("BaseInfoSumbit").submit();
}
BaseInfoSumbit_Class.prototype.GetObj = function()
{
    if (window.document.getElementById("BaseInfo_SumbitData").value == "")
    {
        window.document.getElementById("BaseInfo_SumbitData").value = "{}";
    }
    return JSON.parse(window.document.getElementById("BaseInfo_SumbitData").value)
}

function scrollPage(url)
{
    window["BaseInfoSumbit"].Sumbit(url, window["BaseInfoSumbit"].GetObj(), "_self");
}




function GTBaseGoPage(obj, page)
{
    var a = JSON.parse(window.document.getElementById("__PageValueCacheOfJson$BasePage").value)
    a[obj] = page;
    window.document.getElementById("__PageValueCacheOfJson$BasePage").value = JSON.stringify(a)
    __doPostBack('$GoCurrentPage', '');
}


//时间操作类开始

//取得时间开始
//返回的是当前的时间
//月份操作
Date.prototype.addMonth = function(size)
{
    var NowDate = this;
    var year = NowDate.getFullYear();
    var month = NowDate.getMonth() + 1;
    var day = NowDate.getDate();

    try
    {
        size = parseInt(size);
    }
    catch (e)
    {
        size = 0;
    }
    if (String(size) == "NaN")
    {
        size = 0;
    }

    month = month + size;

    var value = parseInt(month / 12); //除以12的值
    var remainder = month % 12; //除以12的余数

    if (month > 12)
    {
        year = year + value;
        month = remainder;
    }
    else if (month < 1)
    {
        year = year + value - 1;
        month = remainder + 12;
    }

    if (month == 2)
    {
        if (day > 28)
        {
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
            {
                day = 29;
            }
            else
            {
                day = 28;
            }
        }
    }
    else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
    {
        //if((NowDate.getMonth() + 1)==2)
        if(NowDate.getDate()==30 && (NowDate.getMonth() + 1)!=month)
        {
            day = 31;
        }
    }
    else
    {
        if(NowDate.getDate()==31 && (NowDate.getMonth() + 1)!=month)
        {
            day = 30;
        }
    }

    var str = year + "-";

    if (month < 10)
    {
        str += "0"

    }
    str += month + "-";

    if (day < 10)
    {
        str += "0"
    }
    str += day;

    return str;
}


//添加年
Date.prototype.addYear = function(size)
{
    var NowDate = this;
    var year = NowDate.getFullYear();
    var month = NowDate.getMonth() + 1;
    var day = NowDate.getDate();

    try
    {
        size = parseInt(size);
    }
    catch (e)
    {
        size = 0;
    }
    if (String(size) == "NaN")
    {
        size = 0;
    }

    month = month + size;

    year = year + size;

    if (month == 2)
    {
        if (day > 28)
        {
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
            {
                day = 29;
            }
            else
            {
                day = 28;
            }
        }
    }
    

    var str = year + "-";

    if (month < 10)
    {
        str += "0"

    }
    str += month + "-";

    if (day < 10)
    {
        str += "0"
    }
    str += day;

    return str;
}

function AddMonth(size)
{
    var NowDate = new Date();
    return NowDate.addMonth(size);
}


