﻿jQuery.fn.clearSelect = function() {
	 return this.each(function() {
	 	 if (this.tagName == 'SELECT')
	 	 	 this.options.length = 0;
	 });
}

jQuery.fn.fillSelectWithDefault = function(data, defaultText) {
	 return this.each(function() {
	 	 if (this.tagName == 'SELECT') {
	 	 	 var dropdownList = this;

	 	 	 var option = new Option(defaultText, "0");
	 	 	 if (jQuery.browser.msie) {
	 	 	 	 dropdownList.add(option);
	 	 	 }
	 	 	 else {
	 	 	 	 dropdownList.add(option, null);
	 	 	 }

	 	 	 jQuery.each(data, function(index, item) {

	 	 	 	 option = new Option(item.Text, item.Value);

	 	 	 	 if (jQuery.browser.msie) {
	 	 	 	 	 dropdownList.add(option);
	 	 	 	 }
	 	 	 	 else {
	 	 	 	 	 dropdownList.add(option, null);
	 	 	 	 }
	 	 	 });
	 	 }
	 });
}

jQuery.fn.fillSelect = function(data) {
	 return this.each(function() {
	 	 if (this.tagName == 'SELECT') {
	 	 	 var dropdownList = this;

	 	 	 jQuery.each(data, function(index, item) {

	 	 	 	 option = new Option(item.Text, item.Value);

	 	 	 	 if (jQuery.browser.msie) {
	 	 	 	 	 dropdownList.add(option);
	 	 	 	 }
	 	 	 	 else {
	 	 	 	 	 dropdownList.add(option, null);
	 	 	 	 }
	 	 	 });
	 	 }
	 });
}
