﻿// JScript File
tinyMCE.init({
	mode: "specific_textareas",
	editor_selector: "mceEditor",
	theme: "advanced",
	skin: "o2k7",
	skin_variant: "grey",
	plugins: "safari,advlink,iespell,inlinepopups,searchreplace,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,table,contextmenu,attachment",
	content_css: "/cms/css/editor.css",
	valid_elements: "@[id|class|title],"
+ "a[rel|tabindex|accesskey|type|"
+ "name|href|target|title|class],strong/b,em/i,strike,u,"
+ "#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|"
+ "src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,"
+ "-blockquote,-table[border=0|cellspacing|cellpadding|width|frame|rules|"
+ "height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|"
+ "height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,"
+ "#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor"
+ "|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,"
+ "-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face"
+ "|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],"
+ "object[classid|width|height|codebase|*],param[name|value|_value],embed[type|width"
+ "|height|src|*],map[name],area[shape|coords|href|alt|target],bdo,"
+ "button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|"
+ "valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],"
+ "input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],"
+ "kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],"
+ "q[cite],samp,select[disabled|multiple|name|size],small,"
+ "textarea[cols|rows|disabled|name|readonly],tt,var,big",
	theme_advanced_buttons1: "bold,italic,|,link",
	theme_advanced_buttons2: "",
	theme_advanced_buttons3: "",
	theme_advanced_buttons4: "",
	theme_advanced_statusbar_location: "bottom",
	theme_advanced_toolbar_location: "top",
	theme_advanced_toolbar_align: "left",
	theme_advanced_resizing: true,
	theme_advanced_resizing_use_cookie: false,
	theme_advanced_blockformats: "p,h2,h3",
	languages: 'en',
	disk_cache: true,
	debug: false,
	init_instance_callback: 'adjustMceHeight',
	onchange_callback: 'mceContentUpdated',
	template_popup_width: 400,
	template_popup_height: 300
});
var tmpPathObj;
var tmpTitleObj;

//make sure that the textarea gets updated and a fake 'change' event is fired. helpful for validation.
function mceContentUpdated(inst) {
	tinyMCE.triggerSave(false, true);
	jQuery('#' + inst.id).triggerHandler('change');
}

function adjustMceHeight(editorID) {
	return null;
	var frame, doc, docHeight, frameHeight;
	if (editorID.id) editorID=editorID.id;
	frame = document.getElementById(editorID+"_ifr");
	if ( frame != null ) {
		//get the document object
		if (frame.contentDocument) { 
			doc = frame.contentDocument; 
		} else if (frame.contentWindow) { 
			doc = frame.contentWindow.document; 
		} else if (frame.document) { 
			doc = frame.document; 
		}
		
		if ( doc == null )
			return;
		
	
		docHeight;
		frameHeight = parseInt(frame.style.height);
		
		//Firefox
		if ( doc.height ) { docHeight = doc.height; }
		//MSIE
		else { docHeight = parseInt(doc.body.scrollHeight); }
		
		//MAKE BIGGER
		if ( docHeight > frameHeight-20 ) 
		{ 
			if (docHeight < 450)
			{	//prevent the scrollbar from showing
				doc.body.style.overflow = "hidden";
				frame.style.height = (docHeight+20) + "px"; 
				}
			else
				{
				frame.style.height = "470px";
				doc.body.style.overflow = "auto";
				}
			}
		//MAKE SMALLER
		else if ( docHeight < frameHeight-20 ) { frame.style.height = Math.max((docHeight+20), 100) + "px"; }
		
		//only repeat while editor is visible
		setTimeout("adjustMceHeight('" + editorID + "')", 100);
	}
	else
	{
		alert('Problem loading TinyMCE');
	}
}
