var rate_flag = false;
function rating(id,action,user_id,post,imgpath,singlePid,siteSinglePid,profilePid,site_id) {
	/*new Ajax.Updater('test-'+id, 'index.php?eID=dg_content_ajax', {
		asynchronous: true,
		method: 'post',
		parameters: 'id=' + id + '&action=' + action
	});*/

	if(!rate_flag){
		rate_flag = true;
		$("#rate-"+id).hide();
		$("#sign-"+id).hide();
		if(post)
			$("#loader_post-"+id).show();
		else
			$("#loader-"+id).show();
			
		$.ajax({
			   type: "POST",
			   url: 'index.php?eID=dg_content_ajax',
			   asynchronous: true,
			   data: 'id=' + id + '&action=' + action + '&user_id=' + user_id + '&post=' + post + '&imgpath=' + imgpath + '&single_p=' + singlePid + '&s_single_p=' + siteSinglePid + '&profile_p=' + profilePid + '&s_id=' + site_id,
			   success: function(msg){
			   		var arr = msg.split('#');
			   		if(arr[0] > 0)
			   			sign = '+';
			   		else 
			   			sign = '';
		     		
		     		if(post)
						$("#loader_post-"+id).hide();
					else
						$("#loader-"+id).hide();
						
		     		$("#sign-"+id).get(0).innerHTML = sign;
		     		$("#sign-"+id).show();
		     		$("#rate-"+id).get(0).innerHTML = arr[0];
		     		$("#rate-"+id).show();	     			     		
		     		$("#up-"+id).get(0).innerHTML = arr[1];
		     		$("#down-"+id).get(0).innerHTML = arr[2];
		     		rate_flag = false;
				}
			 });
    }
}

function stick(id,lang) {
	/*new Ajax.Updater('stick-'+id, 'index.php?eID=dg_content_ajax', {
		asynchronous: true,
		method: 'post',
		parameters: 'id=' + id
	});*/
	
	$("#stick-"+id).hide();
	$("#loader-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang='+lang ,
		   success: function(msg){
	     		$("#loader-"+id).hide();
	     		$("#stick-"+id).get(0).innerHTML = msg;
	     		$("#stick-"+id).show();	     		
			}
		 });
}

function setBanner(id,lang) {
	$("#isbanner-"+id).hide();
	$("#loader-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang=' + lang + '&fnc_name=setBanner',
		   success: function(msg){
	     		$("#loader-"+id).hide();
	     		$("#isbanner-"+id).get(0).innerHTML = msg;
	     		$("#isbanner-"+id).show();	     		
			}
		 });
}

function deletePost(id,lang,del_message,undel_message) {
	/*new Ajax.Updater('del-'+id, 'index.php?eID=dg_content_ajax', {
		asynchronous: true,
		method: 'post',
		parameters: 'id=' + id + '&fnc_name=deletePost'
	});  */
	var name=$("#icon-"+id).get(0).name;

	if(name=='Delete')
	{	
	    var response = window.confirm(del_message);
		if (!response) 
		{
		    return false;
		}
	}
	if(name=='Undelete')
	{	
	    var response = window.confirm(undel_message);
		if (!response) 
		{
		    return false;
		}
	}	
	$("#del-"+id).hide();
	$("#loader-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang='+lang+'&fnc_name=deletePost' ,
		   success: function(msg){
	     		$("#loader-"+id).hide();
	     		$("#del-"+id).get(0).innerHTML = msg;
	     		$("#del-"+id).show();	     		
			}
		 });
}

function deleteComment(id) {
	$("#del-"+id).hide();
	$("#loader-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&fnc_name=deleteComment' ,
		   success: function(msg){
	     		$("#loader-"+id).hide();
	     		$("#del-"+id).get(0).innerHTML = msg;
	     		$("#del-"+id).show();	     		
			}
		 });
}

