﻿ 
 

  // on theShow eventhandler - working with the list items and saperate the Search Parameter 
  //that came from the server for the callback use . 
  function onShow(sender,args)
  {
 
  var totalItemsToShow;
   if (document.all) 
   {
    totalItemsToShow=sender.get_completionList().children.length;
        for (i=0;i<totalItemsToShow;i++)
           {
             var listItemParamArry= sender.get_completionList().children[i].innerHTML.split(';;;');
               sender.get_completionList().children[i].innerHTML=listItemParamArry[0];
           }
    }
    //firfox etc...
    else 
    {
   
    totalItemsToShow=sender.get_completionList().childNodes.length;
       for (i=0;i<totalItemsToShow;i++)
       {
         var listItemParamArry= sender.get_completionList().childNodes[i].innerHTML.split(';;;');
          sender.get_completionList().childNodes[i].innerHTML=listItemParamArry[0];
       }
    }
 
   
 };
 //this function get the 3 parameter TableName ,FirstParam and SecondParam and pass to the SearchButton Attributes 
 function itemSelected(sender,args) 
 {
  var listItemParamArry= args._value.split(';;;');
  var searchButton=document.getElementById('UcAutoComplete1_ImageButtonSearchButton');
  searchButton.removeAttribute('TableName');
  searchButton.removeAttribute('FirstParam');
  searchButton.removeAttribute('SecondParam');
  searchButton.setAttribute('TableName',listItemParamArry[1]);
  searchButton.setAttribute('FirstParam',listItemParamArry[2]);
  searchButton.setAttribute('SecondParam',listItemParamArry[3]);
  searchButton.focus();
 
   };
   
//Search Button Eventhandler 
function SearchClick(sender)
{
 if (window.event){}
       if (document.all)
                var iframeObject = parent.window.frames['ifrmWork'];
       else
               var iframeObject = parent.window.frames[0];
               
              
iframeObject.location.href="MusicList.aspx?genreId=0&search=true&tableName="+sender.getAttribute('TableName')+"&param1="+sender.getAttribute('FirstParam')+"&param2="+sender.getAttribute('SecondParam');
 // iframeObject.__doPostBack('UpdatePanel1','Search;' + 'Search;'+sender.getAttribute('TableName')+';' +sender.getAttribute('FirstParam')+';' +sender.getAttribute('SecondParam'));
//   var textBox= document.getElementById('UcAutoComplete1$TextBoxAutoComplete');
//   textBox.value='                               Search';
//  textBox.onfocus=TextBoxInit;
   
 };
// function TextBoxInit()
// {
//  var textBox= document.getElementById('UcAutoComplete1$TextBoxAutoComplete');
//  textBox.value='';
//  textBox.onfocus=null;
// };

