/**
 * Common file for applying editor to pop up
 * has common configuration
 * @author hasham
 */
var validElements = "a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
					+"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
					+"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev"
				    +"|shape<circle?default?poly?rect|style|tabindex|title|target|type],"
		+"blockquote[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick"
		  +"|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
		  +"|onmouseover|onmouseup|style|title],"
		+"br[class|clear<all?left?none?right|id|style|title],"
		+"cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
		  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
		  +"|title],"
		+"div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|style|title],"
		+"span[style|class|align],"
		+"em/i[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
		  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
		  +"|title],"
		+"font[class|color|dir<ltr?rtl|face|id|lang|size|style|title],"
		+"h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|style|title],"
		+"h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|style|title],"
		+"h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|style|title],"
		+"hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|size|style|title|width],"
		+"img[width|style|height|class|align<bottom?left?middle?right?top|alt|border|class|dir<ltr?rtl"
		  +"|hspace|ismap<ismap|lang|longdesc|name|onclick|ondblclick|onkeydown"
		  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
		  +"|onmouseup|src|title|usemap|vspace|width],"
		+"li[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
		  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type"
		  +"|value],"
		+"object[align<bottom?left?middle?right?top|archive|border|class|classid"
		  +"|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name"
		  +"|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap"
		  +"|vspace|width],"
		+"embed[src|type|wmode|width|height],"
		+"ol[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
		  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
		  +"|onmouseup|start|style|title|type],"
		+"p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
		  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
		  +"|onmouseout|onmouseover|onmouseup|style|title],"
		+"param[id|name|type|value|_value|valuetype<DATA?OBJECT?REF],"
		+"strike[class|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
		  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
		  +"|onmouseup|style|title],"
		+"strong/b[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
		  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
		  +"|title],"
		+"sub[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
		  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
		  +"|title],"
		+"sup[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
		  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
		  +"|title],"
		+"u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
		  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
		+"ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
		  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
		  +"|onmouseup|style|title|type]";

