(function($) {
	$(document).ready(function() {
		if ($.browser.msie && $.browser.version < 9)
			$('body').addClass(($.browser.version < 7) ? 'ie6' : 'ieLess9');

		$('#login h3').lrworld_LayerToggler({
			'toggleElement': $('#loginFormWrapper'),
			'toggleClassElement': $('#login')
		});
		$('#languages h3').lrworld_LayerToggler({
			'toggleElement': $('#languages ul'),
			'toggleClassElement': $('#languages')
		});
		$('#teaser').lrworld_Slideshow();

		$('.infoBox').lrworld_LayerToggler({
			'toggleElementChildrenSelector': '.infoText',
			'event': 'hover'
		});

		$('.elementSlideToggle').lrworld_ElementSlideToggle();

		if (jQuery('.milestone').length > 1)
		{
			jQuery('.milestone').lrworld_Milestones();
		}

		// Suchfeld
		$('#search .searchfield').each(function() {
			var origValue = null;
			$(this)
				.focus(function() {
					if (origValue === null)
						origValue = $(this).val();
					if ($(this).val() === origValue)
						$(this).val('');
				})
				.blur(function() {
					if ($(this).val().length === 0)
						$(this).val(origValue);
				});
		});

		// Tabs in content
		$('ul.tabs li h3').click(function(){
			var liEl=$(this).parent('li');
			if ($(liEl).hasClass('active') == false)
			{
				$(liEl).parent('ul').find('li').removeClass('active');
				$(liEl).addClass('active')
			}
		});

		// MyLR Laenderauswahl
		$('#changeCountry select').change(function(e) {
			window.location.href = window.location.protocol +'//' + window.location.host + '/' + $(e.target).val();
		});

		// Lightbox links
		$('a.lightbox').lrworld_OpenLightbox();
		$('a[href^="fileadmin/"]')
			.filter(function() { return $(this).attr('href').match(/\.(gif|jpe?g|png|swf|flv)$/i); })
			.lrworld_OpenLightbox();

		// Bookmarking
		if (window.opera)
		{
			if ($('a#favorite').attr('rel') != '')
			{
				// don't overwrite the rel attrib if already set
				$('a#favorite').attr('rel', 'sidebar');
			}
		}

		$('a#favorite').click(function(event) {
			event.preventDefault();
			var url = document.URL;
			var title = document.title;

			if (window.sidebar)
			{ // Mozilla Firefox Bookmark
				window.sidebar.addPanel(title, url,"");
			}
			else if (window.external)
			{ // IE Favorite
				window.external.AddFavorite( url, title);
			}
			else if (window.opera)
			{ // Opera 7+
				return false; // do nothing - the rel="sidebar" should do the trick
			}
			else
			{ // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
				alert('Unfortunately, this browser does not support the requested action,'
					+ ' please bookmark this page manually.');
			}
		});
	});
})(jQuery);
