/*
 * Copyright (c) 2008 Maximilian Antoni. All rights reserved.
 */
window.image = {

lib: [
	{
			file: "spacy1_spacy2",
			name: "Spacy 1 und Spacy 2",
			title: "2004, zweiteilig, je 135 x 135 cm, Öl auf Leinwand"
		},
		{
			file: "schleuderball",
			name: "Schleuderball und Schleuderball",
			title: "2005, zweiteilig, je 135 x 135 cm, Öl auf Leinwand"
		},
		{
			file: "rosa_dont_cry",
			name: "Rosa don't cry",
			title: "2006, 163 x 163 cm, Öl auf Leinwand"
		},
		{
			file: "kaba1_kaba2",
			name: "Kaba mit Kaba",
			title: "2007, zweiteilig, je 140 x 140 cm, Öl auf Leinwand"
		},
		{
			file: "blanka1_blanka2",
			name: "Blanka und Blanka",
			title: "2007, zweiteilig, je 140 x 140 cm, Öl auf Leinwand"
		},
		{
			file: "schritt",
			name: "Schritt",
			title: "Juni 2001, 210 x 210 cm, Öl auf Leinwand"
		},
		{
			file: "sport",
			name: "Sport",
			title: "Juli 2001 August, 210 x 210 cm, Öl auf Leinwand"
		},
		{
			file: "melusine",
			name: "Melusine",
			title: "September 2001 Oktober, 210 x 210 cm, Öl auf Leinwand"
		},
		{
			file: "rudi",
			name: "Rudi",
			title: "November 2001, 210 x 210 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0105",
			name: "NEA",
			title: "2008/2009, 70x140 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0106",
			name: "TOPI",
			title: "2008/2009, 70x140 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0102",
			name: "Chromo",
			title: "1991/2008, 60x60 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0104",
			name: "Lux",
			title: "1991/2008, 60x60 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0565",
			name: "Plants",
			title:"2010, zweiteilig je 70x52 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0539",
			name: "Tondo",
			title:"2009, 180 x 280 cm, Öl auf Leinwand"
		},
		{
			file: "KosMa",
			name: "KosMa & KosMa",
			title: "2008/2009 zweiteilig, je 135x135 cm, Öl auf Leinwand"
		},
		{
			file: "P1020353",
			name: "Lisi",
			title: "2006, 35x35 cm, Öl auf Leinwand"
		},
		{
			file: "Tiger",
			name: "Tiger",
			title: "Dez.1999, 163x163cm, Öl/Wachs auf Leinwand, Abb. im Katalog Kreislauf, S.23"
		},
		{
			file: "Azur",
			name: "Azur",
			title: "Juni Juli 2000, 163x163 cm, Öl/Wachs auf Leinwand, Abb. im Katalog Kreislauf, S.37"
		},
		{
			file: "Luzia",
			name: "Luzia",
			title: "Juli August 2000, 163x163 cm, Öl/Wachs auf Leinwand, Abb. im Katalog Kreislauf, S.39"
		},
		{
			file: "Gerwin",
			name: "Gerwin",
			title: "Mai 2000, 163x163 cm, Öl/Wachs auf Leinwand, Abb. im Katalog Kreislauf, S.33"
		},
		{
			file: "Timmi9",
			name: "Timmi",
			title: "2002, 90x90 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0367",
			name: "Atelierwand 2009",
			title: "diverse kleinere Arbeiten"
		},
		{
			file: "Strech-2006",
			name: "Strech",
			title: "2006, 52x52 cm, Öl auf Leinwand"
		},
		{
			file: "Blub_2007",
			name: "Blub",
			title: "2007, 52x52 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0457",
			name: "Atelierecke 2009",
			title: "diverse kleinere Arbeiten"
		},
		{
			file: "BILD0448",
			name: "Probe",
			title: "2004, 30x30 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0479",
			name: "o.T.",
			title: "1993, 60x180 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0566",
			name: "o.T.",
			title: "1995, 35x40 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0585",
			name: "Phoenix",
			title: "2007/2008, 100x52 cm, Öl auf Leinwand"
		},
		{
			file: "BILD0590",
			name: "Bonbon",
			title: "2008-2009, 52x52 cm, Öl auf Leinwand"
		},
	
],

index: 0,

next: function() {
	if(++image.index == image.lib.length)
		image.index = 0;
	image.change();
},

prev: function() {
	if(--image.index == -1)
		image.index = image.lib.length - 1;
	image.change();
},

change: function() {
	var img = image.lib[image.index];
	image.loader = new Image();
	image.loader.src = "gemaelde/" + img.file + ".jpg";
	image.applyText("bildname", img.name);
	image.applyText("bildunterschrift", img.title);
	image.opacity = 1.0;
	image.animateHide();
	return false;
},

applyText: function(id, text) {
	var n = document.getElementById(id);
	while(n.hasChildNodes()) {
		n.removeChild(n.lastChild);
	}
	n.appendChild(document.createTextNode(text));
},

animateHide: function() {
	image.opacity -= 0.1;
	image.applyOpacity();
	if(image.opacity > 0) {
		setTimeout("image.animateHide()", 40);
	}
	else {
		setTimeout("image.waitLoad()", 1);
	}
},

waitLoad: function() {
	if(image.loader.complete) {
		var n = document.getElementById("bild");
		n.src = image.loader.src;
		n.style.width = image.loader.width + "px";
		image.loader = null;
		setTimeout("image.animateShow()", 1);
	}
	else {
		setTimeout("image.waitLoad()", 40);
	}
},

animateShow: function() {
	image.opacity += 0.1;
	image.applyOpacity();
	if(image.opacity < 1) {
		setTimeout("image.animateShow()", 40);
	}
	else {
		image.opacity = 1;
		image.applyOpacity();
	}
},

applyOpacity: function() {
	var node = document.getElementById("bild");
	node.style.filter = "alpha(opacity=" + (image.opacity * 100) + ")";
	node.style.opacity = String(image.opacity);
},

childElements: function(node) {
	var nodes = [];
	var childNodes = node.childNodes;
	for(var i = 0; i < childNodes.length; i++) {
		if(childNodes[i].nodeType == 1) {
			nodes.push(childNodes[i]);
		}
	}
	return nodes;
}

}
