var MarkupParser = function() {

	this.markupTags =	{	bold: 		[ 'b', 'strong' ],
							italic:		[ 'i', 'em'],
							strike:		[ 'strike' ],
							underline:	[ 'u' ]
						};

	// Get all markup on an element, recursive
	this.getAllMarkup = function(element)
	{
		var current = element;
		var props = [];
		var r_level = 0;
		
		// Iterate recursively though the element's parents till we find the end of the document
		while (current != undefined && current != null)
		{
			// Get the markup for the current element
			this.getMarkup(current, props);
			
			// Iterate to parent
			current = current.parentNode;
			
			r_level++;
			if (r_level > 20)
			{
				alert('Markup parsing cancelled: level too deep!');
				break;
			}
		}
		
		// Return property list
		return props;
	}
						
	// Gets all markup applied on a single element
	this.getMarkup = function(element, props)
	{
		if (!element.style)
		{
			return;
		}
	
		// Get node type name
		var nodeName = element.nodeName.toLowerCase();
		
		// Test for HTML markup tags
		if (this.markupTags.bold.inArray(nodeName) || element.style.fontWeight.contains('bold'))
			this.addProperty(props, 'bold');
		if (this.markupTags.italic.inArray(nodeName) || element.style.fontStyle.contains('italic'))
			this.addProperty(props, 'italic');
		if (this.markupTags.strike.inArray(nodeName) || element.style.textDecoration.contains('line-through'))
			this.addProperty(props, 'strike');
		if (this.markupTags.underline.inArray(nodeName) || element.style.textDecoration.contains('underline'))
			this.addProperty(props, 'underline');
	};
	
	// Adds a markup property to the property list
	this.addProperty = function(props, propertyName)
	{
		var i = props.length;
		
		// Property already in array?
		if (!props.inArray(propertyName))
		{
			// No.
			props[props.length] = propertyName;
		}
	};
}