var post_event_valid_elements = "a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
								+"|rel|rev"
							  +"|shape<circle?default?poly?rect|style|tabindex|title|target|type],"
							+"abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
							  +"|style"
							  +"|title],"
							+"acronym[class|dir<ltr?rtl|id|id|lang"
							  +"style"
							  +"|title],"
							+"address[class|align|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"applet[align<bottom?left?middle?right?top|alt|archive|class|code|codebase"
							  +"|height|hspace|id|name|object|style|title|vspace|width],"
							+"area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref"
							  +"|shape<circle?default?poly?rect|style|tabindex|title|target],"
							+"base[href|target],"
							+"basefont[color|face|id|size],"
							+"bdo[class|dir<ltr?rtl|id|lang|style|title],"
							+"big[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"blockquote[cite|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link"
							  +"|style|title|text|vlink],"
							+"br[class|clear<all?left?none?right|id|style|title],"
							+"button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|name"
							  +"|style|tabindex|title|type"
							  +"|value],"
							+"caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"center[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"cite[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"code[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"col[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
							  +"|lang"
							  +"|span|style|title"
							  +"|valign<baseline?bottom?middle?top|width],"
							+"colgroup[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl"
							  +"|id|lang"
							  +"|span|style|title"
							  +"|valign<baseline?bottom?middle?top|width],"
							+"dd[class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"del[cite|class|datetime|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"dfn[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"dir[class|compact<compact|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"dl[class|compact<compact|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"dt[class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"em/i[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"fieldset[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"font[class|color|dir<ltr?rtl|face|id|lang|size|style|title],"
							/*+"form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang"
							  +"|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
							  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit"
							  +"|style|title|target],"
							+"frame[class|frameborder|id|longdesc|marginheight|marginwidth|name"
							  +"|noresize<noresize|scrolling<auto?no?yes|src|style|title],"
							+"frameset[class|cols|id|onload|onunload|rows|style|title],"*/
							+"h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"h4[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"h5[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"h6[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"head[dir<ltr?rtl|lang|profile],"
							+"hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade"
							  +"|size|style|title|width],"
							/*+"html[dir<ltr?rtl|lang|version],"
							+"iframe[align<bottom?left?middle?right?top|class|frameborder|height|id"
							  +"|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style"
							  +"|title|width],"
							+"input[accept|accesskey|align<bottom?left?middle?right?top|alt"
							  +"|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang"
							  +"|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress"
							  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect"
							  +"|readonly<readonly|size|src|style|tabindex|title"
							  +"|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text"
							  +"|usemap|value],"
							+"ins[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
							  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
							  +"|onmouseup|style|title],"
							+"isindex[class|dir<ltr?rtl|id|lang|prompt|style|title],"
							+"kbd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
							  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
							  +"|title],"
							+"label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick"
							  +"|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
							  +"|onmouseover|onmouseup|style|title],"
							+"legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang"
							  +"|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
							  +"|onmouseout|onmouseover|onmouseup|style|title],"*/
							+"li[class|dir<ltr?rtl|id|lang"
							  +"|style|title|type"
							  +"|value],"
							+"link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media"
							  +"|rel|rev|style|title|target|type],"
							/*+"map[class|dir<ltr?rtl|id|lang|name"
							  +"|style"
							  +"|title],"
							+"menu[class|compact<compact|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"meta[content|dir<ltr?rtl|http-equiv|lang|name|scheme],"
							+"noframes[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"noscript[class|dir<ltr?rtl|id|lang|style|title],"
							+"object[align<bottom?left?middle?right?top|archive|border|class|classid"
							  +"|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name"
							  +"|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
							  +"|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap"
							  +"|vspace|width],"*/
							+"ol[class|compact<compact|dir<ltr?rtl|id|lang"
							  +"|start|style|title|type],"
							+"optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang"
							  +"|style|title],"
							+"option[class|dir<ltr?rtl|disabled<disabled|id|label|lang"
							  +"|selected<selected|style|title|value],"
							+"p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							/*+"param[id|name|type|value|valuetype<DATA?OBJECT?REF],"*/
							/*+"pre/listing/plaintext/xmp[align|class|dir<ltr?rtl|id|lang"
							  +"|style|title|width],"*/
							+"q[cite|class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"s[class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"samp[class|dir<ltr?rtl|id|lang|"
							  +"|style"
							  +"|title],"
							/*+"script[charset|defer|language|src|type],"*/
							/*+"select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name"
							  +"|onblur|onchange|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
							  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style"
							  +"|tabindex|title],"*/
							+"small[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|"
							  +"|style|title],"
							+"strike[class|class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"strong/b[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"style[dir<ltr?rtl|lang|media|title|type],"
							+"sub[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"sup[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title],"
							+"table[align<center?left?right|bgcolor|border|cellpadding|cellspacing|class"
							  +"|dir<ltr?rtl|frame|height|id|lang|"
							  +"|rules"
							  +"|style|summary|title|width],"
							+"tbody[align<center?char?justify?left?right|char|class|charoff|dir<ltr?rtl|id"
							  +"|lang"
							  +"|style|title"
							  +"|valign<baseline?bottom?middle?top],"
							+"td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
							  +"|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap"
							  +"|rowspan|scope<col?colgroup?row?rowgroup"
							  +"|style|title|valign<baseline?bottom?middle?top|width],"
							/*+"textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name"
							  +"|readonly<readonly|rows|style|tabindex|title],"*/
							+"tfoot[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
							  +"|lang"
							  +"|style|title"
							  +"|valign<baseline?bottom?middle?top],"
							+"th[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
							  +"|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap"
							  +"|rowspan|scope<col?colgroup?row?rowgroup"
							  +"|style|title|valign<baseline?bottom?middle?top|width],"
							+"thead[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
							  +"|lang"
							  +"|style|title"
							  +"|valign<baseline?bottom?middle?top],"
							+"title[dir<ltr?rtl|lang],"
							+"tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class"
							  +"|rowspan|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title|valign<baseline?bottom?middle?top],"
							+"tt[class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"u[class|dir<ltr?rtl|id|lang"
							  +"|style|title],"
							+"ul[class|compact<compact|dir<ltr?rtl|id|lang"
							  +"|style|title|type],"
                           +"li[class|dir<ltr?rtl|id|lang|"
                           +"|style|title|type"
                            +"|value],"
							+"var[class|dir<ltr?rtl|id|lang"
							  +"|style"
							  +"|title]";

		var comment_valid_elements = "a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
		  + "|rel|rev"
		  + "|shape<circle?default?poly?rect|tabindex|title|target|type],"
		+ "br[class|clear<all?left?none?right|id|title],"
		+ "span[class|style<text-decoration: underline;?text-decoration: line-through;|align],"
		+ "em/i[class|dir<ltr?rtl|id|lang||title],"
		+ "p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|title],"
		+ "strong/b[class|dir<ltr?rtl|id|lang|title],"
		+ "strike,u";


function absolute_urls(ed, o) {
  var anchors = ed.dom.select('a');
  for (var i=0; i<anchors.length; i++) {
    var href = ed.dom.getAttrib(anchors[i], 'href');
    if (!href.match(/^https?:\/\//)) {
      ed.dom.setAttrib(anchors[i], 'href', 'http://'+href);
    }
  }
}

function add_rewrites(ed) {
  ed.onLoadContent.add(absolute_urls);
  ed.onSaveContent.add(absolute_urls);
  ed.onPreProcess.add(absolute_urls);
}


var tinymceConfigs = [
		/*0*/
		{theme : "advanced",
        mode : "none",
        language : "en",
        width:"752",
		height : "100",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent,indent,|,forecolor,cite,spellchecker",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
		apply_source_formatting : true,
		valid_elements : validElements,
        setup : add_rewrites
		},
		/*1*/
		{theme : "advanced",
        mode : "exact",
		language : "en",
		width : "752",
		height : "200",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent,indent,|,cite,spellchecker",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		apply_source_formatting : true,
        valid_elements : post_event_valid_elements,
        setup : add_rewrites,
		relative_urls : false,
		remove_script_host : false
		},
		/*2*/
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "752",
		height : "300",
		plugins : "preview,paste,spellchecker,xhtmlxtras,media,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent,indent,|,forecolor,cite,spellchecker,|,preview,media",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		onchange_callback : "buildOverlays",
		setupcontent_callback : "buildOverlays",
	  	init_instance_callback : "initEditor",
		handle_event_callback : "myHandleEvent",
		apply_source_formatting : true,
		valid_elements : validElements,
        setup : add_rewrites
		},
		/*3*/
		/* same as on index 1--only difference of width and height */
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "475",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent,indent,|,cite,spellchecker",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",
		apply_source_formatting : true,		
		theme_advanced_path : false,
		/*paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing : true,
		valid_elements : post_event_valid_elements,
        setup : add_rewrites,
        remove_linebreaks : false
		},
		/*4*/
		/* same as on index 1--only difference of width and height */
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "383",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,|,spellchecker",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		apply_source_formatting : true,
		valid_elements : validElements
		},
		/*5*/
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "100",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent",
		theme_advanced_buttons2 : "indent,cite,spellchecker",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		apply_source_formatting : true,
		valid_elements : validElements,
        setup : add_rewrites
		},
		/*6*/
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "100",
		plugins : "preview,paste,spellchecker,xhtmlxtras,media,safari,inlinepopups,style",/*inlinepopups*/
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,pasteword,|,code,link,unlink,|,outdent,indent,|,forecolor,cite,spellchecker,|,preview,media",
		theme_advanced_disable : "removeformat, sub, sup, anchor, charmap, styleselect, formatselect, help, cleanup, code, strikethrough, justifyfull",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		onchange_callback : "buildOverlays",
		setupcontent_callback : "buildOverlays",
	  	init_instance_callback : "initEditor",
		handle_event_callback : "myHandleEvent",
		apply_source_formatting : true,
	  	/*content_css : "/stylesheets/editor.css",
		editor_css : "/stylesheets/editorui.css",*/
		/*media_use_script : true,*/
		//handle_event_callback : "myCustomHandleEvent",
		valid_elements : validElements,
        setup : add_rewrites
		},
		/*7*/
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "754",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,|,spellchecker",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		paste_remove_styles : true,*/
		apply_source_formatting : true,
		valid_elements : validElements,
        setup : add_rewrites
		},
		/*8*/
		/* same as on index 1--only difference of width and height */
		{theme : "advanced",
		mode : "none",
		language : "en",
		width : "494",
		height : "52",
		plugins : "paste,spellchecker,xhtmlxtras,safari,inlinepopups,style",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,pastetext,|,spellchecker",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "",/*
		paste_auto_cleanup_on_paste : true,
		auto_reset_designmode : true,
		paste_remove_styles : true,*/
		apply_source_formatting : true,
		valid_elements : comment_valid_elements,
        setup : add_rewrites
		}
];

function applyEditor(config_id, element_id) {

	if(tinyMCE.get(element_id)) {
		try {
			tinymce.EditorManager.remove(tinyMCE.get(element_id));
			$(element_id).focus();
		}catch(ex)
        {
            //*alert(ex.message);*/
            log_exceptions(" Method: - applyEditor " + ex.message);
        }
	}	
	
	tinyMCE.settings = tinymceConfigs[config_id];
    tinyMCE.execCommand('mceAddControl', false, element_id);
}

function showContribBox(lb_div, text_area_prefix, count, config,prefix)
{
    try
	{
		if (typeof(config) == "undefined") {
			configIndex = 0;
		}else{
			configIndex = config;
		}

		if(typeof(prefix == "undefined"))
			field_prefix="";
		else
			field_prefix=prefix;

		if(count == 0){
			//for submit a url box and blog editor
			//	applyEditor(configIndex,text_area_prefix)
			setTimeout("applyEditor(" + configIndex +",'" + text_area_prefix + "')",900);
		}else{
			setTimeout("applyEditor(" + configIndex + ",'" + text_area_prefix+count + "')",900);	//spellchecker only editor
			//applyEditor(configIndex,text_area_prefix+count);	//spellchecker only editor
		}

        RedBox.showInline(lb_div);

        //register_geo_location_with_id(1,prefix);
        register_geo_location_with_id_new(1,prefix, 2, 'redbox');

		//alert(text_area_prefix);
		//tinyMCE.addEvent(tinyMCE.getInstanceById(text_area_prefix).getDoc(),"onkeydown", alert('oooh'));
		return false;
	}catch(ex)
	{
		//alert(ex.message);
        log_exceptions(" Method: - showContribBox " + ex.message);
	}
}

function showInlineContribBox(lb_div, text_area_prefix, count, config,prefix)
{
    try
	{
		if (typeof(config) == "undefined") {
			configIndex = 0;
		}else{
			configIndex = config;
		}

		if(typeof(prefix == "undefined"))
			field_prefix="";
		else
			field_prefix=prefix;
		
		
		/*
		if(count == 0){
			//for submit a url box and blog editor
			setTimeout("applyEditor(" + configIndex +",'" + text_area_prefix + "')",900);
			
		}else{
				setTimeout("applyEditor(" + configIndex + ",'" + text_area_prefix+count + "')",900);	//spellchecker only editor
			//applyEditor(configIndex,text_area_prefix+count);	//spellchecker only editor
		}
		*/		
		$(lb_div).style.display = "inline";
				
		//register_geo_location_with_id(1,prefix);
		return false;
	}catch(ex)
	{
		//alert(ex.message);
        log_exceptions(" Method: - showInlineContribBox " + ex.message);
	}
}


/*
	this function is used to load editor in 'create event' view
	and  'edit_blog_for_event_person_profile' partial for loading tiny_mce editor
*/
function create_event_loadEditor(element_name,setting_index){
	try
	{
		if(typeof(setting_index) != "undefined")
		{
			applyEditor(setting_index,element_name);
		}
		else
		{
			applyEditor(1,element_name);
		}
	}catch(ex)
    {
         log_exceptions(" Method: - create_event_loadEditor " + ex.message);
    }
}
