// dropdown
Dropdownmanager=
{
	ds:[],
	add:function(d)
	{
		d.manager=this;
		this.ds.push(d);
	},
	closeall:function()
	{
		for(var i=0;i<this.ds.length;i++)
		{
			if(this.ds[i].isopen && !this.ds[i].mouseover)
				this.ds[i].close(true);
		}
	}
};
function Dropdown(element_li)
{
	this.op=element_li;
	var as=this.op.getElementsByTagName('a');
	this.but=as[0];
	this.outclass=this.but.className;
	this.dropdown=this.op.getElementsByTagName('ul')[0];
	this.dstyle=this.dropdown.style;
	
	var p=this;
	for(var i=0;i<as.length;i++)
	{
		as[i].onmouseover=function()
		{
			p.open();
		}
		as[i].onmouseout=function()
		{
			p.close();
		}
	}
	
	this.running=false;
	this.isopen=false;
	this.mouseover=false;
}
$pr=Dropdown.prototype;
$pr.open=function()
{
	this.mouseover=true;
	this.but.className=this.outclass+' hover';
	this.dropdown.className='over';
	if(!this.isopen)
	{
		this.isopen=true;
		
		var h = this.dropdown.offsetHeight;
		this.dstyle.height='1px';
		if(typeof phocus == 'object')
			this.run=phocus.Runtime.addrun(this,'runclose',[1,h],0,10,this,'endopen');
		else
			this.endopen();
		this.manager.closeall();
		this.dstyle.zIndex='101';
	} else
	{
		this.endopen();
	}
	clearInterval(this.closer);
}
$pr.close=function(override)
{
	this.mouseover=false;
	
	if(override)
	{
		clearInterval(this.closer);
		this.run.escape();
	}
	
	if(this.isopen)
	{
		var _doclose=this.doclose;
		var _obj=this;
		this.closer=setInterval(function(){_doclose.apply(_obj)},override ? 10 : 400);
		this.dstyle.zIndex='100';
	}
}
$pr.doclose=function()
{
	if(!this.mouseover)
	{
		var h = this.dropdown.offsetHeight;
		if(typeof phocus == 'object')
			this.run=phocus.Runtime.addrun(this,'runclose',[h,1-h],0,4,this,'endclose');
		else
			this.endclose();
		this.but.className=this.outclass;
		this.dropdown.className='out';
	}
	clearInterval(this.closer);
}
$pr.runclose=function(start,ch,time,runtime)
{
	this.running=true;
	this.dstyle.height=Math.floor(start+(ch/runtime*(runtime-time+1)))+'px';
}
$pr.endclose=function()
{
	this.running=false;
	this.dstyle.height='';
	this.isopen=false;
	this.dropdown.className='';
}
$pr.endopen=function()
{
	this.running=false;
	this.dstyle.height='';
	this.run.escape();
}


delete $pr;

//---------------------------------------------------------------
// Opacity Displayer, Version 1.0
// Copyright Michael Lovitt, 6/2002.
// Distribute freely, but please leave this notice intact.
//---------------------------------------------------------------

//---------------------------------------------------------------
// OPACITY OBJECT
//
// Instantiates the object, defines the properties and methods.
function OpacityObject(divId, strPath) {
	this.id = divId;
	this.path = strPath;
	this.layer=document.getElementById(divId);
	if (ns){
		if (browserVersion>=5) {
			this.layerObject = this.layer.style;
		} else { 
			this.layerObject = eval("document."+divId);
		}
	} else {
		this.layer=document.getElementById(divId);
		this.layerObject = eval(divId + ".style");
	}
	this.setBackground = od_object_setBackground;
}
// Uses AlphaImageLoader filter, or the css background property,
// as appropriate, to apply a PNG or GIF as the background of the layerObject.
function od_object_setBackground(ro)
{	
	if (pngAlpha)
	{
		var _class=this.layer.className;
		this.layerObject.backgroundImage = 'none';
		this.layerObject.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.path+".png', sizingMethod='crop')";
	} else if (pngNormal)
	{
	} else
	{
		this.layerObject.backgroundImage = 'url('+this.path+'.gif)';
	}
}
//---------------------------------------------------------------

//---------------------------------------------------------------
// global variables

// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
if ((browser.isIE55 || browser.isIE6x) && browser.isWin32) {
	var pngAlpha = true;
	var strExt = ".png";
// else, if the browser can display PNGs normally, then do that. that list includes:
	//     -Gecko Engine: Netscape 6 or Mozilla, Mac or PC
	//     -IE5+ Mac (OpacityObject applies the background image at 100% opacity)
	//     -Opera 6+ PC
	//     -Opera 5+ Mac (Doesn't support dynamically-set background images)
	//     -Opera 6+ Linux 
	//     -Omniweb 3.1+ 
	//     -Icab 1.9+ 
	//     -WebTV 
	//     -Sega Dreamcast
} else if ((browser.isIE7x) || (browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) {
	var pngNormal = true;
	var strExt = ".png";
	// otherwise, we use plain old GIFs
} else {
	var strExt = ".gif";
}
var ns = (document.all)?false:true;
var browserVersion = parseFloat(navigator.appVersion );
//---------------------------------------------------------------

// document load
as=[
	{b:"logoarea",url:"/assets/img/header_right_ie",obj:null}];
window.onload=function()
{
	for(var i=0;i<as.length;i++)
	{
		var op=as[i];
		if(document.getElementById(op.b)==null)
			continue;
		op.obj=new OpacityObject(op.b,op.url);
		op.obj.setBackground(op.ro);
	}
	
	var mainmenu=document.getElementById('mainmenu');
	var lis=mainmenu.getElementsByTagName('li');
	for(var i=0;i<lis.length;i++)
	{
		var op=lis[i];
		if(op.getElementsByTagName('ul').length)
			Dropdownmanager.add(new Dropdown(op));
	}
}
