$(document).ready(function()
{
	$("ul.sf-menu").supersubs
					(
						{
							minWidth:    11.5,   // minimum width of sub-menus in em units
				            maxWidth:    40,   // maximum width of sub-menus in em units
				            extraWidth:  2.5     // extra width can ensure lines don't sometimes turn over due to slight rounding differences and font-family
						}
					).superfish
					(
							{
								speed:      'fast',
								animation:	{opacity:'show',height:'show'},
								pathClass:	'currentNavigationPos',
								pathLevels: 1,
							}
					);
	
	$("a.fancybox").fancybox
	(
		{
			'transitionIn'	:	'fade',
			'transitionOut'	:	'fade',
			'speedIn'		:	600, 
			'speedOut'		:	300, 
			'overlayShow'	:	true,
			'hideOnContentClick': false,
			'autoDimensions':	false,
			'autoScale':	 	false,
			'width'			:	600,
			'height'		:	400,
		}
	);
	
	// create gallery if any
	$("a.gallery").fancybox
	(
		{
			'transitionIn'	:	'fade',
			'transitionOut'	:	'fade',
			'speedIn'		:	600, 
			'speedOut'		:	300, 
			'overlayShow'	:	true,
			'hideOnContentClick': false,
			'titleShow' 	:	true,
			'titlePosition'	:	'over',
			'autoScale'		:	true,
			'autoDimensions':	true,
			'type'			:	'image'
		}
	);
});

CKEDITOR.editorConfig = function( config )
				{
				    config.language = 'de';
				    
				    config.toolbar = 'Basic';
				    
					config.toolbar_MyToolbar =
					[
						{ name: 'document', items : [ 'NewPage','Preview' ] },
						{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
						{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
						{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe' ] },
				                '/',
						{ name: 'styles', items : [ 'Styles','Format' ] },
						{ name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
						{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
						{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
						{ name: 'tools', items : [ 'Maximize','-','About' ] }
					];
				};

function showMessageBox(type, text, redirect, width, height)
{
	switch(type)
	{
	case 1:
		type = "messagebox_info.png";
		break;
		
	case 2:
		type = "messagebox_error.png";
		break;
	}
	
	var output = "\
			\
			<div id=\"messagebox\">\
			<table border=\"0\" width=\"100%\">\
			<tr>\
				<td valign=\"top\">\
					<img src=\"img/{type}\" border=\"0\" />\
				</td>\
				<td>\
					{text}\
				</td>\
			</tr>\
			</table>\
			</div>\
			";
	
	output = output.replace("{type}", type);
	output = output.replace("{text}", text);
	
	$(document).ready(function()
	{
		$.fancybox
		(
			output,
			{
				'transitionIn'	:	'fade',
				'transitionOut'	:	'fade',
				'speedIn'		:	600, 
				'speedOut'		:	300, 
				'overlayShow'	:	true,
				'hideOnContentClick': false,
				'title'			:	'BCE Nachricht',
				'titleShow' 	:	true,
				'titlePosition'	:	'over',
				'autoScale'		:	false,
				'autoDimensions':	false,
				'width'			:	width,
				'height'		:	height,
				'onClosed'		:	function()
									{
										if(redirect.length > 0)
										{
											window.location = redirect;
										}
									}
			}
		);
	});
}

function moveListPickerItem(fromId, toId)
{
	var from = document.getElementById(fromId);
	var to = document.getElementById(toId);
	
	for (var i=0; i<from.options.length; i++)
	{
	    if (from.options[i].selected)
	    {
	        to.options.add(new Option(from.options[i].text,from.options[i].value))
	        from.remove(i--);
	    }
	}
}

function selectAllListPickerItems(listpickerId)
{
	var listPicker = document.getElementById(listpickerId);
	listPicker.multiple = true;
	
	for (var i=0; i<listPicker.options.length; i++)
    {
		listPicker[i].selected = true;
    }
}

function selectFileFromDms(target, file)
{
	nd();
	
	$('#' + target).val(file);
	$('#display_' + target).text(file);
	
	if($("#display_image_" + target) != null)
		$("#display_image_" + target).attr("src", file);
	
	// close fancybox
	$.fancybox.close();
	
	return false;
}

function showSimpleMessageBox(message)
{
	prompt("", message);
}

function showAlbumPicture(filename, description)
{
	if(description == null || description.length == 0)
		description = "";
	
	$(document).ready(function()
			{
				$.fancybox
				(
						filename,
					{
						'transitionIn'	:	'fade',
						'transitionOut'	:	'fade',
						'speedIn'		:	600, 
						'speedOut'		:	300, 
						'overlayShow'	:	true,
						'hideOnContentClick': false,
						'title'			:	description,
						'titleShow' 	:	true,
						'titlePosition'	:	'over',
						'autoScale'		:	true,
						'autoDimensions':	true,
						'type'			:	'image'
					}
				);
			});
}

