oldonload_global=window.onload;
window.onload=function()
{
	if(typeof oldonload_global == 'function')
		oldonload_global();
		
//	closecomments();
	navi=new menu();
}
cv={};
function closecomments()
{
    cv.c=document.getElementById('comment_entry');
    if(typeof cv.c != 'undefined' && cv.c != null)
    {
		document.getElementById("comments_body").style.display='none';
		
        var p=cv.c.getElementsByTagName('p')[0];
        cv.form=cv.c.getElementsByTagName('form')[0];
        cv.c.removeChild(p);
        cv.a=document.createElement('a');
        cv.a.href='javascript:opencomments()';
		cv.a.className='a_comment';
        var text=document.createTextNode('Comments');
        cv.a.appendChild(text);
        cv.c.insertBefore(cv.a,cv.c.firstChild);

        var st=cv.c.style;
        st.overflow='hidden';
        st.height='20px';

        cv.form.style.display='none';
    }
}

function opencomments()
{
    if(typeof cv.c != 'undefined' && cv.c != null)
    {
		document.getElementById("comments_body").style.display='block';
		
        var st=cv.c.style;
        st.overflow='visible';
        st.height='140px';

        cv.form.style.display='block';
    }
}

function menu()
{
	var div=document.getElementById('menu');
	var lis=div.getElementsByTagName('li');
	this.as=new Array();
	for(var i=0;i<lis.length;i++)
	{
		if(lis[i].className.indexOf(' sel')!=-1)
			continue;
		var op=lis[i].getElementsByTagName('a')[0];
		this.as.push(new navitem(op,this));
	}
}
$pr=menu.prototype;
$pr.closeall=function()
{
	if(typeof this.as!='undefined' && typeof this.as.length != 'undefined')
	{
		for(var i in this.as)
			if(this.as[i].isopen && !this.as[i].mouseover && !this.as[i].running)
				this.as[i].rollout(true);
	}
}

function navitem(a,p)
{
	this.p=p;
	this.a=a;
	this.a.p=this;
	this.a.style.opacity='1';
	this.a.className='man';
	this.a.onmouseover=function()
	{
		this.p.rollover();
	}
	this.a.onmouseout=function()
	{
		this.p.rollout();
	}
}
$pr=navitem.prototype;
$pr.isopen=false;

$pr.rollover=function()
{
	this.mouseover=true;
	if(!this.isopen)
	{
		this.isopen=true;
		this.dorollover();
//		this.p.closeall();
	} else
	{
		this.rolledover();
	}
	clearInterval(this.closer);
}
$pr.dorollover=function()
{
	this.running=true;
	this.killanimator();
	
	var roundani=false;
	if(browser.isIE6up && typeof this.a.filters=='object')
	{
		element=this.a.filters.alpha;
		var property='opacity';
		var begin=Number(element.opacity);
		roundani=true;
	} else
	{
		element=this.a.style;
		var property='opacity';
		var begin=Number(element.opacity);
	}
	var change=0-begin;
	var time=15;
	var type='outCirc';
	
	this.an=new phocus.Animator(element,property,begin,change,time,type);
	this.an.transform='%%val%%';
	this.an.round=roundani;
	this.an.addListener(this,'rolledover');
	this.an.run();
}
$pr.rolledover=function()
{
	this.running=false;
	if(browser.isIE6up && typeof this.a.filters=='object')
		this.a.filters.alpha.opacity=0;
	else
		element=this.a.style.opacity=0;
}
$pr.rollout=function(override)
{
	this.mouseover=false;
	if(override)
	{
		clearInterval(this.closer);
		this.killanimator();
	}
	if(this.isopen)
	{
		var _doclose=this.dorollout;
		var _obj=this;
		this.closer=setInterval(function(){_doclose.apply(_obj)},override ? 1 : 100);
	}
}
$pr.dorollout=function()
{
	if(typeof navman != 'undefined' && navman.out)
		navman.out();
	clearInterval(this.closer);

	this.running=true;
	this.killanimator();

	var roundani=false;
	if(browser.isIE6up && typeof this.a.filters=='object')
	{
		element=this.a.filters.alpha;
		var property='opacity';
		var begin=Number(element.opacity);
		var change=100-begin;
		roundani=true;
	} else
	{
		element=this.a.style;
		var property='opacity';
		var begin=Number(element.opacity);
		var change=1-begin;
	}
	var time=5;
	var type='outCirc';
	
	this.an=new phocus.Animator(element,property,begin,change,time,type);
	this.an.transform='%%val%%';
	this.an.round=roundani;
	this.an.addListener(this,'rolledout');
	this.an.run();
}
$pr.rolledout=function()
{
	this.running=false;
	this.isopen=false;
}
$pr.killanimator=function()
{
	if(this.an != null && typeof this.an != 'undefined' && this.an.kill != 'undefined')
	{
		this.an.kill();
		this.an=null;
	}
}
