// JavaScript Document
var current = '';

function IntroComplete () {
	updateVideo (getFirst ());
}

function VideoComplete () {
	var path = getNext (current);
	current = path;
	updateVideo (path);
}

function updateVideo (path) {
	if (path != "") {current = path;} else {current = getFirst ();}
	getFlashVideo ("flash-video").updateVideo (current);
}

function getFirst () {
	return $(".videoUrl:first").attr ('id');
}

function getNext (path) {
	next = '';
	var list = $(".videoUrl").get();
	var i = 0;
	var l = $(list).length;
	for (i; i < l; i++) {
	    if ($(list[i]).attr("id") == path) {
	        if ((i+1) == l) {
	            return getFirst();
	        }
			next = $(list[i+1]).attr("id");
		}
    }
	
	return next;
}

function getFlashVideo (movieName) {
	return document.getElementById (movieName);
}

var f = 7;
var v = 3;
var maxfeeds = 12;

function setup () {
	
	var vidStart = $("#mv_content .alt_video:gt(3)").css("height");

	// 6.21.2010 - Commenting out all Flug Feed (ff) code that hides the entries
	// We are changing to a scroll box instead
	//
	
	// feeds = $("#flug_feed ul li");
	vids = $("#mv_content .alt_video");
	
	
	/*if ($(feeds).length < f) { 
		$("#ff_view_more").hide(); 
	} else {
		showAll (feeds, f);
	}*/
	/*
	if ($(vids).length < v) { 
		$("#mv_view_more").hide(); 
	} else {
		showAll (vids, v);
	}
	*/
	var height = $("#mv_content").height();
	
	//$("#ff_view_more").click (function () {showAll (feeds, maxfeeds)});
	$("#mv_view_more").click (
		function () {
			$("#mv_mask").animate({height:height});
		}
	);
	$(".videoUrl").each (
		function (i) {
			$(this).click (
				function () {
					updateVideo ($(this).attr("id"));
				}
			//$(this).attr ("href", "javascript:void(0);");
			);
		}
	);
	$(".videoUrl_thumb").each (
		function (i) {
			$(this).click (
				function () {
					updateVideo ($(this).attr("id"));
				}
			//$(this).attr ("href", "javascript:void(0);");
			);
		}
	);
}

function showAll (list, total) {
	$(list).each (
		function (i) {
			if (i >= total) {
				$(this).hide();
			} else {
				$(this).show(i);
			}
		}
	);
}