// declaration
var PageWrapper, Page, MenuWrapper, Menu, SubmenuWrapper, Submenu, ContentWrapper, Content, Figure;
var Mode, HTMLFiles, ContentHidden, CurrMenuNr = -1, HTMLFilePrefix, ScrollbarWidth, FirstDownloadClick = true, FilenameFieldCleared = false;

var LangGer = [
	'Biographie',
	'Referenzen',
	'Bands &amp; Projekte',
	'Studio',
	'Media',
	'Links',
	'Termine',
	'Impressum',
	'Kontakt',
	'Sprache',
	( 'Dateiname eingeben und OK dr'+ unescape('%FC') +'cken ...' ),
	'Inhalt wird geladen ..'
];
var LangEng = [
	'Biography',
	'References',
	'Bands &amp; Projects',
	'Studio',
	'Media',
	'Links',
	'Events',
	'Legal',
	'Contact',
	'Language',
	'Enter Filename and click OK ...',
	'Loading Content ..'
];
var Lang = LangGer;

function prepare()
{
enterDownload();
if (navigator.appVersion.indexOf('MSIE 6') == -1) preloadImages();
}

function preloadImages()
{
	 // page

	var Imgs = [
		'paper.jpg',
		'bg.png',
		'blank.gif',
		'close.jpg',
		'contentheader0deutsch.jpg','contentheader0englisch.jpg',
		'contentheader1deutsch.jpg','contentheader1englisch.jpg',
		'contentheader2deutsch.jpg','contentheader2englisch.jpg',
		'contentheader3deutsch.jpg','contentheader3englisch.jpg',
		'contentheader4deutsch.jpg','contentheader4englisch.jpg',
		'contentheader5deutsch.jpg','contentheader5englisch.jpg',
		'contentheader6deutsch.jpg','contentheader6englisch.jpg',
		'contentheader7deutsch.jpg','contentheader7englisch.jpg',
		'contentimage0.jpg',
		'contentimage1.jpg',
		'contentimage2.jpg',
		'contentimage3.jpg',
		'contentimage4.jpg',
		'contentimage5.jpg',
		'contentimage6.jpg',
		'figure.jpg',
		'header.jpg',
		'lang_english_on.gif','lang_english_off.gif',
		'lang_german_on.gif','lang_german_off.gif',
		'notenhalter.jpg',
		'pianokey_black.jpg',
		'pianokey_white1.jpg',
		'pianokey_white2.jpg',
		'pianokey_white3.jpg',
		'pianokey_white4.jpg',
		'pianokey_white5.jpg',
		'title.jpg'
	];
	
	var ImgsLength = Imgs.length;
	for (i=0; i < ImgsLength; i++) {
		var Img = new Image();
		Img.src = '../images/layout/'+Imgs[i];
	}
	
	// media & logos & bands und projekte

	Imgs = [
		'domino_cd_cover.jpg',
		'domino_cd_cover_thumb.jpg',
		'hartmut_zeller_conne_portrait.jpg',
		'hartmut_zeller_conne_portrait_thumb.jpg',
		'hartmut_zeller_fluegel.jpg',
		'hartmut_zeller_fluegel_thumb.jpg',
		'hartmut_zeller_gitarre_live.jpg',
		'hartmut_zeller_gitarre_live_thumb.jpg',
		'hartmut_zeller_leiser_wolf.jpg',
		'hartmut_zeller_leiser_wolf_thumb.jpg',
		'hartmut_zeller_mi_buehne.jpg',
		'hartmut_zeller_mi_buehne_thumb.jpg',
		'hartmut_zeller_mi_buehne_2.jpg',
		'hartmut_zeller_mi_buehne_2_thumb.jpg',
		'hartmut_zeller_portrait_boston.jpg',
		'hartmut_zeller_portrait_boston_thumb.jpg',
		'hartmut_zeller_portrait_nah.jpg',
		'hartmut_zeller_portrait_nah_thumb.jpg',
		'icon_audio.png',
		'jazzico.jpg',
		'jazzico_thumb.jpg',
		'jazzico_buehne.jpg',
		'jazzico_buehne_thumb.jpg',
		'jazzico_logo_thumb.jpg',
		'joint_venture.jpg',
		'joint_venture_thumb.jpg',
		'joint_venture_logo_thumb.jpg',
		'live_keys.jpg',
		'live_keys_thumb.jpg',
		'logo_andy_kemmer.jpg',
		'logo_christoph_dangelmaier.jpg',
		'logo_madness.jpg',
		'logo_madness2.jpg',
		'logo_myspace.jpg',
		'logo_youtube.jpg',
		'mahle_ds_motor_thumb.jpg',
		'op3.jpg',
		'op3.jpg_thumb',
		'op3_logo_thumb.jpg',
		'psychonauten.jpg',
		'psychonauten_thumb.jpg',
		'rack.jpg',
		'rack_thumb.jpg',
		'rack_2.jpg',
		'rack_2_thumb.jpg',		
		'rhcp.jpg',
		'rhcp_thumb.jpg',
		'rhcp_zentrum_zoo.jpg',
		'rhcp_zentrum_zoo_thumb.jpg',
		'toktoktok_live_in_muenster.jpg',
		'toktoktok_live_in_muenster_thumb.jpg',
		'schlagzeug.jpg',
		'studio.jpg',
		'studio_thumb.jpg'
	];
	
	ImgsLength = Imgs.length;
	for (i=0; i < ImgsLength; i++) {
		var Img = new Image();
		Img.src = '../images/'+Imgs[i];
	}
}

