var effect = 2;
var intervall = 77;
var colorSteps = 10;
// number of projects
var numStripes = 22;
// the widest image
var balkenWidth = 1333;
var titles = new Array();
titles[0] = "annetteapel.com";
titles[1] = "FOTOGRAFIE";
titles[2] = "KOMMUNIKATION";
titles[3] = "MC";
titles[4] = "ANKE RÖHRSCHEID";
titles[5] = "DEUTSCHE BAHN";
titles[6] = "BMW / ORIGINAL PARTS";
titles[7] = "OP ART";
titles[8] = "ANONYM";
titles[9] = "NICHTS";
titles[10] = "BMW";
titles[11] = "BUNTE";
titles[12] = "JAMES ENSOR";
titles[13] = "RODIN BEUYS";
titles[14] = "WUNSCHWELTEN";
titles[15] = "JAN DE COCK";
titles[16] = "IN CONCERT";
titles[17] = "GOYAGOYA";
titles[18] = "ANTIREFLEX / CARSTEN NICOLAI";
titles[19] = "AYSE ERKMEN";
titles[20] = "3'";
titles[21] = "ASSORTED LOGOS";
var inputColors = new Array();
inputColors[0] = "#e6feb3";
inputColors[1] = "#a2fbb5";
inputColors[2] = "#54fc78";
inputColors[3] = "#01fc95";
inputColors[4] = "#3cfad4";
inputColors[5] = "#44d8be";
inputColors[6] = "#99feec";
inputColors[7] = "#1efcd5";
inputColors[8] = "#1ed0fc";
inputColors[9] = "#1ea0fc";
inputColors[10] = "#1e71fc";
inputColors[11] = "#0018fc";
inputColors[12] = "#5900fc";
inputColors[13] = "#4c03a7";
inputColors[14] = "#7201fd";
inputColors[15] = "#9f3afc";
inputColors[16] = "#cb54fc";
inputColors[17] = "#470287";
inputColors[18] = "#6b059b";
inputColors[19] = "#aa01f9";
inputColors[20] = "#b812d2";
inputColors[21] = "#de65dd";
inputColors[22] = "#ef9bfc";
inputColors[23] = "#fbbaee";
inputColors[24] = "#fd7a8d";
inputColors[25] = "#fecb99";
var preloaded = new Array();
for(var i=0; i<numStripes; i++)
preloaded[i] = false;
var colors = new Array();
if(effect == 1)
colors = inputColors;
var colIndex = 1;
var colChange = true;
var stripes = new Array();
var heads = new Array();
var lastProjectIndex = -1;
var pageOK = false;
var lastScrollPos = -1;
var lastHeight = -1;
function init()
{
for (i=0; i<numStripes; i++)
{
var stripeY = (i * stripeHeight * 2)
var stripe = getLayer("stripe" + i);
stripes[stripes.length] = stripe;
stripe.style.height = stripeHeight + "px";
stripe.style.top = stripeY + "px";
var head = getLayer("head" + i);
head.style.top = stripeY + "px";
var link = getLayer("link" + i);
link.style.top = stripeY + "px";
var head = getLayer("head" + i);
heads[heads.length] = head;
var project = getLayer("project" + i);
project.style.top = (stripeY + stripeHeight) + "px";
}
setWidth();
pageOK = true;
if (document.images)
preloadContent();
changeCol();
window.onresize = setWidth;
}
// preload and set up content
function preloadContent()
{
preloadFlag = true;
for(var i=0; i<numStripes; i++)
{
preloaded[i] = true;
// set the title and link on the stripe
// on the start page use only the first three stripes for the website sections (info, fotografie, kommunikation), the rest is empty
var link = "javascript:displayProject(" + i + ");";
// fixed links to website sections, will be written in link div and extracted from there
if (getLayer("link" + i).innerHTML != "&nbsp;")
{
link = getLayer("link" + i).innerHTML;
if (link.indexOf("http://") >= 0)
{
// open external URLs in new window
link += "' target='_blank";
}
getLayer("link" + i).innerHTML = "&nbsp;"
}
var title = getLayer("head" + i);
if (title.innerHTML.indexOf("empty") >= 0) {
title.innerHTML = "";
}
else {
title.innerHTML = "<a href='" + link + "' onFocus='if(this.blur) this.blur();'><span>" + titles[i] + "</span></a>";
}
getLayer("link" + i).style.visibility = "visible";
}
}
function changeCol()
{
if (preloadFlag == true && preloaded[numStripes-1] == true)
{
if (colChange == true)
{
var topStripe = getLayer("stripe0");
topStripe.style.backgroundColor = colors[colIndex];
for (i=0; i<numStripes; i++)
{
var projectStripe = getLayer("stripe" + i);
if(effect == 2)
var localIndex = parseInt(colIndex);
/* comment this out for uniform color change*/
var localIndex = parseInt(colIndex)+i;
if(localIndex > colors.length-1)
localIndex = localIndex - colors.length;
/**/
if(effect == 2)
projectStripe.style.backgroundColor = colors[localIndex];
else
projectStripe.style.backgroundColor = colors[colIndex];
} 
}
if (colIndex < colors.length-1)
colIndex++;
else
colIndex = 0;
setTimeout("changeCol()",intervall);
}
}
function setWidth()
{
var width = winWidth();
if(width < balkenWidth) 
width = balkenWidth + 20;
for (i=0; i<stripes.length; i++)
{
var stripe = stripes[i];
stripe.style.width = width + "px";
}
if (lastProjectIndex != -1)
{
var curProject = getLayer("project" + lastProjectIndex);
curProject.style.width = width + "px";
}
}
function displayProject(index)
{
if(preloaded[index]== true)
{
closeProjects();
if (lastProjectIndex != index)
{
colChange = false;
var projektLayer = "project" + index;
show(projektLayer);
var project = getLayer(projektLayer);
project.style.width = winWidth() + "px";;
var projectHeight = getHeight(projektLayer) - stripeHeight;
positionLayers(projectHeight, index);
setTimeout('scrollToLink(' + lastProjectIndex + ', ' + index + ')',100);
lastProjectIndex = index;
var linkName = "#p" + index;
}
else
{
lastProjectIndex = -1;
//	    goTop();
}
}
else
document.location.href = document.location.href;
}
function closeProjects()
{
// calculate position for next projekt stripe (keep position after closing last project)
lastScrollPos = scrollPos();
lastHeight = 0;
if(lastProjectIndex != -1)
lastHeight = getHeight("project" + lastProjectIndex) - stripeHeight;
positionLayers(0, 0);
for (i=0; i<numStripes; i++)
hide("project" + i);
colChange = true;
}
function scrollToLink(lastIndex, index)
{
if(lastIndex < index)
self.scrollTo(0, (lastScrollPos - lastHeight))
}
function positionLayers(diffHeight, index)
{
for (i=index+1; i<numStripes; i++)
{
var curProject = stripes[i];
var curHead = heads[i];
var newProjectY = diffHeight + 2 * stripeHeight * i;
var newHeadY = diffHeight + 2 * stripeHeight * i;
positionTop(curProject, newProjectY);
positionTop(curHead, newHeadY);
}
}
function positionTop(layer, pos)
{
layer.style.top = pos + "px";;
}
function getLayer(layerName)
{
return document.getElementById(layerName);
}
function getHeight(layerName)
{
var textHeight = document.getElementById(layerName).firstChild.firstChild.offsetHeight;
var imgHeight = document.getElementById(layerName).offsetHeight;
if(textHeight > imgHeight)
return textHeight;
else
return imgHeight;
}
function scrollPos()
{
var y;
if (self.pageYOffset) // all except Explorer
y = self.pageYOffset;
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
y = document.documentElement.scrollTop;
else if (document.body) // all other Explorers
y = document.body.scrollTop;
return y;
}
function winWidth()
{
if(typeof(window.innerWidth) == 'number')
return myWidth = window.innerWidth; //Non-IE
else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
return myWidth = document.documentElement.clientWidth; //IE 6+ in 'standards compliant mode'
else if(document.body && (document.body.clientWidth || document.body.clientHeight))
return myWidth = document.body.clientWidth; //IE 4 compatible
}
function winHeight()
{
if(typeof(window.innerHeight) == 'number')
return window.innerHeight; //Non-IE
else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
return document.documentElement.clientHeight; //IE 6+ in 'standards compliant mode'
else if(document.body && (document.body.clientWidth || document.body.clientHeight))
return myHeight = document.body.clientHeight; //IE 4 compatible
}
function newImage(arg)
{
if (document.images) {
var rslt = new Image();
rslt.src = arg;
return rslt;
}
}
function show(layer)
{
if (document.getElementById(layer))
document.getElementById(layer).style.visibility = "visible";
}
function hide(layer)
{
if (document.getElementById(layer))
document.getElementById(layer).style.visibility = "hidden";
}
/*
function changeImg()
{
}
*/
window.onResize = setWidth();
if (window.onreload)
window.onreload = goTop();
function goTop()
{
self.scrollTo(0, 0);
}
function openMovie(url, windowName, windowDef)
{
newWin = window.open(url, windowName, "width=300, height=200, scrollbars=no, menubar=no, status=no, toolbar=no, location=no, resizable=yes");
}
/* --------------------------------------------------------------------------------
Farbverlauf
Autor: Dietmar Rabich
Datei: farbverlauf.js
Copyright (c) Dietmar Rabich, Duelmen.
Alle Rechte vorbehalten.
Diese Datei stammt von http://skripte.rabich.de/.
Das Entfernen oder Veraendern dieser Informationen ist
ohne ausdrueckliche Zustimmung des Autors nicht gestattet.
Aenderungen:
5.10.2003  Erstellung
-------------------------------------------------------------------------------- */
if(effect == 2)
{
// Hexadezimalziffern
var	hex_digits	= ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
var f = new Object();
f.anzahl_werte = colorSteps;
f.ausgabe = "hex";
var	fw;
for(var k=0; k<inputColors.length; k++)
{
var col1 = k;
var col2 = k+1;
if(k == inputColors.length-1)
col2 = 0;
f.wert_start_hex = inputColors[col1];
f.wert_start_rot = new Object();
f.wert_start_rot.value = parseInt(inputColors[col1].substr(1, 2), 16);
f.wert_start_gruen = new Object();
f.wert_start_gruen.value = parseInt(inputColors[col1].substr(3, 2), 16);
f.wert_start_blau = new Object();
f.wert_start_blau.value = parseInt(inputColors[col1].substr(5, 2), 16);
f.wert_ende_hex = inputColors[col2];
f.wert_ende_rot = new Object();
f.wert_ende_rot.value = parseInt(inputColors[col2].substr(1, 2), 16);
f.wert_ende_gruen = new Object();
f.wert_ende_gruen.value = parseInt(inputColors[col2].substr(3, 2), 16);
f.wert_ende_blau = new Object();
f.wert_ende_blau.value = parseInt(inputColors[col2].substr(5, 2), 16);
fw = farbwerte_berechnen(f);
for(l = 0; l < fw.length; l++)
colors[colors.length] = fw[l];
}
}
// Vergleich fuer das Sortieren der Farben
function cmp(a, b)
{
return a - b;
}
// Berechnen eines Verlaufs
function verlauf(start, ende, anzahl)
{
if(anzahl < 3)
return null;
var a = new Array();
var i;
for(i = 0; i < anzahl; i++)
a[i] = Math.round(start + (ende - start) * i / (anzahl - 1));
return a;
}
// Ermitteln des gewaehlten Radioknopfs
function get_radio_selected(r)
{
var i;
for(i = 0; i < r.length; i++)
if(r[i].checked)
return i;
return null;
}
// Pruefen, ob Zeichenkette aus Hexadezimalziffern besteht
function is_hexdigits(s)
{
var	i, j;
var	found;
for(i = 0; i < s.length; i++)
{
found	= false;
for(j = 0; j < hex_digits.length; j++)
if(s.substr(i, 1) == hex_digits[j])
found	= true;
if(!found)
return false;
}
return true;
}
// Umrechnung in zweistellige Hexadezimalzahl
function hex(x)
{
return isNaN(x) ? "00" : hex_digits[(x - x % 16) / 16] + hex_digits[x % 16];
}
// Berechnung der Farbwerte
function farbwerte_berechnen(f)
{
var	farbwerte	= new Array();
var	start_r	= parseInt(f.wert_start_rot.value);
var	start_g	= parseInt(f.wert_start_gruen.value);
var	start_b	= parseInt(f.wert_start_blau.value);
var	ende_r	= parseInt(f.wert_ende_rot.value);
var	ende_g	= parseInt(f.wert_ende_gruen.value);
var	ende_b	= parseInt(f.wert_ende_blau.value);
var	anzahl	= parseInt(f.anzahl_werte.value);
if(isNaN(start_r))
{
start_r	= 0;
f.wert_start_rot.value	= String(start_r);
}
if(isNaN(start_g))
{
start_g	= 0;
f.wert_start_gruen.value	= String(start_g);
}
if(isNaN(start_b))
{
start_b	= 0;
f.wert_start_blau.value	= String(start_b);
}
if(isNaN(ende_r))
{
ende_r	= 255;
f.wert_ende_rot.value	= String(ende_r);
}
if(isNaN(ende_g))
{
ende_g	= 255;
f.wert_ende_gruen.value	= String(ende_g);
}
if(isNaN(ende_b))
{
ende_b	= 255;
f.wert_ende_blau.value	= String(ende_b);
}
if(isNaN(anzahl))
{
anzahl	= 10;
f.anzahl_werte.value	= String(anzahl);
}
abgleich_hex(f.wert_start_rot, f.wert_start_gruen, f.wert_start_blau, f.wert_start_hex);
abgleich_hex(f.wert_ende_rot, f.wert_ende_gruen, f.wert_ende_blau, f.wert_ende_hex);
var	rgb_r	= verlauf(start_r, ende_r, anzahl);
var	rgb_g	= verlauf(start_g, ende_g, anzahl);
var	rgb_b	= verlauf(start_b, ende_b, anzahl);
var	ausgabe_fkt	= "hex";
for(i = 0; i < anzahl; i++)
farbwerte[i]	= ausgabe_fkt ? ("rgb(" + rgb_r[i] + "," + rgb_g[i] + "," + rgb_b[i] + ")") : ("#" + hex(rgb_r[i]) + hex(rgb_g[i]) + hex(rgb_b[i]));
return farbwerte;
}
// Hexadezimalzahl nach den Dezimalzahlen uebernehmen
function abgleich_nmb(hx, r, g, b)
{
r.value	= parseInt(hx.value.substr(1, 2), 16);
g.value	= parseInt(hx.value.substr(3, 2), 16);
b.value	= parseInt(hx.value.substr(5, 2), 16);
}
// Dezimalzahl nach Hexadezimalzahl uebernehmen
function abgleich_hex(r, g, b, hx)
{
var wert_r	= parseInt(r.value);
var wert_g	= parseInt(g.value);
var wert_b	= parseInt(b.value);
hx.value	= "#" + hex(parseInt(r.value)) + hex(parseInt(g.value)) + hex(parseInt(b.value));
}
