function gc_gallery_lightbox_start(){
	jQuery(document).ready(function(){
		/* set as default in lightbox.js (this doesnt work in ie6)
		jQuery.Lightbox.construct({
			show_linkback:	false,
			show_extended_info: false,
			download_link: false,
			baseurl: '',
			text: {
				// For translating
				image:		'',
				of:			'/',
				close:		'X',
				closeInfo:	'',
				download:	'',
				help: {
					close:		'',
					interact:	''
				},
				about: {
					text: 	'',
					title:	'',
					link:	''
				}
			},
			files: {
				images: {
					prev: 'typo3/ext/gc_gallery/res/css/lightbox-prev.gif',
					next: 'typo3/ext/gc_gallery/res/css/lightbox-next.gif',
					blank: 'typo3/ext/gc_gallery/res/css/lightbox-blank.gif',
					loading: 'typo3/ext/gc_gallery/res/css/lightbox-loading.gif'
				}
			}
		});
		*/

		// create lightbox
		jQuery('.gc_gallery_lightboxview').each(function () {
			gc_gallery_carousel_thumbs(this);
			jQuery(this).find('img').lightbox();
		});
	});
}

function gc_gallery_carousel_thumbs(cont){
	var _img = jQuery(cont).find('.thumb');
	var _cont = _img.parent();

	// get width, height and offset
	var w = _img.width(); // img width
	var h = _img.height(); // img height
	var a = w / h; // aspect ratio
	var cw = _cont.width(); // cont width
	var ch = _cont.height(); // cont height

	// shrink to cont width
	if(w > cw){
		w = cw;
		h = w / a;
	}
	// shrink to cont height
	if(h > ch){
		h = ch;
		w = h * a;
	}
	// enlarge to cont width
	if(w < cw){
		w = cw;
		h = w / a;
	}
	// enlarge to cont height
	if(h < ch){
		h = ch;
		w = h * a;
	}

	// calc width offset for cropping
	if(w > cw){
		var woff = Math.round((w - cw)/2);
		var hoff = -1;
	// calc height offset for cropping
	} else if(h > ch){
		var hoff = Math.round((h - ch)/2);
		var woff = -1;
	} else {
		var woff = -1;
		var hoff = -1;
	}

	// set width height and offset
	_img.css('width', Math.round(w));
	_img.css('height', Math.round(h));
	/*
	if(hoff == -1){
		_img.css('margin-left', -woff);
	} else if(woff == -1){
		_img.css('margin-top', -hoff);
	}
	*/
}