//<script>
document.writeln('<style type="text/css">');
document.writeln('<!-- ');
document.writeln('#co_combobox_container {position:relative;}');
document.writeln('#co_combobox {overflow-x:hidden;overflow-y:auto;position:absolute;top:20px;left:-1px;z-index:99;background-color:#ffffff;border-width:1px;border-style:solid;padding:1px;}');
document.writeln('#co_combobox_container input {border:0px none;cursor:default;float:left;}');
document.writeln('#co_combobox_container .downarrow {background-image:url(/images/global/bullets/blue_gray_down.gif);background-color:#dddddd;background-position:center center;background-repeat:no-repeat;float:right;width:18px;height:20px;cursor:pointer;}');
document.writeln('#co_combobox a {text-decoration:none;height:15px;font-size:12px;padding:2px;padding-left:5px;display:block;}');
document.writeln('#co_combobox a:hover {border-width:1px;border-style:solid;padding:1px;padding-left:4px;}');
document.writeln(' -->');
document.writeln('</style>');
function Co_ComboBox(Name,doc,allow_edit){this.Name=Name;this.Document=doc||document;this.LimitToList=true;this.MaxVisibleDropItems=8;this.ItemHeight=19;this.Value=this.value="";this.Items=[];this.Options=[];this.selectedIndex=this.SelectedIndex=-1;this.Visible=false;this.Loaded=false;this.Allow_Edit=allow_edit||false;}
Co_ComboBox.prototype.Generate=function(container_name, props)
{
	var o=this.Document.getElementById(container_name);
	if (typeof(o)=="undefined") {alert("Container not found.");return;}
	this.Field=this.Document.createElement("INPUT");this.Field.type="text";this.Field.readonly=this.Allow_Edit;this.ItemHeight=props.itemHeight||this.ItemHeight;
	this.HiddenField=this.Document.createElement("INPUT");this.HiddenField.type="hidden";this.HiddenField.name=this.HiddenField.Name=this.Name
	if(!this.Allow_Edit){this.Field.style.cursor="pointer";}
	this.DisplayName=props.DisplayName;
	if (typeof(props.defaultIndex)=="undefined")props.defaultIndex=-1;
	if (props.defaultIndex==-1)this.DefaultIndex=0;else if (props.defaultIndex>0) this.DefaultIndex=props.defaultIndex; else if (typeof(this.DefaultIndex)=="undefined")this.DefaultIndex=0;
	
	this.Container=o.appendChild(this.Document.createElement("DIV"));
	this.Container.id="co_combobox_container";
	this.Field=this.Container.appendChild(this.Field);
	this.HiddenField=this.Container.appendChild(this.HiddenField);
	
	this.DownArrow=this.Container.appendChild(this.Document.createElement("DIV"));
	
	this.Field.name=this.Field.Name=this.Name+"_val";this.Field.onselect=this.Field.onmousedown=function(e){document.body.focus();e=window.event||e;e.returnValue=false;return false;};this.Field.onclick=function(e){this.blur();Co_ComboBoxField_OnFocus.apply(this, [e].concat());return false;};this.Field.onkeydown=Co_ComboBoxField_OnKeyDown;this.Field.onkeyup=Co_ComboBoxField_OnKeyUp;this.Field.obj=this.DownArrow.obj=this;this.Field.real_value="";this.Field.setAttribute("readonly", "readonly");
	if (this.DefaultIndex<this.Items.length&&props.defaultIndex>=0){this.Field.value=this.Items[this.DefaultIndex].Text;this.Value=this.Items[this.DefaultIndex].Value;this.HiddenField.value=this.Value;this.selectedIndex=this.SelectedIndex=this.DefaultIndex;}else if (typeof(props.DisplayName)!="undefined") {this.Field.value=props.DisplayName;}
	
	this.DownArrow.className="downarrow";this.DownArrow.onclick=Co_ComboBox_DownArrow_Click;
	this.Object=this.Container.appendChild(this.Document.createElement("DIV"));this.Object.id="co_combobox";this.Object.style.display="none";
	
	if (props.width)this.Container.style.width=this.Object.style.width=props.width+"px";
	
	this.Field.style.width=this.Object.style.width.replace("px", "")-22 + "px";

	if (o.clientHeight>0)this.Object.style.top=o.clientHeight+"px"; else if (props.collapsedHeight)this.Object.style.top=props.collapsedHeight+"px";
	this.GenerateItems();
	
	if (props.height)
		this.Object.style.height=props.height+"px";
	else 
		this.SetSize();
	this.Loaded=true;
}
Co_ComboBox.prototype.AddItem=function(text, value){
	
	this.Items.push({Text:text,Value:value});
	if (this.Loaded){
		var o=this.Object.appendChild(this.Document.createElement("A"));
		o.className="item";
		o.value=value;
		o.index=this.Items.length-1;
		o.setAttribute("index",this.Items.length-1);
		o.selected=false;
		o.obj=this;
		o.href="#";
		o.innerHTML=text;
		o.onclick=Co_ComboBoxItem_Click;
		o.onMouseOver=Co_ComboBoxItem_Over;
		o.onMouseOut=Co_ComboBoxItem_Out;
		this.Options.push(o);
		this.SetSize();
	}
	if(!this.Loaded) return;
	if(this.SelectedIndex<0||this.SelectedIndex>=this.Items.length) return;
	this.Field.value=this.Items[this.SelectedIndex].Text;
	this.Value=this.Items[this.SelectedIndex].Value;
	this.HiddenField.value=this.Value;
}
Co_ComboBox.prototype.AddItemAt=function(text, value, idx){if (typeof(idx)=="undefined") {alert("No index supplied.");return;};this.Items.splice(idx, 0, {Text:text, Value:value});if (this.Loaded){var o=this.Object.appendChild(this.Document.createElement("A"));o.className="item";o.value=value;o.index=this.Items.length-1;o.setAttribute("index",i);o.selected=false;o.obj=this;o.href="javascript:;";o.innerHTML=text;o.onclick=Co_ComboBoxItem_Click;o.onMouseOver=Co_ComboBoxItem_Over;o.onMouseOut=Co_ComboBoxItem_Out;this.Options.splice(idx, 0, o);this.SetSize();}}
Co_ComboBox.prototype.RemoveItemAt=function(idx){if (typeof(idx)=="undefined") {alert("No index supplied.");return;};this.Items.splice(idx, 1);if (this.Loaded){var o=this.Options.splice(idx, 1);o.parentNode.removeChild(o);}this.SetSize();}
Co_ComboBox.prototype.Clear=function(){
	var o;
	for(var i=this.Options.length-1;i>=0;i--){
		o=this.Options.pop();
		this.Items.pop();
		o.parentNode.removeChild(o);
	};
	this.selectedIndex=this.DefaultIndex;
	this.Value="";
	this.Field.value=this.DisplayName||this.Name;
	this.HiddenField.value = "";
}
Co_ComboBox.prototype.GenerateItems=function(){
	if (this.Items.length == 0) return;
	var o;
	for (var i=0;i<this.Items.length;i++){
		o=this.Object.appendChild(this.Document.createElement("A"));
		o.className="item";
		o.value=this.Items[i].Value;
		o.index=i;
		o.setAttribute("index",i);
		o.selected=false;
		o.obj=this;
		o.href="#";
		o.innerHTML=this.Items[i].Text;
		o.onclick=Co_ComboBoxItem_Click;
		o.onMouseOver=Co_ComboBoxItem_Over;
		o.onMouseOut=Co_ComboBoxItem_Out;
		this.Options.push(o);
	}
}
Co_ComboBox.prototype.SetSize=function(){
	if (this.MaxVisibleDropItems >= this.Items.length)
		this.Object.style.height=(this.ItemHeight*this.Items.length)+"px";
	else 
		this.Object.style.height=(this.ItemHeight*this.MaxVisibleDropItems)+"px";
}
Co_ComboBox.prototype.Select=function(idx) {
	if (typeof(this.onBeforeChange)=="function"){this.onBeforeChange();}
	if (idx==this.selectedIndex){this.Hide();return false;}
	var o=this.Options[idx];
	if(typeof(o)=="undefined")return false;
	this.Field.value=o.firstChild.data; //gets the textNode and then the content... - this is the alternative to "innerText";
	this.Value=o.value;
	this.HiddenField.value=this.Value;
	this.selectedIndex=this.SelectedIndex=idx;
	this.Hide();
	if(typeof(this.onChange)=="function"){return this.onChange();}
	return false;
}
Co_ComboBox.prototype.Show=function(){
	Co_Tools.ToggleSelect_if_IE(false, true);
	this.Object.style.display="block";
	this.Visible=true;
	Co_Tools.AddEventListener(document, "click", this.ClickHide, null, this);
}
Co_ComboBox.prototype.Hide=function(){Co_Tools.ToggleSelect_if_IE(true, true);this.Object.style.display="none";this.Visible=false;Co_Tools.RemoveEventListener(document, "click", this.ClickHide);}
Co_ComboBox.prototype.ClickHide=function(e)
{
	e=e||window.event;
	var o=e.srcElement||e.target;
	if(o.nodeType==3)o=o.parentNode;
	while (o) {
		if (o.nodeName=="BODY") break;
		if (o==this.Object||o==this.Container)return;
		o=o.parentNode;
	}
	this.Hide();
}
Co_ComboBox.prototype.Find=function(s)
{
	var regX=new RegExp('<a[^>]*index\=\"?([0-9]*)\"?[^>]*>('+s+'[^<]*)</A>','ig');
	regX.lastIndex=1;
	var match=regX.exec(this.Object.innerHTML);
	if (match) {
		this.selectedIndex=match[1];
		this.Field.value=match[2];
		if (Co_BrowserInfo.IsIE) {
			var oSel=this.Field.createTextRange();
			oSel.collapse(true);
			oSel.moveStart("character", s.length);
			oSel.moveEnd("character", this.Field.value.length);
			oSel.select();
		}
		else if (typeof(this.Field.setSelectionRange)=="function") {
			this.Field.focus();
			this.Field.setSelectionRange(s.length, this.Field.value.length);
		}
		return true;
	}
}
var Co_ComboBoxField_OnFocus=function(e){if (this.obj.Visible)this.obj.Hide(); else this.obj.Show();}
var Co_ComboBoxField_OnBlur=function(e){this.obj.Hide();}
var Co_ComboBoxField_OnKeyUp=function(e){}
var Co_ComboBoxField_OnKeyDown=function(e)
{
	return true;
	e=e||window.event;
	if ((e.keyCode||e.which)<65){return true;}
	this.real_value+=String.fromCharCode(e.keyCode||e.which);
	if (this.obj.Find(this.real_value)){return false;}
}
var Co_ComboBox_DownArrow_Click=function() {if(this.obj.Visible)this.obj.Hide();else this.obj.Show();}
var Co_ComboBoxItem_Click=function(){return this.obj.Select(this.index);}
var Co_ComboBoxItem_Over=function(){this.className+=' over';}
var Co_ComboBoxItem_Out=function(){this.className='item';}
//</script>
