// JavaScript Document

function getNextElement(node){
if(node.nodeType==1){
return node;
}
if(node.nextSibling){
return getNextElement(node.nextSibling);
}
return null;
}

function addLoadEvent(func){
var oldonload=window.onload;
if(typeof window.onload!="function"){
window.onload=func;
}
else{
window.onload=function(){
oldonload();
func();
}
}
}

function insertAfter(newElement,targetElement){
var parent=targetElement.parentNode;
if(parent.lastChild==targetElement){
parent.appendChild(newElement);
}
else{
parent.insertBefore(newElement,targetElement.nextSibling);
}
}

function showLayer(){
 try{
	var oTarget=document.getElementById("net");
	var oDiv=document.getElementById("net").getElementsByTagName("ul")[0];
	oTarget.onmouseover=function(){
		oDiv.className+=(oDiv.className.length>0?" ":"")+"show";
	};
	oTarget.onmouseout=function(){
		oDiv.className=oDiv.className.replace(new RegExp("( ?|^)show\\b"),"");
	};
  }catch(e)
  {  
  }
}
addLoadEvent(showLayer);

function onSelect(){
    var oTarget=document.getElementById("networks");
}

function initialClick(){
 try{
	var oTarget=document.getElementById("sidebar").getElementsByTagName("li");
	for(var i=0;i<oTarget.length;i++){
		oTarget[i].className=oTarget[i].className.replace(new RegExp("( ?|^)show\\b"),"");
	}
  }catch(e)
  {  
  }
}
function addClick(){
try{
	var oSource=document.getElementById("sidebar").getElementsByTagName("li");
	for(var j=0;j<oSource.length;j++){
		oSource[j].onclick=function(){
		    if(this.className.indexOf("show")==-1){
		    	initialClick();
			    this.className+=(this.className.length>0?" ":"")+"show";
				//var oTarget=getNextElement(this);
//				oTarget.nextSibling.className+=(oTarget.nextSibling.className.length>0?" ":"")+"show";
				//alert(oTarget.nextSibling.className);
		    }
		    else{
			    this.className=this.className.replace(new RegExp("( ?|^)show\\b"),"");
				//var oTarget=getNextElement(this);
//				oTarget.nextSibling.className=oTarget.nextSibling.className.replace(new RegExp("( ?|^)show\\b"),"");
		    }
		    //return false;
		}
	}
  }catch(e)
  {  
  }
}
addLoadEvent(addClick);

function tabs(m,num,source,target){
	var oSource=document.getElementById(source).getElementsByTagName("li");
	var oTarget=document.getElementById(target).getElementsByTagName("div");
	for(var i=0;i<num;i++){
		oSource[i].className=oSource[i].className.replace(new RegExp("home\\b"),"");
		oTarget[i].className=oTarget[i].className.replace(new RegExp("show\\b"),"");
    }
	oSource[m].className+=(oSource[m].className.length>0?" ":"")+"home";
	oTarget[m].className+=(oTarget[m].className.length>0?" ":"")+"show";
}