
function showList(lstr) 
{
    if(isString(lstr))
    {
        if(document.getElementById(lstr).style.display=="none")
            document.getElementById(lstr).style.display="block";
    }
    else
    {
        if(lstr.style.display="none")
            lstr.style.display="block";        
    }
}

function hideList(lstr) 
{
    if(isString(lstr))
       document.getElementById(lstr).style.display="none";
    else
        lstr.style.display="none";  
 
}

function showHideList(lstr)
{
    if(isString(lstr))
    {
	    if (document.getElementById(lstr).style.display=="block")
		    document.getElementById(lstr).style.display="none";
	    else
	    {
		    document.getElementById(lstr).style.display="block";
	    }
	}
	else
	{
	    if (lstr.style.display=="block")
		    lstr.style.display="none";
	    else
	    {
		    lstr.style.display="block";
	    }	
	}	
}

function handleClickOnList(editControl,list_show,lstr) 
{
	editControl.value = list_show.options[list_show.selectedIndex].text;
	hideList(lstr);
}

	
function updateSearchCombo(editControl,idControl,list_show,lstr) 
{
	editControl.value = list_show.options[list_show.selectedIndex].text;
	idControl.value =  list_show.options[list_show.selectedIndex].value;		
	hideList(lstr);		
}

function fn_NevigateSearchCombo(editControl,valueControl,sourceControl,list1)
{	
    //Tab key is pressed	
    if (event.keyCode == 9)
    {
        hideList(list1);
        return;
    }
	var test,text_value
	var i
	var newPos
	i = 0	
	text_value = editControl.value;
	
	if(event.keyCode == 40 || event.keyCode == 38)
	{
	    showList(list1);
	}
	 
	if (event.keyCode == 40)
	{ 
		newPos = sourceControl.selectedIndex;
		
		if (newPos != -1)
		{
			if (sourceControl.options[newPos].value == sourceControl.options[sourceControl.options.length-1].value)
			{
				return;
		    }
		}
		sourceControl.value = sourceControl.options[newPos + 1].value;
		editControl.value = sourceControl.options[newPos + 1].text;		
		return;
	}
	if (event.keyCode == 38 ){ 
		newPos = sourceControl.selectedIndex;
		
		if (newPos == 0)
			return;
			
		sourceControl.value = sourceControl.options[newPos - 1].value;
		editControl.value = sourceControl.options[newPos - 1].text;
		return;
	}
}

function fn_SearchCombo(editControl,valueControl,sourceControl,list1)
{

    //Up down arrow keys
    if (event.keyCode == 40 || event.keyCode == 38)
        return;
    
    //Tab key is pressed
	if (event.keyCode == 9)
	{
	    hideList(list1);
        return;
    }

	var test,text_value;
	var i;
	var newPos;
	i = 0;
	text_value = editControl.value;
	
	if (text_value.length != 0)
		showList(list1);
	if (event.keyCode == 13 )
	{ 
		editControl.value = sourceControl.options[sourceControl.selectedIndex].text;
		sourceControl.value = sourceControl.options[sourceControl.selectedIndex].value;
		hideList(list1); 
		return;
	}
			
	sourceControl.value= -1;		
	  
	while (sourceControl.options[i]!= null){
		test = sourceControl.options[i].text.substr(0,text_value.length).toUpperCase();
		if (test== text_value.toUpperCase())
		{
		    sourceControl.value =sourceControl.options[i].value;
		    break;
		}
		i++;
	}
	if(sourceControl.value == ''){
	
		sourceControl.value = 0;
		hideList(list1);
	}
}

	
		
	
/* function updateSearchCombo(text_txt,text_val,list,lstr) 
{

alert("Called");

// CODE FOR HIDING OTHER LISTS ON THE DOCUMENT BY RAVINDRA PAWAL
          
  hideAllListControls(lstr);

   // END OF CODE FOR HIDING OTHER LISTS ON THE DOCUMENT BY RAVINDRA PAWAL
   

	text_txt.value = list.options[list.selectedIndex].text;
    text_val.value = list.options[list.selectedIndex].value;    
	hideList(lstr);	
}
*/

