﻿
// --- Klasse zeitleiste --- PS 24.9.07 ---

var zeitleistenNr = 0;
var aZeitleiste = new Array( 
										new Array( 0, 4, "Milano, Francesco da", 1497, 1543, 0, "" ),
										new Array( 0, 2, "Valderrábano, Enríquez de", 1500, 1557, 0, "" ),
										new Array( 0, 5, "Fuenllana, Miguel de", 1500, 1579, 0, "" ),
										new Array( 0, 4, "Narváez, Luis de", 1500, 1555, 0, "" ),
										new Array( 0, 4, "Milán, Luis de", 1500, 1561, 0, "" ),
										new Array( 0, 5, "Mudarra, Alonso", 1508, 1580, 0, "" ),
										new Array( 0, 1, "Neusidler, Hans", 1508, 1563, 0, "" ),
										new Array( 0, 2, "Pisador, Diego", 1509, 1557, 0, "" ),
										new Array( 0, 3, "Morlaye, Guillaume", 1515, 1565, 0, "" ),
										new Array( 0, 5, "Roy, Adrien le", 1520, 1598 , 0, "" ),
										new Array( 0, 2, "Daza, Esteban", 1537, 1591, 0, "" ),
										new Array( 0, 2, "Byrd, William", 1543, 1623, 0, "" ),
										new Array( 0, 2, "Espinel, Vicente", 1550, 1624, 0, "" ),
										new Array( 0, 3, "Dowland, John", 1562, 1626, 0, "" ),
										new Array( 0, 2, "Praetorius, Michael", 1571, 1621, 0, "" ),
										new Array( 0, 5, "Amat, Juan Carles y", 1572, 1642, 0, "" ),
										new Array( 0, 4, "Pelligrini, Domenico", 1600, 1682, 0, "" ),
										new Array( 0, 4, "Foscarini, Giovanni", 1601, 1649, 0, "" ),
										new Array( 0, 5, "Corbetta, Francesco", 1615, 1681, 0, "" ),
										new Array( 0, 2, "Granata, Giovanni", 1620, 1687, 0, "" ),
										new Array( 0, 2, "Lully, Jean-Baptiste", 1632, 1687, 0, "" ),
										new Array( 0, 4, "Sanz, Gaspar", 1640, 1710, 0, "" ),
										new Array( 0, 3, "Guerau, Francisco", 1649, 1722, 0, "" ),
										new Array( 0, 4, "Roncalli, Ludovico", 1654, 1713, 0, "" ),
										new Array( 0, 5, "Visée, Robert de", 1660, 1720, 0, "" ),	
										new Array( 0, 3, "Murcia, Santiago de", 1682, 1732, 0, "" ),
										new Array( 0, 3, "Bach, Johann Sebastian", 1685, 1750, 0, "" ),
										new Array( 0, 2, "Scarlatti, Domenico", 1685, 1757, 0, "" ),
										new Array( 0, 2, "Campion, Francois",1680,1748, 0, "" ),
										new Array( 0, 2, "Weiss, Sylvius Leopold", 1686,1750, 0, "" ),
										new Array( 0, 4, "Baron, Ernst Gottlieb", 1696, 1760, 0, "" ),
										new Array( 0, 2, "Falkenhagen, Adam", 1697,1761, 0, "" ),
										new Array( 0, 4, "Ferandiere, Fernando", 1750, 1816, 0, "" ),
										new Array( 0, 2, "Boccherini, Luigi", 1743, 1805, 0, "" ),
										new Array( 0, 2, "Abreu, Antonio", 1750, 1820, 0, "" ),
										new Array( 0, 4, "Moretti, Frederico", 1760, 1838, 0, "" ),
										new Array( 0, 3, "Molitor, Simon", 1766, 1848, 0, "" ),
										new Array( 0, 2, "Gragnani, Filippo", 1767, 1820, 0, "" ),
										new Array( 0, 2, "Call, Leonhard de", 1768, 1815, 0, "" ),
										new Array( 0, 2, "Gragnani, Filippo", 1768, 1820, 0, "" ),
										new Array( 0, 4, "Carulli, Ferdinando", 1770, 1841, 5, "carulli" ),
										new Array( 0, 2, "Nava, Antonio Maria", 1775, 1828, 0, "" ),
										new Array( 0, 2, "Molino, Francesco", 1775, 1847, 0, "" ),
										new Array( 0, 2, "Küffner, Joseph", 1776, 1856, 0, "" ),
										new Array( 0, 5, "Sor, Fernando", 1778, 1839, 5, "sor" ),
										new Array( 0, 5, "Giuliani, Mauro", 1781, 1829, 5, "giuliani" ),
										new Array( 0, 3, "Diabelli, Anton", 1781, 1858, 0, "" ),
										new Array( 0, 3, "Paganini, Nicolo", 1782, 1840, 0, "" ),
										new Array( 0, 5, "Aguado, Dionisio", 1784, 1849, 5, "aguado" ),
										new Array( 0, 3, "Legnani, Luigi", 1790, 1877, 0, "" ),
										new Array( 0, 5, "Carcassi, Matteo", 1792, 1853, 5, "carcassi" ),
										new Array( 0, 3, "Marschner, Heinrich", 1795, 1861, 0, "" ),
										new Array( 0, 4, "Coste, Napoleon", 1806, 1883, 5, "coste" ),
										new Array( 0, 4, "Mertz, Johann Kaspar", 1806, 1856, 5, "mertz" ),
										new Array( 0, 4, "Antonio Cano-Curriela", 1811, 1897, 0, "" ),
										new Array( 0, 3, "Regondi, Giulio", 1822, 1872, 0, "" ),
										new Array( 0, 2, "Bosch, Jaime", 1826, 1895, 0, "" ),
										new Array( 0, 4, "Arcas, Julian", 1832, 1882, 0, "" ),
										new Array( 0, 2, "Cano, Federico", 1838, 1904, 0, "" ),
										new Array( 0, 5, "Tarrega, Francisco", 1852, 1909, 6, "tarrega" ),
										new Array( 0, 5, "Albéniz, Isaac", 1860, 1909, 0, "" ),
										new Array( 0, 3, "Cottin, Alfred", 1863,1923, 0, "" ),
										new Array( 0, 2, "Buek, Fritz", 1864, 1942, 0, "" ),
										new Array( 0, 4, "Granados, Enrique", 1867, 1916, 0, "" ),
										new Array( 0, 2, "Albert, Heinrich", 1870, 1950, 0, "" ),
										new Array( 0, 3, "Malats, Joaquim", 1872, 1912, 0, "" ),
										new Array( 0, 4, "Falla, Manuel de", 1876, 1946, 0, "" ),
										new Array( 0, 5, "Llobet, Miguel", 1878, 1938, 7, "llobet" ),
										new Array( 0, 4, "Fortea, Daniel", 1878, 1953, 0, "" ),
										new Array( 0, 5, "Ponce, Manuel", 1882, 1948, 0, "" ),
										new Array( 0, 4, "Turina, Joaquin", 1882, 1949, 0, "" ),
										new Array( 0, 5, "Barrios Mangorè, Agustin", 1885, 1944, 0, "" ),
										new Array( 0, 5, "Pujol, Emilio", 1886, 1980, 7, "pujol" ),
										new Array( 0, 5, "Villa-Lobos, Heitor", 1887, 1959, 0, "" ),
										new Array( 0, 4, "Moreno-Torroba, Federico", 1891, 1982, 0, "" ),
										new Array( 0, 5, "Segovia, Andrés", 1893, 1987, 7, "segovia" ),
										new Array( 0, 3, "Federic Mompou", 1893, 1987, 0, "" ),
										new Array( 0, 4, "Castelnuovo-Tedesco, Mario", 1895, 1968, 0, "" ),
										new Array( 0, 4, "Tansman, Alexander", 1897, 1986, 0, "" ),
										new Array( 0, 5, "Rodrigo, Joaquin", 1902, 0, 0, "" ),
										new Array( 0, 3, "Britten, Benjamin", 1913, 1976, 0, "" ),
										new Array( 0, 2, "Albloniz, Miguel", 1917, 2002, 0, "" ),
										new Array( 0, 3, "Lauro, Antonio", 1917, 1985, 0, "" ),
										new Array( 0, 3, "Duarte, John", 1919, 0 , 0, "" ),
										new Array( 0, 3, "Henze, Hans Werner", 1926, 0, 0, "" ),
										new Array( 0, 3, "Yepes, Narciso", 1927, 0, 0, "" ),
										new Array( 0, 3, "Ragossnig, Konrad", 1932, 0, 0, "" ),
										new Array( 0, 5, "Bream, Julian", 1933, 0, 0, "" ),
										new Array( 0, 2, "Chiesa, Ruggero", 1933, 2002, 0, "" ),
										new Array( 0, 5, "Brouwer, Leo", 1939, 0, 0, "" )
									);
										