/*function inappropComment(id) {
	$("#inappropCom-"+id).hide();
	$("#loaderInap-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&fnc_name=inappropComment' ,
		   success: function(msg){
	     		$("#loaderInap-"+id).hide();
	     		$("#inappropCom-"+id).get(0).innerHTML = msg;
	     		$("#inappropCom-"+id).show();	     		
			}
		 });
}*/

function lockPost(id,lang) {
	/*new Ajax.Updater('lock-'+id, 'index.php?eID=dg_content_ajax', {
		asynchronous: true,
		method: 'post',
		parameters: 'id=' + id + '&fnc_name=lockPost'
	});*/
	
	$("#lock-"+id).hide();
	$("#loader-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id +'&lang='+lang+'&fnc_name=lockPost' ,
		   success: function(msg){
	     		$("#loader-"+id).hide();
	     		$("#lock-"+id).get(0).innerHTML = msg;
	     		$("#lock-"+id).show();	     		
			}
		 });
}

function savePost(id,lang,icon) {
	$("#save-"+id).hide();
	$("#loader-save-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang='+lang+'&icon='+icon+'&fnc_name=savePost' ,
		   success: function(msg){
	     		$("#loader-save-"+id).hide();
	     		$("#save-"+id).get(0).innerHTML = msg;
	     		$("#save-"+id).show();	     		
			}
		 });
}


function watchPost(id,lang) {
	$("#watch-"+id).hide();
	$("#loader-watch-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang='+lang+'&fnc_name=watchPost' ,
		   success: function(msg){
	     		$("#loader-watch-"+id).hide();
	     		$("#watch-"+id).get(0).innerHTML = msg;
	     		$("#watch-"+id).show();	     		
			}
		 });
}

function removeFromRecent(id,user_id,lang) {
	$("#recentlyviewed-"+id).hide();
	$("#loader-recentlyviewed-"+id).show();
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id + '&lang='+lang+'&user_id='+user_id+'&fnc_name=removeFromRecent' ,
		   success: function(msg){
	     		$("#loader-recentlyviewed-"+id).hide();
	     		$("#recentlyviewed-"+id).get(0).innerHTML = msg;
	     		$("#recentlyviewed-"+id).show();	     		
			}
		 });
}

function inappropPost(id,user_id,page_id,site_mp,ll,comment_text) {
	$("#inapprop_comment").slideUp("slow");	
	$("#inapprop-"+id).hide();
	$("#inapprop_loader-"+id).show();
	params = 'post_id=' + id + '&inapprop_user_id=' + user_id + '&type=88&L=' + ll;
	if(comment_text!='')
		params = params + '&inapprop_comment=' + comment_text;
	if(site_mp!='')
		params = params + '&MP=' + site_mp;
	$.ajax({
		   type: "POST",
		   url: '/index.php?id=' + page_id,
		   asynchronous: true,
		   data: params,//'id=' + id + '&user_id=' + user_id + '&inapprop_comment=' + comment_text ,
		   success: function(msg){
	     		$("#inapprop_loader-"+id).hide();
	     		$("#inapprop-"+id).get(0).innerHTML = msg;
	     		$("#inapprop-"+id).show();	  
			}
		 });
}

function closeInappropPost(id,page_id,site_mp) {	
	$(".error_message").slideUp("slow");
	//$("#inapprop_loader-"+id).show();
	if(site_mp!='')
		params = params + '&MP=' + site_mp;
	$.ajax({
		   type: "POST",
		   url: '/index.php?id=' + page_id,
		   asynchronous: true,
		   data: 'post_id=' + id + '&fnc_name=closeInappropPost&type=88' ,
		   success: function(msg){
	     		$("#inapprop_loader-"+id).hide();     		
			}
		 });
}

