﻿
function setLocation()
{
    var expdate = new Date();
    expdate = expdate.addDays(7);
    Cookies.setValue("LastLocation", window.location.href, expdate);
}

DataList.setAccID = function(accID)
{
    DataList.v.AccID = accID;
    DataList.v.PageNumber = 1;
    if (accID == "0")
    {
        DataList.v.Constraint = "[Used]=@V0 AND [IsFinish]=@V1";
        DataList.v.Values = [true, true];
    }
    else
    {
        DataList.v.Constraint = "[CategoryID]=@V0 AND [Used]=@V1 AND [IsFinish]=@V2";
        DataList.v.Values = [accID, true, true];
    }
    DataList.render();
};

function iptKeyFocus()
{
    var val = $("S_Key").value;
    if (val == "新闻搜索")
    {
        $("S_Key").value = "";
    }
    $("S_Key").className = "yes_ipt_key";
}

function iptKeyBlur()
{
    var val = $("S_Key").value;
    if (val == null || val == "" || val == "新闻搜索")
    {
        $("S_Key").value = "新闻搜索";
        $("S_Key").className = "no_ipt_key";
    }
}

function iptKeyDown(evt)
{
    var event = window.event || evt;
    if (event.keyCode == 13)
    {
        event.keyCode = 9;
        searchNewsKey();
    }
}

function searchNewsKey()
{
    var key = $("S_Key").value;
    if (key == null || key == "")
    {
        key = "新闻搜索";
    }
    if (key == "新闻搜索")
    {
        if (DataList.v.AccID == "0")
        {
            DataList.v.Constraint = "[Used]=@V0 AND [IsFinish]=@V1";
            DataList.v.Values = [true, true];
        }
        else
        {
            DataList.v.Constraint = "[CategoryID]=@V0 AND [Used]=@V1 AND [IsFinish]=@V2";
            DataList.v.Values = [DataList.v.AccID, true, true];
        }
    }
    else
    {
        if (DataList.v.AccID == "0")
        {
            DataList.v.Constraint = "[Used]=@V0 AND [IsFinish]=@V1 AND ([Title] LIKE @V2 OR [Tags] LIKE @V3)";
            DataList.v.Values = [true, true, "%" + key + "%", "%" + key + "%"];
        }
        else
        {
            DataList.v.Constraint = "[CategoryID]=@V0 AND [Used]=@V1 AND [IsFinish]=@V2 AND ([Title] LIKE @V3 OR [Tags] LIKE @V4)";
            DataList.v.Values = [DataList.v.AccID, true, true, "%" + key + "%", "%" + key + "%"];
        }
    }

    DataList.render();
}
