// predefined variables
var i = 0;
var j;
var k = 0;
var project = [];
var current = 0;

// define project order
var order = ["6","1","2","3","4","5","7","8","9","10"];

// build space[] arrays
for (i = 0; i < 50; i++) {
	project[(i+1)] = [];
}

//// generates HTML
function genHTML(thisVideo,thisAlt) {
	var htmltext = '<video width="536" height="356" controls poster="_video/{video}.jpg"><source src="_video/{video}.mp4" type="video/mp4" /><source src="_video/{video}.ogv" type="video/ogg" />';
	htmltext += '<object width="536" height="356" type="application/x-shockwave-flash" wmode=transparent data="_video/_flashplayer/player.swf"><param name="wmode" value="transparent"><param name="movie" value="_video/_flashplayer/player.swf" /><param name="flashvars" value="controlbar=bottom&amp;image=_video/{video}.jpg&amp;file=../{video}.mp4" /><img src="../{video}.jpg" width="536" height="356" alt="{alt}" title="No video playback capabilities" /></object></video>';	
	htmltext = htmltext.replace(/{video}/gi,thisVideo);
	htmltext = htmltext.replace(/{alt}/gi,thisAlt);
	return htmltext;
}

// project - jeld wen
project[1]["video"] = 'ni48-jeldwen';
project[1]["alt"] = 'NECA/IBEW 48 - Jeld Wen Video';
project[1]["html"] = genHTML(project[1]["video"],project[1]["alt"]);

// project - 100 years ad
project[2]["video"] = 'ni48-100years';
project[2]["alt"] = 'NECA/IBEW 48 - 100 Years Video';
project[2]["html"] = genHTML(project[2]["video"],project[2]["alt"]);

// project - slideshow
project[3]["video"] = "ni48-slideshow";
project[3]["html"] = '<object width="536" height="356"><param name="movie" value="slideshow.swf"><param name="wmode" value="transparent"><embed src="slideshow.swf" width="536" height="356" wmode="transparent"></embed></object>';

// project - job done right
project[4]["video"] = 'ni48-jobdoneright';
project[4]["alt"] = 'NECA/IBEW 48 - Job Done Right Video';
project[4]["html"] = genHTML(project[4]["video"],project[4]["alt"]);

// project - moving forward
project[5]["video"] = 'ni48-movingforward';
project[5]["alt"] = 'NECA/IBEW 48 - Moving Forward';
project[5]["html"] = genHTML(project[5]["video"],project[5]["alt"]);

// project - kgw 100 years, august 2011
project[6]["video"] = 'ni48-100years2';
project[6]["alt"] = 'NECA/IBEW 48 - 100 Years Video 2';
project[6]["html"] = genHTML(project[6]["video"],project[6]["alt"]);

// project [empty]
project[7]["video"] = '';
project[7]["html"] = '';

// project [empty]
project[8]["video"] = '';
project[8]["html"] = '';

// project [empty]
project[9]["video"] = '';
project[9]["html"] = '';

// project [empty]
project[10]["video"] = '';
project[10]["html"] = '';

loadplayer(current);

function loadplayer(startHere) {
	for (i = 1; i < 6; i++) {
		if (project[order[(startHere - 1) + i]]["video"] != '') {
			document.getElementById("space" + i).innerHTML = "<img src='_video/" + project[order[(startHere - 1) + i]]["video"] + "-th.jpg' />";
		} else {
			document.getElementById("space" + i).innerHTML = "<img src='_video/blank.png' />";
		}
	}
	document.getElementById("flashreplace").innerHTML = project[order[startHere]]["html"];
}

function clickplayer(thisspace) {
	document.getElementById("flashreplace").innerHTML = project[order[(thisspace - 1) + current]]["html"];	
}

function clicknext() {
	current = 5;
	loadplayer(current);
	document.getElementById("spacearrow-l").className = 'space';
	document.getElementById("spacearrow-r").className = 'invisible';
}

function clickprev() {
	current = 0;
	loadplayer(current);
	document.getElementById("spacearrow-l").className = 'invisible';
	document.getElementById("spacearrow-r").className = 'space';
}

function raise() {
	window.clearInterval(j);
	j = window.setInterval ("raise_action()",5);
}

function lower() {
	window.clearInterval(j);
	j = window.setInterval ("lower_action()",5);
}

function raise_action () {
	if (k<100) {
		k = (k+5);
		document.getElementById("flashcontent_low").style.bottom = (k-100) + "px";
	} else {
		window.clearInterval(j);
	}
}

function lower_action () {
	if (k>0) {
		k = (k-5);
		document.getElementById("flashcontent_low").style.bottom = (k-100) + "px";
	} else {
		window.clearInterval(j);
	}
}

