﻿function StripHtml(sHtml)
			{
				//alert('zapping!');
				var oldHTML = sHtml;
				var newHTML = '';
				var msg;
				var pos;
				var end;
							
				oldHTML = oldHTML.replace(/<\/p>/gi,'~!!BR!!~~!!BR!!~');
				oldHTML = oldHTML.replace(/<((br|ul|ol|li)[^>]*)>/gi,'~!!$1!!~');
				oldHTML = oldHTML.replace(/<\/((ul|ol|li)[^>]*)>/gi,'~!!/$1!!~');
			
				pos = oldHTML.search('<');
				if( pos == -1 )	// no html tags found
				{	newHTML = oldHTML;	}
							
				while( pos != -1 )
				{
					if( pos == 0 )
					{
						end = oldHTML.search('>');
						oldHTML = oldHTML.slice(end+1);
					}
					else
					{
						newHTML += oldHTML.slice(0,pos);
						end = oldHTML.search('>');
						oldHTML = oldHTML.slice(end+1);
					}
			
					pos = oldHTML.search('<');
					if( pos == -1 )
						newHTML += oldHTML;
				}
			
				newHTML = newHTML.replace(/~!!/g,'<');
				newHTML = newHTML.replace(/!!~/g,'>');
				if( newHTML.length > 0 )
					while( newHTML.lastIndexOf('>') == (newHTML.length-1) )
					{
						// find <
						pos = 1;
						while( newHTML.substring((newHTML.length-pos), ((newHTML.length-pos)+1)) != '<' )
							pos++;
										
						newHTML = newHTML.slice(0, (newHTML.length-pos));
					}
			
				return newHTML;
			}