function inappropPostComment(id,post_id,user_id,page_id,site_mp,ll,comment_text) {
	$("#inappropComm_comment-"+id).slideUp("slow");	
	$("#inappropCom-"+id).hide();
	$("#loaderInap-"+id).show();
	params = 'comm_id='+id+'&post_id=' + post_id + '&inapprop_user_id=' + user_id + '&type=89&L=' + ll;
	if(comment_text!='')
		params = params + '&inapprop_comment=' + comment_text;
	if(site_mp!='')
		params = params + '&MP=' + site_mp;
	$.ajax({
		   type: "POST",
		   url: '/index.php?id=' + page_id,
		   asynchronous: true,
		   data: params,
		   success: function(msg){
	     		$("#loaderInap-"+id).hide();
	     		$("#inappropCom-"+id).get(0).innerHTML = msg;
	     		$("#inappropCom-"+id).show();	     		
			}
		 });
}

function closeInappropPostComment(id,page_id,site_mp) {	
	$(".error_message").slideUp("slow");
	//$("#inapprop_loader-"+id).show();
	if(site_mp!='')
		params = params + '&MP=' + site_mp;	
	$.ajax({
		   type: "POST",
		   url: '/index.php?id=' + page_id,
		   asynchronous: true,
		   data: 'post_id=' + id + '&fnc_name=closeInappropPost&type=88' ,
		   success: function(msg){
	     		$("#inapprop_loader-"+id).hide();     		
			}
		 });
}

function gotoExtUrl(id) {
	$.ajax({
		   type: "POST",
		   url: 'index.php?eID=dg_content_ajax',
		   asynchronous: true,
		   data: 'id=' + id  + '&fnc_name=gotoExtUrl',
		   success: function(msg){
	     		return;	     		
			}
		 });
}


function showRTE1(cur,parrentCmment){		
	//--- Get the scroll value from different browsers ---
	var html = document.getElementsByTagName('BODY')[0];
	if (window.pageYOffset){  
		scrollTop = window.pageYOffset 
	} else if(document.documentElement && document.documentElement.scrollTop){ 
		scrollTop = document.documentElement.scrollTop; 
	} else if(document.body){ 
		scrollTop = document.body.scrollTop; 
	}
	//--- Get window height value from different browsers ---
	if(window.innerWidth){ 
		winWidth=window.innerWidth; 
	} else if(document.documentElement && document.documentElement.clientWidth){ 
		winWidth=document.documentElement.clientWidth; 
	} else if(document.body){ 
		winWidth=document.body.clientWidth; 
	}
	
	temp=document.getElementById("dgcontent_parent_comment");
	temp.value=parrentCmment;
	
	var parrentDiv = cur.parentNode;
	parrentDiv=parrentDiv.parentNode;		
	var rte=document.getElementById("dg_comment_rte");
	if(parrentCmment>0)
		parrentDiv.appendChild(rte);
	else
		document.getElementById("dg_add_comment").appendChild(rte);//cur.nextSibling.appendChild(rte);
	//parrentDiv.appendChild(rte);
	
	//calculate RTE open position	
	rte.style.display='';
	//var topPos=parrentDiv.offsetHeight+parrentDiv.offsetTop;
	var topPos=cur.offsetHeight+cur.offsetTop;
	var leftPos=(winWidth/2)-(rte.offsetWidth/2);
	rte.style.display='none';
	
	//open RTE 
	rte.style.display='';
	//new Effect.BlindDown('dg_comment_rte', { duration: 0.2 });
	//add RTE panel
	
	var comment_area;
	comment_area = new nicEditor({buttonList : ['bold','italic','underline','strikethrough','fontSize','ol','ul','image','link','forecolor','bgcolor'], maxHeight: 150, iconsPath : '/typo3/ext/dg_content/res/nicedit/nicEditorIcons.gif'}).panelInstance('comment_textarea');
	//past event
	$(".nicEdit-main").bind('paste', function(e) {
		openDialog('comment_textarea');
	    return false;
	});
	
	/*$('.rte').rte({
		css: 'default.css',
		width: '99%',
		height: 200,
		controls_rte: rte_toolbar,
		controls_html: html_toolbar
	});*/
	
	//rte.style.top=topPos+'px';
	//rte.style.left=leftPos+'px';//cur.offsetLeft;//parrentDiv.offsetLeft+'px'
	//rte.style.zIndex='10001';
	/*$("dg_comment_rte").style.zIndex=50000;
	rte.style.top=String(Math.round((winHeight-rte.offsetHeight)/2)+scrollTop)+'px';
	rte.style.left=String(Math.round((html.clientWidth-rte.offsetWidth)/2))+'px';*/
}

