/**
 * @author Michael Stuhr
 *         edit by Niels Weber 2009-11
 */
var $j = jQuery.noConflict();
$j(document).ready(function()
{
	function trace(msg, type) 
	{
		if (console != undefined) 
		{
			(type == undefined) ? console.log(msg) : console[type](msg);
		}
	};
	/*
	 * 
	 */
	function insertPoemsTrick()
	{
		if ($j('#Poem').length > 0 )
		{
			$j('#Poem').remove();
			
			// NW EDIT 2009-09-15
			//$j('#Poems .author, #Poems .replay').remove();
			$j('#Poems .replay').remove();
		}
		var poem = $j('#Playlist .current .poem').html();
		$j('#SWF').before('<div id="Poem"><div class="current"></div></div>');
		$j('#Poem .current').html(poem);
		
		// NW EDIT 2009-09-15
		//var html = '<p class="author">' + $j('#Poem .author').html() + '</p>';
		$j('#Poems .std')
		//.after('<p class="replay png32">Video nochmal abspielen</p>')
		.after(html);
		fixIePng();
	}
	/*
	 * 
	 */	
	function redesignVideobox ()
	{
		$j('body').data('activePlayer', 'SWF');
		$j('#Playlist').css(
		{
			overflowY : 'hidden'
		});
		//
		$j('#Playlist .video')
		.css('opacity', 0.5)
		.hover(
			function ()
			{
				$j(this).fadeTo(350, 1);
			},
			function ()
			{
				if (!$j(this).hasClass('current'))
				{
					$j(this).fadeTo(150, 0.5);
				}
			}
		);
		// reset current:
		$j('#Playlist .video.current').css('opacity', 1);
		// setting up playlist
		var previewItems = 3;
		if ($j.browser.msie && $j.browser.version == 6)
			previewItems = 2;
		$j("#Playlist").scrollable(
		{
			items:'.clips',
			size:previewItems,
			vertical:true,
			next:'#Carousel .next',
			prev:'#Carousel .prev',
			activeClass:'current',
			disabledClass:'disabled',
			hoverClass:'hovered'
		});
		// just for debugging:
		/*
		$j.each ($j("#Playlist .video a"), function (i, val)
		{
			$j(this).append('<em class="nr">' + (i+1) + '</em>');
		});
		//*/
		// --- setting up flowplayer:
		var starturl = $j('#Videobox #Playlist .clips a:first').attr('href');
		var flowOptions = {
			canvas: {
				backgroundColor: '#000E25',
				backgroundGradient: 'none'
			},
			clip:{
				accelerated:true,
				//scaling: 'scale',
				fadeInSpeed:3000,
				fadeOutSpeed:2000,
				url: starturl,
				//baseUrl:'http://localhost/Kunden/LHF/lotseninsel.de/video/inselmomente',
		        autoPlay: false, 
		        autoBuffering: true,
				onStart: function (foo)
				{
					if ($j.browser.msie && $j.browser.version == 6)
					{
						$f($j('body').data('activePlayer')).getControls().enable({autohide: 'always'})
						$f($j('body').data('activePlayer')).getControls().widgets({
							time:false,
							scrubber:false
						});
					}
					$j('#VSlider').slider('option', 'value', $f($j('body').data('activePlayer')).getVolume());
					////
					insertPoemsTrick();
				},
				onPause:function ()
				{
					$j('#Playtoggle').removeClass('pause');	
				},
				onResume :function ()
				{
					insertPoemsTrick();
					$j('#Poems .std').fadeOut(1500);
					$j('#Playtoggle').addClass('pause');
				},
				onLastSecond:function ()
				{
					$j('#Playtoggle').removeClass('pause');
				},
				onFinish:function ()
				{
					if ( $j('#SWF').hasClass('fullscreen') )
					{
						$j('#Fullscreentoggle').trigger('click');
					}
					if ($j.browser.msie && $j.browser.version == 6 && $f($j('body').data('activePlayer')).isFullscreen())
					{
						$f($j('body').data('activePlayer')).toggleFullscreen();
					}
					// hide replay item
					this.getPlugin("play").hide();
					//
					
					$j('#Poems .replay').fadeIn(1500);
					
					// NW EDIT 2009-09-15
					//$j('#Poems .author').fadeIn(1500);
					$j('#Poem .author').fadeIn(1500);
					
					$j('#Poem').fadeIn(1500);
					
					$j('#Poems .replay').bind('click', function ()
					{
						$f($j('body').data('activePlayer')).play();
						$j('#Playtoggle').addClass('pause');
						$j('#Poems .replay, #Poems .author, #Poem').fadeOut(700);
					});
				}
			},
			play: { 
	            label: '', // Abspielen
	            replayLabel: '' // Nochmals 
	        },
			plugins:{
				controls:null
			},
			onMouseOver: function() 
			{
		        fadePlayerControlsIn ();
		    },
		    onMouseOut: function() 
			{
		        fadePlayerControlsOut ();
		    }
		};
		// set videocontroller
		//*
		if ($j.browser.msie && $j.browser.version == 6)
		{	
			flowOptions.plugins.controls = {
				all:false,
				play:true,
				volume:true,
				fullscreen:true,
				autoHide:'always',
				hideDelay:1000,
				durationColor: '#ffffff',
				buttonColor: '#373b48',
				buttonOverColor: '#728B94',
				timeColor: '#01DAFF',
				borderRadius: '0px',
				progressColor: '#112233',
				backgroundGradient: 'none',
				backgroundColor: '#000E25',
				bufferColor: '#445566',
				volumeSliderGradient: 'none',
				progressGradient: 'medium',
				tooltipColor: '#5F747C',
				sliderGradient: 'none',
				tooltipTextColor: '#ffffff',
				volumeSliderColor: '#2A2D3E',
				timeBgColor: '#555555',
				bufferGradient: 'none',
				sliderColor: '#000E25',
				height: 19,
				opacity: 1
			}
		}
		//
		$f('SWF', {
			debug: false,
			src: 'fileadmin/LOTSENINSEL/scripts/swf/flowplayer-3.1.0.swf',
			wmode: 'opaque'
		}, flowOptions);
		//
		$j('#Playlist .clips a').bind('click', function ()
		{
			if (!$j(this).parent().hasClass('current'))
			{
				$j('#Poems .replay, #Poems .author, #Poem').fadeOut(500, function (){$j(this).remove()});
				//
				$j(this).parent().parent().find('.current').toggleClass('current');
				$j(this).parent().toggleClass('current');
				$j(this).parent().data('clicked', true);
				$j('body').data('activePlayer', 'SWF');
				$f($j('body').data('activePlayer')).play($j(this).attr('href'));
				//startBuffering
				$j('#Playlist .video:not(.current)').css('opacity', 0.7);
				$j('#Playtoggle').addClass('pause');
			}
			//
			return false;
		});
		/*
		 * Implement Player Controlfunctionality
		 */
		var html = ' \
		<div id="PlayerControls"> \
			<div id="Playtoggle" class="playerctrl png32"></div> \
			<div id="Volumetoggle" class="playerctrl png32"> \
			</div> \
			<div id="VSlider" class="playerctrl png32"></div> \
			<div id="Fullscreentoggle" class="playerctrl png32"></div> \
		</div>';
		// ugly hack for ie6
		if ($j.browser.msie && $j.browser.version == 6) 
		{
			
		}
		else
		{
			$j('#SWF').append(html);
		}
		
		addVSlider();
		// add player controls functionality
		addPlaytoggle();
		$j('#Fullscreentoggle').bind('click', function ()
		{
			if (!$j('#SWF').hasClass('fullscreen')) 
			{
				$j('#SWF')
				.expose({
					zIndex:60,
					color: '#000E25',
					opacity: .90,
					onClose:function ()
					{
						$j('#SWF').css({
							height: 248,
							left: 140,
							width: 440,
						}).removeClass('fullscreen');	
					}
				})
				.css({
					height: 451,
					left: -100,
					width: 800
				})
				.addClass('fullscreen');
			}
			else
			{
				$j.expose.close();
				$j('#SWF').css({
					height: 248,
					left: 140,
					width: 440
				}).removeClass('fullscreen');
			}
		});
		$j('#PlayerControls').css('opacity', .09);
	}
	//
	function addPlaytoggle()
	{
		$j('#Playtoggle').bind('click', function()
		{
			if ($f($j('body').data('activePlayer')).isPaused())
			{
				$j(this).addClass('pause');
				$f($j('body').data('activePlayer')).play();
			}
			else
			{
				$j(this).removeClass('pause');
				$f($j('body').data('activePlayer')).pause();
			}			
		});
	}
	//
	function addVSlider ()
	{
		$j('#Volumetoggle').bind('click', function ()
		{
			$j('#VSlider').slideToggle(90);
		});
		
		var vol = $f($j('body').data('activePlayer')).getVolume() != undefined ? $f($j('body').data('activePlayer')).getVolume() : 0;
		$j('#VSlider').slider(
		{
			orientation: "vertical",
			range: "min",
			min: 0,
			max: 90,
			value: vol,
			slide: function(event, ui) 
			{
				$f($j('body').data('activePlayer')) != undefined ? $f($j('body').data('activePlayer')).setVolume(ui.value) : null
			}
		});
		// initially hide slider
		$j('#VSlider').toggle();
	}
	//
	function fadePlayerControlsIn ()
	{
		$j('#PlayerControls').fadeTo (350, 1);
	}
	function fadePlayerControlsOut()
	{
		$j('#PlayerControls').fadeTo (150, .09);
	}
	/*
	 * fix ie6 png-transperancy "bug"
	 */
	function fixIePng()	{ $j('.png32').ifixpng(); }
	/*
	 * give the search box some usability:
	 */
	function addInputFunctions (str)
	{
		var fields = $j(str);
		$j.each (fields, function (i, val)
		{
			$j(this).data('oStr', $j(this).val())
		})
		$j(fields)
		.bind('click, focus', function()
		{
			var v = $j(this).val();
			if (v == $j(this).data('oStr'))
			{
				$j(this).val('');
				$j(this).removeClass('prefilled')
			}
		})
		.bind('blur', function ()
		{
			var v = $j(this).attr('value');
			if (v == '')
			{
				$j(this).val($j(this).data('oStr'));
				$j(this).addClass('prefilled')
			}
		});
	}
	
	/*
	 * 
	 */
	updateTSlider = function(id)
	{
		if (!$f($j('body').data('activePlayer')).isPaused())
		{
			var t = $f($j('body').data('activePlayer')).getTime();
			$j('#TSlider').slider('option', 'value', t);
			$j('#VTime .current').html(convertTime(t))
		}	
	}
	function beautifyTime (t)
	{
		return t < 10 ? '0' + t : t;
	}
	function strPad( str, places, pad, side )
	{
		while ( str.length < places )
		{
			if ( side == "left" ) str = pad + str;
			else str = str + pad;
		}
		return str;
	}
	function convertTime(t)
	{
		
		var mm = Math.floor( t / 60 );
		var ss = Math.floor( strPad( t % 60, 2, 0, "left" ) );
		return beautifyTime(mm) + ':' + beautifyTime(ss);
	}
	function insertVideoBox()
	{
		($j('#SWF').length > 0) ? $j('#SWF').remove() : null;
		$j('#Map').append('<div id="SWF"></div>');
		//
		var flowOptions = {
			canvas: {
				backgroundColor: '#000E25',
				backgroundGradient: 'none'
			},
			clip:{
				accelerated:true,
				scaling: 'scale',
				url:'',
				fadeInSpeed:4000,
				fadeOutSpeed:4000,
		        autoPlay: true, 
		        autoBuffering: true,
				onStart: function ()
				{
					updateSlider_ID = setInterval("updateTSlider('##')", 20, '###');
					var d = $f($j('body').data('activePlayer')).getClip().fullDuration;
					$j('#TSlider').slider('option', 'max', d);
					$j('#VTime .total').html(convertTime(d));
					addVSlider ();
					if ($j.browser.msie && $j.browser.version == 6) 
					{
						$f($j('body').data('activePlayer')).getControls().enable({
							autohide: 'always'
						})
						$f($j('body').data('activePlayer')).getControls().widgets({
							
						});
					}
					$j('#VSlider').slider('option', 'value', $f($j('body').data('activePlayer')).getVolume());
				},
				onPause:function ()
				{
					$j('#Playtoggle').removeClass('pause');	
				},
				onResume :function ()
				{
					$j('#Playtoggle').addClass('pause');
				},
				onLastSecond:function ()
				{
					$j('#Playtoggle').removeClass('pause');
				},
				onFinish:function ()
				{
					
				}
			},
			play: { 
	            label: 'Abspielen', 
	            replayLabel: 'Nochmals ?' 
	        }, 
			plugins:{
				controls:null
			},
			onMouseOver: function() 
			{
		        fadePlayerControlsIn ();
		    },
		    onMouseOut: function() 
			{
		        fadePlayerControlsOut ();
		    }
		};
		// set videocontroller
		if ($j.browser.msie && $j.browser.version == 6)
		{	
			flowOptions.plugins.controls = {
				all:false,
				play:true,
				volume:true,
				fullscreen:true,
				mute:true,
				scrubber:true,
				time:true,
				autoHide:'always',
				hideDelay:1000,
				durationColor: '#ffffff',
				buttonColor: '#373b48',
				buttonOverColor: '#728B94',
				timeColor: '#01DAFF',
				borderRadius: '0px',
				progressColor: '#112233',
				backgroundGradient: 'none',
				backgroundColor: '#000E25',
				bufferColor: '#445566',
				volumeSliderGradient: 'none',
				progressGradient: 'medium',
				tooltipColor: '#5F747C',
				sliderGradient: 'none',
				tooltipTextColor: '#ffffff',
				volumeSliderColor: '#2A2D3E',
				timeBgColor: '#555555',
				bufferGradient: 'none',
				sliderColor: '#000E25'
			}
		}
		else{
			$j('#SWF')
			.expose({
				zIndex:6,
				color: '#000E25',
				opacity: .90,
				onClose:function ()
				{
					
					clearInterval (updateSlider_ID);
					$j('#Close').fadeOut(550);
					$j('#SWF').fadeOut(550, function ()
					{
						$j('#SWF').remove();
						$j('#Close').remove();
					});
				}
			});
		}
		$f('SWF', {
			debug: false,
			src: 'fileadmin/LOTSENINSEL/scripts/swf/flowplayer-3.1.0.swf',
			wmode: 'opaque'
		}, flowOptions);
		//
	}
	//
	function insertPlayerControls (rel)
	{
		var html = ' \
		<div id="PlayerControls"> \
			<div id="Playtoggle" class="playerctrl png32"></div> \
			<div id="TSlider" class="playerctrl png32"></div> \
			<div id="Volumetoggle" class="playerctrl png32"></div> \
			<div id="VSlider"></div> \
			<div id="VTime"> \
				<span class="current"></span> \
				<span class="total"></span> \
			</div> \
		</div>';
		if ($j.browser.msie && $j.browser.version == 6)
		{
			
		}
		else
		{
			var id = '';
			id = $j(rel).hasClass('teaser') || $j(rel).hasClass('videolink') ?'#TSWF' : '#SWF';
			$j(id).append(html);
		}
		//
		$j(id + ' #TSlider').slider(
		{
			range: "min",
			min: 0,
			max: 90,
			value: 0,
			change: function()
			{
				// do not use this!
			},
			slide: function(event, ui) 
			{
				var t = ui.value;
				$j('#VTime .current').html(convertTime(t))
			},
			start: function(event, ui)
			{
				//updateSlider_ID = setInterval("updateTSlider()", 20);
				clearInterval (updateSlider_ID);
				$j(id +' #TSlider').data('waspausedbefore', $f($j('body').data('activePlayer')).isPaused());
				$f($j('body').data('activePlayer')).pause();
			},
			stop: function (event, ui)
			{
				$f($j('body').data('activePlayer')).seek(ui.value)
				if (!$j(id +' #TSlider').data('waspausedbefore'))
					$f($j('body').data('activePlayer')).play();
				updateSlider_ID = setInterval("updateTSlider()", 20);
			}
		});
		//
		addClose();
		$j('#PlayerControls').css('opacity', .09);
	}
	//
	function addClose()
	{
		var id = ($j('#TSWF').length > 0) ? '#TSWF' : '#Map';
		var vid = ($j('#TSWF').length > 0) ? '#TSWF' : '#SWF';
		$j(id).prepend('<div id="Close" class="png32"><div class="button png32"></div></div>');
		fixIePng();
		$j('#Close').bind('click', function ()
		{
			clearInterval (updateSlider_ID);
			if ($j.browser.msie && $j.browser.version == 6)
			{
				$j(this).remove();
				$j(vid).hide();
				return false;
			}
			else
			{
				$j('#Close').fadeOut(350, function ()
				{
					$j(this).remove();
				});
				$j.expose.close();
				$j('body').removeClass('noscroll');
			}
		});
	}
	//
	function addMapVideo()
	{
		$j('body').data('activePlayer', 'SWF');
		$j('#Map li a').bind('click', function ()
		{
			$j(this).parent().parent().find('li.current').removeClass('current');
			$j(this).parent().addClass('current');
			insertVideoBox(this);
			var href = $j(this).attr('href');
			if (href == '#')
			{
				var imagelist = new Array();
				$j.each($j(this).parent().find('ul.imagelist li img'), function (i, val)
				{
					imagelist.push({url:$j(this).attr('src'), duration:5});
				});
				updateSlider_ID = undefined;
				addClose();
				$j('#SWF').addClass('images');
				$f($j('body').data('activePlayer')).play(imagelist)
			}
			else
			{
				$j('#SWF').removeClass('images');
				$f($j('body').data('activePlayer')).play(href);
				insertPlayerControls(this);
				addPlaytoggle();
				$j('#Playtoggle').addClass('pause');
			}
			$j('#SWF').prepend('<div id="Headline" class="png32">' + $j(this).html() + '</div>');
			if ($j('#Map li.current').find('.meta').length > 0)
			{
				$j('#SWF').append ('<div class="meta">' + $j('#Map li.current').find('.meta').html() + '</div>')
			}
			if ($j.browser.msie && $j.browser.version == 6)
			{
				$j('#Headline').html($j('#Headline').text());
			}
			fixIePng();
			//
			return false;
		});
	}
	//
	function fixImageDescriptions()
	{
		$j('.image.description').css('width', $j('.image.description img').width());
	}
	//
	function addTeaserVideo (rel)
	{
		$j('body').data('activePlayer', 'TSWF');
		var PC = $j('#PlayerControls').clone(true);
		$j('#SWF').data('controls', PC);
		$j('#PlayerControls').remove();
		//
		$j('#Body').append('<div id="TSWF"></div>');
		//
		var flowOptions = {
			canvas: {
				backgroundColor: '#000E25',
				backgroundGradient: 'none'
			},
			clip:{
				accelerated:true,
				scaling: 'scale',
				url:'',
				fadeInSpeed:4000,
				fadeOutSpeed:4000,
		        autoPlay: true, 
		        autoBuffering: true,
				onStart: function ()
				{
					updateSlider_ID = setInterval("updateTSlider()", 20);
					var d = $f($j('body').data('activePlayer')).getClip().fullDuration;
					$j('#TSlider').slider('option', 'max', d);
					$j('#VTime .total').html(convertTime(d));
					addVSlider ();
					if ($j.browser.msie && $j.browser.version == 6) 
					{
						$f($j('body').data('activePlayer')).getControls().enable({
							autohide: 'always'
						})
						$f($j('body').data('activePlayer')).getControls().widgets({});
					}
					$j('#VSlider').slider('option', 'value', $f($j('body').data('activePlayer')).getVolume());
				},
				onPause:function ()
				{
					$j('#Playtoggle').removeClass('pause');	
				},
				onResume :function ()
				{
					$j('#Playtoggle').addClass('pause');
				},
				onLastSecond:function ()
				{
					$j('#Playtoggle').removeClass('pause');
				},
				onFinish:function ()
				{
					
				}
			},
			play: { 
	            label: 'Abspielen', 
	            replayLabel: 'Nochmals ?' 
	        },
			plugins:{
				controls:null
			},
			onMouseOver: function() 
			{
		        fadePlayerControlsIn ();
		    },
		    onMouseOut: function() 
			{
		        fadePlayerControlsOut ();
		    }
		};
		// set videocontroller
		if ($j.browser.msie && $j.browser.version == 6)
		{	
			flowOptions.plugins.controls = {
				all:false,
				play:true,
				volume:true,
				fullscreen:true,
				mute:true,
				scrubber:true,
				time:true,
				autoHide:'always',
				hideDelay:1000,
				durationColor: '#ffffff',
				buttonColor: '#373b48',
				buttonOverColor: '#728B94',
				timeColor: '#01DAFF',
				borderRadius: '0px',
				progressColor: '#112233',
				backgroundGradient: 'none',
				backgroundColor: '#000E25',
				bufferColor: '#445566',
				volumeSliderGradient: 'none',
				progressGradient: 'medium',
				tooltipColor: '#5F747C',
				sliderGradient: 'none',
				tooltipTextColor: '#ffffff',
				volumeSliderColor: '#2A2D3E',
				timeBgColor: '#555555',
				bufferGradient: 'none',
				sliderColor: '#000E25'
			}
		}
		else{
			$j('#TSWF')
			.expose({
				zIndex:6,
				color: '#000E25',
				opacity: .90,
				onClose:function ()
				{
					clearInterval (updateSlider_ID);
					$j('#Close').fadeOut(450);
					$j('#TSWF').fadeOut(550, function ()
					{
						if ($j('#SWF').length > 0)
						{
							$j('body').data('activePlayer', 'SWF');
							$j('#SWF').append($j('#SWF').data('controls'));
						}
						else
						{
							$j.removeData($j('body'), 'activePlayer');
						}
						$j('#Close').remove();
						$j('#TSWF').remove();
						$j('body').removeClass('noscroll');
					});
				}
			});
		}
		//
		$f('TSWF', {
			debug: false,
			src: 'fileadmin/LOTSENINSEL/scripts/swf/flowplayer-3.1.0.swf',
			wmode: 'opaque'
		}, flowOptions);
		//
	}
	//
	function addVideolinkCss()
	{
		$j.each($j('.videolink'), function ()
		{
			var thumb = $j(this).find('img.preview');
			thumb.before('<div class="videoIcon png32"></div>');
			var icon = $j(this).find('.videoIcon');
			
			icon.css({
				width:thumb.width(),
				height:thumb.height(),
				position:'absolute',
				left:thumb.position().x,
				top:thumb.position().y
			});
			icon.fadeTo(0, 0.5);
			icon
			.hover(
			function()
			{
				$j(this).fadeTo(350, 1);
			},
			function()
			{
				$j(this).fadeTo(250, 0.5);
			});
			fixIePng();
			$j(this).bind('click', function ()
			{
				href = $j(this).attr('href');
				$j('#SWF').length > 0 ? $f('SWF').pause() : null;
				addTeaserVideo(this);
				$f('TSWF').play(href);
				if (!$j(this).parent().parent().hasClass('single'))
				{
					$j('#TSWF').prepend('<div id="Headline" class="png32">' + $j(this).parent().parent().find('h3').html() + '</div>');
				}
				else
				{
					$j('#TSWF').prepend('<div id="Headline" class="png32">' + $j(this).parent().parent().find('h4').html() + '</div>');
				}
				var desc = $j(this).parent().parent().find('.description').html();
				if (desc != null) 
				{
					$j('#TSWF').append('<div class="description">' + desc + '</div>');
					$j('#TSWF .description .videolink').remove();
				}
				insertPlayerControls(this);
				addPlaytoggle();
				$j('#Playtoggle').addClass('pause');
				//
				var viewport = {w:$j(window).width(), h:$j(window).height(), sl:$j(document).scrollLeft(), st:$j(document).scrollTop()};
				var top = Math.round(viewport.h / 2 + viewport.st - $j('#Header').height() - $j('#TSWF').height() / 2)
				$j('#TSWF').css({
					 top:top
				});
				$j('body').addClass('noscroll');
				
				return false;
			});
		});
		
	}
	//
	function redesignPoemBox()
	{
		var poems = $j('#Playlist ul li a');
		poems.bind('click', function ()
		{
			var html = '<div class="inner">' + $j(this).parent().find('.poem.hidden').html() + '</div>';
			$j('#POEM').html(html);
			$j('#POEM .inner')
				.hide()
				.fadeIn(350);
			var previewItems =  ($j.browser.msie && $j.browser.version == 6) ? 2 : 3;
			$j("#Playlist").scrollable(
			{
				items:'.clips',
				size:previewItems,
				vertical:true,
				next:'#Carousel .next',
				prev:'#Carousel .prev',
				activeClass:'current',
				disabledClass:'disabled',
				hoverClass:'hovered'
			});
			return false;
		});
		$j('#Playlist ul li:first')
			.addClass('current')
			.find('a').trigger('click');
	}
	//
	function init()
	{
		if ($j('#SWF').length != 0) 
		{
			redesignVideobox();
		}
		
		if ($j('#Map').length == 1)
			{
			addMapVideo();
		}
		
		if ($j('#POEM').length != 0)
		{
			redesignPoemBox();
		}
		
		//addTeaserboxFunctionality();
		//
		addVideolinkCss();
		//
		if ($j('.image.description').length > 0)
		{
			fixImageDescriptions();	
		}
		addInputFunctions('#Search, input:text, textarea');
		fixIePng();
	}
	init();

});


