var LBKSString = "";
var LBKSStatus = "";

function ListBoxKeySearch_KeyDown(evnt)
{
	var e = window.event == null ? evnt : event;
	
	switch (e.keyCode)
	{
	case 8:
	case 46:
		if (LBKSString.length > 0)
		{
			LBKSString = LBKSString.substr(0, LBKSString.length-1);
			__ListBoxKeySearch(window.event == null ? e.target : e.srcElement);
			__ListBoxKeySearchEvent(e);
			return false;
		}
		else
		{
			__ListBoxKeySearchReset();
			return true;
		}
	case 27:
		__ListBoxKeySearchReset();
		__ListBoxKeySearchEvent(e);
		return false;
	default:
		return true;
	}
}
function ListBoxKeySearch_KeyPress(evnt) 
{
	var e = window.event == null ? evnt : event;
	var key = e.keyCode;
	
	if (key != 13) 
	{
		if (LBKSString.length == 0) LBKSStatus = window.status;
		LBKSString += String.fromCharCode(key);
		
		__ListBoxKeySearch(window.event == null ? e.target : e.srcElement);
		__ListBoxKeySearchEvent(e);
		return false;
	} else {
		element.fireEvent("onchange");
		__ListBoxKeySearchReset();
		return true;
	}
}
function ListBoxKeySearch_Blur()
{
	self.status = DefaultStatusbarText;
}
function __ListBoxKeySearch(e)
{
	self.status = __ListBoxKeySearchNajit + LBKSString;
	for (var i=0; i < e.options.length; i++)
	{
		if (e.options[i].text.toLowerCase().indexOf(LBKSString.toLowerCase()) == 0)
		{
			e.selectedIndex = i;
			break;
		}
	}
}
function ListBoxKeySearch_Click()
{
	__ListBoxKeySearchReset();
}
function __ListBoxKeySearchReset()
{
	LBKSString = "";
	try { window.status = LBKSStatus; } catch (e) {}
}
function __ListBoxKeySearchEvent(ev){
	ev.cancelBubble = true;
	ev.returnValue = false;
}

/* ++++++++++++++++++++++++++++++ BUTTON DEFINITION ++++++++++++++++++++++++++++++++++ */
function Button_MouseOver(o) {
    o.css("textDecoration", "underline");
}

function Button_MouseOut(o) {
    o.css("textDecoration", "none");
}


/* CGRID ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function GridRowMouseOver(rowIndex)
{
    this.Rows[rowIndex].Control.className = " CGrid_Over";
}
function GridRowMouseOut(rowIndex)
{
    this.Rows[rowIndex].Control.className = "CGrid_Out";
}

/* CONTAINER ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function Container_Open(id, webRoot) {
    var x = getID(id + "_Box").style.display == "none";
    getID(id + "_Box").style.display = x ? "block" : "none";
    if (getID(id + "_Img") != null)
        getID(id + "_Img").src = webRoot + "gfx/" + (x ? "open.gif" : "close.gif");
}

/* DATEPICKER +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function DatePicker_Click(id) {
    eval(id+".ShowPopup();");
}

// telerik callback loading
function OnCallbackStart()
{
	getID("divLoading").style.display = "block";
}
function OnCallbackEnd()
{
	getID("divLoading").style.display = "none";
}