﻿// JScript 文件
/*=========modified by liuxili 20080711=============*/
window.onload=function load()
{
    /*======判断有无二级子菜单,没有则用背景图片替换========*/
	var leftdiv=document.getElementById("lefttree");
    if(leftdiv!=null)
    {
        if(leftdiv.innerHTML.length==0)
        {
            leftdiv.className='lefttree2';
        }
        else
        {
            leftdiv.className='lefttree1';
        }
    }
    

	
	
	/*=============点击左边树形菜单，维持其展开状态==============*/
	var url=window.location.href;
	var args=url.split("&");
	var arglength=args.length-1;
	var strid=args[arglength];
	var ids=strid.split("=");
	var id=ids[1];
	
	var divid;
    if(id!=null)
    {
        i=id.length;
        while(i>3)
        {
            var imgs;
            divid="_first"+id.substring(0,i-3);
            if(document.getElementById(divid)!=null)
            {
                imgs = document.getElementById(divid).getElementsByTagName("IMG");
            }
            if(id.substring(0,i-3).length>3)
            {
                var tempnode = document.getElementById(id.substring(0,i-3)) ; 
                if(  tempnode )
                    document.getElementById(id.substring(0,i-3)).style.display="block";
            }
            if(imgs!=null&&imgs.length>0)
            {
                imgs[0].src='../images/expand.gif';
            }
            i-=3;
        }
    }
    
     /*===========当模板的左右不等高时，强制左右高度相等（只针对特定模板有用，其他模板报脚本错误=================*/
    var height_leftdiv=document.getElementById("leftdiv");
	var height_rightdiv=document.getElementById("rightdiv");
	if(height_leftdiv!=null&&height_rightdiv!=null)
	{
	if (height_leftdiv.clientHeight>=height_rightdiv.clientHeight){
		height_rightdiv.style.height=height_leftdiv.clientHeight+"px";			
	}
	else{
		height_leftdiv.style.height=height_rightdiv.clientHeight+"px";
	}
	}
	
}


function $(v) { return(document.getElementById(v)); }
function $C(v) {return(document.createElement(v));}
function $S(v) { return(document.getElementById(v).style); }

function ChangeExpand(obj,path1,path2,divID)
{
    var bool = true;
    if(obj.TagName ==null ||obj.TagName == 'close')
    {
        obj.src = path2;
        obj.TagName='expand';
        bool = true;
    }
    else  if(obj.TagName == 'expand')
    {
        obj.src = path1;
        obj.TagName='close';
        bool = false;
    }
    
    ShowOrCloseSonDiv(divID,bool);
}
/*
    显示或关闭div层
    第一个参数是divID，第二个参数是true或false
*/
function ShowOrCloseSonDiv(divID,isShow)
{
    if($(divID)==null)
    {
        return;
    }
    if(isShow == true)
    {
        $(divID).style.display = "block";
    }
    else
    {
        $(divID).style.display = "none";
    }
}

