function clear_form_elements(frm) {
	frm.find(':input').each(function() {
		switch(this.type) {
			case 'password':
			case 'select-multiple':
			case 'select-one':
			case 'text':
			case 'textarea':
				$(this).val('');
				break;
			case 'checkbox':
			case 'radio':
				this.checked = false;
		}
	});
}

(function($) {
    $.fn.emptySelect = function(keepBlank) {
        return this.each(function(){
            if (this.tagName=='SELECT') {
                if(this.options.length > 0) {
                    if(keepBlank) {
                        this.options.length = 1;
                    }
                    else {
                        this.options.length = 0;
                    }
                }
            }
        });
    }

    $.fn.loadSelect = function(optionsDataArray, keepBlank) {
        return this.emptySelect(keepBlank).each(function(){
            if (this.tagName=='SELECT') {
                var selectElement = this;
                $.each(optionsDataArray,function(index,optionData){
                    var option = new Option(optionData.caption, optionData.value);
                    if ($.browser.msie) {
                        selectElement.add(option);
                    }
                    else {
                        selectElement.add(option,null);
                    }
                });
            }
        });
    }
})(jQuery);

