function FormSerializerLite ()
{
}

FormSerializerLite.prototype.serialize = function (form)
{
    var s = new Serializer();
    var formData = new Object();
    var elements = form.getElementsByTagName('*');

    for( var i = 0; i < elements.length; i++ )
    {
        if(elements[i] && !elements[i].disabled && elements[i].name)
        {
            var key = elements[i].name, value = this.getValue(elements[i]);
            if( value != undefined )
            {
				if (formData[key]) {
					if (formData[key].constructor != Array) {
						formData[key] = [formData[key]];
					};
					formData[key].push(value);
				} else {
					formData[key] = value;
				};
            }
        }
    }

    return s.serialize(formData);
}

FormSerializerLite.prototype.getValue = function (element)
{
	element = Element.get(element);
	var method = element.tagName.toLowerCase();
	return this.Serializers[method](element);
}

FormSerializerLite.prototype.Serializers = function() {};

FormSerializerLite.prototype.Serializers.input = function(element) {
	switch (element.type.toLowerCase()) {
		case 'checkbox':
		case 'radio':
			return this.inputSelector(element);
		default:
			return this.textarea(element);
	};
};

FormSerializerLite.prototype.Serializers.inputSelector = function(element) {
	return element.checked ? element.value : null;
}

FormSerializerLite.prototype.Serializers.textarea = function(element) {
	return element.value;
}

FormSerializerLite.prototype.Serializers.select = function(element) {
	return this[element.type == 'select-one' ? 'selectOne' : 'selectMany'](element);
}

FormSerializerLite.prototype.Serializers.selectOne = function(element)	{
	var index = element.selectedIndex;
	return index >= 0 ? this.optionValue(element.options[index]) : null;
}

FormSerializerLite.prototype.Serializers.selectMany = function(element) {
	var values, length = element.length;
	if (!length) {
		return null;
	};

	for (var i = 0, values = []; i < length; i++) {
		var opt = element.options[i];
		if (opt.selected) {
			values.push(this.optionValue(opt));
		};
	};
	return values;
};

FormSerializerLite.prototype.Serializers.optionValue = function(opt) {
	//return opt.hasAttribute('value') ? opt.value : opt.text;
	// IE doesn't support el.hasAttribute
	return opt.value;
};

