var cx = 0;
var h=1;
$.fn.tinymce = function(options){
	
	this.each(function(){
		
		tinyMCE.execCommand("mceAddControl", true, this.id);
		x = setTimeout("check_tiny()", 500);
		
    });

	return true;
}


check_tiny = function(){
	if($('.mceStatusbar').length){
		$('.mceStatusbar > div').hide();
		$('.mceStatusbar, .mceStatusbar > a').css('height','10px');
		h=$('.mceIframeContainer > iframe:eq('+cx+')').height();
		$('.mceIframeContainer > iframe:eq('+cx+')').height(h+3);
		$('.mceResize').css('backgroundPosition','-800px -10px');
		cx++;
	}else{
		x = setTimeout("check_tiny()", 500);
	}

}

function initMCE(){
	
    tinyMCE.init({ mode : "none",
	   theme : "advanced",
	   skin : "thebigreason",
	   plugins : "paste,advhr,style,table,tinyBrowser,advlink,advimage",
	   theme_advanced_layout_manager : "SimpleLayout",
	   theme_advanced_buttons1: "pasteword,charmap,advhr,separator,formatselect,separator,bold,italic,separator,fontsizeselect,link,unlink,separator,image,table,bullist,numlist,undo,redo,code",
	   theme_advanced_buttons2: "",
	   theme_advanced_buttons3: "",
	   theme_advanced_toolbar_location : "top",
	   theme_advanced_statusbar_location : "bottom",
	   theme_advanced_resizing : true,
	   font_size_style_values : "10px,11px,12px,13px,14px,15px,16px",
	   convert_urls : false,
	   relative_urls : false,
	   content_css : "/css/tiny.css",
	   file_browser_callback : "tinyBrowser",
	   theme_advanced_toolbar_align : "left"});
}
// initialize tiny mce
initMCE();