function closeRTE1(){
	var rte=document.getElementById("dg_comment_rte");
	rte.style.display='none';
	//new Effect.BlindUp('dg_comment_rte', { duration: 0.2 });
	//new Effect.Appear('dg_comment_rte', { duration: 0.5,from: 1, to: 0 });
	//$('dg_comment_rte').fade({ duration: 3.0, from: 1, to: 0 });
	
	//bg_div.parentNode.removeChild(bg_div);
	
	//rte=document.getElementById("dg_comment_rte").style.display='none';
	
	//rte.style.display='none';
	/*bod = document.getElementsByTagName('body')[0];
	bod.style.height = '';
	bod.style.overflow = '';
	
	htm = document.getElementsByTagName('html')[0];
	htm.style.height = '';
	htm.style.overflow = '';*/
}

function check_comment1(){
	var editor = nicEditors.findEditor('comment_textarea');
	var text=editor.getContent();
	
	if(text.length>10000){
		$.floatbox({
	        content: "<p>You can not post a comment with more than 10000 chars.</p>",
	        bgConfig: {backgroundColor:"#444",opacity:".40"},
	        boxConfig: {backgroundColor:"#EEE"}
	   	});
		return false;
	}
	clr_text = removeHTMLTags(text);
	if(clr_text=='' && text.indexOf('<img') == -1){
		$.floatbox({
	        content: "<p>You can not post a empty comment.</p>",
	        bgConfig: {backgroundColor:"#444",opacity:".40"},
	        boxConfig: {backgroundColor:"#EEE"}
	   	});
		return false;
	}	
}

