/**
 * method list: addOption(s), subOption(s)
 */
jQuery.fn.addOption = function() {
	var val,txt,op;
	switch(arguments.length) {
		case 0:
			return this;
		case 1:
			val = txt = arguments[0];
			break;
		default:
			val = arguments[0];
			txt = arguments[1];
	} 

	this.each(function(){
		if(this.nodeName.toLowerCase() != "select") return;

		op = document.createElement("option");
		op.value = val;
		op.text = txt;

		this.options.add(op);
	});

	return this;
}

jQuery.fn.addOptions = function(ops, allowIndex) { 
	if(arguments.length == 0 | typeof(arguments[0]) != 'object') return this;

	if(ops.length) {
		for(var i = 0;i < ops.length;i++) {
			this.addOption(allowIndex ? i : ops[i], ops[i]);	
		}
	} else {
		for(var i in ops) this.addOption(i, ops[i]);
	}

	return this;
}

jQuery.fn.subOption = function(v, byIndex) {
	if(arguments.length == 0) return this;
	if(byIndex) this.each(function() {
		this.remove(v);
	});	
	jQuery("option[@value="+ v +"]", this).remove();
}

jQuery.fn.subOptions = function() {
	if(arguments.length == 0) {
		this.each(function(){
			this.options.length = 0;
		});
	} else {
		if(typeof(arguments[0]) != 'object') return this;
		var o = arguments[0];
		for(var i=0; i<o.length; i++) this.subOption(o[i]);
	}

	return this;
}