/* $Id: ParserStyle.js,v 1.1 2004/08/24 15:08:07 jane Exp $ */

function ParserStyle(sStyles) {
	this.style = new Object();
	var vItems = String(sStyles).split(';');
	var sProperties;
	for (var i = 0; i < vItems.length; i++) {
		sProperties = vItems[i];
		var vProperty = sProperties.split(':');
		var sPropertyName, sPropertyValue;
		if (vProperty.length == 2) {
			sPropertyName = trim(vProperty[0]);
			sPropertyValue = trim(vProperty[1]);
			try {
				eval('this.style.' + sPropertyName + ' = ' + '"' + sPropertyValue + '"');
			}
			catch(e){}
		}
	}
	this.length = getStylesItemsLength;
	this.items = getStyleItemValue;
}

function getStylesItemsLength() {
	var length = 0;
	var sPropertyName;
	for (sPropertyName in this.style) length++;
	return length;
}

function getStyleItemValue(ind) {
	var vValue;
	if (isFinite(ind)) {
		if (ind >= 0) {
			var sPropertyName;
			for (sPropertyName in this.style) {
				ind--;
				if (ind < 0) {
					vValue = eval('this.style.' + sPropertyName);
					break;
				}
			}
		}
	}
	else {
		try {
			vValue = eval('this.style.' + ind);
		}
		catch(e){}
	}
	return vValue;
} 