function zeitleiste()
{
	this.nr					= ++zeitleistenNr;
	this.datum				= new Date();
	this.aktjahr			= ( this.datum.getYear() < 1900 ) ? this.datum.getYear() + 1900 : this.datum.getYear();
	this.div					= "";
	this.min					= 1500;
	this.max					= this.aktjahr;
	this.zeilen				= 0;
	this.zeilenabstand	= 5;
	this.titelhoehe		= 20;
	this.jahrzehnte		= 0;
	this.zoom				= 4;
	this.bioindex			= -1;
	
	this.create	= zeitleisteCreate;
	this.fill	= zeitleisteFill;
	this.reorg	= zeitleisteReorg;
	this.layout	= zeitleisteLayout;
	this.para	= zeitleistePara;
	this.add		= zeitleisteAdd;
	this.bio		= zeitleisteBio;
}

function zeitleisteAdd( text, von, bis )
{
	aZeitleiste.unshift( new Array( 0, 6, text, von, bis ) );
}

function zeitleisteCreate( node )
{
	this.para( node.title );

	this.div = document.createElement( "div" );
	this.div.className	= "zeitleiste_main"
	node.appendChild( this.div );

	this.reorg();
	this.fill();
	this.layout();
}

function zeitleisteReorg()
{
	var anzahl = 100;
	var zeile = 0;
	var index = 0;
	var aZeile = new Array( anzahl );
	
	for( i = 0; i < anzahl; i++ )
		aZeile[i] = 0;

	// --- Sortiere Einträge in passende Zeilen ---

	do
	{
		if( aZeitleiste[index][3] < this.max )
		{
			for( j = 0; j < anzahl; j++ )
			{
				if( aZeitleiste[index][3] > aZeile[j] )
				{
					// --- Eintrag passt in Zeile ---
					
					if( aZeitleiste[index][4] == 0 )
						aZeile[j] = this.max;
					else
						aZeile[j] = aZeitleiste[index][4];
					
					aZeitleiste[index][0] = j;
					
					if( j + 1 > this.zeilen )
						this.zeilen = j + 1;
					
					break;
				}
				
			}
		}
		else
			aZeitleiste[index][0] = -1;
				
		index++;
		
	} while( index < aZeitleiste.length );
}

