<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<title>Insert Block</title>
		<meta name="robots" content="noindex, nofollow" />
		<style type="text/css">
			input.textbox{width: 100%;}
		</style>
  		<!--[if IE]>
  		<style type="text/css">
			input.textbox{width: 300px;}
		</style>
        <![endif]-->
		
		<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/mw_lib/fsm/jqueryFileTree/jqueryFileTree.css" />
		<script type="text/javascript" src="/misc/jquery.js"></script>
		<script type="text/javascript" src="/sites/all/modules/mw_lib/fsm/jqueryFileTree/jqueryFileTree.js"></script>
		<script type="text/javascript" src="/sites/all/modules/mw_lib/fsm/fsm.js.php"></script>
		<script type="text/javascript" src="../../fckeditor/editor/dialog/common/fck_dialog_common.js"></script>
		<script type="text/javascript">
		
			function fill_in_url(file)
			{
				GetE('txtLink').value = "{drupal:module_invoke:mw_blocks|build_block|"+file+"}";
			}
			var dialog			= window.parent;
			var oEditor			= dialog.InnerDialogLoaded();
			var FCK				= oEditor.FCK;
			var FCKLang 		= oEditor.FCKLang;
			var olink			= dialog.Selection.GetSelection().MoveToAncestorNode('img');

			window.onload = function()
			{
				oEditor.FCKLanguageManager.TranslatePage(document);
				if(olink)
				{
					FCK.Selection.SelectNode(olink);
					GetE('txtLink').value = olink.alt;
				}
				
				$('#fsmPageBrowser').fileTree(
							{ 
								root: '',
								script: '/admin/fsm/block_tree/1',
								multiFolder: false,
								folderEvent: 'dblclick'
							}, 
					function(file) {
						 fill_in_url(file);
					}
				);
				window.parent.SetAutoSize(true);
				window.parent.SetOkButton(true);
			}
			
			function Ok()
			{
				var txtLink = GetE('txtLink').value;
				
				if(txtLink.length == 0)
				{
					alert(FCKLang.fsmNoCode);
					return false;
				}
				
				oEditor.FCKUndo.SaveUndoStep();

				sValue = FCK.InsertElement('img');
				sValue.src = '/admin/fsm/load_icon/block';
				sValue.alt = txtLink;
				return true;
			}
			
		</script>
	</head>
	
	<body>
		<div id="fsmPageBrowser" style="padding-bottom: 10px">

		</div>
		<span fckLang="fsmBlockLinkName">code to insert</span><br />
		<input id="txtLink" class="textbox" type="text" disabled="disabled" />
	</body>
</html>