﻿// JavaScript Document首页切换

function prepareEvent(e) {
    if (!e) {
        e = window.event;
    }
    return e;
}

//id下className集合
function getElementsByClassName(id,className)
{
    var divMain = document.getElementById(id);
    if(divMain)
    {
	    arrDiv=divMain.getElementsByTagName("div");
	    a=new Array();
	    aIndex=0;
	    for(i=0;i<arrDiv.length;i++)
	    {
		    if(arrDiv[i].className==className)	
		    {
			    a[aIndex]=arrDiv[i];
			    aIndex++;
		    }
	    }
	    return a;
	}
}


//添加鼠标事件
function addMainConEvent()
{
	arrClickTitle=getElementsByClassName("main_content","index_menu_bar");
	if(arrClickTitle)
	{
	    for(j=0;j<arrClickTitle.length;j++)
	    {
		    arrClickTitle[j].title=j;
		    arrClickTitle[j].onclick=function(){showMainCon(this.title);}
	    }
	}
}

//点击内容某一个 事件
function showMainCon(o)
{
	arrCon=getElementsByClassName("main_content","index_nenu_con");
	arrClickTitle=getElementsByClassName("main_content","index_menu_bar");
	for(j=0;j<arrCon.length;j++)
	{
		arrCon[j].style.display="none";
		arrClickTitle[j].style.background="url(images/over_but.jpg)"
	}
	arrClickTitle[o].style.background="url(images/on_but.jpg)"
	arrCon[o].style.display="block";
}


function addLeftEvent()
{
	arrLeftClickTitle=getElementsByClassName("leftbox","left_bar");
	for(j=0;j<arrLeftClickTitle.length;j++)
	{
		arrLeftClickTitle[j].title=j;
		arrLeftClickTitle[j].onclick = function() { showLeft(this.title); }
	}
	
}


function showLeft(o)
{
	arrLeft=document.getElementById("leftbox").getElementsByTagName("ul")
	for(j=0;j<arrLeft.length;j++)
	{
		arrLeft[j].style.display="none";
	}
	arrLeft[o].style.display="block";
}


function addTableColor()
{
	
	for(j=0;j<arrList.length;j++)
	{
		arrList[j].index=j;
		arrList[j].onmouseover=function(){showTableColor(this.index);}
		arrList[j].onmouseout=function(){hiddenTableColor(this.index);}
	}	
}

function showTableColor(o)
{
	arrList[o].style.backgroundColor="#CDE8FB";
	
	arrList[o].getElementsByTagName("a")[0].style.color="#f00"
}

function hiddenTableColor(o)
{
	arrList[o].style.backgroundColor="";
	arrList[o].getElementsByTagName("a")[0].style.color="#000"
}

//getElementsByClassName("main_content","index_menu").length


