var Dropdown = function(liElement, construct) {
	var _listItem;
	var _anchor;
	var _element;
	var _dropdownElement;
	
	var _anchorHover = false;
	var _dropdownHover = false;
	
	var _animate = 200;
	
	var _over = function() {
		_dropdownElement.fadeIn(_animate);
	};
	var _out = function() {
		_dropdownElement.fadeOut(_animate);
	};
	var __construct = function(element, construct) {
		if(typeof element != "object") {
			throw "Invalid argument: element value must contain a jQuery element with a switch class";
		}
		
		if(element.length > 0 && element.hasClass('navItem')) {
			_element = element;
		}
		
		else if(element.length == 0) {
			throw "Invalid argument: required navItem element could not be found.";
		}
		else if(!element.hasClass('navItem')) {
			throw "Invalid argument: required navItem element does not contain the required CSS navItem class.";
		}
		else {
			throw "Invalid argument: element";
		}
		
		_listItem = element;
		_anchor = _element.find('a.navAnchor');
		
		if(!_anchor.length) {
			throw "Runtime exception: Dropdown anchor could not be found.";
		}
		
		if(construct) {
			_listItem.append('\
			<div class="navDropdown lheight26 fsize12" style="display:none">\
				<div class="navDropdownArrow">\
				</div>\
				<div class="navDropdownContent">\
				</div>\
			</div>\
			');
		}
		
		_dropdownElement = _listItem.find('.navDropdown');
		
		if(!_dropdownElement.length) {
			throw "Runtime exception: Dropdown element could not be found.";
		}
		
		_dropdownElement.css("display","none");
	};
	
	this.add = function(name, Anchor, Class) {
		_dropdownElement.find('.navDropdownContent').append('\
			<a class="'+Class+'" href="'+Anchor+'">'+name+'</a>\
		');
	};
	
	this.bind = function() {
		_anchor.bind("mouseover", function() {
			_anchorHover = true;
			
			setTimeout(function() {
				if(!_dropdownHover  && _anchorHover) {
					_over();
				}
			}, 150);
		});
		_anchor.bind("mouseout", function() {
			_anchorHover = false;
			
			setTimeout(function() {
				if(!_dropdownHover && !_anchorHover) {
					_out();
				}
			}, 150);
		});
		
		_dropdownElement.bind("mouseover", function() {
			_dropdownHover = true;
		});
		_dropdownElement.bind("mouseout", function() {
			_dropdownHover = false;
			
			setTimeout(function() {
				if(!_dropdownHover && !_anchorHover) {
					_out();
				}
			}, 150);
		});
	};
	this.unbind = function() {
		_anchor.unbind("mouseover");
		_anchor.unbind("mouseout");
	};
	
	this.setAnimation = function(ms) {
		_animate = ms;
	};
	this.getAnimation = function() {
		return _animate;
	};
	
	__construct(liElement, construct);
};
