

function initMenu()
{
	var nodes = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<nodes.length; i++)
	{
		nodes[i].onmouseover = function()
		{
			this.className += " hover";
		}
		nodes[i].onmouseout = function()
		{
			this.className = this.className.replace(" hover", " ");
		}
	}
}
if (document.all && !window.opera) attachEvent("onload", initMenu);

var initTabs = function(){
	var tab_titles = $$('.photo-video .item-list .categories li a');
	var tab_content = $$('.photo-video .item-list .tab-content');
	//alert(tab_content.length);
	
	var n = tab_titles.length;
	var activeTab = 0;
	var display = 'none';
	
	for (var i=0; i<n; i++){
		tab_titles[i].tabContent = tab_content[i];
		tab_titles[i].index = i;
		display = 'none';
		opacity = 0;
		if (i == activeTab) 
		{
			display = 'block';
			opacity = 1;
		}
		tab_titles[i].tabContent.setStyle('display', display);
		tab_titles[i].tabContent.setStyle('opacity', opacity);		
		tab_titles[i].addEvent('click', function(e){		
		  (e = new Event(e)).stop();
		  if (this.index == activeTab) return;
			for (var j=0; j<n; j++){
				tab_titles[j].getParent().removeClass('current');
			}
			this.getParent().addClass('current');
			this.fx = new Fx.Styles(tab_content[activeTab], {duration:500, wait:false});
			this.fx.start({
				'opacity': 0				
			});
			tab_content[activeTab].setStyle('display','none');
			this.tabContent.setStyle('display', 'block');
			this.fx2 = new Fx.Styles(this.tabContent, {duration:500, wait:false});
			this.fx2.start({
				'opacity': 1				
			});			
			activeTab = this.index;
		});
	} 
} 

var initPreview = function(){
	
	var preview = $$('.photo-video .item-holder .container').pop();
	var preview_text = $$('.photo-video .item-holder .what-show div').pop();
	
	var video_links = $$('#videos li');		
	
	video_links.each(function(item, index){
		
		item.getElements('a').each(function(item_a){		
			item_a.index = index;
			
			item_a.addEvent('click', function(e){				
				new Event(e).stop();			
			
				preview.setHTML(videos[this.index].html);				
				preview_text.setHTML(videos[this.index].text)
			});
		
		});
			
	});


	var photo_links = $$('#photos li');		
	
	photo_links.each(function(item, index){
		
		item.getElements('a').each(function(item_a){		
			item_a.index = index;
			
			item_a.addEvent('click', function(e){				
				new Event(e).stop();			
			
				preview.setHTML(photos[this.index].html);				
				preview_text.setHTML(photos[this.index].text)
			});
		
		});
			
	});
	
}


var initPage = function(){
	initTabs();
	initPreview();	
}

window.addEvent('domready',initPage);