﻿startingColor = new Array() // <-- Do not modify!
endingColor = new Array() // <-- Do not modify!

// Fill this array with the images you wish to preload
var logoUrl="Logos/"
var imgUrl ="images/"
var yourImages = new Array();
	yourImages[0] =logoUrl + "TFG_Logo.jpg";
	yourImages[1] =logoUrl + "TFG_Logo_HText.gif";
	yourImages[2] =logoUrl + "open_logo.gif";
	yourImages[3] =imgUrl + "peom_openlogo.gif";
	yourImages[4] =imgUrl + "lm_btn_1.jpg";
	yourImages[5] =imgUrl + "lm_btn_2.jpg";
	yourImages[6] =imgUrl + "lm_btn_3.jpg";
	yourImages[7] =imgUrl + "lm_btn_4.jpg";
	yourImages[8] =imgUrl + "lm_btn_5.jpg";
	yourImages[9] =imgUrl + "lm_btn_6.jpg";
	yourImages[10] =imgUrl + "lm_btn_1a.jpg";
	yourImages[11] =imgUrl + "lm_btn_2a.jpg";
	yourImages[12] =imgUrl + "lm_btn_3a.jpg";
	yourImages[13] =imgUrl + "lm_btn_4a.jpg";
	yourImages[14] =imgUrl + "lm_btn_5a.jpg";
	yourImages[15] =imgUrl + "lm_btn_6a.jpg";
	yourImages[16] =imgUrl + "tm_btn_1.jpg";
	yourImages[17] =imgUrl + "tm_btn_2.jpg";
	yourImages[18] =imgUrl + "tm_btn_3.jpg";
	yourImages[19] =imgUrl + "tm_btn_4.jpg";
	yourImages[20] =imgUrl + "tm_btn_5.jpg";
	yourImages[21] =imgUrl + "tm_btn_1a.jpg";
	yourImages[22] =imgUrl + "tm_btn_2a.jpg";
	yourImages[23] =imgUrl + "tm_btn_3a.jpg";
	yourImages[24] =imgUrl + "tm_btn_4a.jpg";
	yourImages[25] =imgUrl + "tm_btn_5a.jpg";

var locationAfterPreload = "index_loadpage.htm" 	//  The script will redirect here when the preloading finishes *successfully*
var preloadbarWidth = 270			// The length of the preload bar. Should be greater than total amount of images you want to preload!
var preloadbarHeight = 25			// The height of the gradient/preload bar
var backgroundOfGradient = "#000000"	// Default color while the preload bar is "filling up"

// Color the preloadbar is starting with - enter 1st, 3rd and 5th numbers/letters of color code
startingColor[0] = "c" 
startingColor[1] = "f"
startingColor[2] = "f"

// Color the preloadbar is going to end up with - enter the 1st, 3rd and 5th numbers/letters of color code
endingColor[0] = "c"
endingColor[1] = "0"
endingColor[2] = "0"

// FOR TROUBLESHOOTING:
// PLAY AROUND WITH THIS SETTING IF YOU GET A JAVASCRIPT ERROR!!! 2 is the minumum value!!!
var gap = 3

// DO NOT MODIFY ANYTHING BEYOND THIS POINT!!! 

if (!document.all) location.replace(locationAfterPreload)
var a = 10, b = 11, c = 12, d = 13, e = 14, f=15, i, j, ones = new Array(), sixteens = new Array(), diff = new Array();
var convert = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"), imgLen = yourImages.length;
var loaded = new Array(), preImages = new Array(), currCount = 0, pending = 0, h = 0, hilite = new Array(), cover = new Array();
var num = Math.floor(preloadbarWidth/gap);
for (i = 0; i < 3; i++) {
	startingColor[i] = startingColor[i].toLowerCase();
	endingColor[i] = endingColor[i].toLowerCase();
	startingColor[i] = eval(startingColor[i]);
	endingColor[i] = eval(endingColor[i]);
	diff[i] = (endingColor[i]-startingColor[i])/num;
	ones[i] = Math.floor(diff[i]);
	sixteens[i] = Math.round((diff[i] - ones[i])*15);
}
endingColor[0] = 0;
endingColor[1] = 0;
endingColor[2] = 0;
i = 0, j = 0;
while (i <= num) {
	hilite[i] = "#";
	while (j < 3) {
		hilite[i] += convert[startingColor[j]];
		hilite[i] += convert[endingColor[j]];
		startingColor[j] += ones[j];
		endingColor[j] += sixteens[j];
		if (endingColor[j] > 15) {
			endingColor[j] -= 15;
			startingColor[j]++;
		}
		j++;
	}
	j = 0;
	i++;
}

defaultStatus = "Loaded 0 out of " + imgLen + " images [0%]."


//-------------------------------------------------------------------------------------------
function loadImages() {
	for (i = 0; i < imgLen; i++) {
		preImages[i] = new Image();
		preImages[i].src = yourImages[i];
		loaded[i] = 0;
		cover[i] = Math.floor(num/imgLen)*(i+1)
	}
	cover[cover.length-1] += num%imgLen
	checkLoad();
}

//-------------------------------------------------------------------------------------------
function checkLoad() {
	if (pending) { changeto(); return }
	if (currCount == imgLen) {
		location.replace(locationAfterPreload); return}

	for (i = 0; i < imgLen; i++) {
		if (!loaded[i] && preImages[i].complete) {
			loaded[i] = 1; pending++; currCount++;
			checkLoad();
			return;
		}
	}
	setTimeout("checkLoad()",10);
}

//-------------------------------------------------------------------------------------------
function changeto() {
	if (h+1 > cover[currCount-1]) {
		var percent = Math.round(100/imgLen)*currCount;
		if (percent > 100) while (percent != 100) percent--;
		if (currCount == imgLen && percent < 100) percent = 100;
		defaultStatus = "Loaded " + currCount + " out of " + imgLen + " images [" + percent + "%].";
		document.title= "Loading Main Information . . .  . . . "  + percent + " %";		
		pending--;
		checkLoad();
		return;
	}
	eval("document.all.cell" + (h+1) + ".style.backgroundColor = hilite[h]");;
	h++;
	setTimeout("changeto()",1);
}



//======== Time limit script
//enter limit in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="10:00"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}

//-------------------------------------------------------------------------------------------
function begintimer(){
	if (!document.images)
		return
		if (parselimit==1)
//			window.close()
			window.location.replace("index.htm")
		else{ 
			parselimit-=1
			curmin=Math.floor(parselimit/60)
			cursec=parselimit%60
		if (curmin!=0)
			curtime=curmin+" minutes & "+cursec+" seconds left"
		else
			curtime=cursec+" seconds left"
//			document.title=curtime + " to refresh"
			setTimeout("begintimer()",1000)
		}
	}

