// JavaScript Document




// fomenü kezelése
function init_main_menu() {
//	$('#pg_topmenu UL LI').mouseover( function() {
	$('#pg_topmenu UL LI').click( function() {
		var id = $(this).attr('id');
		$('#pg_submenu UL').hide();
		$('#pg_topmenu UL LI A').removeClass('active');
		$('A', this).addClass('active');
		$('#submenu_'+id).show();
	});
	
	
}



$(document).ready( function() { 
	init_main_menu();
	
	// facebox init
	if( 0 < $('a[rel*=facebox]').length )
		$('a[rel*=facebox]').facebox() ;

	if ( 0 < $('.did_you_know').length ) {
		var nRand = 0, nTempRand, nDidYouKnow = $('.did_you_know').length;
//		$('.did_you_know:first').show(); // első elem
		$('.did_you_know:eq(' + (Math.floor(Math.random() * nDidYouKnow)) + ')' ).show(); // véletlenedik elem
//		$('.did_you_know:eq(21)' ).show(); // véletlenedik elem
		$('.did_you_know .read_more').bind( 'click', function( event ) {
			nTempRand = (Math.floor(Math.random() * nDidYouKnow));
			while ( nRand == nTempRand ) {
				nTempRand = (Math.floor(Math.random() * nDidYouKnow));
			}
			nRand = nTempRand;
			$(this).parent().parent().hide();
//			$(this).parent().parent().next().show(); // a következőt mutatná meg
			$('.did_you_know:eq(' + nRand + ')' ).show(); // random jelenítjük meg
			event.preventDefault();
		} );
	} 

})


function getCss (source, properties){
		var link = document.createElement('link');
		$.each( { 'rel': 'stylesheet', 'media': 'screen', 'type': 'text/css', 'href': source }, function( i, n ){
			link.setAttribute( i, n );
		});
		document.getElementsByTagName('head')[0].appendChild(link);
};

