﻿var IsNewsPage = false;
//跳转页面
function JampToPage(value)
{
    if(IsNewsPage == true )
    {
        ShowNewsByType(value);
    }
    else
    {
        SetCookie("NewsTypeID",value);
        window.location="../page/news.aspx";
    }
}

function JampToPageBySearch(TextBoxID, DefaultText)
{
    var TextBox = document.getElementById(TextBoxID);
    if(TextBox != null && TextBox.value != DefaultText && TextBox.value != "")
    {
        if(IsNewsPage == true )
        {
            Search(TextBox.value);
        }
        else
        {
            SetCookie("NewsTitle",TextBox.value);
            window.location="../page/news.aspx";
        }
    }
    else
    {   alert("请输入搜索条件！");}
}

//设置Cookie(键名，键值)
function SetCookie(Key, value)
{
    if(navigator.cookieEnabled)
    {
        document.cookie = Key + "=" + escape(value) + "; path=/";
    }
}

//读取Cookie（键名）
function ReadCookie(Key)
{
    var cookie = document.cookie;
    var first = cookie.indexOf(Key + "=");
    if(first >= 0)
    {
        var str = cookie.substring(first, cookie.length);
        var last = str.indexOf(";");
        if(last < 0)
        {
            last = str.length;
        }
        str = str.substring(0, last).split("=");
        return unescape(str[1]);        
    }
    else
    {
        return null;
    }
}