﻿
	var hidValName;	//value değerini saklayan hidden id si
	var txtName;			// textbox un id si

	//Açılan listeyi oluşturuyoruz.
    document.write("<div id='droplist' style='position:absolute; left:2px; top:22px;display:none;overflow-x:hidden;overflow-y:scroll; width:120px;height:0px; background-color:White;cursor:default;border:solid 0px  #ee9702;z-index:99999;font-family:Arial;SCROLLBAR-FACE-COLOR:  #020202;SCROLLBAR-HIGHLIGHT-COLOR:#f5c136;	SCROLLBAR-SHADOW-COLOR:#f1ad26;	SCROLLBAR-3DLIGHT-COLOR: #f5c136;SCROLLBAR-ARROW-COLOR:  #020202;SCROLLBAR-TRACK-COLOR: #ee9702;SCROLLBAR-DARKSHADOW-COLOR: #020202' align='center'></div>");

	    //Sayfa resize olduğu zaman açılan listenin textbox ın altından kaymaması için
	        $("#scroller").scroll(function(){
		            SetPosition();
	         });
	    
	    
	    $(document).ready(function(){
	    
	    if ($(".dropdownlist").is("div")){
	         document.getElementById($("#droplist").attr("id")).onselectstart=function(){return false;};
	        txtName =	$(".dropdownlist").attr("id");
		    hidValName = txtName +"_value";
	        $("#droplist").html(CreateListItem());
	        $(".dropdownlist").html("");
	        SetPosition();
	        $("#droplist").css({"height":"0px","border":"solid 2px  #ee9702"})
	        $(".dropdownlist").click(function(){
	            if ($("#droplist").height() <= 0){
	                SetPosition(); 
	                $("#droplist").animate({"height":"70px"},500);
	            }    
	            else{
                   SlideUp();
	            }    
	        });
	        
	      }//end if 
	     
    	     
	        $("#droplist").blur(function(){
			    SlideUp();
		    });
    				
		 
	 });
	    
	      function CreateListItem()
	          {
	          var SB = new StringBuilder();
	          $(".dropdownlist li").each(function(){
	              
	                 SB.append("<div style='float:left;display:block;height:20px;width:100%;color:#000000;text-align:left;font-size:11px;overflow:hidden;border-bottom:solid 1px silver;line-height:18px;text-indent:5px;' ");
		            SB.append("onmouseout='autocompleteout(this);' ");
		            SB.append("onmouseover='autocompleteover(this);' ");
		            SB.append("onclick='SetText(\"" +$(this).text().split(";")[1] + ";" + $(this).text().split(";")[0] + "\");'")
		            SB.append(">")	
		            SB.append($(this).text().split(";")[0]);
		            SB.append("</div>");
		            if ($(".dropdownlist_content input").val() == $(this).text().split(";")[1])
		            {
		                $(".dropdownlist_text").text($(this).text().split(";")[0]);
		            }
	           });
	           //liste yüklendikten sonra div görünürlüğünü açıyoruz, diğer türlü sayfa yüklenince li html leri göürünüyor 
	           $(".dropdownlist").css({"display":"block"});
	            return SB.toString();
	          }
	          
	  
        
        function SlideUp(){
         $("#droplist").animate({"height":"0px"},300,function(){
	                    $("#droplist").fadeOut("normal");
	                    $("#droplist").hide()
	            });
	     }     
	       
        //Listenin elemanları üzerine gelince ki style	
        function autocompleteover(obj){
			        obj.style.backgroundColor="#f0f2f4";
        }	
        
        //Listenin elemanları üzerinden ayrılınca ki style	
        function autocompleteout(obj){
			        obj.style.backgroundColor="#ffffff";
        }
        
        //liste elemanlarından birine tıklayınca
        function SetText(txt){
	        $(".dropdownlist_text").text(txt.split(";")[1]);
	        $(".dropdownlist_content input").val(txt.split(";")[0]);
//	                $("#droplist").animate({"height":"0px"},500,function(){
//	                    $("#droplist").fadeOut("normal");
//	                    $("#droplist").hide()
//	                });
            SlideUp();
	        document.forms[0].submit();
        }
