jQuery( 'document' ).ready(function() { 
	jQuery( '.flash' ).each(function() {
		jQuery(this).flash(
			null,
			{ expressInstall: true },
			function(htmlOptions) {
				htmlOptions.src = '/' + jQuery(this).attr( 'id' ) + '.swf';
				if( jQuery(this).attr( 'id' ) ) {
					var params = jQuery(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]
						}
					}
					jQuery(this).attr( 'id', params[0] );
				}
				this.innerHTML = '';
				jQuery(this).addClass( 'flash-replaced' ).prepend( jQuery.fn.flash.transform(htmlOptions) );
			}
		);
	});
	jQuery( '#mainmenu' ).superfish({dropShadow: false});
	
	jQuery( '.item144' ).find( 'a' ).addClass( 'iframe' ).addClass( 'lightbox' ); // for joomla1.5 menu generation *sigh*
	
	jQuery( '.nlightbox' ).fancybox({
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'hideOnContentClick': true,
		'frameWidth': 500,
		'frameHeight': 220,
		'overlayOpacity': 0.7,
		'overlayShadow': true
	});

	jQuery( '.lightbox' ).fancybox({
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'hideOnContentClick': true,
		'frameWidth': 850,
		'frameHeight': 500,
		'overlayOpacity': 0.7,
		'overlayShadow': true
	});

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

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

