﻿var speed = 7000;
var timeout;

var pics = [];
pics[0] = "meet-1.jpg";
pics[1] = "meet-2.jpg";
pics[2] = "meet-3.jpg";
pics[3] = "meet-4.jpg";
pics[4] = "meet-5.jpg";
pics[5] = "meet-6.jpg";
pics[6] = "meet-7.jpg";
pics[7] = "meet-8.jpg";

var meets = [];
meets[0] = "/meet/meetTom.html";
meets[1] = "/meet/meetDavid.html";
meets[2] = "/meet/meetKathy.html";
meets[3] = "/meet/meetAngel.html";
meets[4] = "/meet/meetThomas.html";
meets[5] = "/meet/meetZoila.html";
meets[6] = "/meet/meetAntavon.html";
meets[7] = "/meet/meetTenika.html";

var alts = [];
alts[0] = "Meet Tom pictured here in his office beside of a laptop computer and alongside a desktop computer. Tom, a Caucasian with slightly graying hair, is dressed in an open colored patterned shirt. His elbow is on the desk and hand under his chin as he looks into the camera. A white walking cane is seen behind Tom’s left shoulder.";
alts[1] = "Meet David pictured here leaning over one cardboard box with arm extended over another box. Boxes of pencils and scotch tape are piled one of the boxes. David, a younger Caucasian wearing glasses, is casually dressed in a brown pullover shirt. In the background are a number are shelving units containing boxes of supplies.";
alts[2] = "Meet Kathy pictured here on the move with her guide dog leaving a glass walled, governmental office. Dressed in formal blue business suit with her governmental identification badge, Kathy, a Caucasian is carrying a file of documents as she moves down an office corridor.";
alts[3] = "Meet Angel pictured here in front of MA Wash Express business. A car washing facility is in the background along with a truck to be washed. Angel, a Hispanic middle aged  with a little bit of gray hair, is in the foreground with his head turned to the left exposing one of his hearing aids. He has a light jacket and baseball cap which are brightly colored and have the logo of MA Wash Express.";
alts[4] = "Meet Thomas pictured here in his professional office. Thomas, a middle aged Causasian, is dressed in light blue shirt and striped dark blue tie at a desk. On the desk we see various medals he has been awarded during his military service. Thomas holds in his left hand a walking support.";
alts[5] = "Meet Zoila pictured here in a classroom setting along with young girls at preschool. The classroom contains a number of colorful books along with a plastic oversized yellow crayon. Zoila, a middle aged Hispanic, wears a green sweater while looking at the camera helps one of the girls read a book. The other young girl plays with another of the books.";
alts[6] = "Meet Antavon pictured here behind a checkout counter in a grocery store. Antavon, a younger African-American, wears a blue staff apron with the Giant grocery store emblem over his bright yellow pullover shirt. In the background we can see a computer monitor checkout display along with shelves of grocery items.";
alts[7] = "Meet Tenika pictured here interning at her local government health department office. The office is modern and well lit. Tenika, a wheelchair user, is a young, African American woman with a large bright smile.  She is wearing a yellow shirt with brown striped pants.";


var curpic = 0;
var numpics = pics.length;
var nextdiv;

function next() {
	swap(nextpic());
}

function nextpic() {
	var nextpic = curpic + 1;
	if (nextpic >= numpics) {
		nextpic = 0; 
	}
	return nextpic;
}

function goto(idx) {
	$(nextdiv).attr('innerHTML', meetimg(idx));
	swap(idx);
}

function swap(to) {
	clearInterval(timeout);

	$(nextdiv).fadeIn();
	
	if (nextdiv == '#meet-img2') {
		nextdiv = '#meet-img1';
	} else {
		nextdiv = '#meet-img2';
	}

	$(nextdiv).fadeOut('fast', preload);

	$('#meet-nav-' + (curpic+1)).attr('innerHTML',navimg(curpic, "o"));
	$('#meet-nav-' + (to+1)).attr('innerHTML', navimg(to, "n"));

	$('#meet-click-img').attr('alt', alts[to]);

	timeout = setInterval(next, speed);
	curpic = to;
}

function preload() {
	$(nextdiv).attr('innerHTML', meetimg(nextpic()));
}

function meetimg(idx) {
	return "<img src=\"meet-" + (idx+1) + ".jpg\" alt=\""+alts[idx]+"\" />"
}

function navimg(idx, str) {
	return "<a href=\"javascript:void(0);\" onclick=\"goto("+idx+")\"><img src=\"" + str + (idx+1) +".jpg\" alt=\""+ (idx+1) +"\" /></a>";
}

function stopr() {
	clearInterval(timeout);
}

function meet() {
	window.location.href = meets[curpic];
}

function norm() {
	$('.smallText').css('font-size', '10px');
	$('.normText').css('font-size', '12px');
	$('.largeText').css('font-size', '14px');
	$('.superText').css('font-size', '16px');
}

function large() {
	$('.smallText').css('font-size', '11px');
	$('.normText').css('font-size', '13px');
	$('.largeText').css('font-size', '15px');
	$('.superText').css('font-size', '17px');
}

function larger() {
	$('.smallText').css('font-size', '12px');
	$('.normText').css('font-size', '14px');
	$('.largeText').css('font-size', '16px');
	$('.superText').css('font-size', '18px');
}


var lastNavObj = "";
var closeTimer = "";

function opennav(navobj) {
	resettimer();
	closenav();

	lastNavObj = navobj;
	$('#' + lastNavObj + '-img').attr('src', lastNavObj + '-on.png');
	$('#' + lastNavObj + '-menu').css('display', 'block');
}

function closenav() {
	if (lastNavObj != "") {
		$('#' + lastNavObj + '-img').attr('src', lastNavObj + '.png');
		$('#' + lastNavObj + '-menu').css('display', 'none');
		lastNavObj = "";
	}
}

function resettimer() {
	clearTimeout(closeTimer);
	closeTimer = setTimeout('closenav()', 4000);
}

$(document).ready(function() {
	curpic = Math.floor(Math.random()*(numpics));
	$('#meet-img1').attr('innerHTML', meetimg(curpic));
	$('#meet-img2').attr('innerHTML', meetimg(nextpic()));
	nextdiv = "#meet-img2";

	for (var i = 0; i < numpics; i++) {
		if (curpic == i) {
			$('#meet-nav-' + (i+1)).attr('innerHTML', navimg(i, "n"));
		} else {
			$('#meet-nav-' + (i+1)).attr('innerHTML', navimg(i, "o"));
		}
	}

	next();

	$('#botnav-aboutjan').bind('mouseenter', function() { opennav('botnav-aboutjan'); });
	$('#botnav-faq').bind('mouseenter', function() { opennav('botnav-faq'); });
	$('#botnav-training').bind('mouseenter', function() { opennav('botnav-training'); });
});



