// function setBoxHeight( box, targetHeight )
// {
// 	var targetDiv = $( box ).find( '.block-mid' ),
// 		boxParts = ['.block-top', '.block-bottom'],
// 		heightDiff = 0;
// 		
// 	$.each( boxParts, function( id, item ){
// 		heightDiff = heightDiff + $( box ).find( item ).height();
// 	});
// 	targetDiv.height( targetHeight - heightDiff );
// }

function normalizeHeight( container )
{
	var _cont = $( container ),
		cols = _cont.find( '.block-mid' ),
		maxHeight = cols.eq(0).height();

	cols.each(function(){
		var col = $( this );
		if( col.height() > maxHeight )
			maxHeight = col.height();
	});

	cols.height( maxHeight );	
}

$.fn.normalizeHeight = function( childSelector )
{
	return this.each( function(){
		var _cont = $( this ),
			cols = _cont.find( childSelector ),
			maxHeight = cols.eq(0).height();

		cols.each(function(){
			var col = $( this );
			if( col.height() > maxHeight )
				maxHeight = col.height();
		});

		cols.height( maxHeight );		
	});
}

$( document ).ready(function(){
	$( '.post-row' ).normalizeHeight( '.post-list-item' );
	
    $( '.thumbs', '.gallery' ).jCarouselLite({
		visible: 4,
		circular: false,
		btnNext: '.gallery-thumbs .next',
		btnPrev: '.gallery-thumbs .prev'	
    });

	$.extend( $.facebox.settings, {
	    loading_image: BASE_HREF + 'img/facebox/loading.gif',
	    close_image: BASE_HREF + 'img/facebox/closelabel.gif'		
	});

	// Gallery alapbeallitasok felulirasa
	$.extend( $.fn.cpGallery.defaults, {
		loadingText: 'Betöltés...',
		beforeInit: function()
		{
			this.mediumImage.find( 'a' ).facebox();			
		}
		,beforeDisplay: function( index, img, thumb )
		{
			this.dom.find( '.gallery-nav' ).width( img.get(0).width );
			this.dom.find( this.options.captionClass ).html( img.attr( 'alt' ) );
		},
		afterDisplay: function( index, img, thumb )
		{
			var _a = $( '<a></a>' )
				.attr( 'href', thumb.find('a').attr('href') )
				.attr( 'title', img.attr( 'alt' ) );
			
			this.mediumImage.wrapInner( _a );
			this.mediumImage.find( 'a' ).facebox();
		}		
	});

});

function quiz( url )
{
	window.open( url, "quiz","menubar=1,resizable=0,width=800,height=600");
}

// $.fn.onEnter = function( cb ){
// 	$( this ).keydown( function( e ){
// 		if( e.which == 13 ){
// 			if( $.isFunction( cb ) )
// 				cb.call( this, e );
// 		};
// 	});
// 
// 	return this;
// }