function searchSel(txtsearch,strddlval){			
			var ddlval=document.getElementById(strddlval);			
			var input=txtsearch.value.toLowerCase();
			var output=ddlval.options
			var currVal='';
			for(var i=0;i<output.length;i++) {
				currVal=output[i].innerText.toLowerCase();
				if(currVal.indexOf(input)==0)//compare through substring method
				{
				output[i].selected=true;
				break;
				}
				if(txtsearch.value==''){
				output[0].selected=true;
				}
			}
		}
		function getleftPos(inputObj)
		{
		var returnValue = inputObj.offsetLeft;
		while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
		return returnValue;
		}
		function getTopPos(inputObj)
		{	
		var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
		while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
		return returnValue-20;
		}
		function visibleSearch(ddlval,imgSearch)
		{
				imgSearch.style.visibility='hidden';
				imgSearch.weidth=0;
				imgSearch.height=0;
				
				var theDiv=document.getElementById('MySearch')
				if(theDiv==null)
				{
					theDiv=document.createElement('Div');
					theDiv.id='MySearch';
					theDiv.style.position='absolute';
					theDiv.style.zIndex=999999;
					theDiv.style.weidth=280+'px';
					theDiv.style.height=50+'px';
					theDiv.style.backgroundImage='url(images/sade.gif)';					
					theDiv.style.marginTop='20px';
					document.body.appendChild(theDiv);
				}
				
				theDiv.style.visibility='';
				theDiv.style.left = getleftPos(ddlval) + 'px';
				theDiv.style.top = getTopPos(ddlval) + 'px';				
				
				//create the iframe
				theiFrame=document.createElement('iFrame');
				theiFrame.id='myiFrame';
				theiFrame.style.filter='alpha(opacity=0)';
				theiFrame.style.position='absolute';
				theiFrame.style.zIndex=999998; //iFrame will be just below the theDiv
				document.body.appendChild(theiFrame);

				//put the html tags which has to be shown in the theDiv here
				//and display the theDiv
				var strEvent="RemoveSearch('"+imgSearch.id+"')";
				var strSearchEvent="searchSel(this,'"+ddlval.id+"')";
				theDiv.innerHTML="<br>&nbsp;&nbsp; <INPUT id='realtxt' onkeyup="+strSearchEvent+" onblur="+strEvent+" type='text' size='16' name='realtxt'>&nbsp;<IMG id='img_remove' onclick="+strEvent+" src='images/Remove.gif'>&nbsp;&nbsp;&nbsp;";
				theDiv.style.display='block';
						
				//set the position of the iframe and display it
				theiFrame.style.top=(parseInt(remove(theDiv.style.top,'px'))+20)+'px';//one less than the value given for theDiv
				theiFrame.style.left=theDiv.style.left; //one less than the value given for theDiv
				theiFrame.style.height = (theDiv.offsetHeight + 2) + 'px';
				theiFrame.style.width = (theDiv.offsetWidth + 2) + 'px';
				theiFrame.style.display='block';
				//theiFrame.style.backgroundImage="url(images/back.gif)";					
		}
		function RemoveSearch(strimgSearch)
		{
				var imgSearch=document.getElementById(strimgSearch);
				imgSearch.style.visibility='';
				imgSearch.weidth=21;		
				imgSearch.height=17;
				var theDiv=document.getElementById('MySearch')
				if(theDiv!=null)
				{
					RemoveObject(theDiv);
				}
				var theframe=document.getElementById('myiFrame')
				if(theframe!=null)
				{
					RemoveObject(theframe);
				}		
		}
		 function RemoveObject(MyObj){
			d = document.body;
			d_nested = MyObj;
			throwaway_node = d.removeChild(d_nested);
       }
		function remove(s, t) {
			/*
			**  Remove all occurrences of a token in a string
			**    s  string to be processed
			**    t  token to be removed
			**  returns new string
			*/
			i = s.indexOf(t);
			r = "";
			if (i == -1) return s;
			r += s.substring(0,i) + remove(s.substring(i + t.length), t);
			return r;
			}
