BT.ns(function() {with(BT) {
	Dropdown = Class.create({
		initialize: function(options) {
			
			this.setOptions(options); //initialize the default options

			this.dropdown = $(this.options.dropdownContainer);
			//var isSelected = dropdown.hasClassName(this.options.selectedClass);
			this.hitArea = this.getHitArea();
			this.list = this.getList();
			
			this.list.hide();
			
			Event.observe(this.hitArea, this.options.mouseBehavior, this.showList.bindAsEventListener(this));
			Event.observe(this.dropdown, "mouseout", this.hideList.bindAsEventListener(this));
	
		},
	
		// hit area should be a className and should follow the format "hitAreaPrefix_dropdownContainer"
		getHitArea: function() {
			return $$("."+this.options.dropdownHitAreaPrefix + "_" + this.dropdown.id)[0];
		},
		
		// list should be an id and should follow the format "listPrefix_dropdownContainer"
		getList: function() {
			return $(this.options.dropdownListPrefix + "_" + this.dropdown.id);
		},
		
		//shows list when mouseBehavior on hitarea
		showList: function(event) {
			this.dropdown.addClassName(this.options.selectedClass);
			this.list.show();	
		},
		
		//hides list when mouseout on container
		hideList: function(event) {
			if(Prototype.Browser.IE){
				if( !event.toElement.childOf(this.dropdown) && event.toElement != this.dropdown ){
					this.list.hide();
					this.dropdown.removeClassName(this.options.selectedClass);
				}
			} else {
				if( !event.relatedTarget.descendantOf(this.dropdown) ){
					this.list.hide();
					this.dropdown.removeClassName(this.options.selectedClass);
				}
			}
			
		},
		
		setOptions: function (options) {
		
			this.options = {
				dropdownContainer: 'dropdown',
				mouseBehavior: 'mouseover',
				dropdownHitAreaPrefix: 'hit',
				dropdownListPrefix: 'list',
				selectedClass: 'selected_hover'
			};
			Object.extend(this.options, options || {});
		}
	});
	
}});