// JavaScript Document
$(function(){
	$('.tiny_content img').each(function(){
		var $this = $(this);
		var imagefloat = $this.css('float');
		var imagestyle = '';
		var imageclass = $this.attr('class');
		$this.removeAttr('class');
		if((imagefloat == 'left') || (imagefloat == 'right')){
			var imagestyle = $this.attr('style');
			$this.removeAttr('style');
			var floatmargin = '';
			if(imagefloat == 'left'){
				floatmargin = 'margin: 5px 10px 5px 0;'		
			}else{
				floatmargin = 'margin: 5px 0 5px 10px;'
			}
		}else{
			imagestyle = 'margin-right: auto; margin-left: auto;';
		}	
		
		
		
		
		
		var width = $this.width();
		var $parent = $this.parent();
		var tagname = $parent.get(0).tagName;
		if(tagname == 'P'){
			$this.insertBefore($parent);
		}
		$this.wrap('<div class="caption '+imageclass+'" style="width: '+width+'px; '+imagestyle+' '+floatmargin+'"><\/div>').after('<div>' + $this.attr('title') + '<\/div>');
		$('#message').html('length: '+width);
	});	
	
});


       
        // Theme options
        //theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
       // theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
       // theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
       // theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
       