/* for Internal search in string Combo * /


	function fn_InternalSearchCombo(editControl,idControl,list_show,sourceControl,list1){
		
		var test,text_value,edit_value
		var previous_text,previous_value
		var i,j
		var newPos
		i = 0;
		j = 0;	
		previous_text = null;
		previous_value = null;
		text_value = new RegExp(editControl.value.toUpperCase());
		edit_value = editControl.value.toUpperCase();
		if (event.keyCode == 40 ||event.keyCode == 38 )
			return;
		if (event.keyCode == 13 ){
			editControl.value = list_show.options[list_show.selectedIndex].text;
			idControl.value=list_show.options[list_show.selectedIndex].value;
			list_show.click();
			hideList(list1); 
			return
		}
		if (text_value == '//'){
			list_show.options.length = 0;
			hideList(list1);
			return;
		}
		else{
			list_show.options.length = 0;
		}
		var tmp_list = new Array();
		list_show.options.length = 0
		while (sourceControl.options[i]!= null){
				if (sourceControl.options[i].text.toUpperCase().search(text_value) != -1 || sourceControl.options[i].text.toUpperCase() == edit_value ){
				list_show.options[j] =  new Option(sourceControl.options[i].text,sourceControl.options[i].value);
				j++;
			}
			i++;
		}
		if(list_show.options.length == 0 || j == 0){
				hideList(list1);
				idControl.value = 0;
		}
		else{
			if (list_show.options.length == 1 && list_show.options[0].text.toUpperCase() == edit_value){
				idControl.value = list_show.options[0].value;
				hideList(list1);
			}
			else
				showList(list1);
		}
	}
	/*
	function fn_NevigateInternalSearchCombo(editControl,idControl,sourceControl,list1){
		var test,text_value
		var i
		var newPos
		i = 0	
		text_value = editControl.value;
		if (sourceControl.options == null || sourceControl.options.length == 0 )
			return;
		if (text_value.length != 0)
			showList(list1);
		if (event.keyCode == 40)
		{ 
			newPos = sourceControl.selectedIndex;
			
			if (newPos != -1)
			{
				if (sourceControl.options[newPos].value == sourceControl.options[sourceControl.options.length-1].value)
					return;
			}
			sourceControl.value = sourceControl.options[newPos + 1].value;
			
			editControl.value = sourceControl.options[sourceControl.selectedIndex].text;
			idControl.value =  sourceControl.options[sourceControl.selectedIndex].value;
			
			return
		}
		if (event.keyCode == 38 ){ 
			newPos = sourceControl.selectedIndex;
			if (newPos == 0)
				return;
			sourceControl.value = sourceControl.options[newPos - 1].value;
			
			editControl.value = sourceControl.options[sourceControl.selectedIndex].text;
			idControl.value =  sourceControl.options[sourceControl.selectedIndex].value;
			return
		}
	}


	function updateInternalSearchCombo(editControl,idControl,list_show,lstr) 
	{
		editControl.value = list_show.options[list_show.selectedIndex].text;
		idControl.value =  list_show.options[list_show.selectedIndex].value;
		hideList(lstr);
	}


/* for Compare string from start * /

	function fn_SearchList(editControl,sourceControl,list1){
		var test,text_value
		var i
		var newPos
		i = 0	
		text_value = editControl.value;
		//if (text_value.length != 0)
			showList(list1);
		if (event.keyCode == 13 ){ 
			editControl.value = sourceControl.options[sourceControl.selectedIndex].text;
			sourceControl.click();
			hideList(list1); 
			return
		}
		sourceControl.value= -1;
		while (sourceControl.options[i]!= null){
			test = sourceControl.options[i].text.substr(0,text_value.length).toUpperCase();
			if (test== text_value.toUpperCase()){
				sourceControl.value =sourceControl.options[i].value
				break
			}
			i++;
		}
		
		if(sourceControl.value == ''){
			sourceControl.value = 0;
			hideList(list1);
		}
	}




	function fn_NevigateSearchList(editControl,sourceControl,list1){
		var test,text_value
		var i
		var newPos
		i = 0	
		text_value = editControl.value;
		if (sourceControl.value == '')
			return;
			showList(list1);
		if (event.keyCode == 40)
		{ 
			newPos = sourceControl.selectedIndex;
			
			if (newPos != -1)
			{
				if (sourceControl.options[newPos].value == sourceControl.options[sourceControl.options.length-1].value)
					return;
			}
			sourceControl.value = sourceControl.options[newPos + 1].value;
			editControl.value = sourceControl.options[sourceControl.selectedIndex].text
			return
		}
		if (event.keyCode == 38 ){ 
			newPos = sourceControl.selectedIndex;
			//alert('ok');
			if (newPos == 0)
				return;
			sourceControl.value = sourceControl.options[newPos - 1].value;
			editControl.value = sourceControl.options[sourceControl.selectedIndex].text
			return
		}
	}


	function updateSearchList(text_txt,list,lstr) 
	{
		text_txt.value = list.options[list.selectedIndex].text;
		//text_val.value = list.options[list.selectedIndex].value;
		hideList(lstr);
	}
*/
/* for Internal search in string * /


	function fn_InternalSearchList(editControl,list_show,sourceControl,list1){
		var test,text_value
		var i,j
		var newPos
		i = 0;
		j = 0;	
		text_value = new RegExp(editControl.value.toUpperCase());
		if (event.keyCode == 40 ||event.keyCode == 38 )
			return;
		if (event.keyCode == 13 ){
			editControl.value = list_show.options[list_show.selectedIndex].text;
			hideList(list1); 
			return
		}
		if (text_value == '//'){
			list_show.options.length = 0;
			hideList(list1);
			return;
		}
		else{
			list_show.options.length = 0;
		}
		var tmp_list = new Array();
		list_show.options.length = 0
		while (sourceControl.options[i]!= null){
				if (sourceControl.options[i].text.toUpperCase().search(text_value) != -1){
						
				list_show.options[j] =  new Option(sourceControl.options[i].text,sourceControl.options[i].value);
				j++;
			}
			i++;
		}
		if(list_show.options.length == 0 || j == 0){
				hideList(list1);
		}
		else{
			showList(list1);
		}
	}
	
	function fn_NevigateInternalSearchList(editControl,sourceControl,list1){
		var test,text_value
		var i
		var newPos
		i = 0	
		text_value = editControl.value;
		if (sourceControl.options.length == 0 )
			return;
		if (text_value.length != 0)
			showList(list1);
		if (event.keyCode == 40)
		{ 
			newPos = sourceControl.selectedIndex;
			
			if (newPos != -1)
			{
				if (sourceControl.options[newPos].value == sourceControl.options[sourceControl.options.length-1].value)
					return;
			}
			sourceControl.value = sourceControl.options[newPos + 1].value;
			return
		}
		if (event.keyCode == 38 ){ 
			newPos = sourceControl.selectedIndex;
			if (newPos == 0)
				return;
			sourceControl.value = sourceControl.options[newPos - 1].value;
			return
		}
		
	}


	function updateInternalSearchList(editControl,list_show,lstr) 
	{
		editControl.value = list_show.options[list_show.selectedIndex].text;
		hideList(lstr);
	}
*/