/* lightbox functions */

/**
*open lightbox with specific width / height
*
* @author Mirjam Verloop
* @since may 2011
* @returns void
*/

function initLightbox() {

	var shadowboxLinks = jQuery('a[rel*="shadowbox"]');
	shadowboxLinks.each(function (index, el) {

		if (jQuery(el).attr('rel').search('player=img') == -1) {

			jQuery(el).click(function (e) {
	
				e.preventDefault();
				//jQuery('#sb-container').addClass('lightbox_fixed_width');
				jQuery('#sb-info').hide();

				var sW = '460';
				var sH = '500';

				var props = jQuery(el).attr('rel').split(';');
				jQuery(props).each(function (index, p) {
					var ps = p.split('=');
					if (ps[0] == 'width') {
						sW = parseInt(ps[1]);
					}
					if (ps[0] == 'height') {
						sH = parseInt(ps[1]);
					}
				});

				Shadowbox.open({
					player: 'iframe',
					content: this.href,
					height: sH,
					width: sW
				});

			});

		}
	});
}

/**
* Closes the lightbox
*
* @author Ralph Meeuws <ralph.meeuws[AT]efocus.nl>
* @version apr 2011
* @returns void
*/
function closeLightbox() {
	if (!jQuery('div.lightbox')) return false;

	var closeLightboxEvent = function (e) {
		e.preventDefault();
		window.parent.parent.Shadowbox.close();
	}

	jQuery('div.lightbox a.btn_round_close').click(function (e) {
		closeLightboxEvent(e);
	});

	jQuery('div.lightbox a.button_close').click(function (e) {
		closeLightboxEvent(e);
	});

	jQuery('div.lightbox h1 a.link_close').click(function (e) {
		closeLightboxEvent(e);
	});
}

/**
* Close lightbox, refresh parent
*
* @author Mirjam <mirjam[AT]efocus.nl>
* @version may 2011
* @returns void
*/

function closeLightBoxUpdateParent() {

	window.parent.parent.location.reload();

}
