﻿function showChildren(id) 
{
    //alert(event.srcElement.tagName);
     if(event.srcElement.tagName.toUpperCase()=="STRONG")
        return false;
     var objDIV = document.getElementById(id);
     if(objDIV.style.display=='none')
     {
        objDIV.style.display = '';
        addCookie(id,id,0);
     }
     else
     {
        objDIV.style.display = 'none';
        deleteCookie(id);
     }
}

function addCookie(name,value,expireHours)
{
    var cookieString=name+"="+escape(value)+";path=/";
    //判断是否设置过期时间
    if(expireHours>0)
    {
        var date=new Date();
        date.setTime(date.getTime+expireHours*3600*1000); // 转换为毫秒
        cookieString=cookieString+";expire="+date.toGMTString();
    }
    document.cookie=cookieString;
}



function deleteCookie(name)
{
    var date=new Date();
    date.setTime(date.getTime()-10000); // 删除一个cookie，就是将其过期时间设定为一个过去的时间
    document.cookie=name+"=v;path=/;expire="+date.toGMTString();
}


function getCookie(name)
{
    var strCookie=document.cookie;
    var arrCookie=strCookie.split("; "); // 将多cookie切割为多个名/值对
    for(var i=0;i<arrCookie.length;i++)
    { // 遍历cookie数组，处理每个cookie对
        var arr=arrCookie[i].split("="); // 找到名称为userId的cookie，并返回它的值
        if(arr[0]==name)
        return arr[1];
    }
    return "";
}
