// By Chris Coyier & tweaked by Mathias Bynens
$(function() {

        // Find all YouTube videos
        var $allVideos = $("iframe[src^='http://www.youtube.com']"),

            // The element that is fluid width
            $fluidEl = $(".contentBody_article");

        // Figure out and save aspect ratio for each video
        $allVideos.each(function() {

                $(this)
                        .data('aspectRatio', this.height / this.width)

                        // and remove the hard coded width/height
                        .removeAttr('height')
                        .removeAttr('width');

        });

        // When the window is resized
        // (You'll probably want to debounce this)
        $(window).resize(function() {

                var newWidth = $fluidEl.width();

                // Resize all videos according to their own aspect ratio
                $allVideos.each(function() {

                        var $el = $(this);
                        $el
                                .width(newWidth)
                                .height(newWidth * $el.data('aspectRatio'));

                });

        // Kick off one resize to fix all videos on page load
        }).resize();

});

function jump(to)
{
	var topOffset = $('#interaktiv_modulok').offset().top;
	$('html,body').animate({scrollTop : topOffset}, 300);
}

function switchLanguageTo(to)
{
	if (to == 'hu' || to == 'en' || to == 'de' || to == 'cz')
	{
		if (BASE_URL == undefined || BASE_URL.toString().length === 0)
		{
			alert('A nyelv váltást nem lehet végrehajtani! ('+to+')');
		}
		else
		{  
			/*BASE_URL = ( BASE_URL.substr(BASE_URL.length-1, BASE_URL.length) == '/' ) ? BASE_URL.substr(0, BASE_URL.length-1) : BASE_URL;
			var querystring = window.location.href;
			querystring = querystring.replace(BASE_URL+'/', '');
			querystring = querystring.substr(querystring.indexOf('/')+1, querystring.length)
			window.location.href = BASE_URL +'/'+ to +'/'+ querystring;*/
			window.location.href = BASE_URL + to + '/index.html';
		}
	}
	else
	{
		alert('Az oldal ezen a nyelven nem érhető el! ('+to+')');
	}
}

