function Scattitle()
{	
	Unselsubcat();
	Dd('categories-title').className = 'selcurrent';
	Ds('categories-l');
}
function Ccattitle()
{
	var pos = JPos.getAbsPos(Dd('categories-title'));
	var pmouse = getMousePos();
	if(pmouse.x <= pos.x || pmouse.x >= (pos.x+188) || pmouse.y <= pos.y)
	{
		Dh('categories-l');
		Dd('categories-title').className = 'nocurrent';
	} 
}?
function Scat(cid)
{	
	Unselsubcat();
	Dd('cat' + cid).className = 'current';
	var pos = JPos.getAbsPos(Dd('cat' + cid));
	Dd('categories-l-subs').style.top = pos.y - 148;
	Ds('subcat' + cid);
}
function Ccat(cid)
{
	var pos = JPos.getAbsPos(Dd('cat' + cid));
	var pmouse = getMousePos();
	if(pmouse.x <= pos.x) 
	{
		Csubcat(cid);
		Dh('categories-l');
		Dd('categories-title').className = 'nocurrent';
	}
}
function Ssubcat(cid)
{
	Dd('cat' + cid).className = 'current';
	Ds('subcat' + cid);
}
function Csubcat(cid)
{
	Dh('subcat' + cid);
	Dd('cat' + cid).className = '';
	setTimeout("Checksubcat();",500);
}
function Snode()
{
	Unselsubcat();
}
function Cnode()
{
	var pos = JPos.getAbsPos(Dd('node'));
	var pmouse = getMousePos();
	if(!(pmouse.y <= pos.y))
	{
		Dh('categories-l');
		Dd('categories-title').className = 'nocurrent';
	}
}
function Checksubcat()
{
	var isCsubcat = true;
	var templi = Dd('categories-l').getElementsByTagName("li");
	for(i=0;i<templi.length; i++){
		if (templi[i].className == 'current') 
		{
			isCsubcat = false;
			break;
		}
	}
	if (isCsubcat)
	{
		Dh('categories-l');
		Dd('categories-title').className = 'nocurrent';
	}
}
function Unselsubcat()
{
	var templi = Dd('categories-l').getElementsByTagName("li");
	for(i=0;i<templi.length; i++){
		var sc = 'sub' + templi[i].id;
		if (Dd(sc)) Dh(sc);
		if (templi[i].className == 'current') templi[i].className = '';
	}
}

function getMousePos()
{
	var x = event.clientX;
	var y = event.clientY;
	if(!document.all){
		mouse_x=event.pageX;
		mouse_y=event.pageY;
	}else{
		mouse_x=document.documentElement.scrollLeft+event.clientX;
		mouse_y=document.documentElement.scrollTop+event.clientY;
	}
	return {x:mouse_x,y:mouse_y};	
}

var JPos = {};
(function($){
	$.getAbsPos = function(pTarget){
		var x_ = y_ = 0;
		if(pTarget.style.position != "absolute"){		
			while(pTarget.offsetParent){
					x_ += pTarget.offsetLeft;
					y_ += pTarget.offsetTop;
					pTarget = pTarget.offsetParent;
			}
		}
			x_ += pTarget.offsetLeft;
			y_ += pTarget.offsetTop;
		return {x:x_,y:y_};
	}
	
	$.getEventPos = function(evt){
			var _x,_y;
			evt = JEvent.getEvent(evt);
			if(evt.pageX || evt.pageY){
				_x = evt.pageX;
				_y = evt.pageY;
			}else if(evt.clientX || evt.clientY){
				_x = evt.clientX + (document.body.scrollLeft || document.documentElement.scrollLeft) - (document.body.clientLeft || document.documentElement.clientLeft);
				_y = evt.clientY + (document.body.scrollTop || document.documentElement.scrollTop) - (document.body.clientTop || document.documentElement.clientTop);
			}else{
				return $.getAbsPos(evt.target);	
			}
			return {x:_x,y:_y};	
	}
})(JPos)

