
//															
//	(c) 2006  e-pla.net/network								
//															



var nwb_V_offset= 1,
	nwb_H_offset= 1,

	nwb_Right	= 0,
	nwb_Down	= 1,

	nwb_Menus	= new Array(),
	nwb_Timer	,

	nwb_SubMenusLoaded	= false,
	nwb_Arguments		= new Array(),
	nwb_ImgWait			= new Image();	nwb_ImgWait.src	  = "http://e-pla.net/img/wait.gif";
	nwb_ImgWait_b		= new Image();	nwb_ImgWait_b.src = "http://e-pla.net/img/wait_b.gif";



	if ((typeof nwb_Host == "undefined"	)
	 || (		nwb_Host == "null"		))	 nwb_Host = '';
	  else									 nwb_Host = 'http://'+nwb_Host;


//									
//	Ajax							
//									

function AjaxCreate()
	{
	try	{return new XMLHttpRequest();					}	catch(e) {}
	try	{return new ActiveXObject ("MSXML2.XMLHTTP"	  );}	catch(e) {}
	try	{return new ActiveXObject ("Microsoft.XMLHTTP");}	catch(e) {}
		 return false ;
	}



function AjaxExecute (url, data, funct)
	{
	var xhr = AjaxCreate();

	xhr.onreadystatechange=function()
		{
		if ((xhr.readyState==  4)
		  &&(xhr.status	   ==200))
			{
//			alert (xhr.responseText);		////
			funct (xhr.responseText);
			}
		};

	xhr.open("POST",url,true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	}








function toggleNetworkBar()
	{
	nwb_MHide(0);

	o = $("networkbar");
	o.style.display = (o.style.display=="block")?"none":"block";
	return false;
	}



function nwb_Show()	{				$("networkbar").style.display="block";}
function nwb_Hide()	{ nwb_MHide(0);	$("networkbar").style.display="none" ;}



function nwb_StartTimer()	{ nwb_Timer = setTimeout ("nwb_Hide()",500);}
function nwb_ResetTimer()	{ clearTimeout (nwb_Timer);					}




function nwb_Over (iItem,iLevel,iSubMenu_Id,iType)
	{
	if (typeof iType == "undefined")
		{
		iType = nwb_Right;
		}


	nwb_MHide(iLevel);

	if (iSubMenu_Id)
		{
		var iMenu		= $(iSubMenu_Id);
		var iMenu_Style	= iMenu.style;

		iMenu_Style.top  = _Get_OffsetTop (iItem) + (iType==nwb_Down  ? iItem.offsetHeight + nwb_V_offset:0) + nwb_MenuOffset + "px";
		iMenu_Style.left = _Get_OffsetLeft(iItem) + (iType==nwb_Right ? iItem.offsetWidth  + nwb_H_offset:0) + nwb_MenuOffset + "px";
		iMenu_Style.display	= "block";

		nwb_Menus[iLevel] = iMenu;

		if (!nwb_SubMenusLoaded
		 && (iLevel != 0)
		 && (nwb_FirstSubMenuAJAX || (iSubMenu_Id.substr(0,6)!="nwb_1_")))
			{
			nwb_Arguments = arguments;

			AjaxExecute (nwb_Host+"/network-bar.ajax.php", (nwb_FirstSubMenuAJAX?"FirstSubMenuAJAX=1":""), nwb_LoadSubMenus);
			}
		}

	return true;
	}




function nwb_LoadSubMenus(iMessage)
	{
	if (iMessage=="")
		{
		return;
		}


	if (nwb_FirstSubMenuAJAX)
		{
		a = iMessage.split('%%');

		$("nwb_SubMenus"	).innerHTML = a[0];
		$("nwb_SiteSubMenus").innerHTML = a[1];
		}
	  else
		{
		$("nwb_SubMenus"	).innerHTML = iMessage;
		}


	nwb_SubMenusLoaded = true ;

	nwb_Over (nwb_Arguments[0],
			  nwb_Arguments[1],
			  nwb_Arguments[2],
			  nwb_Arguments[3]);
	}




function nwb_MHide(iLevel)
	{
	for (var i=iLevel, iMax=nwb_Menus.length; i<iMax; i++)
		{
		nwb_Menus[i].style.display="none";
		}
	}



function _Get_OffsetTop (o) { var i=0;  while (o.offsetParent) {i+=o.offsetTop ; o=o.offsetParent;} return i-$("networkbar_inside").offsetTop; }
function _Get_OffsetLeft(o) { var i=0;  while (o.offsetParent) {i+=o.offsetLeft; o=o.offsetParent;} return i-$("networkbar_inside").offsetLeft;}


