<!--
// JavaScript Document

// Autor:           at-on software gmbh
// Version:         1.0       
// Erstelldatum:    02.06.2005
// Letzte Änderung: 02.06.2005


/**
 * Funktionen und Steuerung
 * des Preloads
 */


var startingColor = new Array(); // <-- NICHT VERAENDERN!
var endingColor   = new Array(); // <-- NICHT VERAENDERN!


startingColor[0] = colorStart.substr(1, 1);
startingColor[1] = colorStart.substr(3, 1);
startingColor[2] = colorStart.substr(5, 1);

endingColor[0] = colorEnd.substr(1, 1);
endingColor[1] = colorEnd.substr(3, 1);
endingColor[2] = colorEnd.substr(5, 1);

var a= 10, b= 11, c= 12, d= 13, e= 14, f= 15, i, j;
var ones = new Array(), sixteens = new Array(), diff = new Array(), loaded = new Array(), preImages = new Array(), hilite = new Array(), cover = new Array();
var convert = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"), imgLen = ar_Images.length;
var currCount = 0, pending = 0, h = 0, topPos, leftPos;
var num = parseInt(preloadbarCol);  

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;

var 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++;
}


function loadImages() 
{
	for (i = 0; i < imgLen; i++) 
	{
		preImages[i] = new Image();
		preImages[i].src = ar_Images[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) { 
		if (locationAfterPreload) 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()", 5);
}


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 + "%].";
		pending--;
		checkLoad();
		return;
	}

	document.getElementById("cell" + (h+1)).style.backgroundColor = hilite[h];
	h++;

	setTimeout("changeto()", 1);
}


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


document.write('<table class="outerLayer"><tr><td class="outerLayer">');

document.write('<table class="preloadBarGraph"><tr>');
for (i = 0; i < num; i++) 
	document.write('<td class="preloadBarGraph" id="cell' + (i+1) + '"></td>');
document.write('</tr></table>');
document.write('<table class="preloadBarInfo"><tr><td class="preloadBarInfo">' + preloadbarText + '</td></tr></table>');

document.write('</td></tr></table>');

loadImages();
//-->
