var url_root = '';
var tmce_config = {
	// General options
	mode : "none",
	theme : "advanced",
	plugins : "safari,style,advlink,inlinepopups,print,contextmenu,paste,directionality,noneditable,visualchars,xhtmlxtras,table,fullscreen,media",

	// Theme options
	theme_advanced_buttons1 : "print,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,separator,media,separator,fullscreen",
	theme_advanced_buttons4 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	theme_advanced_resizing : true,
	


	// Example content CSS (should be your site CSS)
	content_css : url_root + "engine/jscripts/tiny_mce/css/content.css",

	// Drop lists for link/image/media/template dialogs
	external_link_list_url : url_root + "engine/jscripts/tiny_mce/lists/link_list.js"
};


var Engine = {
	load: function(root_path, scriptal, scripts) {
		url_root = root_path;
		if( typeof Prototype == 'undefined' ) {
			throw('Error: Prototype required.');
		} else {
			if( scriptal.match(/[^\s]/) )
			{
				document.write("<script src=\""+root_path+"engine/jscripts/scriptaculous/scriptaculous.js?load="+scriptal+"\" type=\"text/javascript\"></script>");
			}
			scripts.split(',').each( function(sinc) {
				if( sinc.match(/[^\s]/) )
				{
					document.write("<script src=\""+sinc+"\" type=\"text/javascript\"></script>");
				}
			} );
		}
	},
	
	disable_select: function (target) {
		if (typeof target.onselectstart != "undefined")
		{
			target.onselectstart = function() { return false }
		}
		else if ( typeof target.style.MozUserSelect != "undefined" )
		{
			target.style.MozUserSelect = "none";
		}
		else
		{
			target.onmousedown=function() { return false }
		}
		target.style.cursor = "default";
	},
	
	init_grey_box: function( box ) {
		Element.extend(box);
		if( box.hasClassName('grey_box_start') )
		{
			box.removeClassName('grey_box_start');
			box.value = '';
		}
	},
	
	delete_item_confirm: function( item, url ) {
		if( confirm("Are you sure you want to delete " + item + "?") )
		{
			document.location.href=url;
		}
	},
	
	highlight_delete_confirm: function( objid, url ) {
		$(objid).addClassName('cms_delete_highlight');
		var yesorno = confirm("Are you sure you want to delete this?");
		$(objid).removeClassName('cms_delete_highlight');
		if( yesorno )
		{
			if( url == '' || typeof url == 'undefined' )
			{
				document.location.reload();
			}
			else
			{
				document.location.href=url;
			}
		}
	},
	
	apply_wysiwyg: function( sEditorID )
	{
		if( typeof tinyMCE == 'undefined' ) {
			throw('Error: TinyMCE not included. Cannot start.');
		}
		
		tinyMCE.execCommand("mceAddControl", true, sEditorID);
	}
}