﻿//反向展开或收回所有
function MenuClickAll()
{
//    if (document.getElementById("div1").style.display == "")
//    { 
//        for( i = 1 ; i < 8 ; i++ )
//        {
//            document.getElementById("div"+i).style.display = "none";
//        }
//    }
//    else
//    {  
//       for( i = 1 ; i < 8 ; i++ )
//        {
//            document.getElementById("div"+i).style.display = "";
//        }
//    }
     for( i = 1 ; i < 9 ; i++ )
     {
        MenuClick("div"+i);
     }
}

//初始化收回
function MenuLoad()
{ 
   //DelCookie("menu");    
    var hisCookie = GetCookie("menu");
    for( i = 1 ; i < 9 ; i++ )
    {
        if (hisCookie != null )
        {           
            if (hisCookie.indexOf("div"+i) > -1 )
            {              
                if (document.getElementById("div"+i) !=  null)
                {               
                    document.getElementById("div"+i).style.display = "";
                }
            }
            else
            {
                if (document.getElementById("div"+i) != null)
                {
                    document.getElementById("div"+i).style.display = "none";
                }
            }
        }
        else
        {
            if (document.getElementById("div"+i) != null)
            {
                document.getElementById("div"+i).style.display = "";
            }
        }
    }  
 }

//点击时的展开或收回
function MenuClick(divId)
{  
    if (document.getElementById(divId) != null)
    {    
        var hisCookie = GetCookie("menu");    
        if (document.getElementById(divId).style.display == "")
        {    
            if (hisCookie != null)
            {           
                if (hisCookie.indexOf(divId) > -1 )
                {   
                    SetCookie("menu",hisCookie.replace(divId,""));
                }
            }
            document.getElementById(divId).style.display = "none";
        }
        else
        {   
            //展开记录到cookie
            if (hisCookie != null)
            {
                if (hisCookie.indexOf(divId) == -1)
                {    
                    SetCookie("menu",hisCookie+divId);
                }
            }
            else
            {
                SetCookie("menu",divId);
            }
            document.getElementById(divId).style.display = "";
        }
    }
}

//获得Cookie的原始值
function GetCookie(name)
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return GetCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
//设定Cookie值
function SetCookie(name, value)
{
    var expdate = new Date();
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
    +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
    +((secure == true) ? "; secure" : "");
}

//获得Cookie解码后的值
function GetCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

//删除Cookie
function DelCookie(name)
{
    var exp = new Date();
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

//页面跳转
function GoUrl(frameId, url)
{
    if(frameId == "")
    {
	    window.location.href = url;
    }
    else
    {
        window.frames[frameId].location.href = url;
    }
}
    
// 颜色加深
function Fuscous(obj)
{
    obj.style.backgroundColor='#D3DEEF';
}
//颜色恢复为白色
function Undertone(obj)
{
    obj.style.backgroundColor='#ffffff';     
}
//全选及全不选
function ChooseAll(sel,check)
{		
	var objtb=document.getElementById(sel);
	var num=objtb.getElementsByTagName("input");
	var check=document.getElementById(check);
	for(i=0;i<num.length;i++)
	{
		if(num[i].tagName=="INPUT")
		{
			if(check.checked==true)
			{num[i].checked=true;}
			else{num[i].checked=false;}
		}
	}
} 

function OpenAuto(AutoId)
{ 
    window.open('AutoInfo.aspx?id='+AutoId+'','','top=150,left=200,width=630,height=500,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,scrollbars=yes');
}

function OpenUser(UserId)
{ 
    window.open('UserInfo.aspx?id='+UserId+'','','top=150,left=200,width=630,height=450,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,scrollbars=yes');
}

function OpenCompany(CompanyId)
{ 
    window.open('CompanyInfo.aspx?id='+CompanyId+'','','top=150,left=200,width=630,height=450,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,scrollbars=yes');
}
