
var bFilterActive = new Boolean();
bFilterActive = false;

  var aoTd = new Array();
	var aListId = new Array();
	var aoListId = new Array();
	var aList = new Array();
	var i = new Number();
	var ia = new Number();
	var iFlag = new Number();
	
	
	//--==Time Calculation Variables==--	
	var nMs1 = new Number();
	var nMs2 = new Number();
	var nSec1 = new Number();
	var nSec2 = new Number();
	var nMin1 = new Number();
	var nMin2 = new Number();
	var nDiffInit = new Number();
	var nDiff = new Number();
	var sProcessTime = new String();
	var bUserTyping = new Boolean();
	bUserTyping = false;
	
//===============================================================================

function displayListInit() {
	//Populate array with the full list of toggleDisplay elements
	for (i=1;i<=26;i++) {
		aoTd[i-1] = document.getElementById("td1_"+i);
	}
	
	
	
	//Populate array with the full list of links
	iFlag = 0;
	i = 0;
	ia = 0;
	do {
		if (document.getElementById("li"+i)) {
			aListId[ia] = "li"+i;
			aoListId[ia] = document.getElementById(aListId[ia]);
			//read contents of each list item and convert to lower case
			aList[ia] = document.getElementById("li"+i).innerHTML.toLowerCase();
			
			//extract hyperlink code and remove all instances of  " target="_blank"
			aList[ia] = aList[ia].substring(aList[ia].indexOf("<a")+8,aList[ia].indexOf("</a>")).replace(/( target\=\"_blank\"| target\=_blank)/,"");
			
			//alert("ia:"+ia+"\n"+aList[ia]);
			//break;
						
			
			ia++
		} else {
			iFlag++;
			//alert("iFlag:"+iFlag);
		}
		i++
	} while (iFlag<10);
}

//Deactivate live filter
function clearFilter() {
	bFilterActive = false;
	document.frmLiveFilter.criteria.value="";
	for (i in aList) {		
		aoListId[i].style.display="block";
	}
}

function displayList(criteria) {
//--==Time Calculation Part 1==--	
var dTime1 = new Date();
nSec1 = dTime1.getSeconds();
nMs1 = dTime1.getMilliseconds();
		
		var sItem = new String();
		var sTemp = new String();
		var bFound = new Boolean();
		var sVal = new String();
		var aLiBlock = new Array();
		
		var oStyle = new Object();
	
		
		
		//Expand all toggleDisplay items if filter is not active
		if (bFilterActive==false) {
	//		setDisplayState("td","expandAll","");
			bFilterActive = true;
		}
		
		//alert(criteria);
		
		sVal = document.frmLiveFilter.criteria.value.toLowerCase();  //Read entered value
		//alert(criteria+":"+sVal);
		
		var reRegExp = new RegExp(sVal,"i");
		
		
		

		//Hide list items that do not contain the entered string	
		bFound = false;
		for (i in aList) {		
			bFound = reRegExp.test(aList[i]);
			if (bFound==true || aList[i]=="all") {
				//document.getElementById(aListId[i]).style.display="block";
				aoListId[i].style.display="block";
			} else {
				//document.getElementById(aListId[i]).style.display="none";
				aoListId[i].style.display="none";
			}
		}
		
		
		
		
		
		//--==Hide Letters that contain no entries==--
		
		
		//Check each toggleDisplay element for existance of hyperlinks
		var s1 = new String();
		var iLBoundLoc = new Number();
		var iUBoundLoc = new Number();
		var iLBound = new Number();
		var bEmpty = new Boolean();
		var oTd = new Object();
		var rExp = new RegExp();
		var rExp2 = new RegExp();
		var oUl = new Object();
		var oLi1 = new Object();
		var oLi2 = new Object();
		
			rExp = /"|=/gi;
			rExp2 = /idli/gi;
		for (i=1;i<=26;i++) {
			
			
			
	//		s1 = document.getElementById("td1_"+i).innerHTML;

			oTd = document.getElementById("td1_"+i);
			if (oTd == null)
			{
				break;
			}
			oUl = oTd.firstChild;
			bFound = false;
			
			
		
			//Find UL Element
			ia = 0;
			do {
				if (oUl.nodeName=="UL") {
					bFound = true;
					break;
				}
				oUl = oUl.nextSibling;
				ia++;
			} while (bFound==false || ia<20);		
			
			/*
			for (ia in oLi1.childNodes) {
				if (oLi1.childNodes[ia].nodeName=="UL") {
					bFound = true;
					oLi1 = oLi1.childNodes[ia];
					break;
				}
			}
			*/
			
			//Find first LI ID
			oLi1 = oUl.firstChild;
			ia = 0;
			do {
				if (oLi1.nodeName=="LI") {
					bFound = true;
					break;
				}
				oLi1 = oLi1.nextSibling;
				ia++;
			} while (bFound==false || ia<20);	
			
			
			//alert(oLi1.id);
			
			//Find last LI ID
			oLi2 = oUl.lastChild;
			ia = 0;
			do {
				if (oLi2.nodeName=="LI") {
					bFound = true;
					break;
				}
				oLi2 = oLi2.previousSibling;
				ia++;
			} while (bFound==false || ia<20);	
			
			
			//alert(oLi2.id);
			
			iLBound = oLi1.id.replace("li","");
			iUBound = oLi2.id.replace("li","");
			
			//alert(iLBound+";"+iUBound);
			
			
		
		
			
			bEmpty = true;
			for (ia=iLBound;ia<=iUBound;ia++) {//&&ia<10
				//oStyle = document.getElementById(aListId[ia]);
				//alert(iLBound+"-"+iUBound+", "+"li"+i+":"+oStyle);
				//alert(iLBound+"-"+iUBound+", "+"li"+i+":"+document.getElementById(aListId[ia]).style.display);
				//alert(iLBound+"-"+iUBound+", "+"li"+i+":"+document.defaultView.getComputedStyle(document.getElementById(aListId[ia]),"").display);
				if (aoListId[ia].style.display!="none") {
					bEmpty = false;
					break;
				}
			}
			//alert(bEmpty);
			if (bEmpty==true) {
				aoTd[i-1].style.display="none";
				//document.getElementById("td1_"+i).style.display="none";
			} else {
				aoTd[i-1].style.display="block";
				//document.getElementById("td1_"+i).style.display="block";
			}
				
		}
		
//--==Time Calculation Part 2==--	
var dTime2 = new Date();
nMs2 = dTime2.getMilliseconds();
nSec2 = dTime2.getSeconds();
		
			
		//--==Time Calculation Result==--	
		nSec1 = nSec1 + (nMs1/1000);
		nSec2 = nSec2 + (nMs2/1000);
		nDiff = nSec2 - nSec1;
		sProcessTime = nSec1+";"+nSec2+";"+nDiff;
		//alert(sProcessTime);
	
}


//===============================================================================
/*
function isEmpty(td) {
	//Check toggleDisplay element for existance of hyperlinks
	var s1 = new String();
	var iLBoundLoc = new Number();
	var iUBoundLoc = new Number();
	var iLBound = new Number();
	var bEmpty = new Boolean();
	
	s1 = document.getElementById(td).innerHTML;
	iLBoundLoc = s1.indexOf("id=\"li");
	iLBound = s1.substr(iLBoundLoc,10);
	iLBound = iLBound.replace("id=\"li","");
	iLBound = parseFloat(iLBound);
	
	iUBoundLoc = s1.lastIndexOf("id=\"li");
	iUBound = s1.substr(iUBoundLoc,10);
	iUBound = iUBound.replace("id=\"li","");
	iUBound = parseFloat(iUBound);
	
	bEmpty = true;
	for (i=iLBound;i<=iUBound;i++) {
		//alert(iLBound+"-"+iUBound+", "+"li"+i+":"+aListId[i].style.display);
		if (aListId[i].style.display=="block") {
			bEmpty = false;
			break;
		}
	}
	return bEmpty;
}

function test(td) {
	//Check toggleDisplay element for existance of hyperlinks
	var s1 = new String();
	var iLBoundLoc = new Number();
	var iUBoundLoc = new Number();
	var iLBound = new Number();
	var bEmpty = new Boolean();
	
	s1 = document.getElementById(td).innerHTML;
	iLBoundLoc = s1.indexOf("id=\"li");
	iLBound = s1.substr(iLBoundLoc,10);
	iLBound = iLBound.replace("id=\"li","");
	iLBound = parseFloat(iLBound);
	
	iUBoundLoc = s1.lastIndexOf("id=\"li");
	iUBound = s1.substr(iUBoundLoc,10);
	iUBound = iUBound.replace("id=\"li","");
	iUBound = parseFloat(iUBound);
	
	bEmpty = true;
	for (i=iLBound;i<=iUBound;i++) {
		alert(iLBound+"-"+iUBound+", "+"li"+i+":"+document.getElementById("li"+i).style.display);
		if (aListId[i].style.display=="block") {
			bEmpty = false;
			//break;
		}
	}
	return bEmpty;
}
*/