$(document).ready(function()
{

	/**
	 * Internet Explorer 6 warning
	 */

	if($.browser.msie && $.browser.version.substring(0, 1) == '6') {
		$(document.body).append('<div id="IE6Warning"><p>You are using a not supported browser version (Microsoft Internet Explorer 6). Please update to a current version.</p></div>');
		$('object').css('visibility', 'hidden');
	}

	$(window).bind('scroll resize', function()
	{
		if($('#IE6Warning').length) {
			$(document.body).css('padding-bottom', $('#IE6Warning').outerHeight() + 15 + 'px');
			$('#IE6Warning').css('top', ($(window).scrollTop() + $(window).height() - $('#IE6Warning').outerHeight()) + 'px');
		}
	});

	/**
	 * Navigation
	 */

	$('#Navigation li').bind('mouseenter mouseleave', function()
	{
	  $(this).children('ul').toggleClass('Active');
	});

	/**
	 * Language switch
	 */

	$('#switchLanguage, #Language').bind('mouseenter mouseleave', function()
	{
		if($('#Language').css('display') == 'none') {
		  $('#Language').css('display', 'block');
		}
		else {
		  $('#Language').css('display', 'none');
		}
	});

	$('#switchLanguage').bind('click', function()
	{
		return false;
	});

	/**
	 * Press releases
	 */

	$('div.PressReleases ul li a').click(function() {

		var href = $(this).attr('href');
		var id = href.substring(href.indexOf('#') + 1);

		$('div.PressReleases ul li').removeClass('Active');
		$(this).parent().addClass('Active');

		$('div.PressReleases div.Press').removeClass('Active');
		$('#' + id).addClass('Active');

		return false;

	});

	/**
	 * News
	 */

	$('div.Events ul li a').click(function() {

		var href = $(this).attr('href');
		var id = href.substring(href.indexOf('#') + 1);

		$('div.Events ul li').removeClass('Active');
		$(this).parent().addClass('Active');

		$('div.Events div.News').removeClass('Active');
		$('#' + id).addClass('Active');

		return false;

	});

	/**
	 * Search form
	 */

	sLang = 'de';
	// On focus
	$('#Search input.Text').bind('focusin', function()
	{
		// German
		if($(this).attr('value') == 'suche') {
      $(this).attr('value', '');
		}
		// English
		else if($(this).attr('value') == 'search') {
			sLang = 'en';
      $(this).attr('value', '');
		}
	// On blur
	}).bind('focusout', function()
	{
		if($(this).attr('value') == '') {
		  // German
			if(sLang == 'de') {
	    	$(this).attr('value', 'suche');
			}
			// English
			else {
	    	$(this).attr('value', 'search');
			}
		}
	});

	/**
	 * Lightbox trigger
	 */

	$('.Lightbox').attr('rel', 'lightbox[1]');

	/**
	 * Lightbox series
	 */

	$('div.PictureSeries').each(function(x)
	{
		//firstPic = null;
	  $(this).children('p').children('img').each(function(y)
		{
			if(y == 0) {
				firstPic = $(this).attr('src');
				if($(this).attr('title')) {
					firstPic2 = $(this).attr('title');
				} else {
					firstPic2 = '';
				}
			}
			$(this).parent().css('display', 'none');
			$(this).wrap('<a href="' + $(this).attr('src') + '" title="' + $(this).attr('title') + '" rel="lightbox[series' + x + ']"></a>');
		});
		$(this).children('img').wrap('<a href="' + firstPic + '" title="' + firstPic2 + '" rel="lightbox[series' + x + ']"></a>');
	});

    /**
     * Video player
     */

    /*var VideoPlayer = new MediaElementPlayer('#VideoPlayer', {});
    VideoPlayer.changeSkin('mejs-wmp');*/


	
	//var browserWidth = $(window).width();
	var browserWidth = screen.width ;
	
	if(browserWidth <481  || $('#video_high').attr('src')=='') { 
		$('#video_low').show();
		$('#video_high').hide();
		$('#video_low').mediaelementplayer();
		
		}
	else  { 
		$('#video_high').show();
		$('#video_low').hide();
		$('#video_high').mediaelementplayer(); 
		}
	

});