function loadContent ( MenuNr )
{	
	CurrMenuNr = MenuNr;
	var HTMLFile;

	if ( MenuNr == 6 ) HTMLFile = 'deutsch_'+ HTMLFiles[ MenuNr ]; // load appointments only in german
	else HTMLFile = HTMLFilePrefix +'_'+ HTMLFiles[ MenuNr ];
	
	var FadeInTime = 150;
	
	Content.html( Lang[ 12 ] );
	Submenu.html('');
	
	// Starting
	
	var Request = false;
	if(window.XMLHttpRequest)
		Request = new XMLHttpRequest(); 
	else if (window.ActiveXObject) { // IE
		try { Request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
			try { Request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
		}
	}

	Request.onreadystatechange = function() // Sending Request to Server
	{ 
		if(Request.readyState == 4) //Server is ready
		{
			if(Request.status == 200) // Server answered, load content online
			{
				Content.html( Request.responseText );
				Submenu.html( Content.find('div:first') );
				
				var NumOfSubContents = -1;
				
				Submenu.find('li').each( function( i ) {
						var Link = $(this).html();
						var Style = (i==1) ? '#f0d34c' : 'white';
						if ( i==0 ) {
							$('#ContentHeader').css( 'background-image', ( 'url(../images/layout/contentheader'+MenuNr+HTMLFilePrefix+'.jpg)' ) );
							Link = '';
						}
						else Link = '<a href="#" style="color: '+Style+';">'+ Link +'</a>';
						$(this).html( Link );
						$(this).click( function() {
							switchSubmenu( i );
						});
						NumOfSubContents++;
				});
				
				var ShowIndex = 0;
				if ( NumOfSubContents > 0 ) ShowIndex = 1;
				else Submenu.html('');
				
				$('#Content > div').each( function( i ) // foreach div thats direct child of content-div
				{
					if ( i == ShowIndex ) $(this).show();
					else $(this).hide();
				});
				
				Submenu.fadeIn('slow', function() 
					{
						Content.jScrollPane({ showArrows:false, scrollbarWidth:ScrollbarWidth, scrollbarMargin:30 });
						Content.animate( { opacity: 1 }, FadeInTime );
						$('.jScrollPaneContainer').animate( { opacity: 1 }, FadeInTime );
					}
				);
				
				//$('#ContentImage').css( 'background-image', ( 'url(../images/layout/contentimage'+MenuNr+'.jpg)' ) ); 
				
				if ( MenuNr == 7) {
					var TheDate = new Date();
					$('.InsertYear').html( TheDate.getFullYear() );
				}
			}
			else // Server doesn't answered, load content offline
			{
				Content.load( HTMLFile, 1, function() {
					Submenu.html( Content.find('div:first') );
					
					var NumOfSubContents = -1;
	
					Submenu.find('li').each( function( i ) {
						var Link = $(this).html();
						var Style = (i==1) ? '#f0d34c' : 'white';
						if ( i==0 ) {
							$('#ContentHeader').css( 'background-image', ( 'url(../images/layout/contentheader'+MenuNr+HTMLFilePrefix+'.jpg)' ) );
							Link = '';
						}
						else Link = '<a href="#" style="color: '+Style+';">'+ Link +'</a>';
						$(this).html( Link );
						$(this).click( function() {
							switchSubmenu( i );
						});
						NumOfSubContents++;
					});
					
					var ShowIndex = 0;
					if ( NumOfSubContents > 0 ) ShowIndex = 1;
					else Submenu.html('');
					
					$('#Content > div').each( function( i ) // foreach div thats direct child of content-div
					{
						if ( i == ShowIndex ) $(this).show();
						else $(this).hide();
					});
					
					//$('#ContentImage').css( 'background-image', ( 'url(../images/layout/contentimage'+MenuNr+'.jpg)' ) ); 
					
					if ( MenuNr == 7) {
						var TheDate = new Date();
						$('.InsertYear').html( TheDate.getFullYear() );
					}
				});
				
				Submenu.fadeIn('slow', function() 
					{
						Content.jScrollPane({ showArrows:false, scrollbarWidth:ScrollbarWidth, scrollbarMargin:40 });
						Content.animate( { opacity: 1 }, FadeInTime );
						$('.jScrollPaneContainer').animate( { opacity: 1 }, FadeInTime );
					}
				);
			}
		} 
	}; 
	Request.open("GET", HTMLFile, true); 
	Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	Request.send(null);
}


function downloadFile( Filename )
{
	// Download
	// Check: is Mac?
	//if (navigator.userAgent.indexOf('Mac') != -1) { 
		window.open( ('http://www.hartmutzeller.de/html/download.html?Filename='+Filename) ); 
	//} else { window.open( '../ftp/'+Filename ); }
	
	

	/*
	Filename = ( '../ftp/'+Filename );

	var Request = null;
	if(window.XMLHttpRequest)
		Request = new XMLHttpRequest(); 
	else if (window.ActiveXObject)
		Request  = new ActiveXObject(Microsoft.XMLHTTP); 

	Request.onreadystatechange = function() // Sending Request to Server
	{ 
		if(Request.readyState == 4) //Server is ready
		{
			if(Request.status == 200) // Server answered, load content online
			{
				//alert( Request.responseText );
				window.open( Filename );
			}
			else // Server doesn't answered, load content offline
			{
				if ( HTMLFilePrefix == 'deutsch' ) alert('Die angeforderte Datei existiert nicht.');
				else alert('The requested file doesn\'t exist.');
			}
		} 
	}; 
	Request.open("GET", Filename, true); 
	Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	Request.send(null);
	*/
}

function switchSubmenu( SubmenuNr )
{
	$('#Submenu a').each( function( i ) {
		if ( i+1==SubmenuNr ) $(this).css( { color:'#f0d34c' } );
		else $(this).css( { color:'white' } );
	});

	$('#Content > div').each( function( i ) // foreach div thats direct child of content-div
	{
		if ( i != SubmenuNr ) $(this).hide();
		else $(this).fadeIn('slow')
	});
	Content.jScrollPane({ showArrows:false, scrollbarWidth:ScrollbarWidth, scrollbarMargin:40 });
}

function switchMode( NewMode )
{
	if (navigator.appVersion.indexOf('MSIE 6')>-1) ContentWrapper.css({ opacity:0 });
	var FadeDur = 400;

	Content.stop( true, false ).animate( { opacity: 0 }, 200 );
	Submenu.stop( true, false ).animate( { opacity: 0 }, 100 );
	$('.jScrollPaneContainer').stop( true, false ).animate( { opacity: 0 }, 200 );

	switch ( NewMode )
	{
		case 0: Mode = ( Mode == 1 ) ? 2 : 1; break; // switch
		case 1: Mode = NewMode; break; // mainmenu
		case 2: Mode = NewMode; break; // content
	}

	if ( Mode == 1 ) // mainmenu
	{
		var HoverDelay = 170;
		ContentHidden = true;
		
		ContentWrapper.stop( true, false )
			.animate( { top: -20 }, 200 )
			.animate( { top:600 }, 300 );
		Submenu.stop( true, false )
			.animate( { left: 200, opacity: 1 }, HoverDelay )
			.animate( { left: 200, opacity: 0 }, 100 );
		Figure.stop( true, false )
			.animate( { left:305, opacity:1 }, 300 );
	} 
	if ( Mode == 2 ) // content
	{
		ContentWrapper.animate( { marginTop: 0 }, 250 );
		ContentHidden = false;
		var HoverDelay = 300;
				
		ContentWrapper.stop( true, false ).animate( { top: 0 }, HoverDelay );
		Submenu.stop( true, false ).animate( { left: 200, opacity: 0 }, HoverDelay );
		Figure.stop( true, false ).animate( { left:305, opacity: 1 }, HoverDelay );
	
		Submenu.animate( { left: 80, opacity: 1 }, 200 );
		Figure.animate( { left:500 }, 200 );
	}
	if (navigator.appVersion.indexOf('MSIE 6')>-1) ContentWrapper.animate({ opacity:1 }, 1000);
}

function slidePianoKey( KeyNr, MouseIn )
{
	var KeyImageSlide = 40;
	var KeyReaction = 25;
	var SlideDuration = 150;
	var ClearQueue = true;
	var GotoEnd = false;

	$('.KeyImageSlide').each( function( i )
	{
		if ( i == KeyNr )
		{
			if ( MouseIn )
			{	
				$('.Label').each( function(i){ 
					if (i==KeyNr) $(this).css({ color:'#f0d34c' });
				});
			
				$(this).stop( ClearQueue, GotoEnd ).animate( // freezes the key for the amount of KeyReaction
					{ marginLeft: 0 },
					{ duration: KeyReaction }
				);
				$(this).animate(
					{ marginLeft: KeyImageSlide },
					{ duration: SlideDuration }
				);
			} 
			else 
			{
				$('.Label').each( function(i){ 
					$(this).css({ color:'white' });
				});
			
				$(this).stop( ClearQueue, GotoEnd ).animate(
					{ marginLeft: 0 },
					{ duration: SlideDuration }
				);
			}
		}
	});
}

function pressPianoKey( KeyNode )
{
}

function buildMenu()
{
	var Menu = '';

	for ( var i=0; i <= 8; i++ )
	{
		var CloseDivs = '';
		var ColorPianoKeys = '';
		var MenuLinkHref = '#';
		if ( i==8 ) MenuLinkHref = 'mailto:mail@hartmutzeller.de';
		var MenuLinkLabel;
		var KeyImage;
		var MenuSound;
		
		switch ( i )
		{
			case 0: MenuLinkLabel = Lang[ 0 ]; MenuSound = 'Links'; KeyImage = 'white2'; break;
			case 1: MenuLinkLabel = Lang[ 1 ]; MenuSound = 'Media'; KeyImage = 'white1'; break;
			case 2: MenuLinkLabel = Lang[ 2 ]; MenuSound = 'Termine'; KeyImage = 'white5'; break;
			case 3: MenuLinkLabel = Lang[ 3 ]; MenuSound = 'Biographie'; KeyImage = 'white2'; break;
			case 4: MenuLinkLabel = Lang[ 4 ]; MenuSound = 'Referenzen'; KeyImage = 'white3'; break;
			case 5: MenuLinkLabel = Lang[ 5 ]; MenuSound = 'Projekte'; KeyImage = 'white4'; break;
			case 6: MenuLinkLabel = Lang[ 6 ]; MenuSound = 'Studio'; KeyImage = 'white5'; break;
			case 7: MenuLinkLabel = Lang[ 7 ]; MenuSound = 'Impressum'; KeyImage = 'black'; break;
			case 8: MenuLinkLabel = Lang[ 8 ]; MenuSound = 'Kontakt'; KeyImage = 'black'; break;
			
			default: KeyImage = 'black'; break;
		}
		
		KeyImage = '<img class="KeyImage PNG" src="../images/layout/pianokey_'+ KeyImage +'.jpg"/>' 

		if ( i==0 || i==7 ) {
			ColorPianoKeys = ( i==0 ) ? 'WhitePianoKeys' : 'BlackPianoKeys'; //  1 --> white, 7 -> black
			ColorPianoKeys = '<div id="'+ ColorPianoKeys +'" class="PosAbs">';
		}
		
		if ( i==6 ) CloseDivs += '</div>';
		
		if ( i <= 6 ) { // white keys
			Menu += 
				ColorPianoKeys +
						'<a id="MenuLink'+ i +'" href="'+ MenuLinkHref +'" class="MenuLink">\
							<div class="Key" onClick="soundManager.play(\''+ MenuSound +'\');">\
								<table><tr align="right">\
									<td width="100">\
										<div class="KeyLabel"><div class="Label PosAbs">'+ MenuLinkLabel +'</div></div>\
									</td>\
									<td width="230">'
										+ KeyImage +
										'<img class="KeyImageSlide" src="../images/layout/blank.gif" />\
									</td>\
								</tr></table>\
							</div>\
						</a>'
					+ CloseDivs;
		}
		if ( i==7 || i==8 ) { // black keys
			Menu += 		
			ColorPianoKeys +
				'<a id="MenuLink'+ i +'" href="'+ MenuLinkHref +'" class="MenuLink">\
					<div class="Key" onClick="soundManager.play(\''+ MenuSound +'\');">\
						<table><tr align="left">\
							<td width="150">\
								<img class="KeyImageSlide" src="../images/layout/blank.gif" />'
								+ KeyImage +
							'</td>\
							<td width="80">\
								<div class="KeyLabel"><div class="Label PosAbs">'+ MenuLinkLabel +'</div></div>\
							</td>\
						</tr></table>\
					</div>\
				</a>'
			+ CloseDivs;
		}
	}
	
	for ( var i = 1; i <= 3; i++ ) $('#KeyPlaceHolder').append( '<div><img src="../images/layout/pianokey_black.jpg"></div>' );
	for ( var i = 1; i <= 2; i++ ) $('#KeyPlaceHolder2').append( '<div><img src="../images/layout/pianokey_black.jpg"></div>' );
	$('#Menu').html( Menu );
}

function switchLang( SetLang )
{
	if ( SetLang != HTMLFilePrefix )
	{
		Submenu.fadeOut( 200 );
	
		if ( SetLang == 'deutsch' )
		{ 
			Lang = LangGer; HTMLFilePrefix = SetLang;
			$('#LangGer img').attr('src', '../images/layout/lang_german_on.gif' );
			$('#LangEng img').attr('src', '../images/layout/lang_english_off.gif' );
		}
		if ( SetLang == 'englisch' )
		{
			Lang = LangEng; HTMLFilePrefix = SetLang;
			$('#LangEng img').attr('src', '../images/layout/lang_english_on.gif' );
			$('#LangGer img').attr('src', '../images/layout/lang_german_off.gif' );
		}
		
		if ( FirstDownloadClick ) document.FilenameForm.FilenameField.value = Lang[10];
		
		$('.MenuLink').each( function( i ) {
			$(this).find('.KeyLabel').html( '<div class="Label PosAbs">'+ Lang[ i ] +'</div>' );
		});
	
		$('#Imprint').html( Lang[ 7 ] );
		$('#Contact').html( Lang[ 8 ] );
	
		Content.fadeOut( 300, function(){
			if ( CurrMenuNr != -1 ) loadContent ( CurrMenuNr );
			Content.fadeIn( 'slow' );
		});
	}
	
	fixLayoutByBrowser();
}

function viewImage( ImgFile, ImgDesc )
{
	var CloseMsg = ( HTMLFilePrefix == 'deutsch' ) ? 'zum schliessen klicken' : 'click to close';
	var CloseMsg = ( HTMLFilePrefix == 'deutsch' ) ? 'zum schliessen klicken' : 'click to close';
	var HTML = '<table height="100%" width="100%">\
				<tr align="center"><td valign="center">\
				<div style="text-align:center;">\
					<img src="../images/'+ ImgFile +'" style="border:10px solid white; border-bottom:50px solid white;">\
					<div style="margin-top:-45px; font-size:0.9em; font-weight:bold;">'+ ImgDesc +'</div>\
					<div style="font-size:0.75em; font-weight:normal;">'+ CloseMsg +'<div>\
				</div>\
				</td></tr>\
				</table>';
	$('#PageOverlay').html( HTML );
	$('#PageOverlay').css({ top:0 });
}

function buildLangChooser()
{
	var X = '<div id="LangList">\
			<a href="#" id="LangGer"><img src="../images/layout/lang_german_on.gif"></a>\
			<a href="#" id="LangEng"><img src="../images/layout/lang_english_off.gif"></a>\
		</div>';

	$('#LangChooser').html( X );
	
	$('#LangGer img').hover( 
		function() { if ( HTMLFilePrefix != 'deutsch' ) $(this).attr('src', '../images/layout/lang_german_on.gif' );  },
		function() { if ( HTMLFilePrefix != 'deutsch' ) $(this).attr('src', '../images/layout/lang_german_off.gif' ); } 
	);
	
	$('#LangEng img').hover( 
		function() { if ( HTMLFilePrefix != 'englisch' ) $(this).attr('src', '../images/layout/lang_english_on.gif' );  },
		function() { if ( HTMLFilePrefix != 'englisch' ) $(this).attr('src', '../images/layout/lang_english_off.gif' ); } 
	);
}

function getURLParameter( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function checkBrowserName(name){  
	var agent = navigator.userAgent.toLowerCase();  
	if (agent.indexOf(name.toLowerCase())>-1) return true;  
	return false;  
} 

function start()
{
	$('#JSDisabled').hide();

	// container

	PageWrapper = $('#PageWrapper');
	Page = $('#Page');
	MenuWrapper = $('#MenuWrapper');
	Menu = $('#Menu');
	MenuHover = $('#MenuHover');
	SubmenuWrapper = $('#SubmenuWrapper');
	Submenu = $('#Submenu');
	ContentWrapper = $('#ContentWrapper');
	Content = $('#Content');
	Figure = $('#Figure');
		
	// files
	HTMLFiles = [
		'biographie.html',
		'referenzen.html',
		'bands_und_projekte.html',
		'studio.html',
		'media.html',
		'links.html',
		'termine.html',
		'impressum.html'
	];

	
	HTMLFilePrefix = 'deutsch';
	ContentHidden = false;
	ScrollbarWidth = 8;
	$('#Download').css({ opacity: 1 });
	document.FilenameForm.FilenameField.value = Lang[10];
	
	soundManagerInit(); // sound on
	Mode = 1; // default: mainmenu
	
	buildMenu();
	buildLangChooser();
	
	$('#LangGer').click( function() { switchLang( 'deutsch' ); } );
	$('#LangEng').click( function() { switchLang( 'englisch' ); } );
	
	// events

		// menuhover
		$('#MenuLink0').hover( function() { slidePianoKey( 0, true ); }, function() { slidePianoKey( 0, false ); } );
		$('#MenuLink1').hover( function() { slidePianoKey( 1, true ); }, function() { slidePianoKey( 1, false ); } );
		$('#MenuLink2').hover( function() { slidePianoKey( 2, true ); }, function() { slidePianoKey( 2, false ); } );
		$('#MenuLink3').hover( function() { slidePianoKey( 3, true ); }, function() { slidePianoKey( 3, false ); } );
		$('#MenuLink4').hover( function() { slidePianoKey( 4, true ); }, function() { slidePianoKey( 4, false ); } );
		$('#MenuLink5').hover( function() { slidePianoKey( 5, true ); }, function() { slidePianoKey( 5, false ); } );
		$('#MenuLink6').hover( function() { slidePianoKey( 6, true ); }, function() { slidePianoKey( 6, false ); } );
		$('#MenuLink7').hover( function() { slidePianoKey( 7, true ); }, function() { slidePianoKey( 7, false ); } );
		$('#MenuLink8').hover( function() { slidePianoKey( 8, true ); }, function() { slidePianoKey( 8, false ); } );
	
		// menuclick
		$('#MenuLink0').click( function() { switchMode( 2 ); loadContent( 0 ); pressPianoKey( $(this) ); } ); // bio
		$('#MenuLink1').click( function() { switchMode( 2 ); loadContent( 1 ); pressPianoKey( $(this) ); } ); // ref
		$('#MenuLink2').click( function() { switchMode( 2 ); loadContent( 2 ); pressPianoKey( $(this) ); } ); // proj
		$('#MenuLink3').click( function() { switchMode( 2 ); loadContent( 3 ); pressPianoKey( $(this) ); } ); // studio
		$('#MenuLink4').click( function() { switchMode( 2 ); loadContent( 4 ); pressPianoKey( $(this) ); } ); // media
		$('#MenuLink5').click( function() { switchMode( 2 ); loadContent( 5 ); pressPianoKey( $(this) ); } ); // links
		$('#MenuLink6').click( function() { switchMode( 2 ); loadContent( 6 ); pressPianoKey( $(this) ); } ); // termine
		$('#MenuLink7').click( function() { switchMode( 2 ); loadContent( 7 ); pressPianoKey( $(this) ); } ); // impress
		$('#MenuLink8').click( function() { pressPianoKey( $(this) ); } ); // kontakt
		
	$('#ContentEscape').click(function() {
		if ( Mode==2 ) switchMode( 1 );
	});
	
	$('#ContentEscape').hover(function() {
		$(this).css({ opacity:1 });
	}, function() {
		$(this).css({ opacity:0.3 });
	});
	
	$('#Download').toggle();
	$('#Figure').click( function() {
		$('#Download').toggle();
	});
	
	$('#SendDownloadRequest').click( function(){ 
		var Filename = document.FilenameForm.FilenameField.value;
		if ( Filename != '' ) downloadFile( Filename );
	} );
	
	$('#Download').click( function() {
		var X = document.FilenameForm.FilenameField.value;
		if ( FirstDownloadClick && X == Lang[ 10 ]) {
			document.FilenameForm.FilenameField.value = '';
			FilenameFieldCleared = true;
			FirstDownloadClick = false;
		}
	});
	
	$('#PageOverlay').click( function() {
		$('#PageOverlay').css({ top:10000 });
	});
	
	fixLayoutByBrowser();
}

function fixLayoutByBrowser()
{
	$('.Label').css({ width: 200 });

	// Fixing Layout for IE 6 Support
	if (navigator.appVersion.indexOf('MSIE 6')>-1) {
	
		$('#WhitePianoKeys .Label').css({ marginRight: 150 });
		$('#WhitePianoKeys .Key').css({ marginBottom: -7 });
		$('#MenuLink8 .Key').css({ marginTop: 24 });
		$('#KeyPlaceHolder').css({ top:103 });
		$('#KeyPlaceHolder div').css({ marginBottom: -27 });
		
		$('.MenuLink').hover( 
			function() { $(this).css({ cursor: 'hand' }) },
			function() { $(this).css({ cursor: 'pointer' }) }
		)
	}
}

function enterDownload()
{
	var FilenameFieldValue = getURLParameter( 'FilenameField' );
	if ( FilenameFieldValue != '' ) 
	{   
		document.FilenameForm.FilenameField.value = FilenameFieldValue
		$('#Download').toggle();
		alert( 'Please press OK to download Files. /\nBitte dr'+ unescape('%FC') +'cken Sie OK um Dateien runterzuladen.' );
	}
}
