function right(e) {
   
   if (navigator.appName =='Netscape' && (e.which ==3|| e.which ==2))     {
     
     if (window.XMLHttpRequest && (!window.ActiveXObject)){        
        alert("版權所有請勿複製!!");        
     }
      return false;
   }
   else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2|| event.button ==3)) {
      alert("版權所有請勿複製!!");
      return false;
   }
   
   return true;
}
 
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;


function changeArrowOn(where)
{
	var childID=getCookie('childID');
	if(childID!=where)
	{
		var obj=document.getElementById(where);
		obj.src='../image/img_arrow_on.png';
	}
}
function changeArrowOff(where)
{
	var childID=getCookie('childID');
	if(childID!=where)
	{
		var obj=document.getElementById(where);
		obj.src='../image/img_arrow_off.png';
	}
}
function changeThirdArrowOff(where)
{
	var thirdChildID=getCookie('thirdChildID');
	if(thirdChildID!=where)
	{
		var obj=document.getElementById(where);
		obj.src='../image/img_arrow_off.png';
	}
}
function setCookie(pid,psrc)
{
	document.cookie="perentID="+pid;
	document.cookie="perentSRC="+psrc;
}
function getCookie( Name )
{
	var search = Name + "=";
	
	var returnvalue = "";
	if( document.cookie.length > 0 ) 
	{
		offset = document.cookie.indexOf( search );
		
		if( offset != -1 ) 
		{ 
			offset += search.length;

			end = document.cookie.indexOf( ";" , offset );
			if( end == -1 ) 
				end = document.cookie.length;
			
			returnvalue = unescape( document.cookie.substring( offset , end ) );
			return returnvalue;
		}
		else
			return false;
	}
	else
		return false;	
}
function loadCookie()
{
	
	var perentID=getCookie('perentID');
	var perentSRC=getCookie('perentSRC');	
	var childID=getCookie('childID');
	var childSRC=getCookie('childSRC');		
	var thirdChildID=getCookie('thirdChildID');
	var thirdChildSRC=getCookie('thirdChildSRC');		
	var openPerentID=getCookie('openPerentID');
	
	if(perentID!="")
	{
		document.getElementById(perentID).src='images/'+perentSRC;
		if(openPerentID!==false)
			showChildNodes(document.getElementById(perentID).parentNode,null,null,childID);
	}

	//alert(childID);
	if(childID!==false)
	{
		try{
			document.getElementById(childID).src='../image/'+childSRC;			
			document.getElementById(childID).parentNode.childNodes.item(2).style.color='#920202';
		}
		catch(e)
		{}
	}
	
	var thirdName=getCookie('thirdName');
	if(thirdName!="")
	{		
		showThirdChild(thirdName);
	}
		
	if(thirdChildID!="")
	{		
		try{
		document.getElementById(thirdChildID).src='../image/'+thirdChildSRC;	
		document.getElementById(thirdChildID).parentNode.childNodes.item(2).style.color='#920202';
		}
		catch(e)
		{}
	}
}
function changeIMGon(obj,img)
{
	obj.src=img;
}
function changeIMGoff(obj,img)
{
	var perentID=getCookie('perentID');
	if(perentID!=(obj.getAttribute('id')))
		obj.src=img;
}
function showChildNodes(obj,pid,psrc,cid)
{	
	if(obj!=null)
	{
		var children=obj.parentNode.childNodes.length;		
		
		if (window.XMLHttpRequest)
		{//Mozilla, Safari,...IE7    
			//alert('Mozilla, Safari,...IE7 ');   
			if(!window.ActiveXObject)// Mozilla, Safari,...   
			{
				//alert('Mozilla, Safari');				
				if(children==4)
					obj.parentNode.childNodes.item(2).style.display='';		
			}
			else
			{
				//alert('IE7'); 
				if(children==3)
					obj.parentNode.childNodes.item(2).style.display='';
			}
		}   
		else  
		{
			//alert('IE6');
			if(children==3)
				obj.parentNode.childNodes.item(2).style.display='';		
		}
	}
	else
	{
		//alert(getCookie('openPerentID'));
		if(getCookie('openPerentID')===false)
		{
			document.cookie="openPerentID="+pid;
		}
		else if(getCookie('openPerentID')!==pid)
		{
			document.cookie="openPerentID="+pid;
		}
		else
		{
			//document.cookie="openPerentID=;expires=Thu,01-Jun-70 00:00:01 GMT";
			//closeThisPerent(getCookie('openPerentID'));
		}
	}
	
	if((pid != null) && (psrc != null))
	{
		setCookie(pid,psrc);		
	}
		
	if(cid != null)
	{
		//setChildStatus(cid);
		document.cookie="childID="+cid;
		document.cookie="childSRC=img_arrow_on.png";	
	}

}
function setChildNodes(pid,psrc,cid)
{
	if(getCookie('preOpenPerentID')===false)
	{
		document.cookie="preOpenPerentID="+pid;
		//if(getCookie('openPerentID')===false)
		//{
			document.cookie="openPerentID="+pid;
		//}
		
		if((pid != null) && (psrc != null))
		{
			setCookie(pid,psrc);		
		}
			
		if(cid != null)
		{
			//setChildStatus(cid);
			document.cookie="childID="+cid;
			document.cookie="childSRC=img_arrow_on.png";	
		}
	}
}
function closeThisPerent(pid)
{
	var obj=document.getElementById(pid).parentNode;
	var children=obj.parentNode.childNodes.length;		
		
	if (window.XMLHttpRequest)
	{//Mozilla, Safari,...IE7    
		//alert('Mozilla, Safari,...IE7 ');   
		if(!window.ActiveXObject)// Mozilla, Safari,...   
		{
			//alert('Mozilla, Safari');				
			if(children==4)
				obj.parentNode.childNodes.item(2).style.display='none';		
		}
		else
		{
			//alert('IE7'); 
			if(children==3)
				obj.parentNode.childNodes.item(2).style.display='none';
		}
	}   
	else  
	{
		//alert('IE6');
		if(children==3)
			obj.parentNode.childNodes.item(2).style.display='none';		
	}
}
function setChildStatus(cid)
{
	document.cookie="childID="+cid;
	document.cookie="childSRC=img_arrow_on.png";	
}
function killcookie()
{
	document.cookie="childID=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="childSRC=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="perentID=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="perentSRC=;expires=Thu,01-Jun-70 00:00:01 GMT";	
	document.cookie="thirdName=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="thirdChildID=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="thirdChildSRC=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="openPerentID=;expires=Thu,01-Jun-70 00:00:01 GMT";
	document.cookie="preOpenPerentID=;expires=Thu,01-Jun-70 00:00:01 GMT";
}
function showThirdChild(li_name)
{
	var children = document.getElementsByTagName( 'li' );
	for( i = 0 ; i < children.length ; i++ )
	{
		//alert(children[i].getAttribute("NAME"));
		if(children[i].getAttribute("NAME")==li_name)		
			children[i].style.display='';
	}
	if(children.length>0)
	{
		var childID=getCookie('childID');
		var obj=document.getElementById(childID);
		obj.src='../image/img_arrow_down_on.png';	
	}
}
function setThirdChild(li_name)
{
	if(getCookie('thirdName')===false)
	{
		document.cookie="thirdName="+li_name;
	}
	else if(getCookie('thirdName')!==li_name)
	{
		document.cookie="thirdName="+li_name;
	}
	else
	{
		document.cookie="thirdName=;expires=Thu,01-Jun-70 00:00:01 GMT";
		closeThirdChild(getCookie('thirdName'));
	}	
	//document.cookie="thirdName="+li_name;
}
function closeThirdChild(li_name)
{
	var children = document.getElementsByTagName( 'li' );
	for( i = 0 ; i < children.length ; i++ )
	{
		if(children[i].getAttribute("NAME")==li_name)		
			children[i].style.display='none';
	}
}
function killThirdChild()
{
	document.cookie="thirdName=;expires=Thu,01-Jun-70 00:00:01 GMT";	
}
function setThirdChildStatus(third_id)
{
	document.cookie="thirdChildID="+third_id;
	document.cookie="thirdChildSRC=img_arrow_on.png";
}
