new function() {
// compiled on Wed 12/10/2008 15:52:03.49

// ***
// category-tree.js
	
	estrada.behavior('category-tree').is({
		bind: function(node) {
			///////////////////////////////////////////////////////////////////////
			// include script for category-editor, if needed
			///////////////////////////////////////////////////////////////////////
			if (filter(node.getElementsByTagName('div'), function(div) {
				return div.className.indexOf('category-editor') >= 0;
			}).length > 0) {
				tilt.addScript('dynamictree.js');	
			}
		}
	});
// ***
// date-selector.js
	
	estrada.behavior('date-selector').is({
		bind: function(node) {
			///////////////////////////////////////////////////////////////////////
			// include script for datetime picker, if needed
			///////////////////////////////////////////////////////////////////////
			if (filter(node.getElementsByTagName('input'), function(input) {
				return input.className.indexOf('date') >= 0;
			}).length > 0) {
				tilt.addScript('datetime.js');	
			}
		}
	});

// ***
// first-li.js
	
	estrada.behavior('first-li').is({
		bind: function(node) {
			foreach(node.getElementsByTagName('ul'), function(ul) {
				foreach(ul.getElementsByTagName('li'), function(li) {
					li.className += ' l-first';
					return true;
				});
			});
		}
	});

// ***
// grid-visibility.js

	estrada.behavior('grid-visibility').is({
		bind: function(node) {
			///////////////////////////////////////////////////////////////////////
			// include script for grid, if needed
			///////////////////////////////////////////////////////////////////////
			var oContent = node.getElementById('l-content');
			if (oContent) {
				if (foreach(oContent.getElementsByTagName('div'), function(div) {
					if (div.className == 'visibility') {
						div.id = 'grid-visibility';
						return true;
					}
				})) {
					tilt.addScript('grid.js');
				}
			}
		}
	});
// ***
// isolate-submits.js
	
	estrada.behavior('isolate-submits').is({
		bind: function(node) {
			////////////////////////////////////////////////////////////////////
			// This code sets all text input elements in an ancestor element
			// with a single submit input to post when enter is hit while in the
			// text field
			////////////////////////////////////////////////////////////////////    
			var oInputSubmits = getElementsByType(node, 'input', 'submit');
			var iIdx = 0;
			foreach (map(oInputSubmits), function(oInputSubmit) {
				var oAncestorNode = null;
				oCurrentNode = oInputSubmit.parentNode;
				while (oAncestorNode == null && oCurrentNode != document) {
					var oInputTextFields = getElementsByType(oCurrentNode, 'input', 'text');
					if (oInputTextFields && oInputTextFields.length > 0) {
						oAncestorNode = oCurrentNode;
					} else {
						oCurrentNode = oCurrentNode.parentNode;
					}
				}
				if (oAncestorNode) {
					var oSubmitCheck = getElementsByType(oAncestorNode, 'input', 'submit');
					if (oSubmitCheck && oSubmitCheck.length == 1) {
						if (oInputSubmit.id == '') {
							oInputSubmit.id = oInputSubmit.name;
						}
						foreach (map(oAncestorNode.getElementsByTagName('input')), function (oInput) {
							if (oInput.type == 'text' || oInput.type == 'password') {
								oInput.setAttribute('submitId', oInputSubmit.id);
								tilt.attachEvent(oInput, 'keydown', function(oNode, oE) {
									if (oE.keyCode == 13) {
										var oSubmitId = oNode.getAttribute('submitId');
										window.setTimeout('var oSubmit = document.getElementById(\'' + oSubmitId + '\');oSubmit.focus();oSubmit.click()', 0);
										return false;
									}
									return true;
								});
							}
						});
						iIdx++;
					}
				}
			});
		}
	});

// ***
// pretty-search.js
	
	estrada.behavior('pretty-search').is({
		bind: function(node) {
			var searchQuery = node.getElementById('search-query');
			if (searchQuery) {
				var defaultText = 'Search';
				var blurClassName = 'text l-blur';
				searchQuery.value = defaultText;
				searchQuery.className = blurClassName;
				tilt.attachEvent(searchQuery, 'focus', function() {
					if (searchQuery.value == defaultText) {
						searchQuery.value = '';
						searchQuery.className = 'text';
					}
				});
				tilt.attachEvent(searchQuery, 'blur', function() {
					if (searchQuery.value.length == 0) {
						searchQuery.value = defaultText;
						searchQuery.className = blurClassName;
					}
				});
				tilt.attachEvent(searchQuery, 'keydown', function(searchQuery, e) {
					if (e.keyCode == 13) {
						window.setTimeout('document.getElementById(\'search-submit\').click()', 0);
						return false;
					}
					return true;
				});
			}
			
			var searchSubmit = node.getElementById('search-submit');
			if (searchSubmit) {
				var parent = searchSubmit.parentNode;
				var div = parent.appendChild(document.createElement('div'));
				div.id = 'l-search-submit';
				tilt.attachEvent(div, 'click', function() {
					document.getElementById('search-submit').click();
				});
			}
		}
	});

// ***
// tiny-mce.js
  // Commenting out the old (static loading) way, giving way to the new way
  // TinyMCE is now loaded dynamically

	//window.tinyMCE && tinyMCE.init({
	//	mode : "none",
	//	theme : "advanced",
	//	plugins : "table,advhr,advimage,advlink,insertdatetime,preview,zoom,searchreplace,print,contextmenu,paste,fullscreen,noneditable,iespell",
	//	width: "100%",
	//	height: "300px",
	//	safari_warning : false,
	//	cleanup_on_startup : false,
	//	relative_urls: true,
	//	theme_advanced_buttons1_add : "fontselect,fontsizeselect",
	//	theme_advanced_buttons2_add : "separator,preview,forecolor,backcolor",
	//	theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
	//	theme_advanced_buttons3_add_before : "tablecontrols,separator",
	//	theme_advanced_buttons3_add : "flash,advhr,separator,print,separator,fullscreen,iespell",
	//	theme_advanced_toolbar_location : "top",
	//	theme_advanced_toolbar_align : "left",
	//	theme_advanced_path_location : "bottom",
	//	content_css : "Assets/Styles/Editor.css",
	//	plugin_insertdate_dateFormat : "%Y-%m-%d",
	//	plugin_insertdate_timeFormat : "%H:%M:%S",
	//	extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
	//	theme_advanced_resize_horizontal : false,
	//	theme_advanced_resizing : true
	//});
	
	estrada.behavior('tiny-mce').is({
		bind: function(node) {
      if (!$) return;
      $('textarea.rich-text').tinyMce();
		}
	});
}