function zeitleisteFill()
{
	// --- Titel ---
	
	var titelDiv = document.createElement( "div" );

	titelDiv.className		= "zeitleiste_titel";
	titelDiv.id					= this.nr + "titel";
	
	// --- Jahresangaben ---

	for( i = 0; i < this.jahrtexte; i++ )
	{
		var jahrDiv = document.createElement( "div" );
		
		jahrDiv.innerHTML = this.min + i * 50;

		jahrDiv.style.position	= "absolute";
		jahrDiv.id					= this.nr + "zlt" + i;		
		
		titelDiv.appendChild( jahrDiv );
	}

	this.div.appendChild( titelDiv );

	// --- Epochen ---

	//	Renaissance	1500-1600
	// Barock 1600-1750
	// Klassik 1750-1840
	// Romantik 1840-1900
	// Moderne 1900-
	
	// --- Jahrzehnte ---

	for( i = 0; i < this.jahrzehnte; i++ )
	{
		var timeDiv = document.createElement( "div" );
		
		timeDiv.className = "zeitleiste_block";
		timeDiv.id			= this.nr + "zlb" + i;		

		if( i > 0 )
		{
			if( i % 5 == 0 )
				timeDiv.className += " zeitleiste_dunkel";
			else
				timeDiv.className += " zeitleiste_hell";
		}
					
		this.div.appendChild( timeDiv );
	}	

	// --- Einträge ---

	for( i = 0; i < aZeitleiste.length; i++ )
	{
		if( aZeitleiste[i][0] != -1 )
		{
			var kompDiv = document.createElement( "div" );
			
			kompDiv.className = "zeitleiste_eintrag";
			kompDiv.id			= this.nr + "zle" + i;
			
			if( aZeitleiste[i][4] == 0 )
			{
				kompDiv.title = aZeitleiste[i][2] + ": " + aZeitleiste[i][3] + "-";
				kompDiv.style.borderRight = "0";
			}
			else
				kompDiv.title = aZeitleiste[i][2] + ": " + aZeitleiste[i][3] + "-" + aZeitleiste[i][4];
				
			if( aZeitleiste[i][1] == 6 )
				kompDiv.style.backgroundColor = "#90d090";
			else if( aZeitleiste[i][1] == 5 )
				kompDiv.style.backgroundColor = "#fff8c8";
			else if( aZeitleiste[i][1] == 4 )
				kompDiv.style.backgroundColor = "#fff8e0";
				
			if( aZeitleiste[i][5] != 0 )
			{
				kompDiv.style.fontWeight = "bold";
				kompDiv.bioindex = i;
				kompDiv.onclick = this.bio;
			}

			this.div.appendChild( kompDiv );
		}
	}
}

