var as = [];
var curr_index = 0;
var duration = 1500;
var stop_duration = 5000;
var _max_height = 0;

function initPage()
{
	var nav = document.getElementById("gallery-nav");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		for (var i = 0; i < nodes.length; i++)
		{
			if (nodes[i].parentNode.id == "gallery-nav")
			{
				nodes[i].onmouseover = function () 
				{
					if (this.className.indexOf("hover") == -1)
					{
						this.className += " hover";
					}
					var uls = this.getElementsByTagName("ul");
					if (uls.length)
					{
						hideSelectBoxes(uls[0]);
					}
				}
				nodes[i].onmouseout = function ()
				{
					this.className = this.className.replace(" hover", "");
					var uls = this.getElementsByTagName("ul");
					if (uls.length)
					{
						showSelectBoxes(uls[0]);
					}
				}
			}
		}
	}
	var nav = document.getElementById("accordion2");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("strong");
		for (var i = 0; i < nodes.length; i++)
		{
			if(this.className != "aaa")
			{
				nodes[i].onmouseover = function () 
				{
					if (this.className.indexOf("hover") == -1)
					{
						this.className += " hover";
					}
					var uls = this.getElementsByTagName("div");
					if (uls.length)
					{
						hideSelectBoxes(uls[0]);
					}
				}
				nodes[i].onmouseout = function ()
				{
					this.className = this.className.replace(" hover", "");
					var uls = this.getElementsByTagName("div");
					if (uls.length)
					{
						showSelectBoxes(uls[0]);
					}
				}
			}
		}
	}
}

if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initPage);


function manual_initAccordion(number) {
	var accordion_block = document.getElementById('accordion2');
	if(accordion_block)
	{
		
		var accordion = new Accordion('strong.clicker', 'a.recent-content', {
			alwaysHide: true,
			opacity: false,
			show:number,
			onActive: function(toggler, element){
				if(toggler.className.indexOf("active") == -1)
					toggler.className += ' active';
			},
		 
			onBackground: function(toggler, element){
				toggler.className = toggler.className.replace('active','');
			}
		}, accordion_block);
	}
}

function initAccordion()
{
	/*var accordion_block = document.getElementById('accordion2');
	if(accordion_block)
	{
		
		var accordion = new Accordion('strong.clicker', 'a.recent-content', {
			alwaysHide: true,
			opacity: false,
			show:0,
			onActive: function(toggler, element){
				if(toggler.className.indexOf("active") == -1)
					toggler.className += ' active';
			},
		 
			onBackground: function(toggler, element){
				toggler.className = toggler.className.replace('active','');
			}
		}, accordion_block);
	}*/
	accordion_block = document.getElementById('accordion');
	if(accordion_block)
	{
		var accordion = new Accordion('strong.click', 'div.drop-panel', {
			alwaysHide: true,
			opacity: false,
			show:0,
			onActive: function(toggler, element){
				if(toggler.className.indexOf("active") == -1)
					toggler.className += ' active';
			},
		 
			onBackground: function(toggler, element){
				toggler.className = toggler.className.replace('active','');
			}
		}, accordion_block);
	}
}

if (window.addEventListener)
	window.addEventListener("load", initAccordion, false);
else if (window.attachEvent)
	window.attachEvent("onload", initAccordion);

function initNews()
{
	var _news = document.getElementById('last-news');
	if(_news)
	{	
		_news.style.position = "relative";
		_max_height = 0;
		var _as = _news.getElementsByTagName('ul');
		var cnt = 0;
		var total_cnt = 0;

		for(i = 0; i < _as.length; i++)
		{
			if(_as[i].parentNode.id == "last-news")
			{
				total_cnt++;
			}
		}		
		for(i = 0; i < _as.length; i++)
		{
			if(_as[i].parentNode.id == "last-news")
			{

				as[cnt] = _as[i];
				as[cnt]._index = cnt;
				as[cnt]._height = as[cnt].offsetHeight;
				
				as[cnt].style.position = "absolute";
				as[cnt].style.left = "0px";				
				
				if(as[cnt].offsetHeight > _max_height) _max_height = as[cnt].offsetHeight;
				
				if(cnt == total_cnt)
				{
					as[cnt].style.top = "0px";
				}
				else
				{
					as[cnt].style.top = - as[cnt]._height + "px";
				}

				cnt++;				
			}
		}

		_news.style.height = _max_height + "px";
		_news.style.overflow = "hidden";
		_news.style.visibility = "visible";

		curr_index = 0;
		_switch();
	}
}

if (window.attachEvent){
	window.attachEvent("onload", initNews);
}
else if (window.addEventListener){
	window.addEventListener("load", initNews, false);
}

function _switch()
{
	var as_cnt = as.length;
	if(as_cnt > 1)
	{
			var _opacity1 = new Fx.Styles( as[curr_index], {duration: duration,
				
				onStart: function(){},
				onComplete: function()
				{
					setTimeout('_remove()',duration + stop_duration);	
				}	
				
				});

		
			_opacity1.custom({'top': [-1*as[curr_index]._height,0]});	
	}
}

function _remove()
{
	var as_cnt = as.length;
	if(as_cnt > 1)
	{
			var _opacity1 = new Fx.Styles( as[curr_index], {duration: duration,
				
				onStart: function(){},
				onComplete: function(){}	
				
				});
		
			_opacity1.custom({'top': [0,_max_height]});
	}

	var next_index = curr_index + 1;
	if(next_index == as_cnt) next_index = 0;
	curr_index = next_index;
	
	setTimeout('_switch()',duration);		
}