/*function openDialog1(){
	var html = document.getElementsByTagName('BODY')[0];
	var mydiv = $("<div id='dialog' title='Paste'>" +
			"<p id='validateTips'>Please paste inside the box.</p>" +
			"<div id='container'>" +
			"<textarea id='plain_textarea' style='width: 500px; height: 150px; border:solid 1px;'></textarea>" +
			"</div><br><label >paste from Word</label>" +
			"<input id='asWord' type='checkbox' onclick='convertToiFame(this);'/></div>");
	mydiv.appendTo("html");
	
	$("#dialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 300,
		width: 530,
		modal: true,
		buttons: {
		  Cancel: function(){
			$(this).dialog('close');			
		  },
		  Ok: function() {
			  checkbox=$("#asWord").get(0);//document.getElementById( 'asWord' )
			  if(checkbox.checked){				  
				  var oFrame = document.getElementById('frmData') ;
				  var oBody ;

				  if ( oFrame.contentDocument )
					  oBody = oFrame.contentDocument.body ;
				  else
					  oBody = oFrame.contentWindow.document.body ;
				  text = oBody.innerHTML;
				  text = CleanWord(text);
			  }
			  else{
				  text = $("#plain_textarea").val();
				  text = HTMLEncode(text);
				  text = ProcessLineBreaks(text);				  
			  }
			  InsertToRTE(text);
		      $(this).dialog('close');
		  }
		},
		close: function() {
			$("#dialog").remove();
		}
	});
	
	$('#dialog').dialog('open');
}

function convertToiFame1(chk){
	var eFrameSpace = document.getElementById( 'container' );
	if(chk.checked){
		sFrameUrl='javascript:void(0)';
		sFrameUrl='javascript:void( (function(){' +
			'document.open() ;' +
			'document.domain=\'' + document.domain + '\' ;' +
			'document.write(\'<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>\') ;' +
			'document.close() ;' +
			'document.body.contentEditable = true ;' +
			'window.focus() ;' +
			'})() )' ;
		//var eFrameSpace = document.getElementById( 'container' );
		$('#container').get(0).innerHTML='<iframe id="frmData" src="' + sFrameUrl + '" ' +' frameborder="0" style="width: 500px; height: 150px; border:solid 1px; background-color: #ffffff"><\/iframe>';
		var oFrame = eFrameSpace.firstChild;
		var oDoc = oFrame.contentWindow.document;
		oDoc.open();
		oDoc.write('<html><head><script>window.onerror = function() { return true ; };<\/script><\/head><body><\/body><\/html>');
		oDoc.close();
		oDoc.designMode = 'on';
		oFrame.contentWindow.focus();
	}
	else{
		$('#container').get(0).innerHTML='<textarea id="plain_textarea" style="width: 500px; height: 150px; border:solid 1px;"></textarea>';
	}
}

function InsertToRTE1(text){
	var editor = nicEditors.findEditor('comment_textarea');
	var rteContent = editor.getContent();
	rteContent=rteContent.substring(0,rteContent.length-4);//clear last <br> added by NicEdit
	
	joinedText = rteContent+text;
	editor.setContent(joinedText);
}

function removeHTMLTags1(text) {
	strInputCode = text.replace(/&(lt|gt);/g, function (strMatch, p1){
	        return (p1 == "lt")? "<" : ">";
	});
	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	
	return strTagStrippedText;
}

function HTMLEncode1( text )
{
	if ( !text )
		return '' ;

	text = text.replace( /&/g, '&amp;' ) ;
	text = text.replace( /</g, '&lt;' ) ;
	text = text.replace( />/g, '&gt;' ) ;

	return text ;
}

function ProcessLineBreaks1(text)
{
	var closeState = 0 ;
	var blockStartTag = "<br />" ;
	var blockEndTag = "" ;
	var strArray = [] ;

	for ( var i = 0 ; i < text.length ; i++ )
	{
		var c = text.charAt( i ) ;
		if ( c == '\r' )
			continue ;

		if ( c != '\n' )
		{
			strArray.push( c ) ;
			continue ;
		}

		if ( closeState && blockEndTag.length )
			strArray.push ( blockEndTag ) ;
		strArray.push( blockStartTag ) ;
		closeState = 1 ;
	}
	return strArray.join( "" ) ;
}*/

function CleanWord1( txt, bIgnoreFont, bRemoveStyles )
{
	var html = txt;//.innerHTML ;
	html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
	html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, '&nbsp;') ;

	// Remove mso-xxx styles.
	html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;

	// Remove margin styles.
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ;
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;

	html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;
	html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;

	html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
	html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;

	// Remove Class attributes
	html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	// Remove styles.
	if ( bRemoveStyles )
		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;

	// Remove style, meta and link tags
	html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' ) ;
	html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' ) ;

	// Remove empty styles.
	html =  html.replace( /\s*style="\s*"/gi, '' ) ;

	html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;

	html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;

	// Remove Lang attributes
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ;

	html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ;

	// Remove XML elements and declarations
	html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;

	// Remove w: tags with contents.
	html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' ) ;

	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
	html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;

	// Remove comments [SF BUG-1481861].
	html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ;

	html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;

	html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;

	// Remove "display:none" tags.
	html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ;

	// Remove language tags
	html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	// Remove onmouseover and onmouseout events (from MS Word comments effect)
	html = html.replace( /<(\w[^>]*) onmouseover="([^\"]*)"([^>]*)/gi, "<$1$3") ;
	html = html.replace( /<(\w[^>]*) onmouseout="([^\"]*)"([^>]*)/gi, "<$1$3") ;
	
	/*html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
	html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
	html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
	html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
	html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
	html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;

	html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;

	// Transform <P> to <DIV>
	var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ;	// Different because of a IE 5.0 error
	html = html.replace( re, '<div$2><\/div>' ) ;

	// Remove empty tags (three times, just to be sure).
	// This also removes any empty anchor
	html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
	html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
	html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;*/
	
	// The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
	html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;

	// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
	html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );
	html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );

	return html ;
}
