/*
	File:	fg.js
	Author:	Rik Hocking
	Date:	Feb 2010
	Desc:	Javascript for website
*/

//employee list
var emp = new Array();
emp [00] = "Bill Aleksandrian		201		billa@fischergroup.com			Outside Sales (San Diego County)";
emp [01] = "Gene Austin				252		genea@fischergroup.com			General Manager";
emp [02] = "Kelly Avakian			237		kellya@fischergroup.com			Marketing Coordinator";
emp [03] = "Mary Ellen Drake		207		maryellend@fischergroup.com		Outside Sales (San Fernando Valley, Ventura, Santa Barbara)";
emp [04] = "Gina Fero				212		ginaf@fischergroup.com			School Specialist (San Fernando Valley, Santa Barbara, Ventura)";
emp [05] = "LeAnn Harrington		250		leannh@fischergroup.com			Outside Sales (Orange & Los Angeles Counties)";
emp [06] = "Greg Herron				224		gregh@fischergroup.com			Outside Sales (Orange & Los Angeles Counties)";
emp [07] = "Julie Hocking			251		julieh@fischergroup.com			Inside Sales";
emp [08] = "Dennis Jaworski			205		dennisj@fischergroup.com		Outside Sales (Las Vegas)";
emp [09] = "Craig Leets				202		craigl@fischergroup.com			Outside Sales (Las Vegas)";
emp [10] = "Michele Martinez		221		michelem@fischergroup.com		Inside Sales";
emp [11] = "Judith McKibben			238		judithm@fischergroup.com		Office Manager";
emp [12] = "Jay Morse				209		jaym@fischergroup.com			Outside Sales (Orange & San Diego Counties)";
emp [13] = "Lily Oyenoki			236		lilyo@fischergroup.com			Inside Sales";
emp [14] = "Tung Pham				240		tungp@fischergroup.com			Warehouse Coordinator";
emp [15] = "Shannon Santangelo		245		shannons@fischergroup.com		Inside Sales";
emp [16] = "Debbie Scaran			230		debbies@fischergroup.com		Inside Sales";
emp [17] = "George Simmons			232		georges@fischergroup.com		Inside Sales Mngr/IT Coordinator";
emp [18] = "Justin Smith			203		justins@fischergroup.com		Outside Sales (Inland Empire, San Gabriel Valley)";
emp [19] = "Kevin Stegall			233		kevins@fischergroup.com			Project Manager - All Areas";
emp [20] = "Mike vonRadesky			208		mikev@fischergroup.com			Outside Sales (San Fernando Valley, Ventura, Santa Barbara)";
emp [21] = "Mike Wake				206		mikew@fischergroup.com			Outside Sales (Inland Empire)";

//init rotator img path
var rotatorImgPath;

//-----------------------------------
// get data
//-----------------------------------
function getData(row, col) {
	d = emp[row].split(/\t+/);
  	return d[col];
}

//-----------------------------------
// preload images (called from Home page)
//-----------------------------------
function preLoad() {
	
	imgObj = new Image();
	imgList = new Array();
	
	//menu
	imgList[0] = "img/sidebar/home-n.png";
	imgList[1] = "img/sidebar/team-h.png";
	imgList[2] = "img/sidebar/fac-h.png";
	imgList[3] = "img/sidebar/manufac-h.png";
	imgList[4] = "img/sidebar/resources-h.png";
	
	//team
	imgList[5] = "img/team/TFGHoliday2009_crane.jpg";
	
	//facilities
	imgList[6] = "img/fac/kitch312w.jpg";
	imgList[7] = "img/fac/conf312w.jpg";
	
	//load images
	for (i=0; i<imgList.length; i++) {
		imgObj.src = imgList[i];
	}
	
	rotatorImgPath = getRandomImagePath();	//init path
	setInterval("rotateImages()", 5000);
}

//-----------------------------------
// slideshow rotatorImg image
//-----------------------------------
function rotateImages() {
	document.images.rotatorImg.src = rotatorImgPath;
	rotatorImgPath = getRandomImagePath();	//done immediately after so next image can download during the slideshow idle time
}

//-----------------------------------
// get random image path (also preloads the image)
//-----------------------------------
function getRandomImagePath() {
	nextImage = new Image();
	n = Math.floor(Math.random() * 18);				//0.jpg through 17.jpg
	nextImage.src = "img/rotator/" + n + ".jpg";	//downloads image
	return nextImage.src;	
}

//-----------------------------------
// start rotator (called from Resources page)
//-----------------------------------
function startRotator() {
	rotatorImgPath = getRandomImagePath();	//init path
	setInterval("rotateImages()", 5000);
}

//-----------------------------------
// swap images
//-----------------------------------
function swapIn(imgName) {
	document.images[imgName].src = 'img/sidebar/' + imgName + '-h.png';
}

function swapOut(imgName) {
	document.images[imgName].src = 'img/sidebar/' + imgName + '-n.png';
}

//-----------------------------------
// year used for copyright
//-----------------------------------
function getFullYear() {
	return new Date().getFullYear();
}

//-----------------------------------
// open mail window (team)
//-----------------------------------
function mailWindow() {
	var empEmail = document.dirForm.emailBox.value;
	if (empEmail.length == 0) return false;	//excludes blank and sheryl
	location = 'mailto:' + empEmail;
}

//-----------------------------------
// open mail window (team)
//-----------------------------------
function getRandomImgLine() {	
	return	'<img src="' + getRandomImagePath() + '" width="712" height="310" name="rotatorImg"><br>';
}

//-----------------------------------
// load fields
//-----------------------------------
function loadFormFromName() {
	var theIndex = document.dirForm.nameSel.selectedIndex;
	if (theIndex == 0) {
		document.dirForm.titleBox.value = "";
		document.dirForm.extBox.value = "";
		document.dirForm.emailBox.value	= "";
		
	} else {
		theIndex = theIndex - 1;
		document.dirForm.titleBox.value = getData(theIndex, 3);
		document.dirForm.extBox.value = getData(theIndex, 1);
		document.dirForm.emailBox.value	= getData(theIndex, 2);
	}	
}

function loadFormFromImgMap(theIndex) {
	document.dirForm.nameSel.selectedIndex = theIndex + 1;
	document.dirForm.titleBox.value	= getData(theIndex, 3);
	document.dirForm.extBox.value	= getData(theIndex, 1);
	document.dirForm.emailBox.value	= getData(theIndex, 2);
}