function zeitleisteLayout()
{
	var x = 0;
	var y = this.titelhoehe + 10;
	var w = this.max - this.min;
	var bereich = this.max - this.min;
	var kh = 16;
	
	this.div.style.width = this.zoom * w;
	this.div.style.height = 2 + 10 + this.titelhoehe + this.zeilen * ( kh + this.zeilenabstand );

	// --- Titel ---

	var div = document.getElementById( this.nr + "titel" );
	
	div.style.left		= 0;
	div.style.width	= this.zoom * w;
	div.style.top		= 0;
	div.style.height	= this.titelhoehe;

	for( i = 0; i < this.jahrtexte; i++ )
	{
		var div = document.getElementById( this.nr + "zlt" + i );
		
		div.style.left		= x + i * this.zoom * 50;
		div.style.top		= 2;
	}
	
	// --- Jahrzehnte ---

	for( i = 0; i < this.jahrzehnte; i++ )
	{
		var div = document.getElementById( this.nr + "zlb" + i );

		var kx = x + i * this.zoom * 10;
		var ky = this.titelhoehe;
		var kw = this.zoom * 10;
		
		div.style.left		= kx;
		div.style.width	= kw;
		div.style.top		= ky;
		div.style.height	= 2 + 10 + this.zeilen * ( kh + this.zeilenabstand );
	}

	// --- Einträge ---
	
	for( i = 0; i < aZeitleiste.length; i++ )
	{
		var div = document.getElementById( this.nr + "zle" + i );

		if( div )
		{
			var kx = x + ( this.zoom * w ) * ( aZeitleiste[i][3] - this.min ) / bereich;
			var ky = y + aZeitleiste[i][0] * ( kh + this.zeilenabstand );
			var kw = x + ( this.zoom * w ) * ( aZeitleiste[i][4] - aZeitleiste[i][3] ) / bereich - 1;
			
			if( aZeitleiste[i][4] == 0 )
			{
				kw = x + ( this.zoom * w ) * ( this.max - aZeitleiste[i][3] ) / bereich - 1;
			}

			div.style.left		= kx;
			div.style.width	= kw;
			div.style.top		= ky;
			div.style.height	= kh;

			//div.style.filter='alpha(opacity='+parseInt(100*0.75)+')';
			//div.style.opacity=0.75;

			if( aZeitleiste[i][4] > this.max )
			{
				var kw = x + ( this.zoom * w ) * ( this.max - this.min ) / bereich - kx;
				
				div.style.width = kw;
				div.style.borderRight = "0";
				
				if( kw > 100 )
					div.innerHTML = aZeitleiste[i][2];
			}
			else
				div.innerHTML = aZeitleiste[i][2];
		}
	}
}

function zeitleistePara( title )
{
	if( title.length > 0 )
	{
		var para = title.split("|");

		if( para.length >= 1 )
			this.zoom = parseInt( para[0] );

		if( para.length >= 2 )
			this.min = parseInt( para[1] );

		if( para.length >= 3 )
			this.max = parseInt( para[2] );
	}
			
	this.jahrzehnte = (this.max - this.min)/10;
	this.jahrtexte = (this.max - this.min)/50;
}

function zeitleisteBio()
{
	if( this.bioindex != -1 )
	{
		var link = '/geschichte/index.php?page=' + aZeitleiste[this.bioindex][5] + '#bio_' + aZeitleiste[this.bioindex][6];
		document.location.href = link;
	}
};
				