/**
 * This javascript file is included if there is no BE-user logged
 * in. The purpose of this file is to find if there is an anchor in
 * the page with the class 'ssfe-belogin-link'. If such an anchor
 * exists, endow it with magical Shadowbox capacity. What it will do
 * is open the backend login-page page in a Shadowbox.
 */

// Setup ShadowBox. These functions document.write out the script-tags
// they require, and thus must be run directly, and not put in the
// jQuery.onready event handler.
Shadowbox.loadSkin('classic', 'typo3/contrib/shadowbox-2.0/src/skin');

// I'm not sure we need language nor skin for anything. However,
// ShadowBox throws an error if no language is loaded. It is very
// rude like that.
Shadowbox.loadLanguage('en', 'typo3/contrib/shadowbox-2.0/src/lang');
Shadowbox.loadPlayer('iframe', 'typo3/contrib/shadowbox-2.0/src/player');


// When the document is ready
jQuery(function ($) {

	// We look the link with a class of ssfe-belogin-link.
	var beLoginLink = $('.ssfe-belogin-link');

	// If such a link exists.
	if (beLoginLink.length) {
		// Set Shadowbox options.
		Shadowbox.init({
			overlayColor: 'black',
			overlayOpacity: 0.2,
			animateFade: true,
			animate: false,
			viewportPadding: 0,
			skipSetup: true
		});

		// Add the login-url. We could set it in the document.
		var baseHref = ($('base').attr('href') || '');
		beLoginLink.attr(
			'href',
			baseHref + 'typo3/index.php?redirect_url=close.html&close_url=close.html'
		);

		// Setup shadowbox with the correct width.
		Shadowbox.setup(beLoginLink, {width: "600"});
	}
});

