

function doSubmit(tabName, sheet)
{
	var inp = document.all[tabName + "SelSheet"]
	inp.value = sheet;	
	document.forms[0].submit();
}

function sortfnc(a,b) {
	//text = a.text.substr(item.textFrom, item.textWidth);
	//alert("ts_sort_caseinsensitive"+a+","+b);
    //aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
    //bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
    if (a.sortText==b.sortText) return 0;
    if (a.sortText<b.sortText) return -1;
    return 1;
}
function sortList(list, item)
{
	arr = new Array();
	opt = new Array();
	//alert(item.textFrom+","+item.textWidth+","+list.options[0].text.substr(item.textFrom, item.textWidth));
	for(i=0;i<list.options.length;i++) {
		arr[i] = new Object;
		//text = a.text.substr(item.textFrom, item.textWidth);
		arr[i].sortText = list.options[i].text.substr(item.textFrom, item.textWidth);
		
		arr[i].optText = list.options[i].text;
		arr[i].optValue = list.options[i].value;
	}
	arr.sort(sortfnc);
	//return;
	for(i=0;i<list.options.length;i++) {
		list.options[i].text = arr[i].optText;
		list.options[i].value = arr[i].optValue;
	}
}
function selectListItem(el, item, from, width)
{
	value = item.value;
	if(value.search('%')==-1)
		value = '^'+value;
	else
		value = value.substr(1);
	value = new RegExp(value,"i") ;
	if(el.lastFound!=null)
		el.options[el.lastFound].style.backgroundColor = "";//el.lastBgColor;
	for(i=0;i<el.options.length;i++) {
		//alert(el.options[i].text+","+item.textFrom+","+item.textWidth);if(i>5) break;
		
		text = el.options[i].text.substr(item.textFrom, item.textWidth);
		//alert(text);break;
		if(text.search(value)>-1) {
			el.lastBgColor = el.options[i].style.backgroundColor;
			if(document.getElementById('scrollDIV'+el.id))
				el.options[i].style.backgroundColor="red";
			//el.selectedIndex = i;//makeVisible();
			
			el.lastFound = i;
			//alert("found at "+i+" ("+text+")");
			//el.selectedIndex =i;
			//el.selceted = true;
			if(document.getElementById('scrollDIV'+el.id))
				document.getElementById('scrollDIV'+el.id).scrollTop=i*15;
			//alert(el.checkVisible
			break;
		}
	}
}
function expandSelect(sel, compressControl)
{
	//alert(sel+','+compressControl);
	sel.style.width=window.document.getElementById(compressControl).offsetWidth+20;
	window.document.getElementById(compressControl).style.display="none";
	
	sel.onmouseout= function anonymus() {
		window.document.getElementById(compressControl).style.display='';//style.width=\"250\";
		sel.style.width="20";
		window.document.getElementById(compressControl).focus();
		//sel.focus();
		sel.onmouseout = null;
		sel.onblur = null;
	}
	sel.onblur=sel.onmouseout;
	sel.onfocus=function anonymus() {
		
		sel.onmouseout=null;
	}
	
}

