var $platform_showcase_articles;
var $platform_showcase_links;
var $platform_showcase_current_index;
var $platform_showcase_prev_index;

function initPlatformShowcase(){
	$platform_showcase_content = $("#platform_showcase_content");
	$platform_showcase_content_ui = $platform_showcase_content.tabs({
		show: function() {
		    $("#platform_showcase_content article.hide").removeClass("hide"); 
		  }
	});


	
	$platform_showcase_content_ui.tabs('rotate', 5000, true);
	
	$platform_showcase_content.click(function(){
		$platform_showcase_content_ui.tabs('rotate', 0, true);
	});
	$platform_showcase_content.mouseover(function(){
		$platform_showcase_content_ui.tabs('rotate', 0, true);
	});

	/*($platform_showcase_links = $('#platform_showcase_nav li');
	$platform_showcase_articles = $('#platform_showcase article');
	$platform_showcase_articles.hide().removeClass('hide');
	
	$platform_showcase_links.each(function(){
		$this = $(this);
		id_parts = $this.attr("id").split('_');
		var article_index = id_parts[id_parts.length-1];
		$this.click(function(){
			setArticle(article_index);
			return false;
		});
	});
	
	setArticle(0, true);*/
}



function initNav(){
	$("#main_header li:not(.current) img").each(function(){
		var $this = $(this);
		$this.hover(	
			function(){
				$img_src_parts = $(this).attr('src').split('.png');
				$(this).attr('src', $img_src_parts[0]+ "_current" + '.png');
			},
			function(){
				$(this).attr('src', $(this).attr('src').replace("_current", ''));
			}
		);
	});
}

function setNav(articleIndex){
	$platform_showcase_links.removeClass('current');
	$("#platform_showcase_link_"+articleIndex).addClass('current');
}
function initBuddyFaces(){
	$('#buddy_faces').galleria({
		autoplay:true,
		height: 510,
		show_info: true,
		show_imagenav: true,
		history   : true, // activates the history object for bookmarking, back-button etc.
		clicknext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		transition: 'fade',
		data_type:'json',
		data_source: mydata,
//		debug:true,
		extend: function() {
            var gallery = this; // save the scope
            $('#g_nav a').click(function(e) {
                e.preventDefault(); // prevent default actions on the links
            })
            // attach gallery methods to links:
            $('#g_prev').click(function() {
                gallery.prev();
            });
            $('#g_next').click(function() {
                gallery.next();
            });
            $('#g_play').click(function() {
                gallery.play();
            });
            $('#g_pause').click(function() {
                gallery.pause();
            });
            $('#g_fullscreen').click(function() {
                gallery.enterFullscreen();
            });
        }
	}).delay(10000).removeClass('loading');
	


}

$(window).load(function(){
	initNav();
});
