$( 'document' ).ready(function() { 
	$( '.flash' ).each(function() {
		$(this).flash(
			null,
			{ expressInstall: true },
			function(htmlOptions) {
				htmlOptions.src = '/' + $(this).attr( 'id' ) + '.swf';
				if( $(this).attr( 'id' ) ) {
					var params = $(this).attr( 'id' ).split( ':' );
					htmlOptions.width = params[1];
					htmlOptions.height = params[2];
					htmlOptions.wmode = 'transparent';
					htmlOptions.src = '/' + params[0] + '.swf';
					if( typeof( params[3] ) != 'undefined' ) {
						htmlOptions.flashvars = {
							xmlUrl: 'http://' + params[3],
							xml: 'http://' + params[3]
						}
					}
					$(this).attr( 'id', params[0] );
				}
				this.innerHTML = '';
				$(this).addClass( 'flash-replaced' ).prepend( $.fn.flash.transform(htmlOptions) );
			}
		);
	});
	$( '#mainmenu' ).superfish({dropShadow: false});
	
	$( '.item144' ).find( 'a' ).addClass( 'iframe' ).addClass( 'lightbox' ); // for joomla1.5 menu generation *sigh*
	
	$( '.lightbox' ).fancybox({
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'hideOnContentClick': true,
		'frameWidth': 850,
		'frameHeight': 500,
		'overlayOpacity': 0.7,
		'overlayShadow': true
	});

	$( '#langFlags li' ).each( function() {
		$( this ).find( 'a' ).bind( 'click', function() {
			var lang = $( this ).attr( 'href' );
			$.cookie( 'locale', lang.replace( '#', '' ) );
			window.location.href = window.location.href;
			return false;
		});
	});
	$( '#lang' ).bind( 'change', function() {
		$.cookie( 'locale', $( '#lang' ).val() );
		window.location.href = window.location.href;
	});
	//if( $.cookie( 'locale' ) != null )
	//	$( '#lang' ).val( $.cookie( 'locale' ) );

	$( '.slideshow' ).ready(function() {
		$( '.slideshow' ).cycle( 'turnDown' );
	});
	
	$( document ).pngFix();
});
