Dropdown = function(obj,form,field,sendform){

	this.init(obj,form,field,sendform);

	if (document.all) {

		document.body.attachEvent("onclick",function(e){if (e.srcElement.className.indexOf("dropdown") == -1){$(obj+"Content").style.display = "none"}});

	} else {

		document.body.addEventListener("mousedown",function(e){ if (e.target.className.indexOf("dropdown") == -1){$(obj+"Content").style.display = "none"}},false);

	}

}

var d = Dropdown.prototype;



d.init = function(obj,form,field,sendform){	

	if (!arguments.length) return;

	this.obj = obj;

	this.form = form;

	this.field = field;

	this.sendform = sendform;

	for (i=0;i<$(this.obj+"Content").childNodes.length;i++) {

		if ($(this.obj+"Content").childNodes[i].tagName == "DIV") {

			if (document.all) {

				$(this.obj+"Content").childNodes[i].attachEvent("onmouseover",function(e){e.srcElement.className = 'dropdownContentItemHover'});

				$(this.obj+"Content").childNodes[i].attachEvent("onmouseout",function(e){e.srcElement.className = 'dropdownContentItem'});

			} else  {

				$(this.obj+"Content").childNodes[i].addEventListener("mouseover",function(event){this.className = 'dropdownContentItemHover'},false);

				$(this.obj+"Content").childNodes[i].addEventListener("mouseout",function(event){this.className = 'dropdownContentItem'},false);

			}

		}

	}

}



d.expand = function(){	

	$(this.obj+"Content").style.display = $(this.obj+"Content").style.display == 'block' ? 'none' : 'block';

}



d.collapse = function(item,formvalue){

	this.item = item;

	$(this.obj+"Label").innerHTML = this.item.innerHTML.length > 16 ? this.item.innerHTML.substr(0,16)+"..." : this.item.innerHTML ;

	$(this.obj+"Content").style.display = 'none';

	document.forms[this.form+"Form"].elements[this.field].value = formvalue;

	if (this.sendform) {

	//submit the form

	}

}
