// JavaScript Document
$(function(){
/* 
 * Changes language between English and German
 * The following action assumes that all english files are in the form name.html and german language
 * filea are in the form name-de.html
 * The function redirects to the alternative page. This is OK, but not very elegant since each page already has a 'language' 
 * dreamweaver parameter already which we could use. 
 * Also, if we introduce PHP files we will need to change this to allow for different suffices
*/
$('.togglelanguage').click(
		function(){
			
			var spath = window.location.href;
			var german; // zero or greater if German language page with a -de suffix
			if (spath.indexOf('html')<0) { // there is not path file indicated so assume index.html in english
				spath = spath+'index.html'; 
				german = -1; } 
			else {
			 	german = spath.indexOf('-de.html'); 
			}
		
			if ( german!=-1)  { // its GERMAN so get rid of teh -de suffix
					spath =  spath.replace('-de.html','.html');
					
			} else 
			{                  // its ENGLISH so add the -de suffix
					spath = spath.replace('.html','-de.html');
					
			};
			
			window.location.href = spath;  // redirect the page to the new location
			return false;
									
		});
/* 
 * Pops up a window when the class name area is clicked 
 */
$('.popup').click(function(){
		window.open(this.href, 
					'_blank',
					'scrollbars=yes,resizable=yes,width=900,height=700');
					return false;				   
		});
$('.popupsmall').click(function(){
		window.open(this.href, 
					'_blank',
					'scrollbars=yes,resizable=yes,width=450,height=350');
					return false;				   
		});
/*
 * sets the background of the top right image
 * we could test the pngsupported variable (set it the dw template) for ie6 and before and display
 * either a gif or nothing
*/
var pagename = $('body').attr('id');
$('#topright').css('background-image','url(images/website/topright/'+pagename+'.png)');


$('a>img').parent().addClass('imglink');
$('a>img').hover(
		function(){
			$(this).fadeTo('slow', .6);
		}, 
		function(){
			$(this).fadeTo('slow', 1);
		});


$('.english #nav12').append("<div class='new'>NEW<br/>Summer School<br/>2009 Photos</div>");
$('.german #nav12').append("<div class='new'>NEUE<br/>SommerSchule<br/>2009 bilder</div>");

})